@ferrule-io/ok-fine 0.3.12 → 0.3.13

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.
@@ -54,18 +54,18 @@ Error generating stack: `+e.message+`
54
54
  `},pT=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},mT=function(){m.useEffect(function(){return document.body.setAttribute(dT,(pT()+1).toString()),function(){var e=pT()-1;e<=0?document.body.removeAttribute(dT):document.body.setAttribute(dT,e.toString())}},[])},hT=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;mT();var a=m.useMemo(function(){return lT(i)},[i]);return m.createElement(uT,{styles:fT(a,!t,i,n?``:`!important`)})},gT=!1;if(typeof window<`u`)try{var _T=Object.defineProperty({},"passive",{get:function(){return gT=!0,!0}});window.addEventListener(`test`,_T,_T),window.removeEventListener(`test`,_T,_T)}catch{gT=!1}var vT=gT?{passive:!1}:!1,yT=function(e){return e.tagName===`TEXTAREA`},bT=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!yT(e)&&n[t]===`visible`)},xT=function(e){return bT(e,`overflowY`)},ST=function(e){return bT(e,`overflowX`)},CT=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),ET(e,r)){var i=DT(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},wT=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},TT=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},ET=function(e,t){return e===`v`?xT(t):ST(t)},DT=function(e,t){return e===`v`?wT(t):TT(t)},OT=function(e,t){return e===`h`&&t===`rtl`?-1:1},kT=function(e,t,n,r,i){var a=OT(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=DT(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&ET(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},AT=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},jT=function(e){return[e.deltaX,e.deltaY]},MT=function(e){return e&&`current`in e?e.current:e},NT=function(e,t){return e[0]===t[0]&&e[1]===t[1]},PT=function(e){return`
55
55
  .block-interactivity-${e} {pointer-events: none;}
56
56
  .allow-interactivity-${e} {pointer-events: all;}
57
- `},FT=0,IT=[];function LT(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(FT++)[0],a=m.useState(aT)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Fw([e.lockRef.current],(e.shards||[]).map(MT),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=AT(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=CT(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=CT(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return kT(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if(IT.length&&IT[IT.length-1]===a){var r=`deltaY`in n?jT(n):AT(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&NT(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(MT).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:RT(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=AT(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,jT(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,AT(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return IT.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,vT),document.addEventListener(`touchmove`,c,vT),document.addEventListener(`touchstart`,u,vT),function(){IT=IT.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,vT),document.removeEventListener(`touchmove`,c,vT),document.removeEventListener(`touchstart`,u,vT)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:PT(i)}):null,p?m.createElement(hT,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function RT(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var zT=Yw(Xw,LT),BT=m.forwardRef(function(e,t){return m.createElement(Qw,Nw({},e,{ref:t,sideCar:zT}))});BT.classNames=Qw.classNames;var VT=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},HT=new WeakMap,UT=new WeakMap,WT={},GT=0,KT=function(e){return e&&(e.host||KT(e.parentNode))},qT=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=KT(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},JT=function(e,t,n,r){var i=qT(t,Array.isArray(e)?e:[e]);WT[n]||(WT[n]=new WeakMap);var a=WT[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(HT.get(e)||0)+1,l=(a.get(e)||0)+1;HT.set(e,c),a.set(e,l),o.push(e),c===1&&i&&UT.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),GT++,function(){o.forEach(function(e){var t=HT.get(e)-1,i=a.get(e)-1;HT.set(e,t),a.set(e,i),t||(UT.has(e)||e.removeAttribute(r),UT.delete(e)),i||e.removeAttribute(n)}),GT--,GT||(HT=new WeakMap,HT=new WeakMap,UT=new WeakMap,WT={})}},YT=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||VT(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),JT(r,i,n,`aria-hidden`)):function(){return null}},XT=Object.defineProperty,ZT=(e,t)=>XT(e,`name`,{value:t,configurable:!0}),QT=`Dialog`,[$T,eE]=YS(QT),[tE,nE]=$T(QT),rE=ZT(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=dC({prop:r,defaultProp:i??!1,onChange:a,caller:QT}),[d,f]=m.useState(0),[p,g]=m.useState(0);return(0,h.jsx)(tE,{scope:t,triggerRef:s,contentRef:c,contentId:nC(),titleId:nC(),descriptionId:nC(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:g,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),iE=`DialogPortal`,[aE,oE]=$T(iE,{forceMount:void 0}),sE=ZT(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=nE(iE,t);return(0,h.jsx)(aE,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,h.jsx)(bw,{present:n||a.open,children:(0,h.jsx)(gw,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),cE=`DialogOverlay`,lE=m.forwardRef(ZT(function(e,t){let n=oE(cE,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=nE(cE,e.__scopeDialog);return a.modal?(0,h.jsx)(bw,{present:r||a.open,children:(0,h.jsx)(dE,{...i,ref:t})}):null},`DialogOverlay`)),uE=vC(`DialogOverlay.RemoveScroll`),dE=m.forwardRef(ZT(function(e,t){let{__scopeDialog:n,...r}=e,i=nE(cE,n),a=GS(t,KC());return(0,h.jsx)(BT,{as:uE,allowPinchZoom:!0,shards:[i.contentRef],children:(0,h.jsx)(NC.div,{"data-state":_E(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),fE=`DialogContent`,pE=m.forwardRef(ZT(function(e,t){let n=oE(fE,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=nE(fE,e.__scopeDialog);return(0,h.jsx)(bw,{present:r||a.open,children:a.modal?(0,h.jsx)(mE,{...i,ref:t}):(0,h.jsx)(hE,{...i,ref:t})})},`DialogContent`)),mE=m.forwardRef(ZT(function(e,t){let n=nE(fE,e.__scopeDialog),r=m.useRef(null),i=GS(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return YT(e)},[]),(0,h.jsx)(gE,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:IS(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:IS(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:IS(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),hE=m.forwardRef(ZT(function(e,t){let n=nE(fE,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(gE,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),gE=m.forwardRef(ZT(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=nE(fE,n);return jw(),(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(rw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(GC,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":_E(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`));function _E(e){return e?`open`:`closed`}ZT(_E,`getState`);var vE=`[cmdk-group=""]`,yE=`[cmdk-group-items=""]`,bE=`[cmdk-group-heading=""]`,xE=`[cmdk-item=""]`,SE=`${xE}:not([aria-disabled="true"])`,CE=`cmdk-item-select`,wE=`data-value`,TE=(e,t,n)=>MS(e,t,n),EE=m.createContext(void 0),DE=()=>m.useContext(EE),OE=m.createContext(void 0),kE=()=>m.useContext(OE),AE=m.createContext(void 0),jE=m.forwardRef((e,t)=>{let n=GE(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=GE(()=>new Set),i=GE(()=>new Map),a=GE(()=>new Map),o=GE(()=>new Set),s=UE(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:_=!0,...v}=e,y=nC(),b=nC(),x=nC(),S=m.useRef(null),C=JE();WE(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),WE(()=>{C(6,ee)},[]);let w=m.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(y))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=A()?.id,w.emit()}),r||C(5,ee),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=m.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:y,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??TE;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;te().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(yE);t?t.appendChild(e.parentElement===t?e:e.closest(`${yE} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${yE} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${vE}[${wE}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=te().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(wE);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function ee(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(vE)?.querySelector(bE))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return S.current?.querySelector(`${xE}[aria-selected="true"]`)}function te(){return Array.from(S.current?.querySelectorAll(SE)||[])}function ne(e){let t=te()[e];t&&w.setState(`value`,t.getAttribute(wE))}function re(e){var t;let n=A(),r=te(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(wE))}function ie(e){let t=A()?.closest(vE),n;for(;t&&!n;)t=e>0?VE(t,vE):HE(t,vE),n=t?.querySelector(SE);n?w.setState(`value`,n.getAttribute(wE)):re(e)}let ae=()=>ne(te().length-1),oe=e=>{e.preventDefault(),e.metaKey?ae():e.altKey?ie(1):re(1)},se=e=>{e.preventDefault(),e.metaKey?ne(0):e.altKey?ie(-1):re(-1)};return m.createElement(NC.div,{ref:t,tabIndex:-1,...v,"cmdk-root":``,onKeyDown:e=>{var t;(t=v.onKeyDown)==null||t.call(v,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:_&&e.ctrlKey&&oe(e);break;case`ArrowDown`:oe(e);break;case`p`:case`k`:_&&e.ctrlKey&&se(e);break;case`ArrowUp`:se(e);break;case`Home`:e.preventDefault(),ne(0);break;case`End`:e.preventDefault(),ae();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(CE);t.dispatchEvent(e)}}}}},m.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:ZE},c),XE(e,e=>m.createElement(OE.Provider,{value:w},m.createElement(EE.Provider,{value:T},e))))}),ME=m.forwardRef((e,t)=>{let n=nC(),r=m.useRef(null),i=m.useContext(AE),a=DE(),o=UE(e),s=o.current?.forceMount??i?.forceMount;WE(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=qE(n,r,[e.value,e.children,r],e.keywords),l=kE(),u=KE(e=>e.value&&e.value===c.current),d=KE(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);m.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(CE,f),()=>t.removeEventListener(CE,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:h,value:g,onSelect:_,forceMount:v,keywords:y,...b}=e;return m.createElement(NC.div,{ref:WS(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!u,"data-disabled":!!h,"data-selected":!!u,onPointerMove:h||a.getDisablePointerSelection()?void 0:p,onClick:h?void 0:f},e.children)}),NE=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=nC(),s=m.useRef(null),c=m.useRef(null),l=nC(),u=DE(),d=KE(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));WE(()=>u.group(o),[]),qE(o,s,[e.value,e.heading,c]);let f=m.useMemo(()=>({id:o,forceMount:i}),[i]);return m.createElement(NC.div,{ref:WS(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&m.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),XE(e,e=>m.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},m.createElement(AE.Provider,{value:f},e))))}),PE=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=m.useRef(null),a=KE(e=>!e.search);return!n&&!a?null:m.createElement(NC.div,{ref:WS(i,t),...r,"cmdk-separator":``,role:`separator`})}),FE=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=kE(),o=KE(e=>e.search),s=KE(e=>e.selectedItemId),c=DE();return m.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),m.createElement(NC.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),IE=m.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=m.useRef(null),o=m.useRef(null),s=KE(e=>e.selectedItemId),c=DE();return m.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),m.createElement(NC.div,{ref:WS(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},XE(e,e=>m.createElement(`div`,{ref:WS(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),LE=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return m.createElement(rE,{open:n,onOpenChange:r},m.createElement(sE,{container:o},m.createElement(lE,{"cmdk-overlay":``,className:i}),m.createElement(pE,{"aria-label":e.label,"cmdk-dialog":``,className:a},m.createElement(jE,{ref:t,...s}))))}),RE=m.forwardRef((e,t)=>KE(e=>e.filtered.count===0)?m.createElement(NC.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),zE=m.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return m.createElement(NC.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},XE(e,e=>m.createElement(`div`,{"aria-hidden":!0},e)))}),BE=Object.assign(jE,{List:IE,Item:ME,Input:FE,Group:NE,Separator:PE,Dialog:LE,Empty:RE,Loading:zE});function VE(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function HE(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function UE(e){let t=m.useRef(e);return WE(()=>{t.current=e}),t}var WE=typeof window>`u`?m.useEffect:m.useLayoutEffect;function GE(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function KE(e){let t=kE(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function qE(e,t,n,r=[]){let i=m.useRef(),a=DE();return WE(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(wE,s),i.current=s}),i}var JE=()=>{let[e,t]=m.useState(),n=GE(()=>new Map);return WE(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function YE(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function XE({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(YE(t),{ref:t.ref},n(t.props.children)):n(t)}var ZE={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},QE={"http:":!0,"https:":!0,"mailto:":!0,"tel:":!0};function $E(e){return e.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>{let n=Number.parseInt(t,16);return n>0&&n<1114111?String.fromCodePoint(n):``}).replace(/&#([0-9]+);?/g,(e,t)=>{let n=Number.parseInt(t,10);return n>0&&n<1114111?String.fromCodePoint(n):``}).replace(/&colon;?/gi,`:`).replace(/&tab;?/gi,``).replace(/&newline;?/gi,``)}function eD(e){let t=``;for(let n of e){let e=n.charCodeAt(0);e>32&&!(e>=127&&e<=159)&&!/\s/.test(n)&&(t+=n)}return t}function tD(e){let t=eD($E(e.trim())),n=/^[a-z][a-z0-9+.-]*:/i.exec(t);return n?n[0].toLowerCase():null}function nD(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split(`/`),i=[];for(let e=0;e<r.length;e++){let n=r[e];n&&n!==`.`&&(n===`..`?i.length>0&&i[i.length-1]!==`..`?i.pop():t||i.push(`..`):i.push(n))}let a=i.join(`/`);return t&&(a=`/${a}`),a.length===0?t?`/`:`.`:(n&&!a.endsWith(`/`)&&(a+=`/`),a)}function rD(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:e.slice(0,n)}function iD(e){if(e.length===0)return``;let t=0,n=-1,r=!0;for(let i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!r){t=i+1;break}}else n===-1&&(r=!1,n=i+1);return n===-1?``:e.slice(t,n)}function aD(e,t){if(!e)return{kind:`invalid`};let n=tD(e);if(n!==null)return QE[n]?{kind:`external`,href:e.trim()}:{kind:`invalid`};let r=e.trim();if(r.startsWith(`//`)){if(e.includes(`\\`)||!/^\/\/[^/?#\s\\]+(?:\/[^\s\\]*)?(?:#[^\s\\]*)?$/.test(r))return{kind:`invalid`};let t=r;try{t=decodeURI(r)}catch{return{kind:`invalid`}}return t.includes(`\\`)?{kind:`invalid`}:{kind:`external`,href:r}}if(e.startsWith(`#`))return{kind:`anchor`,hash:e};if(e.includes(`\\`))return{kind:`invalid`};let i=e;try{i=decodeURI(e)}catch{}if(i.includes(`\\`)||i.startsWith(`//`)||i.startsWith(`/\\`))return{kind:`invalid`};let a=``,o=i.indexOf(`#`);o!==-1&&(a=i.slice(o),i=i.slice(0,o));let s=i.indexOf(`?`);s!==-1&&(i=i.slice(0,s));let c;if(i.startsWith(`/`))c=nD(i.slice(1));else{let e=rD(t),n=e===`.`?``:e;c=nD(n?`${n}/${i}`:i)}if(c.includes(`\\`)||c===`..`||c.startsWith(`../`)||i.endsWith(`/`))return{kind:`invalid`};if(c.endsWith(`.md`)){let e=iD(c);return e===`index.md`||e===`log.md`?{kind:`invalid`}:{kind:`concept`,id:c.slice(0,-3),hash:a}}return{kind:`file`,path:c,hash:a}}function oD(e,t){let n=t.startsWith(`/`)?t.slice(1):t;return`/p/${encodeURIComponent(e)}/c/${n}`}function sD(e,t){let n=t.startsWith(`/`)?t.slice(1):t;return`/p/${encodeURIComponent(e)}/f/${n}`}var cD=`okf.recent`,lD=8;function uD(e){return!!(e&&typeof e==`object`&&`project`in e&&typeof e.project==`string`&&`id`in e&&typeof e.id==`string`&&`title`in e&&typeof e.title==`string`&&`type`in e&&(e.type===null||typeof e.type==`string`))}function dD(){try{if(typeof localStorage>`u`)return[];let e=localStorage.getItem(cD);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(uD).slice(0,lD):[]}catch{return[]}}function fD(e){try{if(typeof localStorage>`u`)return;let t=[e,...dD().filter(t=>t.project!==e.project||t.id!==e.id)].slice(0,lD);localStorage.setItem(cD,JSON.stringify(t))}catch{}}function pD({text:e,query:t,className:n}){if(!e)return null;if(!t?.trim())return(0,h.jsx)(`span`,{className:n,children:e});let r=t.trim().split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),i=[],a={};for(let e of r){let t=e.toLowerCase();a[t]||(a[t]=!0,i.push(e))}if(i.sort((e,t)=>t.length-e.length),i.length===0)return(0,h.jsx)(`span`,{className:n,children:e});let o=i.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),s=RegExp(`(${o.join(`|`)})`,`gi`),c=e.split(s);return(0,h.jsx)(`span`,{className:n,children:c.map((e,t)=>i.some(t=>t.toLowerCase()===e.toLowerCase())?(0,h.jsx)(`mark`,{className:`rounded-xs bg-amber-400/25 px-0.5 font-medium text-fg dark:bg-amber-400/35`,children:e},t):e)})}var mD=[`Project`,`Decision`,`Convention`,`Architecture`,`Component`,`Playbook`,`Interface`,`Reference`,`Glossary Term`],hD={project:`text-accent-500`,decision:`text-violet-600 dark:text-violet-400`,convention:`text-sky-600 dark:text-sky-400`,architecture:`text-cyan-600 dark:text-cyan-400`,component:`text-cyan-600 dark:text-cyan-400`,playbook:`text-emerald-600 dark:text-emerald-400`,interface:`text-amber-600 dark:text-amber-400`,reference:`text-zinc-600 dark:text-zinc-400`,"glossary term":`text-pink-600 dark:text-pink-400`};function gD(e){return e?hD[e.trim().toLowerCase()]??`text-zinc-600 dark:text-zinc-400`:`text-zinc-600 dark:text-zinc-400`}function _D({type:e,className:t,size:n=16}){let r=e?e.trim().toLowerCase():``,i=X(`shrink-0`,gD(e),t);switch(r){case`project`:return(0,h.jsx)(lx,{size:n,className:i});case`decision`:return(0,h.jsx)(Gx,{size:n,className:i});case`convention`:return(0,h.jsx)(Ux,{size:n,className:i});case`architecture`:return(0,h.jsx)(Lx,{size:n,className:i});case`component`:return(0,h.jsx)(jb,{size:n,className:i});case`playbook`:return(0,h.jsx)(Tb,{size:n,className:i});case`interface`:return(0,h.jsx)(zx,{size:n,className:i});case`reference`:return(0,h.jsx)(Db,{size:n,className:i});case`glossary term`:return(0,h.jsx)(Cb,{size:n,className:i});default:return(0,h.jsx)(sx,{size:n,className:i})}}function vD({open:e=!1,className:t,size:n=16}){let r=X(`shrink-0 text-muted`,t);return e?(0,h.jsx)(dx,{size:n,className:r}):(0,h.jsx)(px,{size:n,className:r})}function yD({className:e,size:t=16}){return(0,h.jsx)(rx,{size:t,className:X(`shrink-0 text-muted`,e)})}var bD=(0,m.createContext)(null);function xD(){let e=(0,m.useContext)(bD);if(!e)throw Error(`useCommandPalette must be used within CommandPaletteContext.Provider`);return e}function SD(e){let t=e?.toLowerCase();return t===`human-reviewed`?`bg-emerald-500`:t===`machine-confirmed`?`bg-sky-500`:t===`proposed`?`bg-violet-500`:`bg-zinc-400 dark:bg-zinc-600`}function CD({open:e,onOpenChange:t,currentProject:n}){let r=kh(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!!n),[u,d]=(0,m.useState)(``);(0,m.useEffect)(()=>{l(!!n)},[n]),(0,m.useEffect)(()=>{let e=setTimeout(()=>{s(i)},150);return()=>clearTimeout(e)},[i]),(0,m.useEffect)(()=>{function n(n){if((n.metaKey||n.ctrlKey)&&n.key===`k`){n.preventDefault(),t(!e);return}if(n.key===`/`&&!e){let e=n.target;e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`||e.isContentEditable||e.closest(`input, textarea, select, [contenteditable]`))||(n.preventDefault(),t(!0))}}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let f=D_(),p=e?dD():[],g=o.trim().length>=2,_=c&&n?n:void 0,v=P_({q:o.trim(),project:_,limit:20},g&&e),y=g?v.data?.[0]:void 0,b=p[0],x=f.data?.[0],S=``;y?S=`hit-${y.project}-${y.id}`:o.trim().length>0?S=`search-all-results`:b?S=`recent-${b.project}-${b.id}`:x&&(S=`proj-${x.project}`),(0,m.useEffect)(()=>{d(S)},[S]);let C=e=>{t(!1),a(``),r(e)};return(0,h.jsxs)(BE.Dialog,{value:u,onValueChange:d,open:e,onOpenChange:e=>{t(e),e||a(``)},label:`Search concepts, projects…`,shouldFilter:!1,overlayClassName:`fixed inset-0 bg-black/60 backdrop-blur-xs z-50 animate-[okf-fade-in_120ms_ease-out]`,contentClassName:`fixed left-1/2 top-[15%] -translate-x-1/2 w-full max-w-xl z-50 p-3 outline-none`,className:`w-full bg-surface border border-border-strong rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[70vh] text-fg animate-[okf-scale-in_120ms_ease-out]`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border`,children:[(0,h.jsx)(qx,{size:16,className:`text-muted shrink-0`}),(0,h.jsx)(BE.Input,{value:i,onValueChange:a,placeholder:`Search concepts, projects…`,className:`w-full bg-transparent py-3 text-sm text-fg placeholder:text-muted outline-none`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{n&&l(e=>!e)},disabled:!n,className:X(`shrink-0 text-xs px-2.5 py-1 rounded-md font-medium transition-colors select-none`,n?c?`bg-accent-500/10 text-accent-500 ring-1 ring-accent-500/20 hover:bg-accent-500/20 cursor-pointer`:`bg-surface-2 text-muted ring-1 ring-border hover:text-fg cursor-pointer`:`bg-surface-2 text-muted/60 ring-1 ring-border cursor-default`),title:n?`Click to toggle search scope`:void 0,children:c&&n?`This project`:`All projects`})]}),(0,h.jsxs)(BE.List,{className:`overflow-y-auto max-h-[380px] p-2 space-y-1`,children:[g&&v.isLoading&&(0,h.jsx)(BE.Loading,{className:`px-4 py-8 text-center text-xs text-subtle`,children:`Searching...`}),g&&!v.isLoading&&v.data&&v.data.length===0&&(0,h.jsx)(BE.Empty,{className:`px-4 py-8 text-center text-xs text-subtle`,children:`No matching concepts or files`}),g&&v.data&&v.data.length>0&&(0,h.jsx)(BE.Group,{heading:`Concepts & Files`,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-[11px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-subtle [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider`,children:v.data.map(e=>(0,h.jsxs)(BE.Item,{value:`hit-${e.project}-${e.id}`,onSelect:()=>C(oD(e.project,e.id)),className:`flex flex-col gap-1 px-2.5 py-2 rounded-lg text-xs cursor-pointer data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,h.jsx)(_D,{type:e.type,size:14}),(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:e.title}),(0,h.jsxs)(`span`,{className:`font-mono text-[11px] text-subtle truncate`,children:[e.project,`/`,e.id]}),(0,h.jsx)(`span`,{className:X(`ml-auto h-2 w-2 rounded-full shrink-0`,SD(e.trustTier)),title:e.trustTier})]}),e.snippet&&(0,h.jsx)(`div`,{className:`text-[11px] text-muted truncate pl-5`,children:(0,h.jsx)(pD,{text:e.snippet,query:o})})]},`${e.project}/${e.id}`))}),!g&&(0,h.jsxs)(h.Fragment,{children:[p.length>0&&(0,h.jsx)(BE.Group,{heading:`Recent`,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-[11px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-subtle [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider`,children:p.map(e=>(0,h.jsxs)(BE.Item,{value:`recent-${e.project}-${e.id}`,onSelect:()=>C(oD(e.project,e.id)),className:`flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs cursor-pointer data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsx)(_D,{type:e.type,size:14}),(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:e.title}),(0,h.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-subtle shrink-0`,children:[e.project,`/`,e.id]})]},`recent-${e.project}-${e.id}`))}),f.data&&f.data.length>0&&(0,h.jsx)(BE.Group,{heading:`Projects`,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-[11px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-subtle [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider`,children:f.data.map(e=>(0,h.jsxs)(BE.Item,{value:`proj-${e.project}`,onSelect:()=>C(`/p/${encodeURIComponent(e.project)}`),className:`flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs cursor-pointer data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsx)(lx,{size:14,className:`text-accent-500 shrink-0`}),(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:e.title}),(0,h.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-subtle shrink-0`,children:e.project})]},`proj-${e.project}`))})]}),o.trim().length>0&&(0,h.jsx)(BE.Group,{className:`pt-1 border-t border-border mt-1`,children:(0,h.jsxs)(BE.Item,{value:`search-all-results`,onSelect:()=>{let e=new URLSearchParams;e.set(`q`,o.trim()),c&&n&&e.set(`project`,n),C(`/search?${e.toString()}`)},className:`flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs cursor-pointer text-muted hover:text-fg data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsx)(qx,{size:14,className:`shrink-0 text-muted`}),(0,h.jsxs)(`span`,{children:[`Search all results for “`,(0,h.jsx)(`strong`,{className:`text-fg font-medium`,children:o.trim()}),`”`]})]})})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-3 px-3.5 py-2 border-t border-border text-[11px] text-subtle bg-surface-2/40 select-none`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`kbd`,{className:`font-mono bg-surface px-1 py-0.2 rounded border border-border`,children:`↑↓`}),` navigate`]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`kbd`,{className:`font-mono bg-surface px-1 py-0.2 rounded border border-border`,children:`↵`}),` open`]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`kbd`,{className:`font-mono bg-surface px-1 py-0.2 rounded border border-border`,children:`esc`}),` close`]})]})]})}function Q({className:e}){return(0,h.jsx)(`div`,{className:X(`animate-shimmer rounded-md bg-surface-2`,e),"aria-hidden":`true`})}var wD=(0,m.createContext)(null);function TD(){let e=(0,m.useContext)(wD);if(!e)throw Error(`useTreeState must be used within a TreeStateContext.Provider`);return e}function ED(e,t){let n=[],r=[],i=[];for(let a of e)if(a.kind===`directory`)n.push(a);else if(a.kind===`concept`){if(t&&a.id===`overview`)continue;r.push(a)}else a.kind===`file`&&i.push(a);return n.sort((e,t)=>e.path.localeCompare(t.path)),r.sort((e,t)=>e.title.localeCompare(t.title)),i.sort((e,t)=>e.path.localeCompare(t.path)),[...n,...r,...i]}function DD({project:e,dir:t,depth:n,activeConceptId:r,activeFilePath:i}){let{data:a,isLoading:o}=k_(e,t,!0),{expanded:s,toggle:c}=TD(),l=(0,m.useMemo)(()=>a?ED(a,t===``):[],[a,t]);return o?(0,h.jsxs)(`div`,{className:`py-1 space-y-1`,style:{paddingLeft:`${n*12+12}px`},children:[(0,h.jsx)(Q,{className:`h-5 w-3/4 rounded-md`}),(0,h.jsx)(Q,{className:`h-5 w-1/2 rounded-md`})]}):l.length===0?(0,h.jsx)(`div`,{className:`py-1 text-[11px] text-subtle italic select-none`,style:{paddingLeft:`${n*12+16}px`},children:`Empty directory`}):(0,h.jsx)(`div`,{className:`space-y-0.5`,children:l.map(t=>{if(t.kind===`directory`){let a=s.has(t.path),o=t.path.split(`/`).pop()??t.path;return(0,h.jsxs)(`div`,{"data-tree-path":t.path,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>c(t.path),className:`group flex w-full items-center gap-1.5 py-1 pr-2 rounded-md text-xs font-medium text-muted hover:text-fg hover:bg-surface-2 transition-colors cursor-pointer text-left`,style:{paddingLeft:`${n*12+6}px`},children:[(0,h.jsx)(Lb,{size:12,className:X(`text-subtle transition-transform duration-150 shrink-0`,a&&`rotate-90`)}),(0,h.jsx)(vD,{open:a,size:14}),(0,h.jsx)(`span`,{className:`truncate flex-1`,children:o}),(0,h.jsx)(`span`,{className:`ml-auto text-[11px] text-subtle font-mono tabular-nums`,children:t.conceptCount})]}),(0,h.jsx)(tu,{initial:!1,children:a&&(0,h.jsx)(Gd.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:`easeInOut`},className:`overflow-hidden`,children:(0,h.jsx)(DD,{project:e,dir:t.path,depth:n+1,activeConceptId:r,activeFilePath:i})})})]},`dir-${t.path}`)}if(t.kind===`concept`){let i=r===t.id;return(0,h.jsx)(`div`,{"data-tree-path":t.id,children:(0,h.jsxs)($g,{to:oD(e,t.id),className:X(`group flex items-center gap-2 py-1 pr-2 rounded-md text-xs transition-colors`,i?`border-l-2 border-accent-500 bg-surface-2 text-fg font-medium pl-[calc(var(--tree-pad)-2px)]`:`border-l-2 border-transparent text-muted hover:text-fg hover:bg-surface-2`),style:{"--tree-pad":`${n*12+20}px`,paddingLeft:i?`${n*12+18}px`:`${n*12+20}px`},children:[(0,h.jsx)(_D,{type:t.type,size:14}),(0,h.jsx)(`span`,{className:`truncate`,children:t.title})]})},`concept-${t.id}`)}if(t.kind===`file`){let r=i===t.path,a=t.path.split(`/`).pop()??t.path;return(0,h.jsx)(`div`,{"data-tree-path":t.path,children:(0,h.jsxs)($g,{to:sD(e,t.path),className:X(`group flex items-center gap-2 py-1 pr-2 rounded-md text-xs transition-colors`,r?`border-l-2 border-accent-500 bg-surface-2 text-fg font-medium font-mono`:`border-l-2 border-transparent text-muted hover:text-fg hover:bg-surface-2 font-mono`),style:{paddingLeft:r?`${n*12+18}px`:`${n*12+20}px`},children:[(0,h.jsx)(yD,{size:14}),(0,h.jsx)(`span`,{className:`truncate`,children:a})]})},`file-${t.path}`)}return null})})}function OD({project:e}){let t=Nh(),n=Dh(),r=t[`*`]??null,i=n.pathname.includes(`/c/`)&&r!==null,a=n.pathname.includes(`/f/`)&&r!==null,o=i?r:null,s=a?r:null,{expanded:c,toggle:l}=TD();return(0,m.useEffect)(()=>{let e=o??s;if(!e)return;let t=e.split(`/`);if(t.length<=1)return;let n=``;for(let e=0;e<t.length-1;e++){let r=t[e];r&&(n=n?`${n}/${r}`:r,c.has(n)||l(n))}},[o,s,c,l]),(0,h.jsx)(`div`,{className:`py-1`,children:(0,h.jsx)(DD,{project:e,dir:``,depth:0,activeConceptId:o,activeFilePath:s})})}var kD=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`}),AD=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function jD(e){let t=new Date(e).getTime();if(Number.isNaN(t))return e;let n=Math.round((t-Date.now())/1e3);if(Math.abs(n)<60)return kD.format(n,`second`);let r=Math.round(n/60);if(Math.abs(r)<60)return kD.format(r,`minute`);let i=Math.round(r/60);if(Math.abs(i)<24)return kD.format(i,`hour`);let a=Math.round(i/24);if(Math.abs(a)<7)return kD.format(a,`day`);let o=Math.round(a/7);if(Math.abs(o)<5)return kD.format(o,`week`);let s=Math.round(a/30);if(Math.abs(s)<12)return kD.format(s,`month`);let c=Math.round(a/365);return kD.format(c,`year`)}function MD(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:AD.format(t)}function ND(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)%360}function PD(e){let t=e.startsWith(`human:`)?e.slice(6):e,n=t.indexOf(`@`);n!==-1&&(t=t.slice(0,n));let r=t.match(/[A-Za-z0-9]+/g);return!r||r.length===0?``:r.slice(0,2).map(e=>e[0]?.toUpperCase()??``).join(``)}function FD(e){return e.startsWith(`human:`)?`human`:`agent`}function ID(e){return e.slice(0,7)}function LD({className:e}){let{data:t,isLoading:n}=F_();if(n||!t)return(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-zinc-500/10 text-zinc-500 ring-1 ring-inset ring-zinc-500/20`,e),children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-zinc-400 animate-pulse`}),(0,h.jsx)(`span`,{children:`Syncing...`})]});if(t.remote===null)return(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 ring-1 ring-inset ring-zinc-500/20`,e),children:[(0,h.jsx)(yx,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Local only`})]});if(t.lastError)return(0,h.jsxs)(`span`,{title:t.lastError,className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-rose-500/10 text-rose-600 dark:text-rose-400 ring-1 ring-inset ring-rose-500/20`,e),children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-rose-500 shrink-0`}),(0,h.jsx)(`span`,{className:`truncate max-w-[120px]`,children:`Sync error`})]});if(t.ahead>0||t.behind>0)return(0,h.jsx)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-1 ring-inset ring-amber-500/20 font-mono`,e),children:(0,h.jsxs)(`span`,{children:[`↑`,t.ahead,` ↓`,t.behind]})});let r=t.lastSyncAt?jD(t.lastSyncAt):`just now`;return(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-1 ring-inset ring-emerald-500/20`,e),children:[(0,h.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0`,children:[(0,h.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75`}),(0,h.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full bg-emerald-500`})]}),(0,h.jsxs)(`span`,{children:[`Synced `,r]})]})}var RD={system:`light`,light:`dark`,dark:`system`};function zD({className:e}){let[t,n]=ab();return(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{n(RD[t])},className:e??`inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg transition-colors`,"aria-label":`Toggle theme (current: ${t})`,title:`Theme: ${t} (click to switch to ${RD[t]})`,children:[t===`system`&&(0,h.jsx)(Nx,{size:16}),t===`light`&&(0,h.jsx)($x,{size:16}),t===`dark`&&(0,h.jsx)(Fx,{size:16})]})}function BD({actor:e,size:t=28,className:n}){let r=ND(e),i=PD(e),a=FD(e),o=Math.max(10,Math.round(t*.42)),s=Math.max(10,Math.round(t*.4));return(0,h.jsxs)(`div`,{className:X(`relative inline-flex shrink-0 select-none`,n),style:{width:t,height:t},title:e,children:[(0,h.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded-full font-medium text-white shadow-xs`,style:{background:`linear-gradient(135deg, hsl(${r} 70% 55%), hsl(${(r+40)%360} 70% 45%))`,fontSize:s},children:i}),(0,h.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 flex items-center justify-center rounded-full bg-surface text-muted ring-1 ring-border`,style:{width:o+4,height:o+4},children:a===`human`?(0,h.jsx)(aS,{size:o}):(0,h.jsx)(kb,{size:o})})]})}function VD({className:e}){let{state:t,logout:n}=Yy(),[r,i]=(0,m.useState)(!1),a=(0,m.useRef)(null);if((0,m.useEffect)(()=>{if(!r)return;function e(e){a.current&&!a.current.contains(e.target)&&i(!1)}function t(e){e.key===`Escape`&&i(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),t.status===`loading`)return(0,h.jsx)(`div`,{className:X(`h-7 w-24 rounded-md bg-surface-2 animate-pulse`,e)});let o=t.status===`open`,s=t.status===`signed-in`,c=`config`in t?t.config.version:null,l=s?t.identity:null;return(0,h.jsxs)(`div`,{ref:a,className:X(`relative inline-block`,e),children:[o?(0,h.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-1 ring-inset ring-amber-500/20 hover:bg-amber-500/20 transition-colors`,title:`Running in local mode without authentication`,"aria-expanded":r,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-500`}),(0,h.jsx)(`span`,{children:`Local mode · auth off`})]}):s?(0,h.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex items-center gap-2 rounded-lg p-1 text-left hover:bg-surface-2 transition-colors max-w-[200px]`,"aria-expanded":r,children:[(0,h.jsx)(BD,{actor:l??`User`,size:26}),(0,h.jsx)(`span`,{className:`truncate text-xs font-medium text-fg`,children:l??`Signed in`})]}):null,r&&(0,h.jsxs)(`div`,{role:`menu`,className:`absolute bottom-full left-0 mb-2 w-56 rounded-xl border border-border bg-surface p-1.5 shadow-xl z-50 text-xs`,children:[l&&(0,h.jsxs)(`div`,{className:`px-2.5 py-1.5 border-b border-border mb-1`,children:[(0,h.jsx)(`div`,{className:`font-medium text-fg truncate`,children:l}),(0,h.jsx)(`div`,{className:`text-[11px] text-muted truncate`,children:`Identity provider session`})]}),c&&(0,h.jsxs)(`div`,{className:`px-2.5 py-1 text-[11px] text-muted font-mono`,children:[`ok-fine v`,c]}),s&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(!1),n()},className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-xs font-medium text-rose-600 dark:text-rose-400 hover:bg-rose-500/10 transition-colors cursor-pointer`,children:[(0,h.jsx)(kx,{size:13,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Sign out`})]})]})]})]})}function HD({project:e,drawerOpen:t,onCloseDrawer:n}){let r=kh(),i=D_(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null),c=i.data?.find(t=>t.project===e)?.title??e??`All projects`;(0,m.useEffect)(()=>{if(!a)return;function e(e){s.current&&!s.current.contains(e.target)&&o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let l=e=>{o(!1),n(),r(e?`/p/${encodeURIComponent(e)}`:`/`)};return(0,h.jsxs)(h.Fragment,{children:[t&&(0,h.jsx)(`button`,{type:`button`,"aria-label":`Close sidebar`,onClick:n,className:`fixed inset-0 z-40 bg-black/50 backdrop-blur-xs lg:hidden animate-[fade-in_150ms_ease-out] cursor-default border-none p-0`}),(0,h.jsxs)(`aside`,{className:X(`fixed inset-y-0 left-0 z-50 w-[272px] bg-surface border-r border-border flex flex-col h-full shadow-2xl lg:shadow-none transition-transform duration-200 ease-out lg:static lg:z-auto lg:translate-x-0`,t?`translate-x-0`:`-translate-x-full lg:translate-x-0`),children:[(0,h.jsxs)(`div`,{className:`h-14 border-b border-border flex items-center justify-between px-4 shrink-0`,children:[(0,h.jsx)($g,{to:`/`,onClick:n,className:`hover:opacity-90 transition-opacity`,title:`ok-fine home`,children:(0,h.jsx)(dS,{size:22})}),(0,h.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close sidebar`,className:`lg:hidden p-1.5 rounded-lg text-muted hover:text-fg hover:bg-surface-2 transition-colors cursor-pointer`,children:(0,h.jsx)(sS,{size:18})})]}),(0,h.jsxs)(`div`,{ref:s,className:`relative p-2 border-b border-border shrink-0`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`flex w-full items-center justify-between gap-2 px-2.5 py-1.5 rounded-lg bg-surface-2 hover:bg-surface border border-border text-xs font-medium text-fg transition-colors cursor-pointer text-left`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:c}),(0,h.jsx)(zb,{size:14,className:`text-subtle shrink-0`})]}),a&&(0,h.jsxs)(`div`,{role:`menu`,className:`absolute left-2 right-2 top-full mt-1 rounded-xl border border-border bg-surface p-1 shadow-xl z-50 text-xs space-y-0.5 max-h-64 overflow-y-auto`,children:[(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>l(),className:X(`flex w-full items-center justify-between px-2.5 py-1.5 rounded-lg text-left transition-colors cursor-pointer`,e?`text-muted hover:text-fg hover:bg-surface-2`:`bg-accent-500/10 text-accent-500 font-medium`),children:[(0,h.jsx)(`span`,{children:`All projects`}),!e&&(0,h.jsx)(Nb,{size:14,className:`shrink-0`})]}),(0,h.jsx)(`div`,{className:`my-1 border-t border-border`}),i.data?.map(t=>{let n=t.project===e;return(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>l(t.project),className:X(`flex w-full items-center justify-between px-2.5 py-1.5 rounded-lg text-left transition-colors cursor-pointer`,n?`bg-accent-500/10 text-accent-500 font-medium`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsxs)(`div`,{className:`truncate pr-2`,children:[(0,h.jsx)(`div`,{className:`font-medium truncate`,children:t.title}),(0,h.jsx)(`div`,{className:`font-mono text-[10px] text-subtle truncate`,children:t.project})]}),n&&(0,h.jsx)(Nb,{size:14,className:`shrink-0`})]},t.project)})]})]}),(0,h.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0 flex flex-col p-2 space-y-4`,children:e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`nav`,{"aria-label":`Project sections`,className:`space-y-0.5`,children:[(0,h.jsxs)(e_,{to:`/p/${encodeURIComponent(e)}`,end:!0,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(Tx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Overview`})]}),(0,h.jsxs)(e_,{to:`/p/${encodeURIComponent(e)}/activity`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(Vx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Activity`})]}),(0,h.jsxs)(e_,{to:`/p/${encodeURIComponent(e)}/health`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(xx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Health`})]}),(0,h.jsxs)(e_,{to:`/search?project=${encodeURIComponent(e)}`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(qx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Search`})]})]}),(0,h.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,h.jsx)(`div`,{className:`px-2 pb-1 text-[11px] font-medium uppercase tracking-wider text-subtle select-none`,children:`Knowledge`}),(0,h.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,h.jsx)(OD,{project:e})})]})]}):(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`nav`,{"aria-label":`Global navigation`,className:`space-y-0.5`,children:[(0,h.jsxs)(e_,{to:`/`,end:!0,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(Tx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Projects`})]}),(0,h.jsxs)(e_,{to:`/search`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(qx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Search`})]})]}),i.data&&i.data.length>0&&(0,h.jsxs)(`div`,{className:`pt-2`,children:[(0,h.jsx)(`div`,{className:`px-2 pb-1 text-[11px] font-medium uppercase tracking-wider text-subtle select-none`,children:`Projects`}),(0,h.jsx)(`div`,{className:`space-y-0.5`,children:i.data.map(e=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e.project)}`,onClick:n,className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-xs text-muted hover:text-fg hover:bg-surface-2 transition-colors`,children:[(0,h.jsx)(lx,{size:14,className:`text-accent-500 shrink-0`}),(0,h.jsx)(`span`,{className:`truncate`,children:e.title})]},e.project))})]})]})}),(0,h.jsxs)(`div`,{className:`p-3 border-t border-border flex flex-col gap-2.5 mt-auto bg-surface shrink-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(LD,{}),(0,h.jsx)(zD,{})]}),(0,h.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,h.jsx)(VD,{})})]})]})]})}function UD({className:e}){let t=Nh(),n=Dh(),r=t.project,i=t[`*`],a=O_(r??``).data?.title??r,o=n.pathname.includes(`/c/`)&&!!i,s=n.pathname.includes(`/f/`)&&!!i,c=n.pathname.endsWith(`/activity`),l=n.pathname.endsWith(`/health`),u=n.pathname===`/search`,d=A_(r??``,o?i??``:``).data?.derived?.title??(i?i.split(`/`).pop():``),f=i?i.split(`/`):[],p=f.slice(0,-1),m=f[f.length-1]??``,g=(0,h.jsx)(`span`,{className:`text-subtle/50 select-none mx-0.5`,children:`/`});return(0,h.jsxs)(`nav`,{"aria-label":`Breadcrumbs`,className:X(`flex items-center gap-1 text-xs overflow-hidden whitespace-nowrap min-w-0`,e),children:[(0,h.jsx)($g,{to:`/`,className:X(`transition-colors shrink-0`,!r&&!u?`font-medium text-fg`:`text-muted hover:text-fg`),children:`Projects`}),u&&(0,h.jsxs)(h.Fragment,{children:[g,(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:`Search`})]}),r&&(0,h.jsxs)(h.Fragment,{children:[g,!o&&!s&&!c&&!l?(0,h.jsx)(`span`,{className:`font-medium text-fg truncate max-w-[200px]`,title:a,children:a}):(0,h.jsx)($g,{to:`/p/${encodeURIComponent(r)}`,className:`text-muted hover:text-fg transition-colors truncate max-w-[160px] shrink-0`,title:a,children:a})]}),c&&(0,h.jsxs)(h.Fragment,{children:[g,(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:`Activity`})]}),l&&(0,h.jsxs)(h.Fragment,{children:[g,(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:`Health`})]}),(o||s)&&(0,h.jsxs)(h.Fragment,{children:[p.map((e,t)=>{let n=p.slice(0,t+1).join(`/`);return(0,h.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[g,(0,h.jsx)(`span`,{className:`text-subtle select-none max-w-[120px] truncate`,title:e,children:e})]},n)}),g,o?(0,h.jsx)(`span`,{className:`font-medium text-fg truncate max-w-[220px]`,title:d,children:d}):(0,h.jsx)(`span`,{className:`font-medium font-mono text-fg truncate max-w-[220px]`,title:m,children:m})]})]})}function WD({onMenuClick:e}){let{open:t}=xD();return(0,h.jsxs)(`header`,{className:`sticky top-0 z-30 h-14 bg-bg/70 backdrop-blur-xl border-b border-border flex items-center justify-between px-4 gap-4 shrink-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Open sidebar menu`,className:`lg:hidden p-1.5 -ml-1 rounded-lg text-muted hover:text-fg hover:bg-surface-2 transition-colors cursor-pointer shrink-0`,children:(0,h.jsx)(jx,{size:18})}),(0,h.jsx)(UD,{})]}),(0,h.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 px-2.5 py-1 rounded-lg bg-surface-2 hover:bg-surface border border-border hover:border-border-strong text-xs transition-colors cursor-pointer shrink-0`,title:`Search knowledge base (⌘K or /)`,children:[(0,h.jsx)(qx,{size:13,className:`text-muted shrink-0`}),(0,h.jsx)(`span`,{className:`text-muted hidden sm:inline`,children:`Search knowledge…`}),(0,h.jsx)(`kbd`,{className:`hidden sm:inline-block font-mono text-[10px] text-subtle bg-surface px-1.5 py-0.5 rounded border border-border`,children:`⌘K`})]})]})}function GD(){let{project:e}=Nh(),[t,n]=(0,m.useState)(()=>new Set),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(e);(0,m.useEffect)(()=>{s.current!==e&&(s.current=e,n(new Set))},[e]);let{pathname:c}=Dh();(0,m.useEffect)(()=>{c&&i(!1)},[c]);let l=(0,m.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),u=(0,m.useCallback)(e=>{n(t=>{let n=new Set(t),r=e.split(`/`),i=``;for(let e of r)e&&(i=i?`${i}/${e}`:e,n.add(i));return n}),i(!0),requestAnimationFrame(()=>{try{document.querySelector(`[data-tree-path="${CSS.escape(e)}"]`)?.scrollIntoView({block:`nearest`,behavior:`smooth`})}catch{document.querySelector(`[data-tree-path]`)?.scrollIntoView({block:`nearest`,behavior:`smooth`})}})},[]),d=(0,m.useMemo)(()=>({expanded:t,toggle:l,reveal:u}),[t,l,u]),f=(0,m.useMemo)(()=>({open:()=>o(!0)}),[]);return(0,h.jsx)(wD.Provider,{value:d,children:(0,h.jsxs)(bD.Provider,{value:f,children:[(0,h.jsxs)(`div`,{className:`flex h-screen w-screen overflow-hidden text-fg`,children:[(0,h.jsx)(HD,{project:e,drawerOpen:r,onCloseDrawer:()=>i(!1)}),(0,h.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 h-full overflow-hidden`,children:[(0,h.jsx)(WD,{onMenuClick:()=>i(!0)}),(0,h.jsx)(`main`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,h.jsx)(og,{})})]})]}),(0,h.jsx)(CD,{open:a,onOpenChange:o,currentProject:e})]})})}var KD=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function qD(){let e=Nh().project??``,{data:t}=O_(e),{data:n,isLoading:r,isError:i,error:a,refetch:o}=M_(e,{limit:100}),s=(0,m.useMemo)(()=>{if(!n||n.length===0)return[];let e=[],t=``,r=[];for(let i of n){let n=KD.format(new Date(i.at));n===t?r.push(i):(r.length>0&&e.push({day:t,entries:r}),t=n,r=[i])}return r.length>0&&e.push({day:t,entries:r}),e},[n]),c=t?.title?`${t.title} Activity`:`Activity`;return r?(0,h.jsxs)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-32 rounded-md`}),(0,h.jsx)(Q,{className:`h-8 w-48 rounded-lg`})]}),(0,h.jsx)(`div`,{className:`mt-8 space-y-8`,children:Array.from({length:2}).map((e,t)=>(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(Q,{className:`h-5 w-40 rounded-md`}),(0,h.jsx)(`div`,{className:`rounded-xl border border-border bg-surface divide-y divide-border p-4 space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(Q,{className:`h-7 w-7 rounded-full shrink-0`}),(0,h.jsxs)(`div`,{className:`space-y-1`,children:[(0,h.jsx)(Q,{className:`h-4 w-48`}),(0,h.jsx)(Q,{className:`h-3 w-32`})]})]}),(0,h.jsx)(Q,{className:`h-6 w-16 rounded-md`})]},t))})]},t))})]}):i?(0,h.jsx)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:a,onRetry:()=>void o()})}):!n||n.length===0?(0,h.jsxs)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-6`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}`,className:`transition-colors hover:text-fg`,children:t?.title??e}),(0,h.jsx)(`span`,{children:`/`}),(0,h.jsx)(`span`,{className:`text-fg`,children:`Activity`})]}),(0,h.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:`Activity`})]}),(0,h.jsx)(cS,{icon:Vx,title:`No activity recorded`,hint:`Changes to concepts and files in this project will appear here.`,className:`mt-8 py-16`})]}):(0,h.jsxs)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}`,className:`transition-colors hover:text-fg`,children:t?.title??e}),(0,h.jsx)(`span`,{children:`/`}),(0,h.jsx)(`span`,{className:`text-fg`,children:`Activity`})]}),(0,h.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:`Activity`}),(0,h.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`History of commits and updates for `,t?.title??e]})]}),(0,h.jsx)(`div`,{className:`space-y-8`,children:s.map(e=>(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-muted`,children:e.day}),(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:e.entries.map(e=>{let t=e.actor.startsWith(`human:`),n=t?e.actor.slice(6):e.actor;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,h.jsx)(BD,{actor:e.actor,size:28,className:`mt-0.5 shrink-0`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`text-sm font-medium text-fg break-words`,children:e.subject}),(0,h.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-subtle`,children:[t?(0,h.jsx)(aS,{size:12,className:`shrink-0 text-muted`}):(0,h.jsx)(kb,{size:12,className:`shrink-0 text-muted`}),(0,h.jsx)(`span`,{className:`truncate max-w-[200px]`,children:n})]}),e.principal&&(0,h.jsxs)(`span`,{className:`font-mono text-xs text-subtle truncate max-w-[200px]`,children:[`(`,e.principal,`)`]}),(0,h.jsx)(`span`,{children:`·`}),(0,h.jsx)(`span`,{title:MD(e.at),children:jD(e.at)})]})]})]}),(0,h.jsx)(`div`,{className:`flex items-center gap-2 self-end sm:self-center shrink-0`,children:(0,h.jsx)(mS,{value:e.sha,label:ID(e.sha),className:`font-mono text-xs`})})]},e.sha)})})]},e.day))})]})}function JD(){let{completeLogin:e}=Yy(),t=kh(),[n,r]=(0,m.useState)(null),i=(0,m.useRef)(!1);return(0,m.useEffect)(()=>{if(i.current)return;i.current=!0;let n=new URL(window.location.href);e(n).then(e=>{t(Gy(e),{replace:!0})}).catch(e=>{let t;t=e instanceof wv||e instanceof Cv?e.error_description?`${e.error}: ${e.error_description}`:e.error:e instanceof Error?e.message:String(e),r(t)})},[e,t]),n===null?(0,h.jsx)(fS,{title:`Signing in`,className:`min-h-screen flex items-center justify-center p-6 bg-bg`,children:(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3`,children:[(0,h.jsx)(Dx,{size:36,className:`animate-spin text-accent-500`}),(0,h.jsx)(`p`,{className:`text-sm font-medium text-muted`,children:`Signing you in…`})]})}):(0,h.jsx)(gS,{error:n})}function YD({className:e,children:t}){return(0,h.jsx)(`span`,{className:X(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset`,e),children:t})}function XD({status:e,className:t}){let n=e.toLowerCase(),r=`bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 ring-zinc-500/20`;return n===`draft`?r=`bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-amber-500/20`:n===`stable`?r=`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`:n===`deprecated`&&(r=`bg-rose-500/10 text-rose-600 dark:text-rose-400 ring-rose-500/20`),(0,h.jsx)(YD,{className:X(r,t),children:e})}function ZD({tier:e,className:t}){let n=e.toLowerCase();return n===`human-reviewed`?(0,h.jsxs)(YD,{className:X(`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`,t),children:[(0,h.jsx)(Yx,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`human-reviewed`})]}):n===`machine-confirmed`?(0,h.jsxs)(YD,{className:X(`bg-sky-500/10 text-sky-600 dark:text-sky-400 ring-sky-500/20`,t),children:[(0,h.jsx)(xb,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`machine-confirmed`})]}):n===`proposed`?(0,h.jsxs)(YD,{className:X(`bg-violet-500/10 text-violet-600 dark:text-violet-400 ring-violet-500/20`,t),children:[(0,h.jsx)(_x,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`proposed`})]}):(0,h.jsxs)(YD,{className:X(`bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 ring-zinc-500/20`,t),children:[(0,h.jsx)(Gb,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:e||`unverified`})]})}function QD({className:e}){return(0,h.jsxs)(YD,{className:X(`bg-orange-500/10 text-orange-600 dark:text-orange-400 ring-orange-500/20`,e),children:[(0,h.jsx)(qb,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Stale`})]})}function $D({type:e,className:t}){return(0,h.jsxs)(YD,{className:X(`bg-surface-2 text-fg ring-border`,t),children:[(0,h.jsx)(_D,{type:e,size:12}),(0,h.jsx)(`span`,{children:e||`Concept`})]})}function eO({code:e,lang:t,lineNumbers:n=!1,className:r}){let[i,a]=(0,m.useState)(null);(0,m.useEffect)(()=>{let n=!1;if(!t){a(null);return}return Ag(async()=>{let{highlight:e}=await import(`./highlight-D8LQtOZ_.js`);return{highlight:e}},[]).then(({highlight:n})=>n(e,t)).then(e=>{n||a(e)}).catch(()=>{n||a(null)}),()=>{n=!0}},[e,t]);let o=e.split(`
57
+ `},FT=0,IT=[];function LT(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(FT++)[0],a=m.useState(aT)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Fw([e.lockRef.current],(e.shards||[]).map(MT),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=AT(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=CT(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=CT(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return kT(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if(IT.length&&IT[IT.length-1]===a){var r=`deltaY`in n?jT(n):AT(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&NT(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(MT).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:RT(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=AT(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,jT(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,AT(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return IT.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,vT),document.addEventListener(`touchmove`,c,vT),document.addEventListener(`touchstart`,u,vT),function(){IT=IT.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,vT),document.removeEventListener(`touchmove`,c,vT),document.removeEventListener(`touchstart`,u,vT)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:PT(i)}):null,p?m.createElement(hT,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function RT(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var zT=Yw(Xw,LT),BT=m.forwardRef(function(e,t){return m.createElement(Qw,Nw({},e,{ref:t,sideCar:zT}))});BT.classNames=Qw.classNames;var VT=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},HT=new WeakMap,UT=new WeakMap,WT={},GT=0,KT=function(e){return e&&(e.host||KT(e.parentNode))},qT=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=KT(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},JT=function(e,t,n,r){var i=qT(t,Array.isArray(e)?e:[e]);WT[n]||(WT[n]=new WeakMap);var a=WT[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(HT.get(e)||0)+1,l=(a.get(e)||0)+1;HT.set(e,c),a.set(e,l),o.push(e),c===1&&i&&UT.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),GT++,function(){o.forEach(function(e){var t=HT.get(e)-1,i=a.get(e)-1;HT.set(e,t),a.set(e,i),t||(UT.has(e)||e.removeAttribute(r),UT.delete(e)),i||e.removeAttribute(n)}),GT--,GT||(HT=new WeakMap,HT=new WeakMap,UT=new WeakMap,WT={})}},YT=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||VT(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),JT(r,i,n,`aria-hidden`)):function(){return null}},XT=Object.defineProperty,ZT=(e,t)=>XT(e,`name`,{value:t,configurable:!0}),QT=`Dialog`,[$T,eE]=YS(QT),[tE,nE]=$T(QT),rE=ZT(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=dC({prop:r,defaultProp:i??!1,onChange:a,caller:QT}),[d,f]=m.useState(0),[p,g]=m.useState(0);return(0,h.jsx)(tE,{scope:t,triggerRef:s,contentRef:c,contentId:nC(),titleId:nC(),descriptionId:nC(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:g,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),iE=`DialogPortal`,[aE,oE]=$T(iE,{forceMount:void 0}),sE=ZT(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=nE(iE,t);return(0,h.jsx)(aE,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,h.jsx)(bw,{present:n||a.open,children:(0,h.jsx)(gw,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),cE=`DialogOverlay`,lE=m.forwardRef(ZT(function(e,t){let n=oE(cE,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=nE(cE,e.__scopeDialog);return a.modal?(0,h.jsx)(bw,{present:r||a.open,children:(0,h.jsx)(dE,{...i,ref:t})}):null},`DialogOverlay`)),uE=vC(`DialogOverlay.RemoveScroll`),dE=m.forwardRef(ZT(function(e,t){let{__scopeDialog:n,...r}=e,i=nE(cE,n),a=GS(t,KC());return(0,h.jsx)(BT,{as:uE,allowPinchZoom:!0,shards:[i.contentRef],children:(0,h.jsx)(NC.div,{"data-state":_E(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),fE=`DialogContent`,pE=m.forwardRef(ZT(function(e,t){let n=oE(fE,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=nE(fE,e.__scopeDialog);return(0,h.jsx)(bw,{present:r||a.open,children:a.modal?(0,h.jsx)(mE,{...i,ref:t}):(0,h.jsx)(hE,{...i,ref:t})})},`DialogContent`)),mE=m.forwardRef(ZT(function(e,t){let n=nE(fE,e.__scopeDialog),r=m.useRef(null),i=GS(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return YT(e)},[]),(0,h.jsx)(gE,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:IS(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:IS(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:IS(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),hE=m.forwardRef(ZT(function(e,t){let n=nE(fE,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(gE,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),gE=m.forwardRef(ZT(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=nE(fE,n);return jw(),(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(rw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(GC,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":_E(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`));function _E(e){return e?`open`:`closed`}ZT(_E,`getState`);var vE=`[cmdk-group=""]`,yE=`[cmdk-group-items=""]`,bE=`[cmdk-group-heading=""]`,xE=`[cmdk-item=""]`,SE=`${xE}:not([aria-disabled="true"])`,CE=`cmdk-item-select`,wE=`data-value`,TE=(e,t,n)=>MS(e,t,n),EE=m.createContext(void 0),DE=()=>m.useContext(EE),OE=m.createContext(void 0),kE=()=>m.useContext(OE),AE=m.createContext(void 0),jE=m.forwardRef((e,t)=>{let n=GE(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=GE(()=>new Set),i=GE(()=>new Map),a=GE(()=>new Map),o=GE(()=>new Set),s=UE(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:_=!0,...v}=e,y=nC(),b=nC(),x=nC(),S=m.useRef(null),C=JE();WE(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),WE(()=>{C(6,ee)},[]);let w=m.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(y))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=A()?.id,w.emit()}),r||C(5,ee),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=m.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:y,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??TE;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;te().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(yE);t?t.appendChild(e.parentElement===t?e:e.closest(`${yE} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${yE} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${vE}[${wE}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=te().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(wE);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function ee(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(vE)?.querySelector(bE))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return S.current?.querySelector(`${xE}[aria-selected="true"]`)}function te(){return Array.from(S.current?.querySelectorAll(SE)||[])}function ne(e){let t=te()[e];t&&w.setState(`value`,t.getAttribute(wE))}function re(e){var t;let n=A(),r=te(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(wE))}function ie(e){let t=A()?.closest(vE),n;for(;t&&!n;)t=e>0?VE(t,vE):HE(t,vE),n=t?.querySelector(SE);n?w.setState(`value`,n.getAttribute(wE)):re(e)}let ae=()=>ne(te().length-1),oe=e=>{e.preventDefault(),e.metaKey?ae():e.altKey?ie(1):re(1)},se=e=>{e.preventDefault(),e.metaKey?ne(0):e.altKey?ie(-1):re(-1)};return m.createElement(NC.div,{ref:t,tabIndex:-1,...v,"cmdk-root":``,onKeyDown:e=>{var t;(t=v.onKeyDown)==null||t.call(v,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:_&&e.ctrlKey&&oe(e);break;case`ArrowDown`:oe(e);break;case`p`:case`k`:_&&e.ctrlKey&&se(e);break;case`ArrowUp`:se(e);break;case`Home`:e.preventDefault(),ne(0);break;case`End`:e.preventDefault(),ae();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(CE);t.dispatchEvent(e)}}}}},m.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:ZE},c),XE(e,e=>m.createElement(OE.Provider,{value:w},m.createElement(EE.Provider,{value:T},e))))}),ME=m.forwardRef((e,t)=>{let n=nC(),r=m.useRef(null),i=m.useContext(AE),a=DE(),o=UE(e),s=o.current?.forceMount??i?.forceMount;WE(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=qE(n,r,[e.value,e.children,r],e.keywords),l=kE(),u=KE(e=>e.value&&e.value===c.current),d=KE(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);m.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(CE,f),()=>t.removeEventListener(CE,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:h,value:g,onSelect:_,forceMount:v,keywords:y,...b}=e;return m.createElement(NC.div,{ref:WS(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!u,"data-disabled":!!h,"data-selected":!!u,onPointerMove:h||a.getDisablePointerSelection()?void 0:p,onClick:h?void 0:f},e.children)}),NE=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=nC(),s=m.useRef(null),c=m.useRef(null),l=nC(),u=DE(),d=KE(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));WE(()=>u.group(o),[]),qE(o,s,[e.value,e.heading,c]);let f=m.useMemo(()=>({id:o,forceMount:i}),[i]);return m.createElement(NC.div,{ref:WS(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&m.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),XE(e,e=>m.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},m.createElement(AE.Provider,{value:f},e))))}),PE=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=m.useRef(null),a=KE(e=>!e.search);return!n&&!a?null:m.createElement(NC.div,{ref:WS(i,t),...r,"cmdk-separator":``,role:`separator`})}),FE=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=kE(),o=KE(e=>e.search),s=KE(e=>e.selectedItemId),c=DE();return m.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),m.createElement(NC.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),IE=m.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=m.useRef(null),o=m.useRef(null),s=KE(e=>e.selectedItemId),c=DE();return m.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),m.createElement(NC.div,{ref:WS(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},XE(e,e=>m.createElement(`div`,{ref:WS(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),LE=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return m.createElement(rE,{open:n,onOpenChange:r},m.createElement(sE,{container:o},m.createElement(lE,{"cmdk-overlay":``,className:i}),m.createElement(pE,{"aria-label":e.label,"cmdk-dialog":``,className:a},m.createElement(jE,{ref:t,...s}))))}),RE=m.forwardRef((e,t)=>KE(e=>e.filtered.count===0)?m.createElement(NC.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),zE=m.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return m.createElement(NC.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},XE(e,e=>m.createElement(`div`,{"aria-hidden":!0},e)))}),BE=Object.assign(jE,{List:IE,Item:ME,Input:FE,Group:NE,Separator:PE,Dialog:LE,Empty:RE,Loading:zE});function VE(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function HE(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function UE(e){let t=m.useRef(e);return WE(()=>{t.current=e}),t}var WE=typeof window>`u`?m.useEffect:m.useLayoutEffect;function GE(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function KE(e){let t=kE(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function qE(e,t,n,r=[]){let i=m.useRef(),a=DE();return WE(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(wE,s),i.current=s}),i}var JE=()=>{let[e,t]=m.useState(),n=GE(()=>new Map);return WE(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function YE(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function XE({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(YE(t),{ref:t.ref},n(t.props.children)):n(t)}var ZE={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},QE={"http:":!0,"https:":!0,"mailto:":!0,"tel:":!0};function $E(e){return e.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>{let n=Number.parseInt(t,16);return n>0&&n<1114111?String.fromCodePoint(n):``}).replace(/&#([0-9]+);?/g,(e,t)=>{let n=Number.parseInt(t,10);return n>0&&n<1114111?String.fromCodePoint(n):``}).replace(/&colon;?/gi,`:`).replace(/&tab;?/gi,``).replace(/&newline;?/gi,``)}function eD(e){let t=``;for(let n of e){let e=n.charCodeAt(0);e>32&&!(e>=127&&e<=159)&&!/\s/.test(n)&&(t+=n)}return t}function tD(e){let t=eD($E(e.trim())),n=/^[a-z][a-z0-9+.-]*:/i.exec(t);return n?n[0].toLowerCase():null}function nD(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split(`/`),i=[];for(let e=0;e<r.length;e++){let n=r[e];n&&n!==`.`&&(n===`..`?i.length>0&&i[i.length-1]!==`..`?i.pop():t||i.push(`..`):i.push(n))}let a=i.join(`/`);return t&&(a=`/${a}`),a.length===0?t?`/`:`.`:(n&&!a.endsWith(`/`)&&(a+=`/`),a)}function rD(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:e.slice(0,n)}function iD(e){if(e.length===0)return``;let t=0,n=-1,r=!0;for(let i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!r){t=i+1;break}}else n===-1&&(r=!1,n=i+1);return n===-1?``:e.slice(t,n)}function aD(e){if(!e||e.includes(`\\`))return null;let t=$E(e.trim());try{t=decodeURI(t)}catch{}if(t.includes(`\\`)||!t.toLowerCase().startsWith(`okf://`))return null;let n=t,r=n.indexOf(`#`);r!==-1&&(n=n.slice(0,r));let i=n.indexOf(`?`);i!==-1&&(n=n.slice(0,i));let a=n.slice(6),o=a.indexOf(`/`);if(o===-1)return null;let s=a.slice(0,o);if(!/^[a-z0-9][a-z0-9-]{0,62}$/.test(s))return null;let c=a.slice(o+1);if(c.endsWith(`.md`)&&(c=c.slice(0,-3)),c.length===0||c.length>512)return null;let l=c.split(`/`);if(l.length>12)return null;for(let e of l)if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(e))return null;let u=l[l.length-1];if(!u)return null;let d=u.toLowerCase();return d===`index`||d===`log`?null:{project:s,id:l.join(`/`)}}function oD(e,t){if(!e)return{kind:`invalid`};let n=tD(e);if(n!==null){if(n===`okf:`){if(e.includes(`\\`))return{kind:`invalid`};let t=aD(e);if(!t)return{kind:`invalid`};let n=e.indexOf(`#`),r=n===-1?``:e.slice(n);return{kind:`concept`,project:t.project,id:t.id,hash:r}}return QE[n]?{kind:`external`,href:e.trim()}:{kind:`invalid`}}let r=e.trim();if(r.startsWith(`//`)){if(e.includes(`\\`)||!/^\/\/[^/?#\s\\]+(?:\/[^\s\\]*)?(?:#[^\s\\]*)?$/.test(r))return{kind:`invalid`};let t=r;try{t=decodeURI(r)}catch{return{kind:`invalid`}}return t.includes(`\\`)?{kind:`invalid`}:{kind:`external`,href:r}}if(e.startsWith(`#`))return{kind:`anchor`,hash:e};if(e.includes(`\\`))return{kind:`invalid`};let i=e;try{i=decodeURI(e)}catch{}if(i.includes(`\\`)||i.startsWith(`//`)||i.startsWith(`/\\`))return{kind:`invalid`};let a=``,o=i.indexOf(`#`);o!==-1&&(a=i.slice(o),i=i.slice(0,o));let s=i.indexOf(`?`);s!==-1&&(i=i.slice(0,s));let c;if(i.startsWith(`/`))c=nD(i.slice(1));else{let e=rD(t),n=e===`.`?``:e;c=nD(n?`${n}/${i}`:i)}if(c.includes(`\\`)||c===`..`||c.startsWith(`../`)||i.endsWith(`/`))return{kind:`invalid`};if(c.endsWith(`.md`)){let e=iD(c);return e===`index.md`||e===`log.md`?{kind:`invalid`}:{kind:`concept`,id:c.slice(0,-3),hash:a}}return{kind:`file`,path:c,hash:a}}function sD(e,t){let n=t.startsWith(`/`)?t.slice(1):t;return`/p/${encodeURIComponent(e)}/c/${n}`}function cD(e,t){let n=t.startsWith(`/`)?t.slice(1):t;return`/p/${encodeURIComponent(e)}/f/${n}`}var lD=`okf.recent`,uD=8;function dD(e){return!!(e&&typeof e==`object`&&`project`in e&&typeof e.project==`string`&&`id`in e&&typeof e.id==`string`&&`title`in e&&typeof e.title==`string`&&`type`in e&&(e.type===null||typeof e.type==`string`))}function fD(){try{if(typeof localStorage>`u`)return[];let e=localStorage.getItem(lD);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(dD).slice(0,uD):[]}catch{return[]}}function pD(e){try{if(typeof localStorage>`u`)return;let t=[e,...fD().filter(t=>t.project!==e.project||t.id!==e.id)].slice(0,uD);localStorage.setItem(lD,JSON.stringify(t))}catch{}}function mD({text:e,query:t,className:n}){if(!e)return null;if(!t?.trim())return(0,h.jsx)(`span`,{className:n,children:e});let r=t.trim().split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),i=[],a={};for(let e of r){let t=e.toLowerCase();a[t]||(a[t]=!0,i.push(e))}if(i.sort((e,t)=>t.length-e.length),i.length===0)return(0,h.jsx)(`span`,{className:n,children:e});let o=i.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),s=RegExp(`(${o.join(`|`)})`,`gi`),c=e.split(s);return(0,h.jsx)(`span`,{className:n,children:c.map((e,t)=>i.some(t=>t.toLowerCase()===e.toLowerCase())?(0,h.jsx)(`mark`,{className:`rounded-xs bg-amber-400/25 px-0.5 font-medium text-fg dark:bg-amber-400/35`,children:e},t):e)})}var hD=[`Project`,`Decision`,`Convention`,`Architecture`,`Component`,`Playbook`,`Interface`,`Reference`,`Glossary Term`],gD={project:`text-accent-500`,decision:`text-violet-600 dark:text-violet-400`,convention:`text-sky-600 dark:text-sky-400`,architecture:`text-cyan-600 dark:text-cyan-400`,component:`text-cyan-600 dark:text-cyan-400`,playbook:`text-emerald-600 dark:text-emerald-400`,interface:`text-amber-600 dark:text-amber-400`,reference:`text-zinc-600 dark:text-zinc-400`,"glossary term":`text-pink-600 dark:text-pink-400`};function _D(e){return e?gD[e.trim().toLowerCase()]??`text-zinc-600 dark:text-zinc-400`:`text-zinc-600 dark:text-zinc-400`}function vD({type:e,className:t,size:n=16}){let r=e?e.trim().toLowerCase():``,i=X(`shrink-0`,_D(e),t);switch(r){case`project`:return(0,h.jsx)(lx,{size:n,className:i});case`decision`:return(0,h.jsx)(Gx,{size:n,className:i});case`convention`:return(0,h.jsx)(Ux,{size:n,className:i});case`architecture`:return(0,h.jsx)(Lx,{size:n,className:i});case`component`:return(0,h.jsx)(jb,{size:n,className:i});case`playbook`:return(0,h.jsx)(Tb,{size:n,className:i});case`interface`:return(0,h.jsx)(zx,{size:n,className:i});case`reference`:return(0,h.jsx)(Db,{size:n,className:i});case`glossary term`:return(0,h.jsx)(Cb,{size:n,className:i});default:return(0,h.jsx)(sx,{size:n,className:i})}}function yD({open:e=!1,className:t,size:n=16}){let r=X(`shrink-0 text-muted`,t);return e?(0,h.jsx)(dx,{size:n,className:r}):(0,h.jsx)(px,{size:n,className:r})}function bD({className:e,size:t=16}){return(0,h.jsx)(rx,{size:t,className:X(`shrink-0 text-muted`,e)})}var xD=(0,m.createContext)(null);function SD(){let e=(0,m.useContext)(xD);if(!e)throw Error(`useCommandPalette must be used within CommandPaletteContext.Provider`);return e}function CD(e){let t=e?.toLowerCase();return t===`human-reviewed`?`bg-emerald-500`:t===`machine-confirmed`?`bg-sky-500`:t===`proposed`?`bg-violet-500`:`bg-zinc-400 dark:bg-zinc-600`}function wD({open:e,onOpenChange:t,currentProject:n}){let r=kh(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!!n),[u,d]=(0,m.useState)(``);(0,m.useEffect)(()=>{l(!!n)},[n]),(0,m.useEffect)(()=>{let e=setTimeout(()=>{s(i)},150);return()=>clearTimeout(e)},[i]),(0,m.useEffect)(()=>{function n(n){if((n.metaKey||n.ctrlKey)&&n.key===`k`){n.preventDefault(),t(!e);return}if(n.key===`/`&&!e){let e=n.target;e&&(e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`||e.isContentEditable||e.closest(`input, textarea, select, [contenteditable]`))||(n.preventDefault(),t(!0))}}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let f=D_(),p=e?fD():[],g=o.trim().length>=2,_=c&&n?n:void 0,v=P_({q:o.trim(),project:_,limit:20},g&&e),y=g?v.data?.[0]:void 0,b=p[0],x=f.data?.[0],S=``;y?S=`hit-${y.project}-${y.id}`:o.trim().length>0?S=`search-all-results`:b?S=`recent-${b.project}-${b.id}`:x&&(S=`proj-${x.project}`),(0,m.useEffect)(()=>{d(S)},[S]);let C=e=>{t(!1),a(``),r(e)};return(0,h.jsxs)(BE.Dialog,{value:u,onValueChange:d,open:e,onOpenChange:e=>{t(e),e||a(``)},label:`Search concepts, projects…`,shouldFilter:!1,overlayClassName:`fixed inset-0 bg-black/60 backdrop-blur-xs z-50 animate-[okf-fade-in_120ms_ease-out]`,contentClassName:`fixed left-1/2 top-[15%] -translate-x-1/2 w-full max-w-xl z-50 p-3 outline-none`,className:`w-full bg-surface border border-border-strong rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[70vh] text-fg animate-[okf-scale-in_120ms_ease-out]`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-border`,children:[(0,h.jsx)(qx,{size:16,className:`text-muted shrink-0`}),(0,h.jsx)(BE.Input,{value:i,onValueChange:a,placeholder:`Search concepts, projects…`,className:`w-full bg-transparent py-3 text-sm text-fg placeholder:text-muted outline-none`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{n&&l(e=>!e)},disabled:!n,className:X(`shrink-0 text-xs px-2.5 py-1 rounded-md font-medium transition-colors select-none`,n?c?`bg-accent-500/10 text-accent-500 ring-1 ring-accent-500/20 hover:bg-accent-500/20 cursor-pointer`:`bg-surface-2 text-muted ring-1 ring-border hover:text-fg cursor-pointer`:`bg-surface-2 text-muted/60 ring-1 ring-border cursor-default`),title:n?`Click to toggle search scope`:void 0,children:c&&n?`This project`:`All projects`})]}),(0,h.jsxs)(BE.List,{className:`overflow-y-auto max-h-[380px] p-2 space-y-1`,children:[g&&v.isLoading&&(0,h.jsx)(BE.Loading,{className:`px-4 py-8 text-center text-xs text-subtle`,children:`Searching...`}),g&&!v.isLoading&&v.data&&v.data.length===0&&(0,h.jsx)(BE.Empty,{className:`px-4 py-8 text-center text-xs text-subtle`,children:`No matching concepts or files`}),g&&v.data&&v.data.length>0&&(0,h.jsx)(BE.Group,{heading:`Concepts & Files`,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-[11px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-subtle [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider`,children:v.data.map(e=>(0,h.jsxs)(BE.Item,{value:`hit-${e.project}-${e.id}`,onSelect:()=>C(sD(e.project,e.id)),className:`flex flex-col gap-1 px-2.5 py-2 rounded-lg text-xs cursor-pointer data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,h.jsx)(vD,{type:e.type,size:14}),(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:e.title}),(0,h.jsxs)(`span`,{className:`font-mono text-[11px] text-subtle truncate`,children:[e.project,`/`,e.id]}),(0,h.jsx)(`span`,{className:X(`ml-auto h-2 w-2 rounded-full shrink-0`,CD(e.trustTier)),title:e.trustTier})]}),e.snippet&&(0,h.jsx)(`div`,{className:`text-[11px] text-muted truncate pl-5`,children:(0,h.jsx)(mD,{text:e.snippet,query:o})})]},`${e.project}/${e.id}`))}),!g&&(0,h.jsxs)(h.Fragment,{children:[p.length>0&&(0,h.jsx)(BE.Group,{heading:`Recent`,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-[11px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-subtle [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider`,children:p.map(e=>(0,h.jsxs)(BE.Item,{value:`recent-${e.project}-${e.id}`,onSelect:()=>C(sD(e.project,e.id)),className:`flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs cursor-pointer data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsx)(vD,{type:e.type,size:14}),(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:e.title}),(0,h.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-subtle shrink-0`,children:[e.project,`/`,e.id]})]},`recent-${e.project}-${e.id}`))}),f.data&&f.data.length>0&&(0,h.jsx)(BE.Group,{heading:`Projects`,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-[11px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-subtle [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider`,children:f.data.map(e=>(0,h.jsxs)(BE.Item,{value:`proj-${e.project}`,onSelect:()=>C(`/p/${encodeURIComponent(e.project)}`),className:`flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs cursor-pointer data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsx)(lx,{size:14,className:`text-accent-500 shrink-0`}),(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:e.title}),(0,h.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-subtle shrink-0`,children:e.project})]},`proj-${e.project}`))})]}),o.trim().length>0&&(0,h.jsx)(BE.Group,{className:`pt-1 border-t border-border mt-1`,children:(0,h.jsxs)(BE.Item,{value:`search-all-results`,onSelect:()=>{let e=new URLSearchParams;e.set(`q`,o.trim()),c&&n&&e.set(`project`,n),C(`/search?${e.toString()}`)},className:`flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs cursor-pointer text-muted hover:text-fg data-[selected=true]:bg-surface-2 data-[selected=true]:text-fg transition-colors`,children:[(0,h.jsx)(qx,{size:14,className:`shrink-0 text-muted`}),(0,h.jsxs)(`span`,{children:[`Search all results for “`,(0,h.jsx)(`strong`,{className:`text-fg font-medium`,children:o.trim()}),`”`]})]})})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-3 px-3.5 py-2 border-t border-border text-[11px] text-subtle bg-surface-2/40 select-none`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`kbd`,{className:`font-mono bg-surface px-1 py-0.2 rounded border border-border`,children:`↑↓`}),` navigate`]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`kbd`,{className:`font-mono bg-surface px-1 py-0.2 rounded border border-border`,children:`↵`}),` open`]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`kbd`,{className:`font-mono bg-surface px-1 py-0.2 rounded border border-border`,children:`esc`}),` close`]})]})]})}function Q({className:e}){return(0,h.jsx)(`div`,{className:X(`animate-shimmer rounded-md bg-surface-2`,e),"aria-hidden":`true`})}var TD=(0,m.createContext)(null);function ED(){let e=(0,m.useContext)(TD);if(!e)throw Error(`useTreeState must be used within a TreeStateContext.Provider`);return e}function DD(e,t){let n=[],r=[],i=[];for(let a of e)if(a.kind===`directory`)n.push(a);else if(a.kind===`concept`){if(t&&a.id===`overview`)continue;r.push(a)}else a.kind===`file`&&i.push(a);return n.sort((e,t)=>e.path.localeCompare(t.path)),r.sort((e,t)=>e.title.localeCompare(t.title)),i.sort((e,t)=>e.path.localeCompare(t.path)),[...n,...r,...i]}function OD({project:e,dir:t,depth:n,activeConceptId:r,activeFilePath:i}){let{data:a,isLoading:o}=k_(e,t,!0),{expanded:s,toggle:c}=ED(),l=(0,m.useMemo)(()=>a?DD(a,t===``):[],[a,t]);return o?(0,h.jsxs)(`div`,{className:`py-1 space-y-1`,style:{paddingLeft:`${n*12+12}px`},children:[(0,h.jsx)(Q,{className:`h-5 w-3/4 rounded-md`}),(0,h.jsx)(Q,{className:`h-5 w-1/2 rounded-md`})]}):l.length===0?(0,h.jsx)(`div`,{className:`py-1 text-[11px] text-subtle italic select-none`,style:{paddingLeft:`${n*12+16}px`},children:`Empty directory`}):(0,h.jsx)(`div`,{className:`space-y-0.5`,children:l.map(t=>{if(t.kind===`directory`){let a=s.has(t.path),o=t.path.split(`/`).pop()??t.path;return(0,h.jsxs)(`div`,{"data-tree-path":t.path,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>c(t.path),className:`group flex w-full items-center gap-1.5 py-1 pr-2 rounded-md text-xs font-medium text-muted hover:text-fg hover:bg-surface-2 transition-colors cursor-pointer text-left`,style:{paddingLeft:`${n*12+6}px`},children:[(0,h.jsx)(Lb,{size:12,className:X(`text-subtle transition-transform duration-150 shrink-0`,a&&`rotate-90`)}),(0,h.jsx)(yD,{open:a,size:14}),(0,h.jsx)(`span`,{className:`truncate flex-1`,children:o}),(0,h.jsx)(`span`,{className:`ml-auto text-[11px] text-subtle font-mono tabular-nums`,children:t.conceptCount})]}),(0,h.jsx)(tu,{initial:!1,children:a&&(0,h.jsx)(Gd.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:`easeInOut`},className:`overflow-hidden`,children:(0,h.jsx)(OD,{project:e,dir:t.path,depth:n+1,activeConceptId:r,activeFilePath:i})})})]},`dir-${t.path}`)}if(t.kind===`concept`){let i=r===t.id;return(0,h.jsx)(`div`,{"data-tree-path":t.id,children:(0,h.jsxs)($g,{to:sD(e,t.id),className:X(`group flex items-center gap-2 py-1 pr-2 rounded-md text-xs transition-colors`,i?`border-l-2 border-accent-500 bg-surface-2 text-fg font-medium pl-[calc(var(--tree-pad)-2px)]`:`border-l-2 border-transparent text-muted hover:text-fg hover:bg-surface-2`),style:{"--tree-pad":`${n*12+20}px`,paddingLeft:i?`${n*12+18}px`:`${n*12+20}px`},children:[(0,h.jsx)(vD,{type:t.type,size:14}),(0,h.jsx)(`span`,{className:`truncate`,children:t.title})]})},`concept-${t.id}`)}if(t.kind===`file`){let r=i===t.path,a=t.path.split(`/`).pop()??t.path;return(0,h.jsx)(`div`,{"data-tree-path":t.path,children:(0,h.jsxs)($g,{to:cD(e,t.path),className:X(`group flex items-center gap-2 py-1 pr-2 rounded-md text-xs transition-colors`,r?`border-l-2 border-accent-500 bg-surface-2 text-fg font-medium font-mono`:`border-l-2 border-transparent text-muted hover:text-fg hover:bg-surface-2 font-mono`),style:{paddingLeft:r?`${n*12+18}px`:`${n*12+20}px`},children:[(0,h.jsx)(bD,{size:14}),(0,h.jsx)(`span`,{className:`truncate`,children:a})]})},`file-${t.path}`)}return null})})}function kD({project:e}){let t=Nh(),n=Dh(),r=t[`*`]??null,i=n.pathname.includes(`/c/`)&&r!==null,a=n.pathname.includes(`/f/`)&&r!==null,o=i?r:null,s=a?r:null,{expanded:c,toggle:l}=ED();return(0,m.useEffect)(()=>{let e=o??s;if(!e)return;let t=e.split(`/`);if(t.length<=1)return;let n=``;for(let e=0;e<t.length-1;e++){let r=t[e];r&&(n=n?`${n}/${r}`:r,c.has(n)||l(n))}},[o,s,c,l]),(0,h.jsx)(`div`,{className:`py-1`,children:(0,h.jsx)(OD,{project:e,dir:``,depth:0,activeConceptId:o,activeFilePath:s})})}var AD=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`}),jD=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function MD(e){let t=new Date(e).getTime();if(Number.isNaN(t))return e;let n=Math.round((t-Date.now())/1e3);if(Math.abs(n)<60)return AD.format(n,`second`);let r=Math.round(n/60);if(Math.abs(r)<60)return AD.format(r,`minute`);let i=Math.round(r/60);if(Math.abs(i)<24)return AD.format(i,`hour`);let a=Math.round(i/24);if(Math.abs(a)<7)return AD.format(a,`day`);let o=Math.round(a/7);if(Math.abs(o)<5)return AD.format(o,`week`);let s=Math.round(a/30);if(Math.abs(s)<12)return AD.format(s,`month`);let c=Math.round(a/365);return AD.format(c,`year`)}function ND(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:jD.format(t)}function PD(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)%360}function FD(e){let t=e.startsWith(`human:`)?e.slice(6):e,n=t.indexOf(`@`);n!==-1&&(t=t.slice(0,n));let r=t.match(/[A-Za-z0-9]+/g);return!r||r.length===0?``:r.slice(0,2).map(e=>e[0]?.toUpperCase()??``).join(``)}function ID(e){return e.startsWith(`human:`)?`human`:`agent`}function LD(e){return e.slice(0,7)}function RD({className:e}){let{data:t,isLoading:n}=F_();if(n||!t)return(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-zinc-500/10 text-zinc-500 ring-1 ring-inset ring-zinc-500/20`,e),children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-zinc-400 animate-pulse`}),(0,h.jsx)(`span`,{children:`Syncing...`})]});if(t.remote===null)return(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 ring-1 ring-inset ring-zinc-500/20`,e),children:[(0,h.jsx)(yx,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Local only`})]});if(t.lastError)return(0,h.jsxs)(`span`,{title:t.lastError,className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-rose-500/10 text-rose-600 dark:text-rose-400 ring-1 ring-inset ring-rose-500/20`,e),children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-rose-500 shrink-0`}),(0,h.jsx)(`span`,{className:`truncate max-w-[120px]`,children:`Sync error`})]});if(t.ahead>0||t.behind>0)return(0,h.jsx)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-1 ring-inset ring-amber-500/20 font-mono`,e),children:(0,h.jsxs)(`span`,{children:[`↑`,t.ahead,` ↓`,t.behind]})});let r=t.lastSyncAt?MD(t.lastSyncAt):`just now`;return(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-1 ring-inset ring-emerald-500/20`,e),children:[(0,h.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0`,children:[(0,h.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75`}),(0,h.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full bg-emerald-500`})]}),(0,h.jsxs)(`span`,{children:[`Synced `,r]})]})}var zD={system:`light`,light:`dark`,dark:`system`};function BD({className:e}){let[t,n]=ab();return(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{n(zD[t])},className:e??`inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg transition-colors`,"aria-label":`Toggle theme (current: ${t})`,title:`Theme: ${t} (click to switch to ${zD[t]})`,children:[t===`system`&&(0,h.jsx)(Nx,{size:16}),t===`light`&&(0,h.jsx)($x,{size:16}),t===`dark`&&(0,h.jsx)(Fx,{size:16})]})}function VD({actor:e,size:t=28,className:n}){let r=PD(e),i=FD(e),a=ID(e),o=Math.max(10,Math.round(t*.42)),s=Math.max(10,Math.round(t*.4));return(0,h.jsxs)(`div`,{className:X(`relative inline-flex shrink-0 select-none`,n),style:{width:t,height:t},title:e,children:[(0,h.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded-full font-medium text-white shadow-xs`,style:{background:`linear-gradient(135deg, hsl(${r} 70% 55%), hsl(${(r+40)%360} 70% 45%))`,fontSize:s},children:i}),(0,h.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 flex items-center justify-center rounded-full bg-surface text-muted ring-1 ring-border`,style:{width:o+4,height:o+4},children:a===`human`?(0,h.jsx)(aS,{size:o}):(0,h.jsx)(kb,{size:o})})]})}function HD({className:e}){let{state:t,logout:n}=Yy(),[r,i]=(0,m.useState)(!1),a=(0,m.useRef)(null);if((0,m.useEffect)(()=>{if(!r)return;function e(e){a.current&&!a.current.contains(e.target)&&i(!1)}function t(e){e.key===`Escape`&&i(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),t.status===`loading`)return(0,h.jsx)(`div`,{className:X(`h-7 w-24 rounded-md bg-surface-2 animate-pulse`,e)});let o=t.status===`open`,s=t.status===`signed-in`,c=`config`in t?t.config.version:null,l=s?t.identity:null;return(0,h.jsxs)(`div`,{ref:a,className:X(`relative inline-block`,e),children:[o?(0,h.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-1 ring-inset ring-amber-500/20 hover:bg-amber-500/20 transition-colors`,title:`Running in local mode without authentication`,"aria-expanded":r,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-500`}),(0,h.jsx)(`span`,{children:`Local mode · auth off`})]}):s?(0,h.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex items-center gap-2 rounded-lg p-1 text-left hover:bg-surface-2 transition-colors max-w-[200px]`,"aria-expanded":r,children:[(0,h.jsx)(VD,{actor:l??`User`,size:26}),(0,h.jsx)(`span`,{className:`truncate text-xs font-medium text-fg`,children:l??`Signed in`})]}):null,r&&(0,h.jsxs)(`div`,{role:`menu`,className:`absolute bottom-full left-0 mb-2 w-56 rounded-xl border border-border bg-surface p-1.5 shadow-xl z-50 text-xs`,children:[l&&(0,h.jsxs)(`div`,{className:`px-2.5 py-1.5 border-b border-border mb-1`,children:[(0,h.jsx)(`div`,{className:`font-medium text-fg truncate`,children:l}),(0,h.jsx)(`div`,{className:`text-[11px] text-muted truncate`,children:`Identity provider session`})]}),c&&(0,h.jsxs)(`div`,{className:`px-2.5 py-1 text-[11px] text-muted font-mono`,children:[`ok-fine v`,c]}),s&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(!1),n()},className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-xs font-medium text-rose-600 dark:text-rose-400 hover:bg-rose-500/10 transition-colors cursor-pointer`,children:[(0,h.jsx)(kx,{size:13,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Sign out`})]})]})]})]})}function UD({project:e,drawerOpen:t,onCloseDrawer:n}){let r=kh(),i=D_(),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null),c=i.data?.find(t=>t.project===e)?.title??e??`All projects`;(0,m.useEffect)(()=>{if(!a)return;function e(e){s.current&&!s.current.contains(e.target)&&o(!1)}function t(e){e.key===`Escape`&&o(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let l=e=>{o(!1),n(),r(e?`/p/${encodeURIComponent(e)}`:`/`)};return(0,h.jsxs)(h.Fragment,{children:[t&&(0,h.jsx)(`button`,{type:`button`,"aria-label":`Close sidebar`,onClick:n,className:`fixed inset-0 z-40 bg-black/50 backdrop-blur-xs lg:hidden animate-[fade-in_150ms_ease-out] cursor-default border-none p-0`}),(0,h.jsxs)(`aside`,{className:X(`fixed inset-y-0 left-0 z-50 w-[272px] bg-surface border-r border-border flex flex-col h-full shadow-2xl lg:shadow-none transition-transform duration-200 ease-out lg:static lg:z-auto lg:translate-x-0`,t?`translate-x-0`:`-translate-x-full lg:translate-x-0`),children:[(0,h.jsxs)(`div`,{className:`h-14 border-b border-border flex items-center justify-between px-4 shrink-0`,children:[(0,h.jsx)($g,{to:`/`,onClick:n,className:`hover:opacity-90 transition-opacity`,title:`ok-fine home`,children:(0,h.jsx)(dS,{size:22})}),(0,h.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close sidebar`,className:`lg:hidden p-1.5 rounded-lg text-muted hover:text-fg hover:bg-surface-2 transition-colors cursor-pointer`,children:(0,h.jsx)(sS,{size:18})})]}),(0,h.jsxs)(`div`,{ref:s,className:`relative p-2 border-b border-border shrink-0`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`flex w-full items-center justify-between gap-2 px-2.5 py-1.5 rounded-lg bg-surface-2 hover:bg-surface border border-border text-xs font-medium text-fg transition-colors cursor-pointer text-left`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:c}),(0,h.jsx)(zb,{size:14,className:`text-subtle shrink-0`})]}),a&&(0,h.jsxs)(`div`,{role:`menu`,className:`absolute left-2 right-2 top-full mt-1 rounded-xl border border-border bg-surface p-1 shadow-xl z-50 text-xs space-y-0.5 max-h-64 overflow-y-auto`,children:[(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>l(),className:X(`flex w-full items-center justify-between px-2.5 py-1.5 rounded-lg text-left transition-colors cursor-pointer`,e?`text-muted hover:text-fg hover:bg-surface-2`:`bg-accent-500/10 text-accent-500 font-medium`),children:[(0,h.jsx)(`span`,{children:`All projects`}),!e&&(0,h.jsx)(Nb,{size:14,className:`shrink-0`})]}),(0,h.jsx)(`div`,{className:`my-1 border-t border-border`}),i.data?.map(t=>{let n=t.project===e;return(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>l(t.project),className:X(`flex w-full items-center justify-between px-2.5 py-1.5 rounded-lg text-left transition-colors cursor-pointer`,n?`bg-accent-500/10 text-accent-500 font-medium`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsxs)(`div`,{className:`truncate pr-2`,children:[(0,h.jsx)(`div`,{className:`font-medium truncate`,children:t.title}),(0,h.jsx)(`div`,{className:`font-mono text-[10px] text-subtle truncate`,children:t.project})]}),n&&(0,h.jsx)(Nb,{size:14,className:`shrink-0`})]},t.project)})]})]}),(0,h.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0 flex flex-col p-2 space-y-4`,children:e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`nav`,{"aria-label":`Project sections`,className:`space-y-0.5`,children:[(0,h.jsxs)(e_,{to:`/p/${encodeURIComponent(e)}`,end:!0,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(Tx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Overview`})]}),(0,h.jsxs)(e_,{to:`/p/${encodeURIComponent(e)}/activity`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(Vx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Activity`})]}),(0,h.jsxs)(e_,{to:`/p/${encodeURIComponent(e)}/health`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(xx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Health`})]}),(0,h.jsxs)(e_,{to:`/search?project=${encodeURIComponent(e)}`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(qx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Search`})]})]}),(0,h.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,h.jsx)(`div`,{className:`px-2 pb-1 text-[11px] font-medium uppercase tracking-wider text-subtle select-none`,children:`Knowledge`}),(0,h.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,h.jsx)(kD,{project:e})})]})]}):(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`nav`,{"aria-label":`Global navigation`,className:`space-y-0.5`,children:[(0,h.jsxs)(e_,{to:`/`,end:!0,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(Tx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Projects`})]}),(0,h.jsxs)(e_,{to:`/search`,onClick:n,className:({isActive:e})=>X(`flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-colors`,e?`bg-surface-2 text-fg`:`text-muted hover:text-fg hover:bg-surface-2`),children:[(0,h.jsx)(qx,{size:14,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Search`})]})]}),i.data&&i.data.length>0&&(0,h.jsxs)(`div`,{className:`pt-2`,children:[(0,h.jsx)(`div`,{className:`px-2 pb-1 text-[11px] font-medium uppercase tracking-wider text-subtle select-none`,children:`Projects`}),(0,h.jsx)(`div`,{className:`space-y-0.5`,children:i.data.map(e=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e.project)}`,onClick:n,className:`flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-xs text-muted hover:text-fg hover:bg-surface-2 transition-colors`,children:[(0,h.jsx)(lx,{size:14,className:`text-accent-500 shrink-0`}),(0,h.jsx)(`span`,{className:`truncate`,children:e.title})]},e.project))})]})]})}),(0,h.jsxs)(`div`,{className:`p-3 border-t border-border flex flex-col gap-2.5 mt-auto bg-surface shrink-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(RD,{}),(0,h.jsx)(BD,{})]}),(0,h.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,h.jsx)(HD,{})})]})]})]})}function WD({className:e}){let t=Nh(),n=Dh(),r=t.project,i=t[`*`],a=O_(r??``).data?.title??r,o=n.pathname.includes(`/c/`)&&!!i,s=n.pathname.includes(`/f/`)&&!!i,c=n.pathname.endsWith(`/activity`),l=n.pathname.endsWith(`/health`),u=n.pathname===`/search`,d=A_(r??``,o?i??``:``).data?.derived?.title??(i?i.split(`/`).pop():``),f=i?i.split(`/`):[],p=f.slice(0,-1),m=f[f.length-1]??``,g=(0,h.jsx)(`span`,{className:`text-subtle/50 select-none mx-0.5`,children:`/`});return(0,h.jsxs)(`nav`,{"aria-label":`Breadcrumbs`,className:X(`flex items-center gap-1 text-xs overflow-hidden whitespace-nowrap min-w-0`,e),children:[(0,h.jsx)($g,{to:`/`,className:X(`transition-colors shrink-0`,!r&&!u?`font-medium text-fg`:`text-muted hover:text-fg`),children:`Projects`}),u&&(0,h.jsxs)(h.Fragment,{children:[g,(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:`Search`})]}),r&&(0,h.jsxs)(h.Fragment,{children:[g,!o&&!s&&!c&&!l?(0,h.jsx)(`span`,{className:`font-medium text-fg truncate max-w-[200px]`,title:a,children:a}):(0,h.jsx)($g,{to:`/p/${encodeURIComponent(r)}`,className:`text-muted hover:text-fg transition-colors truncate max-w-[160px] shrink-0`,title:a,children:a})]}),c&&(0,h.jsxs)(h.Fragment,{children:[g,(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:`Activity`})]}),l&&(0,h.jsxs)(h.Fragment,{children:[g,(0,h.jsx)(`span`,{className:`font-medium text-fg truncate`,children:`Health`})]}),(o||s)&&(0,h.jsxs)(h.Fragment,{children:[p.map((e,t)=>{let n=p.slice(0,t+1).join(`/`);return(0,h.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[g,(0,h.jsx)(`span`,{className:`text-subtle select-none max-w-[120px] truncate`,title:e,children:e})]},n)}),g,o?(0,h.jsx)(`span`,{className:`font-medium text-fg truncate max-w-[220px]`,title:d,children:d}):(0,h.jsx)(`span`,{className:`font-medium font-mono text-fg truncate max-w-[220px]`,title:m,children:m})]})]})}function GD({onMenuClick:e}){let{open:t}=SD();return(0,h.jsxs)(`header`,{className:`sticky top-0 z-30 h-14 bg-bg/70 backdrop-blur-xl border-b border-border flex items-center justify-between px-4 gap-4 shrink-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Open sidebar menu`,className:`lg:hidden p-1.5 -ml-1 rounded-lg text-muted hover:text-fg hover:bg-surface-2 transition-colors cursor-pointer shrink-0`,children:(0,h.jsx)(jx,{size:18})}),(0,h.jsx)(WD,{})]}),(0,h.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-2 px-2.5 py-1 rounded-lg bg-surface-2 hover:bg-surface border border-border hover:border-border-strong text-xs transition-colors cursor-pointer shrink-0`,title:`Search knowledge base (⌘K or /)`,children:[(0,h.jsx)(qx,{size:13,className:`text-muted shrink-0`}),(0,h.jsx)(`span`,{className:`text-muted hidden sm:inline`,children:`Search knowledge…`}),(0,h.jsx)(`kbd`,{className:`hidden sm:inline-block font-mono text-[10px] text-subtle bg-surface px-1.5 py-0.5 rounded border border-border`,children:`⌘K`})]})]})}function KD(){let{project:e}=Nh(),[t,n]=(0,m.useState)(()=>new Set),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(e);(0,m.useEffect)(()=>{s.current!==e&&(s.current=e,n(new Set))},[e]);let{pathname:c}=Dh();(0,m.useEffect)(()=>{c&&i(!1)},[c]);let l=(0,m.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),u=(0,m.useCallback)(e=>{n(t=>{let n=new Set(t),r=e.split(`/`),i=``;for(let e of r)e&&(i=i?`${i}/${e}`:e,n.add(i));return n}),i(!0),requestAnimationFrame(()=>{try{document.querySelector(`[data-tree-path="${CSS.escape(e)}"]`)?.scrollIntoView({block:`nearest`,behavior:`smooth`})}catch{document.querySelector(`[data-tree-path]`)?.scrollIntoView({block:`nearest`,behavior:`smooth`})}})},[]),d=(0,m.useMemo)(()=>({expanded:t,toggle:l,reveal:u}),[t,l,u]),f=(0,m.useMemo)(()=>({open:()=>o(!0)}),[]);return(0,h.jsx)(TD.Provider,{value:d,children:(0,h.jsxs)(xD.Provider,{value:f,children:[(0,h.jsxs)(`div`,{className:`flex h-screen w-screen overflow-hidden text-fg`,children:[(0,h.jsx)(UD,{project:e,drawerOpen:r,onCloseDrawer:()=>i(!1)}),(0,h.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 h-full overflow-hidden`,children:[(0,h.jsx)(GD,{onMenuClick:()=>i(!0)}),(0,h.jsx)(`main`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,h.jsx)(og,{})})]})]}),(0,h.jsx)(wD,{open:a,onOpenChange:o,currentProject:e})]})})}var qD=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function JD(){let e=Nh().project??``,{data:t}=O_(e),{data:n,isLoading:r,isError:i,error:a,refetch:o}=M_(e,{limit:100}),s=(0,m.useMemo)(()=>{if(!n||n.length===0)return[];let e=[],t=``,r=[];for(let i of n){let n=qD.format(new Date(i.at));n===t?r.push(i):(r.length>0&&e.push({day:t,entries:r}),t=n,r=[i])}return r.length>0&&e.push({day:t,entries:r}),e},[n]),c=t?.title?`${t.title} Activity`:`Activity`;return r?(0,h.jsxs)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-32 rounded-md`}),(0,h.jsx)(Q,{className:`h-8 w-48 rounded-lg`})]}),(0,h.jsx)(`div`,{className:`mt-8 space-y-8`,children:Array.from({length:2}).map((e,t)=>(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(Q,{className:`h-5 w-40 rounded-md`}),(0,h.jsx)(`div`,{className:`rounded-xl border border-border bg-surface divide-y divide-border p-4 space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(Q,{className:`h-7 w-7 rounded-full shrink-0`}),(0,h.jsxs)(`div`,{className:`space-y-1`,children:[(0,h.jsx)(Q,{className:`h-4 w-48`}),(0,h.jsx)(Q,{className:`h-3 w-32`})]})]}),(0,h.jsx)(Q,{className:`h-6 w-16 rounded-md`})]},t))})]},t))})]}):i?(0,h.jsx)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:a,onRetry:()=>void o()})}):!n||n.length===0?(0,h.jsxs)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-6`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}`,className:`transition-colors hover:text-fg`,children:t?.title??e}),(0,h.jsx)(`span`,{children:`/`}),(0,h.jsx)(`span`,{className:`text-fg`,children:`Activity`})]}),(0,h.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:`Activity`})]}),(0,h.jsx)(cS,{icon:Vx,title:`No activity recorded`,hint:`Changes to concepts and files in this project will appear here.`,className:`mt-8 py-16`})]}):(0,h.jsxs)(fS,{title:c,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}`,className:`transition-colors hover:text-fg`,children:t?.title??e}),(0,h.jsx)(`span`,{children:`/`}),(0,h.jsx)(`span`,{className:`text-fg`,children:`Activity`})]}),(0,h.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:`Activity`}),(0,h.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`History of commits and updates for `,t?.title??e]})]}),(0,h.jsx)(`div`,{className:`space-y-8`,children:s.map(e=>(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-muted`,children:e.day}),(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:e.entries.map(e=>{let t=e.actor.startsWith(`human:`),n=t?e.actor.slice(6):e.actor;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,h.jsx)(VD,{actor:e.actor,size:28,className:`mt-0.5 shrink-0`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`text-sm font-medium text-fg break-words`,children:e.subject}),(0,h.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-subtle`,children:[t?(0,h.jsx)(aS,{size:12,className:`shrink-0 text-muted`}):(0,h.jsx)(kb,{size:12,className:`shrink-0 text-muted`}),(0,h.jsx)(`span`,{className:`truncate max-w-[200px]`,children:n})]}),e.principal&&(0,h.jsxs)(`span`,{className:`font-mono text-xs text-subtle truncate max-w-[200px]`,children:[`(`,e.principal,`)`]}),(0,h.jsx)(`span`,{children:`·`}),(0,h.jsx)(`span`,{title:ND(e.at),children:MD(e.at)})]})]})]}),(0,h.jsx)(`div`,{className:`flex items-center gap-2 self-end sm:self-center shrink-0`,children:(0,h.jsx)(mS,{value:e.sha,label:LD(e.sha),className:`font-mono text-xs`})})]},e.sha)})})]},e.day))})]})}function YD(){let{completeLogin:e}=Yy(),t=kh(),[n,r]=(0,m.useState)(null),i=(0,m.useRef)(!1);return(0,m.useEffect)(()=>{if(i.current)return;i.current=!0;let n=new URL(window.location.href);e(n).then(e=>{t(Gy(e),{replace:!0})}).catch(e=>{let t;t=e instanceof wv||e instanceof Cv?e.error_description?`${e.error}: ${e.error_description}`:e.error:e instanceof Error?e.message:String(e),r(t)})},[e,t]),n===null?(0,h.jsx)(fS,{title:`Signing in`,className:`min-h-screen flex items-center justify-center p-6 bg-bg`,children:(0,h.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3`,children:[(0,h.jsx)(Dx,{size:36,className:`animate-spin text-accent-500`}),(0,h.jsx)(`p`,{className:`text-sm font-medium text-muted`,children:`Signing you in…`})]})}):(0,h.jsx)(gS,{error:n})}function XD({className:e,children:t}){return(0,h.jsx)(`span`,{className:X(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset`,e),children:t})}function ZD({status:e,className:t}){let n=e.toLowerCase(),r=`bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 ring-zinc-500/20`;return n===`draft`?r=`bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-amber-500/20`:n===`stable`?r=`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`:n===`deprecated`&&(r=`bg-rose-500/10 text-rose-600 dark:text-rose-400 ring-rose-500/20`),(0,h.jsx)(XD,{className:X(r,t),children:e})}function QD({tier:e,className:t}){let n=e.toLowerCase();return n===`human-reviewed`?(0,h.jsxs)(XD,{className:X(`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`,t),children:[(0,h.jsx)(Yx,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`human-reviewed`})]}):n===`machine-confirmed`?(0,h.jsxs)(XD,{className:X(`bg-sky-500/10 text-sky-600 dark:text-sky-400 ring-sky-500/20`,t),children:[(0,h.jsx)(xb,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`machine-confirmed`})]}):n===`proposed`?(0,h.jsxs)(XD,{className:X(`bg-violet-500/10 text-violet-600 dark:text-violet-400 ring-violet-500/20`,t),children:[(0,h.jsx)(_x,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`proposed`})]}):(0,h.jsxs)(XD,{className:X(`bg-zinc-500/10 text-zinc-600 dark:text-zinc-400 ring-zinc-500/20`,t),children:[(0,h.jsx)(Gb,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:e||`unverified`})]})}function $D({className:e}){return(0,h.jsxs)(XD,{className:X(`bg-orange-500/10 text-orange-600 dark:text-orange-400 ring-orange-500/20`,e),children:[(0,h.jsx)(qb,{size:12,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Stale`})]})}function eO({type:e,className:t}){return(0,h.jsxs)(XD,{className:X(`bg-surface-2 text-fg ring-border`,t),children:[(0,h.jsx)(vD,{type:e,size:12}),(0,h.jsx)(`span`,{children:e||`Concept`})]})}function tO({code:e,lang:t,lineNumbers:n=!1,className:r}){let[i,a]=(0,m.useState)(null);(0,m.useEffect)(()=>{let n=!1;if(!t){a(null);return}return Ag(async()=>{let{highlight:e}=await import(`./highlight-CpEbRnLL.js`);return{highlight:e}},[]).then(({highlight:n})=>n(e,t)).then(e=>{n||a(e)}).catch(()=>{n||a(null)}),()=>{n=!0}},[e,t]);let o=e.split(`
58
58
  `);return(0,h.jsxs)(`div`,{className:X(`relative group`,r),children:[(0,h.jsx)(`div`,{className:`absolute top-2.5 right-2.5 z-10 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,children:(0,h.jsx)(mS,{value:e})}),i?(0,h.jsx)(`div`,{className:X(n&&`okf-lines`),dangerouslySetInnerHTML:{__html:i}}):(0,h.jsx)(`pre`,{className:X(`okf-code overflow-x-auto`,n&&`okf-lines`),children:(0,h.jsx)(`code`,{children:n?o.map((e,t)=>(0,h.jsxs)(`span`,{className:`line`,children:[e,t<o.length-1?`
59
- `:``]},t)):e})})]})}var tO=14;function nO({project:e,conceptId:t,inbound:n,outbound:r,className:i}){let a=kh();if(n.length===0&&r.length===0)return(0,h.jsx)(`div`,{className:X(`rounded-xl border border-border bg-surface-2/40 p-4 text-center text-xs text-muted italic`,i),children:`No connections yet`});let o=n.slice(0,6),s=n.length-o.length,c=r.slice(0,6),l=r.length-c.length,u=t.split(`/`).pop()??t,d=u.length>tO?`${u.slice(0,13)}…`:u,f=(e,t)=>t===1?110:24+e*172/(t-1),p=(e,t)=>t===1?110:24+e*172/(t-1);return(0,h.jsxs)(`div`,{className:X(`rounded-xl border border-border bg-surface-2/30 p-2.5`,i),children:[(0,h.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold uppercase tracking-wider text-muted`,children:`Connections`}),(0,h.jsxs)(`svg`,{viewBox:`0 0 280 220`,className:`w-full h-auto overflow-visible select-none text-[11px]`,"aria-label":`Connections graph`,children:[(0,h.jsxs)(`defs`,{children:[(0,h.jsxs)(`linearGradient`,{id:`okf-grad-inbound`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`0%`,children:[(0,h.jsx)(`stop`,{offset:`0%`,stopColor:`#22d3ee`}),(0,h.jsx)(`stop`,{offset:`100%`,stopColor:`#8b5cf6`})]}),(0,h.jsxs)(`linearGradient`,{id:`okf-grad-outbound`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`0%`,children:[(0,h.jsx)(`stop`,{offset:`0%`,stopColor:`#8b5cf6`}),(0,h.jsx)(`stop`,{offset:`100%`,stopColor:`#22d3ee`})]}),(0,h.jsx)(`marker`,{id:`okf-arrow-in`,viewBox:`0 0 8 8`,refX:`6`,refY:`4`,markerWidth:`5`,markerHeight:`5`,orient:`auto`,children:(0,h.jsx)(`path`,{d:`M 0 1 L 6 4 L 0 7`,fill:`none`,stroke:`#8b5cf6`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsx)(`marker`,{id:`okf-arrow-out`,viewBox:`0 0 8 8`,refX:`6`,refY:`4`,markerWidth:`5`,markerHeight:`5`,orient:`auto`,children:(0,h.jsx)(`path`,{d:`M 0 1 L 6 4 L 0 7`,fill:`none`,stroke:`#22d3ee`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),o.map((e,t)=>{let n=f(t,o.length),r=`M 70 ${n} C 85 ${n}, 85 110, 100 110`;return(0,h.jsx)(Gd.path,{d:r,fill:`none`,stroke:`url(#okf-grad-inbound)`,strokeWidth:`1.5`,markerEnd:`url(#okf-arrow-in)`,initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.4,delay:t*.04,ease:`easeOut`}},`edge-in-${o[t]}`)}),c.map((e,t)=>{let n=p(t,c.length),r=`M 180 110 C 195 110, 195 ${n}, 210 ${n}`;return(0,h.jsx)(Gd.path,{d:r,fill:`none`,stroke:`url(#okf-grad-outbound)`,strokeWidth:`1.5`,markerEnd:`url(#okf-arrow-out)`,initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.4,delay:(o.length+t)*.04,ease:`easeOut`}},`edge-out-${e.id}`)}),(0,h.jsxs)(`g`,{className:`cursor-default`,children:[(0,h.jsx)(`rect`,{x:`100`,y:`98`,width:`80`,height:`24`,rx:`6`,className:`fill-surface stroke-accent-500/50 stroke-1.5`}),(0,h.jsx)(`text`,{x:`140`,y:`110`,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-fg font-medium`,children:d}),(0,h.jsx)(`title`,{children:t})]}),o.map((t,n)=>{let r=f(n,o.length),i=t.split(`/`).pop()??t,s=i.length>tO?`${i.slice(0,13)}…`:i;return(0,h.jsxs)(`g`,{className:`cursor-pointer`,onClick:()=>a(oD(e,t)),children:[(0,h.jsx)(`rect`,{x:`2`,y:r-10,width:`68`,height:`20`,rx:`5`,className:`fill-surface stroke-border hover:stroke-accent-500 hover:fill-surface-2 transition-colors stroke-1`}),(0,h.jsx)(`text`,{x:`36`,y:r,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-muted hover:fill-fg text-[10px] pointer-events-none`,children:s}),(0,h.jsx)(`title`,{children:t})]},`in-${t}`)}),s>0&&(0,h.jsxs)(`text`,{x:`36`,y:`212`,textAnchor:`middle`,className:`fill-subtle text-[10px] font-mono`,children:[`+`,s,` more`]}),c.map((t,n)=>{let r=p(n,c.length),i=t.id.split(`/`).pop()??t.id,o=i.length>tO?`${i.slice(0,13)}…`:i,s=t.exists!==!1;return(0,h.jsxs)(`g`,{className:s?`cursor-pointer`:`cursor-not-allowed`,onClick:()=>{s&&a(oD(e,t.id))},children:[(0,h.jsx)(`rect`,{x:`210`,y:r-10,width:`68`,height:`20`,rx:`5`,strokeDasharray:t.exists===!1?`3 2`:void 0,className:t.exists===!1?`fill-surface stroke-rose-500/80 stroke-1`:`fill-surface stroke-border hover:stroke-accent-500 hover:fill-surface-2 transition-colors stroke-1`}),(0,h.jsx)(`text`,{x:`244`,y:r,textAnchor:`middle`,dominantBaseline:`central`,className:t.exists===!1?`fill-rose-500 text-[10px] pointer-events-none`:`fill-muted hover:fill-fg text-[10px] pointer-events-none`,children:o}),(0,h.jsxs)(`title`,{children:[t.id,t.exists===!1?` (missing)`:``]})]},`out-${t.id}`)}),l>0&&(0,h.jsxs)(`text`,{x:`244`,y:`212`,textAnchor:`middle`,className:`fill-subtle text-[10px] font-mono`,children:[`+`,l,` more`]})]})]})}function rO(e,t){this.v=e,this.k=t}function iO(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function aO(e){if(Array.isArray(e))return e}function oO(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function sO(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
60
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cO(e,t){return aO(e)||oO(e,t)||lO(e,t)||sO()}function lO(e,t){if(e){if(typeof e==`string`)return iO(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?iO(e,t):void 0}}function uO(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof rO;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}uO.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},uO.prototype.next=function(e){return this._invoke(`next`,e)},uO.prototype.throw=function(e){return this._invoke(`throw`,e)},uO.prototype.return=function(e){return this._invoke(`return`,e)};var dO=Object.entries,fO=Object.setPrototypeOf,pO=Object.isFrozen,mO=Object.getPrototypeOf,hO=Object.getOwnPropertyDescriptor,gO=Object.freeze,_O=Object.seal,vO=Object.create,yO=typeof Reflect<`u`&&Reflect,bO=yO.apply,xO=yO.construct;gO||=function(e){return e},_O||=function(e){return e},bO||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},xO||=function(e){return new e(...[...arguments].slice(1))};var SO=HO(Array.prototype.forEach);Array.prototype.indexOf;var CO=HO(Array.prototype.lastIndexOf),wO=HO(Array.prototype.pop),TO=HO(Array.prototype.push);Array.prototype.slice;var EO=HO(Array.prototype.splice),DO=Array.isArray,OO=HO(String.prototype.toLowerCase),kO=HO(String.prototype.toString),AO=HO(String.prototype.match),jO=HO(String.prototype.replace),MO=HO(String.prototype.indexOf),NO=HO(String.prototype.trim),PO=HO(Number.prototype.toString),FO=HO(Boolean.prototype.toString),IO=typeof BigInt>`u`?null:HO(BigInt.prototype.toString),LO=typeof Symbol>`u`?null:HO(Symbol.prototype.toString),RO=HO(Object.prototype.hasOwnProperty),zO=HO(Object.prototype.toString),BO=HO(RegExp.prototype.test),VO=UO(TypeError);function HO(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return bO(e,t,n)}}function UO(e){return function(){return xO(e,[...arguments])}}function WO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:OO;if(fO&&fO(e,null),!DO(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(pO(t)||(t[r]=e),i=e)}e[i]=!0}return e}function GO(e){for(let t=0;t<e.length;t++)RO(e,t)||(e[t]=null);return e}function KO(e){let t=vO(null);for(let r of dO(e)){var n=cO(r,2);let i=n[0],a=n[1];RO(e,i)&&(t[i]=DO(a)?GO(a):a&&typeof a==`object`&&a.constructor===Object?KO(a):a)}return t}function qO(e){switch(typeof e){case`string`:return e;case`number`:return PO(e);case`boolean`:return FO(e);case`bigint`:return IO?IO(e):`0`;case`symbol`:return LO?LO(e):`Symbol()`;case`undefined`:return zO(e);case`function`:case`object`:{if(e===null)return zO(e);let t=e,n=JO(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:zO(e)}return zO(e)}default:return zO(e)}}function JO(e,t){for(;e!==null;){let n=hO(e,t);if(n){if(n.get)return HO(n.get);if(typeof n.value==`function`)return HO(n.value)}e=mO(e)}function n(){return null}return n}function YO(e){try{return BO(e,``),!0}catch{return!1}}var XO=gO(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),ZO=gO(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),QO=gO([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),$O=gO([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),ek=gO(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),tk=gO([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),nk=gO([`#text`]),rk=gO(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),ik=gO(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),ak=gO(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ok=gO([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),sk=_O(/{{[\w\W]*|^[\w\W]*}}/g),ck=_O(/<%[\w\W]*|^[\w\W]*%>/g),lk=_O(/\${[\w\W]*/g),uk=_O(/^data-[\-\w.\u00B7-\uFFFF]+$/),dk=_O(/^aria-[\-\w]+$/),fk=_O(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),pk=_O(/^(?:\w+script|data):/i),mk=_O(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),hk=_O(/^html$/i),gk=_O(/^[a-z][.\w]*(-[.\w]+)+$/i),_k=_O(/<[/\w!]/g),vk=_O(/<[/\w]/g),yk=_O(/<\/no(script|embed|frames)/i),bk=_O(/\/>/i),xk={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Sk=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],Ck=gO(WO({},Sk)),wk=function(){let e={};return SO(Sk,t=>{e[t]=_O(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),gO(e)}(),Tk=function(){return typeof window>`u`?null:window},Ek=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Dk=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ok=function(e,t,n,r){return RO(e,t)&&DO(e[t])?WO(r.base?KO(r.base):{},e[t],r.transform):n},kk=function(e,t,n){let r=RO(e,t)?e[t]:void 0;return r&&typeof r==`object`?KO(r):n()};function Ak(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tk(),t=e=>Ak(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==xk.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=JO(d,`cloneNode`),p=JO(d,`remove`),m=JO(d,`removeAttributeNode`),h=JO(d,`nextSibling`),g=JO(d,`childNodes`),_=JO(d,`parentNode`),v=JO(d,`shadowRoot`),y=JO(d,`attributes`),b=o&&o.prototype?JO(o.prototype,`nodeType`):null,x=o&&o.prototype?JO(o.prototype,`nodeName`):null,S=o&&o.prototype?JO(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let T,E=``,D,O=!1,k=0,ee=function(){if(k>0)throw VO(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},A=function(e){ee(),k++;try{return T.createHTML(e)}finally{k--}},te=function(e){ee(),k++;try{return T.createScriptURL(e)}finally{k--}},ne=function(){return O||=(D=Ek(u,i),!0),D},re=n,ie=re.implementation,ae=re.createNodeIterator,oe=re.createDocumentFragment,se=re.getElementsByTagName,ce=r.importNode,j=Dk();t.isSupported=typeof dO==`function`&&typeof _==`function`&&ie&&ie.createHTMLDocument!==void 0;let le=sk,ue=ck,de=lk,fe=uk,pe=dk,me=pk,he=mk,ge=gk,M=fk,N=null,_e=WO({},[...XO,...ZO,...QO,...ek,...nk]),P=null,ve=WO({},[...rk,...ik,...ak,...ok]),F=Object.seal(vO(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ye=null,be=null,xe=Object.seal(vO(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Se=!0,Ce=!0,we=!1,Te=!0,Ee=!1,De=!0,Oe=!1,ke=!1,Ae=null,je=null,Me=!1,Ne=!1,Pe=!1,Fe=!1,Ie=!0,Le=!1,Re=`user-content-`,ze=!0,Be=!1,Ve={},He=null,Ue=WO({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),We=null,Ge=WO({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ke=null,qe=WO({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Je=`http://www.w3.org/1998/Math/MathML`,Ye=`http://www.w3.org/2000/svg`,Xe=`http://www.w3.org/1999/xhtml`,Ze=Xe,Qe=!1,$e=null,et=WO({},[Je,Ye,Xe],kO),tt=gO([`mi`,`mo`,`mn`,`ms`,`mtext`]),nt=WO({},tt),rt=gO([`annotation-xml`]),it=WO({},rt),at=WO({},[`title`,`style`,`font`,`a`,`script`]),ot=null,st=[`application/xhtml+xml`,`text/html`],ct=null,lt=null,ut=n.createElement(`form`),dt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(lt&&lt===e)return;(!e||typeof e!=`object`)&&(e={}),e=KO(e),ot=st.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ct=ot===`application/xhtml+xml`?kO:OO,N=Ok(e,`ALLOWED_TAGS`,_e,{transform:ct}),P=Ok(e,`ALLOWED_ATTR`,ve,{transform:ct}),$e=Ok(e,`ALLOWED_NAMESPACES`,et,{transform:kO}),Ke=Ok(e,`ADD_URI_SAFE_ATTR`,qe,{transform:ct,base:qe}),We=Ok(e,`ADD_DATA_URI_TAGS`,Ge,{transform:ct,base:Ge}),He=Ok(e,`FORBID_CONTENTS`,Ue,{transform:ct}),ye=Ok(e,`FORBID_TAGS`,KO({}),{transform:ct}),be=Ok(e,`FORBID_ATTR`,KO({}),{transform:ct}),Ve=RO(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?KO(e.USE_PROFILES):e.USE_PROFILES:!1,Se=e.ALLOW_ARIA_ATTR!==!1,Ce=e.ALLOW_DATA_ATTR!==!1,we=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Te=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=e.SAFE_FOR_TEMPLATES||!1,De=e.SAFE_FOR_XML!==!1,Oe=e.WHOLE_DOCUMENT||!1,Ne=e.RETURN_DOM||!1,Pe=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,Ie=e.SANITIZE_DOM!==!1,Le=e.SANITIZE_NAMED_PROPS||!1,ze=e.KEEP_CONTENT!==!1,Be=e.IN_PLACE||!1,M=YO(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:fk,Ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:Xe,nt=kk(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>WO({},tt)),it=kk(e,`HTML_INTEGRATION_POINTS`,()=>WO({},rt));let t=kk(e,`CUSTOM_ELEMENT_HANDLING`,()=>vO(null));if(F=vO(null),RO(t,`tagNameCheck`)&&dt(t.tagNameCheck)&&(F.tagNameCheck=t.tagNameCheck),RO(t,`attributeNameCheck`)&&dt(t.attributeNameCheck)&&(F.attributeNameCheck=t.attributeNameCheck),RO(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(F.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),_O(F),Ee&&(Ce=!1),Pe&&(Ne=!0),Ve&&(N=WO({},nk),P=vO(null),Ve.html===!0&&(WO(N,XO),WO(P,rk)),Ve.svg===!0&&(WO(N,ZO),WO(P,ik),WO(P,ok)),Ve.svgFilters===!0&&(WO(N,QO),WO(P,ik),WO(P,ok)),Ve.mathMl===!0&&(WO(N,ek),WO(P,ak),WO(P,ok))),xe.tagCheck=null,xe.attributeCheck=null,RO(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?xe.tagCheck=e.ADD_TAGS:DO(e.ADD_TAGS)&&(N===_e&&(N=KO(N)),WO(N,e.ADD_TAGS,ct))),RO(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?xe.attributeCheck=e.ADD_ATTR:DO(e.ADD_ATTR)&&(P===ve&&(P=KO(P)),WO(P,e.ADD_ATTR,ct))),RO(e,`ADD_FORBID_CONTENTS`)&&DO(e.ADD_FORBID_CONTENTS)&&(He===Ue&&(He=KO(He)),WO(He,e.ADD_FORBID_CONTENTS,ct)),ze&&(N[`#text`]=!0),Oe&&WO(N,[`html`,`head`,`body`]),N.table&&(WO(N,[`tbody`]),delete ye.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw VO(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw VO(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=T;T=e.TRUSTED_TYPES_POLICY;try{E=A(``)}catch(e){throw T=t,e}}else e.TRUSTED_TYPES_POLICY===null?(T=void 0,E=``):(T===void 0&&(T=ne()),T&&typeof E==`string`&&(E=A(``)));gO&&gO(e),lt=e},pt=WO({},[...ZO,...QO,...$O]),mt=WO({},[...ek,...tk]),ht=function(e,t,n){return t.namespaceURI===Xe?e===`svg`:t.namespaceURI===Je?e===`svg`&&(n===`annotation-xml`||nt[n]):!!pt[e]},gt=function(e,t,n){return t.namespaceURI===Xe?e===`math`:t.namespaceURI===Ye?e===`math`&&it[n]:!!mt[e]},_t=function(e,t,n){return t.namespaceURI===Ye&&!it[n]||t.namespaceURI===Je&&!nt[n]?!1:!mt[e]&&(at[e]||!pt[e])},vt=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ze,tagName:`template`});let n=OO(e.tagName),r=OO(t.tagName);return $e[e.namespaceURI]?e.namespaceURI===Ye?ht(n,t,r):e.namespaceURI===Je?gt(n,t,r):e.namespaceURI===Xe?_t(n,t,r):!!(ot===`application/xhtml+xml`&&$e[e.namespaceURI]):!1},yt=function(e){TO(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw VO(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},bt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},xt=function(e){wt(e);let t=g(e);if(t){let e=[];SO(t,t=>{TO(e,t)}),SO(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&bt(e,r,i)}},St=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}TO(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ne||Pe)try{yt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Ct=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||P[ct(i)]||bt(e,r,i)}},wt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===xk.element&&Ct(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Tt=function(e,t){return De?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Et=function(e){if(!De)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===xk.processingInstruction||n===xk.comment&&BO(vk,e.data)){try{p(e)}catch{}continue}if(n===xk.element){let t=e,n=ct(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Tt(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Dt=function(e){let t=null,r=null;if(Me)e=`<remove></remove>`+e;else{let t=AO(e,/^[\r\n\t ]+/);r=t&&t[0]}ot===`application/xhtml+xml`&&Ze===Xe&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=T?A(e):e;if(Ze===Xe)try{t=new l().parseFromString(i,ot)}catch{}if(!t||!t.documentElement){t=ie.createDocument(Ze,`template`,null);try{t.documentElement.innerHTML=Qe?E:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ze===Xe?se.call(t,Oe?`html`:`body`)[0]:Oe?t.documentElement:a},Ot=function(e){let t=S?S(e):e.ownerDocument;return ae.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},kt=function(e){return e=jO(e,le,` `),e=jO(e,ue,` `),e=jO(e,de,` `),e},At=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=ae.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=kt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&SO(i,e=>{Mt(e.content)&&At(e.content)})},jt=function(e){let t=x?x(e):null;return typeof t!=`string`||ct(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},Mt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===xk.documentFragment}catch{return!1}},Nt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Pt(e,n,r){e.length!==0&&SO(e,e=>{e.call(t,n,r,lt)})}let Ft=function(e,t){return!!(De&&e.hasChildNodes()&&!Nt(e.firstElementChild)&&BO(_k,e.textContent)&&BO(_k,e.innerHTML)||De&&e.namespaceURI===Xe&&Ck[t]&&(Nt(e.firstElementChild)||typeof e.textContent==`string`&&BO(wk[t],e.textContent))||e.nodeType===xk.processingInstruction||De&&e.nodeType===xk.comment&&BO(vk,e.data))},It=function(e,t){return e instanceof RegExp?BO(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Lt=function(e,t,n){if(!ye[t]&&Ut(t)&&It(F.tagNameCheck,t))return!1;if(ze&&!He[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return yt(e),!0},Rt=function(e,t,n,r){return e.length===0?t:t===n||t===r?KO(t):t},zt=function(e,t){return e===t||_(e)!==null?!1:(Be&&wt(e),!0)},Bt=function(e,n){if(Pt(j.beforeSanitizeElements,e,null),zt(e,n))return!0;if(jt(e))return yt(e),!0;let r=ct(w(e));if(N=Rt(j.uponSanitizeElement,N,_e,Ae),Pt(j.uponSanitizeElement,e,{tagName:r,allowedTags:N}),zt(e,n))return!0;if(Ft(e,r))return yt(e),!0;if(ye[r]||!(xe.tagCheck instanceof Function&&xe.tagCheck(r))&&!N[r]){let t=Lt(e,r,n);return t===!1&&(Pt(j.afterSanitizeElements,e,null),zt(e,n))?!0:t}if(C(e)===xk.element&&!vt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&BO(yk,e.innerHTML))return yt(e),!0;if(Ee&&e.nodeType===xk.text){let n=kt(e.textContent);e.textContent!==n&&(TO(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Pt(j.afterSanitizeElements,e,null),zt(e,n)},Vt=function(e,t,r){if(be[t]||Tt(t,e)||Ie&&(t===`id`||t===`name`)&&(r in n||r in ut))return!1;let i=P[t]||xe.attributeCheck instanceof Function&&xe.attributeCheck(t,e);return Ce&&BO(fe,t)||Se&&BO(pe,t)?!0:i?Ke[t]||BO(M,jO(r,he,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&MO(r,`data:`)===0&&We[e]||we&&!BO(me,jO(r,he,``))?!0:!r:Ut(e)&&It(F.tagNameCheck,e)&&It(F.attributeNameCheck,t,e)||t===`is`&&F.allowCustomizedBuiltInElements&&It(F.tagNameCheck,r)},Ht=WO({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Ut=function(e){return!Ht[OO(e)]&&BO(ge,e)},Wt=function(e,t,n,r){if(T&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return A(r);case`TrustedScriptURL`:return te(r)}return r},Gt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!jt(e)||(yt(e),!1)}catch{return St(t,e),!1}},Kt=function(e,n){if(Pt(j.beforeSanitizeAttributes,e,null),zt(e,n))return;let r=e.attributes;if(!r||jt(e))return;P=Rt(j.uponSanitizeAttribute,P,ve,je);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:P,forceKeepAttr:void 0},a=r.length,o=ct(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=ct(s),d=l,f=s===`value`?d:NO(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Pt(j.uponSanitizeAttribute,e,i),f=i.attrValue,Le&&(u===`id`||u===`name`)&&MO(f,Re)!==0&&(St(s,e,n),f=Re+f,p=!0),De&&BO(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){St(s,e,n);continue}if(u===`attributename`&&AO(f,`href`)){St(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){St(s,e,n);continue}if(!Te&&BO(bk,f)){St(s,e,n);continue}if(Ee&&(f=kt(f)),!Vt(o,u,f)){St(s,e,n);continue}f=Wt(o,u,c,f),f!==d&&Gt(e,s,c,f)&&p&&wO(t.removed)}}Pt(j.afterSanitizeAttributes,e,null),zt(e,n)},I=function(e){let t=null,n=Ot(e);for(Pt(j.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Pt(j.uponSanitizeShadowNode,t,null),Bt(t,e),Kt(t,e),Mt(t.content)&&I(t.content),C(t)===xk.element){let e=v(t);Mt(e)&&(qt(e),I(e))}Pt(j.afterSanitizeShadowDOM,e,null)},qt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){I(e.shadow);continue}let n=e.node,r=C(n)===xk.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&ct(e)===`template`){let e=n.content;Mt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);Mt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Qe=!e,Qe&&(e=`<!-->`),typeof e!=`string`&&!Nt(e)&&(e=qO(e),typeof e!=`string`))throw VO(`dirty is not a string, aborting`);if(!t.isSupported)return e;ke?(N=Ae,P=je):ft(n),(j.uponSanitizeElement.length>0||j.uponSanitizeAttribute.length>0)&&(N=KO(N)),j.uponSanitizeAttribute.length>0&&(P=KO(P)),t.removed=[];let c=Be&&typeof e!=`string`&&Nt(e);if(c){Et(e);let t=w(e);if(typeof t==`string`){let n=ct(t);if(!N[n]||ye[n])throw xt(e),VO(`root node is forbidden and cannot be sanitized in-place`)}if(jt(e))throw xt(e),VO(`root node is clobbered and cannot be sanitized in-place`);try{qt(e)}catch(t){throw xt(e),t}}else if(Nt(e))i=Dt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===xk.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),qt(i);else{if(!Ne&&!Ee&&!Oe&&e.indexOf(`<`)===-1)return T&&Fe?A(e):e;if(i=Dt(e),!i)return Ne?null:Fe?E:``}i&&Me&&yt(i.firstChild);let l=c?e:i;try{let e=Ot(l);for(;o=e.nextNode();)Bt(o,l),Kt(o,l),Mt(o.content)&&I(o.content)}catch(n){throw c&&(xt(e),SO(t.removed,e=>{e.element&&wt(e.element)})),n}if(c){let n=!1;if(SO(t.removed,t=>{t.element&&(t.element===e&&(n=!0),wt(t.element))}),n)throw VO(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Ee&&At(e),e}if(Ne){if(Ee&&At(i),Pe)for(s=oe.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(P.shadowroot||P.shadowrootmode)&&(s=ce.call(r,s,!0)),s}let u=Oe?i.outerHTML:i.innerHTML;return Oe&&N[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&BO(hk,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
61
- `+u),Ee&&(u=kt(u)),T&&Fe?A(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(e),ke=!0,Ae=N,je=P},t.clearConfig=function(){lt=null,ke=!1,Ae=null,je=null,T=D,E=``},t.isValidAttribute=function(e,t,n){lt||ft({});let r=ct(e),i=ct(t);return Vt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&RO(j,e)&&TO(j[e],t)},t.removeHook=function(e,t){if(RO(j,e)){if(t!==void 0){let n=CO(j[e],t);return n===-1?void 0:EO(j[e],n,1)[0]}return wO(j[e])}},t.removeHooks=function(e){RO(j,e)&&(j[e]=[])},t.removeAllHooks=function(){j=Dk()},t}var jk=Ak();function Mk(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Nk=Mk();function Pk(e){Nk=e}var Fk={exec:()=>null};function Ik(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function $(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(Rk.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Lk=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Rk={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,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:Ik(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Ik(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Ik(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Ik(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Ik(e=>RegExp(`^ {0,${e}}(?:</?(?:${$k})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:Ik(e=>RegExp(`^ {0,${e}}>`))},zk=/^(?:[ \t]*(?:\n|$))+/,Bk=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Vk=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Hk=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Uk=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wk=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Gk=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Kk=$(Gk).replace(/bull/g,Wk).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),qk=$(Gk).replace(/bull/g,Wk).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Jk=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Yk=/^[^\n]+/,Xk=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Zk=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Xk).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qk=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Wk).getRegex(),$k=`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`,eA=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,tA=$(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,eA).replace(`tag`,$k).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),nA=e=>$(Jk).replace(`hr`,Hk).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,$k).getRegex(),rA=nA(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),iA=nA(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),aA={blockquote:$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,iA).getRegex(),code:Bk,def:Zk,fences:Vk,heading:Uk,hr:Hk,html:tA,lheading:Kk,list:Qk,newline:zk,paragraph:rA,table:Fk,text:Yk},oA=$(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Hk).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,$k).getRegex(),sA={...aA,lheading:qk,table:oA,paragraph:$(Jk).replace(`hr`,Hk).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,oA).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,$k).getRegex()},cA={...aA,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,eA).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:Fk,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(Jk).replace(`hr`,Hk).replace(`heading`,` *#{1,6} *[^
62
- ]`).replace(`lheading`,Kk).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},lA=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,uA=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,dA=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,fA=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,pA=/[\p{P}\p{S}]/u,mA=/[\s\p{P}\p{S}]/u,hA=/[^\s\p{P}\p{S}]/u,gA=$(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,mA).getRegex(),_A=/[\p{Pi}\p{Ps}"']/u,vA=/(?!~)[\p{P}\p{S}]/u,yA=/(?!~)[\s\p{P}\p{S}]/u,bA=/(?:[^\s\p{P}\p{S}]|~)/u,xA=$(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Lk?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),SA=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,CA=$(SA,`u`).replace(/punct/g,pA).getRegex(),wA=$(SA,`u`).replace(/punct/g,vA).getRegex(),TA=$(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,_A).replace(/punct/g,pA).getRegex(),EA=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,DA=$(EA,`gu`).replace(/notPunctSpace/g,hA).replace(/punctSpace/g,mA).replace(/punct/g,pA).getRegex(),OA=$(EA,`gu`).replace(/notPunctSpace/g,bA).replace(/punctSpace/g,yA).replace(/punct/g,vA).getRegex(),kA=$(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,hA).replace(/punctSpace/g,mA).replace(/punct/g,pA).getRegex(),AA=$(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,hA).replace(/punctSpace/g,mA).replace(/punct/g,pA).getRegex(),jA=$(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,hA).replace(/punctSpace/g,mA).replace(/punct/g,pA).getRegex(),MA=$(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,pA).getRegex(),NA=$(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,hA).replace(/punctSpace/g,mA).replace(/punct/g,pA).getRegex(),PA=$(/\\(punct)/,`gu`).replace(/punct/g,pA).getRegex(),FA=$(/^<(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(),IA=$(eA).replace(`(?:-->|$)`,`-->`).getRegex(),LA=$(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,IA).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),RA=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,zA=$(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,RA).getRegex(),BA=$(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,zA).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),VA=$(/^!?\[(label)\]\[(ref)\]/).replace(`label`,zA).replace(`ref`,Xk).getRegex(),HA=$(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Xk).getRegex(),UA=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,WA=$(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,RA).getRegex(),GA=$(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,$(/^!?\[(label)\]\[(ref)\]/).replace(`label`,WA).replace(`ref`,UA).getRegex()).replace(`nolink`,$(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,UA).getRegex()).getRegex(),KA=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,qA=$(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),JA={_backpedal:Fk,anyPunctuation:PA,autolink:FA,blockSkip:xA,br:dA,code:uA,del:Fk,delLDelim:Fk,delRDelim:Fk,emStrongLDelim:CA,emStrongRDelimAst:DA,emStrongRDelimUnd:AA,escape:lA,link:BA,nolink:HA,punctuation:gA,reflink:VA,reflinkSearch:GA,tag:LA,text:fA,url:Fk},YA={...JA,emStrongLDelim:TA,emStrongRDelimAst:kA,emStrongRDelimUnd:jA,link:$(/^!?\[(label)\]\((.*?)\)/).replace(`label`,zA).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,zA).getRegex()},XA={...JA,emStrongRDelimAst:OA,emStrongLDelim:wA,delLDelim:MA,delRDelim:NA,url:$(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,qA).replace(`protocol`,KA).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:$(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,KA).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},ZA={...XA,br:$(dA).replace(`{2,}`,`*`).getRegex(),text:$(XA.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},QA={normal:aA,gfm:sA,pedantic:cA},$A={normal:JA,gfm:XA,breaks:ZA,pedantic:YA},ej={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},tj=e=>ej[e];function nj(e,t){if(t){if(Rk.escapeTest.test(e))return e.replace(Rk.escapeReplace,tj)}else if(Rk.escapeTestNoEncode.test(e))return e.replace(Rk.escapeReplaceNoEncode,tj);return e}function rj(e){return e.replace(Rk.numericCharacterReference,(e,t,n)=>{let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}function ij(e){try{e=encodeURI(e).replace(Rk.percentDecode,`%`)}catch{return null}return e}function aj(e,t){let n=e.replace(Rk.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Rk.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(Rk.slashPipe,`|`);return n}function oj(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 sj(e){let t=e.split(`
63
- `),n=t.length-1;for(;n>=0&&Rk.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
64
- `)}function cj(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function lj(e,t){if(e.indexOf(t[0])===-1&&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 uj(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 dj(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function fj(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
59
+ `:``]},t)):e})})]})}var nO=14;function rO({project:e,conceptId:t,inbound:n,outbound:r,className:i}){let a=kh();if(n.length===0&&r.length===0)return(0,h.jsx)(`div`,{className:X(`rounded-xl border border-border bg-surface-2/40 p-4 text-center text-xs text-muted italic`,i),children:`No connections yet`});let o=n.slice(0,6),s=n.length-o.length,c=r.slice(0,6),l=r.length-c.length,u=t.split(`/`).pop()??t,d=u.length>nO?`${u.slice(0,13)}…`:u,f=(e,t)=>t===1?110:24+e*172/(t-1),p=(e,t)=>t===1?110:24+e*172/(t-1);return(0,h.jsxs)(`div`,{className:X(`rounded-xl border border-border bg-surface-2/30 p-2.5`,i),children:[(0,h.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold uppercase tracking-wider text-muted`,children:`Connections`}),(0,h.jsxs)(`svg`,{viewBox:`0 0 280 220`,className:`w-full h-auto overflow-visible select-none text-[11px]`,"aria-label":`Connections graph`,children:[(0,h.jsxs)(`defs`,{children:[(0,h.jsxs)(`linearGradient`,{id:`okf-grad-inbound`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`0%`,children:[(0,h.jsx)(`stop`,{offset:`0%`,stopColor:`#22d3ee`}),(0,h.jsx)(`stop`,{offset:`100%`,stopColor:`#8b5cf6`})]}),(0,h.jsxs)(`linearGradient`,{id:`okf-grad-outbound`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`0%`,children:[(0,h.jsx)(`stop`,{offset:`0%`,stopColor:`#8b5cf6`}),(0,h.jsx)(`stop`,{offset:`100%`,stopColor:`#22d3ee`})]}),(0,h.jsx)(`marker`,{id:`okf-arrow-in`,viewBox:`0 0 8 8`,refX:`6`,refY:`4`,markerWidth:`5`,markerHeight:`5`,orient:`auto`,children:(0,h.jsx)(`path`,{d:`M 0 1 L 6 4 L 0 7`,fill:`none`,stroke:`#8b5cf6`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsx)(`marker`,{id:`okf-arrow-out`,viewBox:`0 0 8 8`,refX:`6`,refY:`4`,markerWidth:`5`,markerHeight:`5`,orient:`auto`,children:(0,h.jsx)(`path`,{d:`M 0 1 L 6 4 L 0 7`,fill:`none`,stroke:`#22d3ee`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),o.map((e,t)=>{let n=f(t,o.length),r=`M 70 ${n} C 85 ${n}, 85 110, 100 110`;return(0,h.jsx)(Gd.path,{d:r,fill:`none`,stroke:`url(#okf-grad-inbound)`,strokeWidth:`1.5`,markerEnd:`url(#okf-arrow-in)`,initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.4,delay:t*.04,ease:`easeOut`}},`edge-in-${o[t]}`)}),c.map((e,t)=>{let n=p(t,c.length),r=`M 180 110 C 195 110, 195 ${n}, 210 ${n}`;return(0,h.jsx)(Gd.path,{d:r,fill:`none`,stroke:`url(#okf-grad-outbound)`,strokeWidth:`1.5`,markerEnd:`url(#okf-arrow-out)`,initial:{pathLength:0},animate:{pathLength:1},transition:{duration:.4,delay:(o.length+t)*.04,ease:`easeOut`}},`edge-out-${e.id}`)}),(0,h.jsxs)(`g`,{className:`cursor-default`,children:[(0,h.jsx)(`rect`,{x:`100`,y:`98`,width:`80`,height:`24`,rx:`6`,className:`fill-surface stroke-accent-500/50 stroke-1.5`}),(0,h.jsx)(`text`,{x:`140`,y:`110`,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-fg font-medium`,children:d}),(0,h.jsx)(`title`,{children:t})]}),o.map((t,n)=>{let r=f(n,o.length),i=aD(t),s=i?i.project:e,c=i?i.id:t,l=i!==null,u=c.split(`/`).pop()??c,d=l?`${i.project}/${u}`:u,p=d.length>nO?`${d.slice(0,13)}…`:d;return(0,h.jsxs)(`g`,{className:`cursor-pointer`,onClick:()=>a(sD(s,c)),children:[(0,h.jsx)(`rect`,{x:`2`,y:r-10,width:`68`,height:`20`,rx:`5`,className:`fill-surface stroke-border hover:stroke-accent-500 hover:fill-surface-2 transition-colors stroke-1`}),(0,h.jsx)(`text`,{x:`36`,y:r,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-muted hover:fill-fg text-[10px] pointer-events-none`,children:p}),(0,h.jsx)(`title`,{children:l?`${s}/${c}`:c})]},`in-${t}`)}),s>0&&(0,h.jsxs)(`text`,{x:`36`,y:`212`,textAnchor:`middle`,className:`fill-subtle text-[10px] font-mono`,children:[`+`,s,` more`]}),c.map((t,n)=>{let r=p(n,c.length),i=t.project??e,o=t.project&&t.project!==e,s=t.id.split(`/`).pop()??t.id,l=o?`${t.project}/${s}`:s,u=l.length>nO?`${l.slice(0,13)}…`:l,d=t.exists!==!1;return(0,h.jsxs)(`g`,{className:d?`cursor-pointer`:`cursor-not-allowed`,onClick:()=>{d&&a(sD(i,t.id))},children:[(0,h.jsx)(`rect`,{x:`210`,y:r-10,width:`68`,height:`20`,rx:`5`,strokeDasharray:t.exists===!1?`3 2`:void 0,className:t.exists===!1?`fill-surface stroke-rose-500/80 stroke-1`:`fill-surface stroke-border hover:stroke-accent-500 hover:fill-surface-2 transition-colors stroke-1`}),(0,h.jsx)(`text`,{x:`244`,y:r,textAnchor:`middle`,dominantBaseline:`central`,className:t.exists===!1?`fill-rose-500 text-[10px] pointer-events-none`:`fill-muted hover:fill-fg text-[10px] pointer-events-none`,children:u}),(0,h.jsxs)(`title`,{children:[o?`${t.project}/${t.id}`:t.id,t.exists===!1?` (missing)`:``]})]},`out-${t.project?`${t.project}/`:``}${t.id}`)}),l>0&&(0,h.jsxs)(`text`,{x:`244`,y:`212`,textAnchor:`middle`,className:`fill-subtle text-[10px] font-mono`,children:[`+`,l,` more`]})]})]})}function iO(e,t){this.v=e,this.k=t}function aO(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function oO(e){if(Array.isArray(e))return e}function sO(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function cO(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
60
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lO(e,t){return oO(e)||sO(e,t)||uO(e,t)||cO()}function uO(e,t){if(e){if(typeof e==`string`)return aO(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?aO(e,t):void 0}}function dO(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof iO;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}dO.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},dO.prototype.next=function(e){return this._invoke(`next`,e)},dO.prototype.throw=function(e){return this._invoke(`throw`,e)},dO.prototype.return=function(e){return this._invoke(`return`,e)};var fO=Object.entries,pO=Object.setPrototypeOf,mO=Object.isFrozen,hO=Object.getPrototypeOf,gO=Object.getOwnPropertyDescriptor,_O=Object.freeze,vO=Object.seal,yO=Object.create,bO=typeof Reflect<`u`&&Reflect,xO=bO.apply,SO=bO.construct;_O||=function(e){return e},vO||=function(e){return e},xO||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},SO||=function(e){return new e(...[...arguments].slice(1))};var CO=UO(Array.prototype.forEach);Array.prototype.indexOf;var wO=UO(Array.prototype.lastIndexOf),TO=UO(Array.prototype.pop),EO=UO(Array.prototype.push);Array.prototype.slice;var DO=UO(Array.prototype.splice),OO=Array.isArray,kO=UO(String.prototype.toLowerCase),AO=UO(String.prototype.toString),jO=UO(String.prototype.match),MO=UO(String.prototype.replace),NO=UO(String.prototype.indexOf),PO=UO(String.prototype.trim),FO=UO(Number.prototype.toString),IO=UO(Boolean.prototype.toString),LO=typeof BigInt>`u`?null:UO(BigInt.prototype.toString),RO=typeof Symbol>`u`?null:UO(Symbol.prototype.toString),zO=UO(Object.prototype.hasOwnProperty),BO=UO(Object.prototype.toString),VO=UO(RegExp.prototype.test),HO=WO(TypeError);function UO(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return xO(e,t,n)}}function WO(e){return function(){return SO(e,[...arguments])}}function GO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kO;if(pO&&pO(e,null),!OO(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(mO(t)||(t[r]=e),i=e)}e[i]=!0}return e}function KO(e){for(let t=0;t<e.length;t++)zO(e,t)||(e[t]=null);return e}function qO(e){let t=yO(null);for(let r of fO(e)){var n=lO(r,2);let i=n[0],a=n[1];zO(e,i)&&(t[i]=OO(a)?KO(a):a&&typeof a==`object`&&a.constructor===Object?qO(a):a)}return t}function JO(e){switch(typeof e){case`string`:return e;case`number`:return FO(e);case`boolean`:return IO(e);case`bigint`:return LO?LO(e):`0`;case`symbol`:return RO?RO(e):`Symbol()`;case`undefined`:return BO(e);case`function`:case`object`:{if(e===null)return BO(e);let t=e,n=YO(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:BO(e)}return BO(e)}default:return BO(e)}}function YO(e,t){for(;e!==null;){let n=gO(e,t);if(n){if(n.get)return UO(n.get);if(typeof n.value==`function`)return UO(n.value)}e=hO(e)}function n(){return null}return n}function XO(e){try{return VO(e,``),!0}catch{return!1}}var ZO=_O(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),QO=_O(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),$O=_O([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),ek=_O([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),tk=_O(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),nk=_O([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),rk=_O([`#text`]),ik=_O(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),ak=_O(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),ok=_O(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),sk=_O([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),ck=vO(/{{[\w\W]*|^[\w\W]*}}/g),lk=vO(/<%[\w\W]*|^[\w\W]*%>/g),uk=vO(/\${[\w\W]*/g),dk=vO(/^data-[\-\w.\u00B7-\uFFFF]+$/),fk=vO(/^aria-[\-\w]+$/),pk=vO(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),mk=vO(/^(?:\w+script|data):/i),hk=vO(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),gk=vO(/^html$/i),_k=vO(/^[a-z][.\w]*(-[.\w]+)+$/i),vk=vO(/<[/\w!]/g),yk=vO(/<[/\w]/g),bk=vO(/<\/no(script|embed|frames)/i),xk=vO(/\/>/i),Sk={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ck=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],wk=_O(GO({},Ck)),Tk=function(){let e={};return CO(Ck,t=>{e[t]=vO(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),_O(e)}(),Ek=function(){return typeof window>`u`?null:window},Dk=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Ok=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},kk=function(e,t,n,r){return zO(e,t)&&OO(e[t])?GO(r.base?qO(r.base):{},e[t],r.transform):n},Ak=function(e,t,n){let r=zO(e,t)?e[t]:void 0;return r&&typeof r==`object`?qO(r):n()};function jk(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ek(),t=e=>jk(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==Sk.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=YO(d,`cloneNode`),p=YO(d,`remove`),m=YO(d,`removeAttributeNode`),h=YO(d,`nextSibling`),g=YO(d,`childNodes`),_=YO(d,`parentNode`),v=YO(d,`shadowRoot`),y=YO(d,`attributes`),b=o&&o.prototype?YO(o.prototype,`nodeType`):null,x=o&&o.prototype?YO(o.prototype,`nodeName`):null,S=o&&o.prototype?YO(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let T,E=``,D,O=!1,k=0,ee=function(){if(k>0)throw HO(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},A=function(e){ee(),k++;try{return T.createHTML(e)}finally{k--}},te=function(e){ee(),k++;try{return T.createScriptURL(e)}finally{k--}},ne=function(){return O||=(D=Dk(u,i),!0),D},re=n,ie=re.implementation,ae=re.createNodeIterator,oe=re.createDocumentFragment,se=re.getElementsByTagName,ce=r.importNode,j=Ok();t.isSupported=typeof fO==`function`&&typeof _==`function`&&ie&&ie.createHTMLDocument!==void 0;let le=ck,ue=lk,de=uk,fe=dk,pe=fk,me=mk,he=hk,ge=_k,M=pk,N=null,_e=GO({},[...ZO,...QO,...$O,...tk,...rk]),P=null,ve=GO({},[...ik,...ak,...ok,...sk]),F=Object.seal(yO(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ye=null,be=null,xe=Object.seal(yO(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Se=!0,Ce=!0,we=!1,Te=!0,Ee=!1,De=!0,Oe=!1,ke=!1,Ae=null,je=null,Me=!1,Ne=!1,Pe=!1,Fe=!1,Ie=!0,Le=!1,Re=`user-content-`,ze=!0,Be=!1,Ve={},He=null,Ue=GO({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),We=null,Ge=GO({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ke=null,qe=GO({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Je=`http://www.w3.org/1998/Math/MathML`,Ye=`http://www.w3.org/2000/svg`,Xe=`http://www.w3.org/1999/xhtml`,Ze=Xe,Qe=!1,$e=null,et=GO({},[Je,Ye,Xe],AO),tt=_O([`mi`,`mo`,`mn`,`ms`,`mtext`]),nt=GO({},tt),rt=_O([`annotation-xml`]),it=GO({},rt),at=GO({},[`title`,`style`,`font`,`a`,`script`]),ot=null,st=[`application/xhtml+xml`,`text/html`],ct=null,lt=null,ut=n.createElement(`form`),dt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(lt&&lt===e)return;(!e||typeof e!=`object`)&&(e={}),e=qO(e),ot=st.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ct=ot===`application/xhtml+xml`?AO:kO,N=kk(e,`ALLOWED_TAGS`,_e,{transform:ct}),P=kk(e,`ALLOWED_ATTR`,ve,{transform:ct}),$e=kk(e,`ALLOWED_NAMESPACES`,et,{transform:AO}),Ke=kk(e,`ADD_URI_SAFE_ATTR`,qe,{transform:ct,base:qe}),We=kk(e,`ADD_DATA_URI_TAGS`,Ge,{transform:ct,base:Ge}),He=kk(e,`FORBID_CONTENTS`,Ue,{transform:ct}),ye=kk(e,`FORBID_TAGS`,qO({}),{transform:ct}),be=kk(e,`FORBID_ATTR`,qO({}),{transform:ct}),Ve=zO(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?qO(e.USE_PROFILES):e.USE_PROFILES:!1,Se=e.ALLOW_ARIA_ATTR!==!1,Ce=e.ALLOW_DATA_ATTR!==!1,we=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Te=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=e.SAFE_FOR_TEMPLATES||!1,De=e.SAFE_FOR_XML!==!1,Oe=e.WHOLE_DOCUMENT||!1,Ne=e.RETURN_DOM||!1,Pe=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,Ie=e.SANITIZE_DOM!==!1,Le=e.SANITIZE_NAMED_PROPS||!1,ze=e.KEEP_CONTENT!==!1,Be=e.IN_PLACE||!1,M=XO(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:pk,Ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:Xe,nt=Ak(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>GO({},tt)),it=Ak(e,`HTML_INTEGRATION_POINTS`,()=>GO({},rt));let t=Ak(e,`CUSTOM_ELEMENT_HANDLING`,()=>yO(null));if(F=yO(null),zO(t,`tagNameCheck`)&&dt(t.tagNameCheck)&&(F.tagNameCheck=t.tagNameCheck),zO(t,`attributeNameCheck`)&&dt(t.attributeNameCheck)&&(F.attributeNameCheck=t.attributeNameCheck),zO(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(F.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),vO(F),Ee&&(Ce=!1),Pe&&(Ne=!0),Ve&&(N=GO({},rk),P=yO(null),Ve.html===!0&&(GO(N,ZO),GO(P,ik)),Ve.svg===!0&&(GO(N,QO),GO(P,ak),GO(P,sk)),Ve.svgFilters===!0&&(GO(N,$O),GO(P,ak),GO(P,sk)),Ve.mathMl===!0&&(GO(N,tk),GO(P,ok),GO(P,sk))),xe.tagCheck=null,xe.attributeCheck=null,zO(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?xe.tagCheck=e.ADD_TAGS:OO(e.ADD_TAGS)&&(N===_e&&(N=qO(N)),GO(N,e.ADD_TAGS,ct))),zO(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?xe.attributeCheck=e.ADD_ATTR:OO(e.ADD_ATTR)&&(P===ve&&(P=qO(P)),GO(P,e.ADD_ATTR,ct))),zO(e,`ADD_FORBID_CONTENTS`)&&OO(e.ADD_FORBID_CONTENTS)&&(He===Ue&&(He=qO(He)),GO(He,e.ADD_FORBID_CONTENTS,ct)),ze&&(N[`#text`]=!0),Oe&&GO(N,[`html`,`head`,`body`]),N.table&&(GO(N,[`tbody`]),delete ye.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw HO(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw HO(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=T;T=e.TRUSTED_TYPES_POLICY;try{E=A(``)}catch(e){throw T=t,e}}else e.TRUSTED_TYPES_POLICY===null?(T=void 0,E=``):(T===void 0&&(T=ne()),T&&typeof E==`string`&&(E=A(``)));_O&&_O(e),lt=e},pt=GO({},[...QO,...$O,...ek]),mt=GO({},[...tk,...nk]),ht=function(e,t,n){return t.namespaceURI===Xe?e===`svg`:t.namespaceURI===Je?e===`svg`&&(n===`annotation-xml`||nt[n]):!!pt[e]},gt=function(e,t,n){return t.namespaceURI===Xe?e===`math`:t.namespaceURI===Ye?e===`math`&&it[n]:!!mt[e]},_t=function(e,t,n){return t.namespaceURI===Ye&&!it[n]||t.namespaceURI===Je&&!nt[n]?!1:!mt[e]&&(at[e]||!pt[e])},vt=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ze,tagName:`template`});let n=kO(e.tagName),r=kO(t.tagName);return $e[e.namespaceURI]?e.namespaceURI===Ye?ht(n,t,r):e.namespaceURI===Je?gt(n,t,r):e.namespaceURI===Xe?_t(n,t,r):!!(ot===`application/xhtml+xml`&&$e[e.namespaceURI]):!1},yt=function(e){EO(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw HO(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},bt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},xt=function(e){wt(e);let t=g(e);if(t){let e=[];CO(t,t=>{EO(e,t)}),CO(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&bt(e,r,i)}},St=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}EO(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ne||Pe)try{yt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Ct=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||P[ct(i)]||bt(e,r,i)}},wt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===Sk.element&&Ct(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Tt=function(e,t){return De?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Et=function(e){if(!De)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===Sk.processingInstruction||n===Sk.comment&&VO(yk,e.data)){try{p(e)}catch{}continue}if(n===Sk.element){let t=e,n=ct(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Tt(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Dt=function(e){let t=null,r=null;if(Me)e=`<remove></remove>`+e;else{let t=jO(e,/^[\r\n\t ]+/);r=t&&t[0]}ot===`application/xhtml+xml`&&Ze===Xe&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=T?A(e):e;if(Ze===Xe)try{t=new l().parseFromString(i,ot)}catch{}if(!t||!t.documentElement){t=ie.createDocument(Ze,`template`,null);try{t.documentElement.innerHTML=Qe?E:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ze===Xe?se.call(t,Oe?`html`:`body`)[0]:Oe?t.documentElement:a},Ot=function(e){let t=S?S(e):e.ownerDocument;return ae.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},kt=function(e){return e=MO(e,le,` `),e=MO(e,ue,` `),e=MO(e,de,` `),e},At=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=ae.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=kt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&CO(i,e=>{Mt(e.content)&&At(e.content)})},jt=function(e){let t=x?x(e):null;return typeof t!=`string`||ct(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},Mt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===Sk.documentFragment}catch{return!1}},Nt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Pt(e,n,r){e.length!==0&&CO(e,e=>{e.call(t,n,r,lt)})}let Ft=function(e,t){return!!(De&&e.hasChildNodes()&&!Nt(e.firstElementChild)&&VO(vk,e.textContent)&&VO(vk,e.innerHTML)||De&&e.namespaceURI===Xe&&wk[t]&&(Nt(e.firstElementChild)||typeof e.textContent==`string`&&VO(Tk[t],e.textContent))||e.nodeType===Sk.processingInstruction||De&&e.nodeType===Sk.comment&&VO(yk,e.data))},It=function(e,t){return e instanceof RegExp?VO(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Lt=function(e,t,n){if(!ye[t]&&Ut(t)&&It(F.tagNameCheck,t))return!1;if(ze&&!He[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return yt(e),!0},Rt=function(e,t,n,r){return e.length===0?t:t===n||t===r?qO(t):t},zt=function(e,t){return e===t||_(e)!==null?!1:(Be&&wt(e),!0)},Bt=function(e,n){if(Pt(j.beforeSanitizeElements,e,null),zt(e,n))return!0;if(jt(e))return yt(e),!0;let r=ct(w(e));if(N=Rt(j.uponSanitizeElement,N,_e,Ae),Pt(j.uponSanitizeElement,e,{tagName:r,allowedTags:N}),zt(e,n))return!0;if(Ft(e,r))return yt(e),!0;if(ye[r]||!(xe.tagCheck instanceof Function&&xe.tagCheck(r))&&!N[r]){let t=Lt(e,r,n);return t===!1&&(Pt(j.afterSanitizeElements,e,null),zt(e,n))?!0:t}if(C(e)===Sk.element&&!vt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&VO(bk,e.innerHTML))return yt(e),!0;if(Ee&&e.nodeType===Sk.text){let n=kt(e.textContent);e.textContent!==n&&(EO(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Pt(j.afterSanitizeElements,e,null),zt(e,n)},Vt=function(e,t,r){if(be[t]||Tt(t,e)||Ie&&(t===`id`||t===`name`)&&(r in n||r in ut))return!1;let i=P[t]||xe.attributeCheck instanceof Function&&xe.attributeCheck(t,e);return Ce&&VO(fe,t)||Se&&VO(pe,t)?!0:i?Ke[t]||VO(M,MO(r,he,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&NO(r,`data:`)===0&&We[e]||we&&!VO(me,MO(r,he,``))?!0:!r:Ut(e)&&It(F.tagNameCheck,e)&&It(F.attributeNameCheck,t,e)||t===`is`&&F.allowCustomizedBuiltInElements&&It(F.tagNameCheck,r)},Ht=GO({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Ut=function(e){return!Ht[kO(e)]&&VO(ge,e)},Wt=function(e,t,n,r){if(T&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return A(r);case`TrustedScriptURL`:return te(r)}return r},Gt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!jt(e)||(yt(e),!1)}catch{return St(t,e),!1}},Kt=function(e,n){if(Pt(j.beforeSanitizeAttributes,e,null),zt(e,n))return;let r=e.attributes;if(!r||jt(e))return;P=Rt(j.uponSanitizeAttribute,P,ve,je);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:P,forceKeepAttr:void 0},a=r.length,o=ct(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=ct(s),d=l,f=s===`value`?d:PO(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Pt(j.uponSanitizeAttribute,e,i),f=i.attrValue,Le&&(u===`id`||u===`name`)&&NO(f,Re)!==0&&(St(s,e,n),f=Re+f,p=!0),De&&VO(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){St(s,e,n);continue}if(u===`attributename`&&jO(f,`href`)){St(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){St(s,e,n);continue}if(!Te&&VO(xk,f)){St(s,e,n);continue}if(Ee&&(f=kt(f)),!Vt(o,u,f)){St(s,e,n);continue}f=Wt(o,u,c,f),f!==d&&Gt(e,s,c,f)&&p&&TO(t.removed)}}Pt(j.afterSanitizeAttributes,e,null),zt(e,n)},I=function(e){let t=null,n=Ot(e);for(Pt(j.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Pt(j.uponSanitizeShadowNode,t,null),Bt(t,e),Kt(t,e),Mt(t.content)&&I(t.content),C(t)===Sk.element){let e=v(t);Mt(e)&&(qt(e),I(e))}Pt(j.afterSanitizeShadowDOM,e,null)},qt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){I(e.shadow);continue}let n=e.node,r=C(n)===Sk.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&ct(e)===`template`){let e=n.content;Mt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);Mt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Qe=!e,Qe&&(e=`<!-->`),typeof e!=`string`&&!Nt(e)&&(e=JO(e),typeof e!=`string`))throw HO(`dirty is not a string, aborting`);if(!t.isSupported)return e;ke?(N=Ae,P=je):ft(n),(j.uponSanitizeElement.length>0||j.uponSanitizeAttribute.length>0)&&(N=qO(N)),j.uponSanitizeAttribute.length>0&&(P=qO(P)),t.removed=[];let c=Be&&typeof e!=`string`&&Nt(e);if(c){Et(e);let t=w(e);if(typeof t==`string`){let n=ct(t);if(!N[n]||ye[n])throw xt(e),HO(`root node is forbidden and cannot be sanitized in-place`)}if(jt(e))throw xt(e),HO(`root node is clobbered and cannot be sanitized in-place`);try{qt(e)}catch(t){throw xt(e),t}}else if(Nt(e))i=Dt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Sk.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),qt(i);else{if(!Ne&&!Ee&&!Oe&&e.indexOf(`<`)===-1)return T&&Fe?A(e):e;if(i=Dt(e),!i)return Ne?null:Fe?E:``}i&&Me&&yt(i.firstChild);let l=c?e:i;try{let e=Ot(l);for(;o=e.nextNode();)Bt(o,l),Kt(o,l),Mt(o.content)&&I(o.content)}catch(n){throw c&&(xt(e),CO(t.removed,e=>{e.element&&wt(e.element)})),n}if(c){let n=!1;if(CO(t.removed,t=>{t.element&&(t.element===e&&(n=!0),wt(t.element))}),n)throw HO(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Ee&&At(e),e}if(Ne){if(Ee&&At(i),Pe)for(s=oe.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(P.shadowroot||P.shadowrootmode)&&(s=ce.call(r,s,!0)),s}let u=Oe?i.outerHTML:i.innerHTML;return Oe&&N[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&VO(gk,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
61
+ `+u),Ee&&(u=kt(u)),T&&Fe?A(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(e),ke=!0,Ae=N,je=P},t.clearConfig=function(){lt=null,ke=!1,Ae=null,je=null,T=D,E=``},t.isValidAttribute=function(e,t,n){lt||ft({});let r=ct(e),i=ct(t);return Vt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&zO(j,e)&&EO(j[e],t)},t.removeHook=function(e,t){if(zO(j,e)){if(t!==void 0){let n=wO(j[e],t);return n===-1?void 0:DO(j[e],n,1)[0]}return TO(j[e])}},t.removeHooks=function(e){zO(j,e)&&(j[e]=[])},t.removeAllHooks=function(){j=Ok()},t}var Mk=jk();function Nk(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Pk=Nk();function Fk(e){Pk=e}var Ik={exec:()=>null};function Lk(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function $(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(zk.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Rk=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),zk={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,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:Lk(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Lk(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Lk(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Lk(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Lk(e=>RegExp(`^ {0,${e}}(?:</?(?:${eA})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:Lk(e=>RegExp(`^ {0,${e}}>`))},Bk=/^(?:[ \t]*(?:\n|$))+/,Vk=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Hk=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Uk=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Wk=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Gk=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Kk=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,qk=$(Kk).replace(/bull/g,Gk).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Jk=$(Kk).replace(/bull/g,Gk).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Yk=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Xk=/^[^\n]+/,Zk=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qk=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Zk).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$k=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Gk).getRegex(),eA=`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`,tA=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nA=$(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,tA).replace(`tag`,eA).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rA=e=>$(Yk).replace(`hr`,Uk).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,eA).getRegex(),iA=rA(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),aA=rA(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),oA={blockquote:$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,aA).getRegex(),code:Vk,def:Qk,fences:Hk,heading:Wk,hr:Uk,html:nA,lheading:qk,list:$k,newline:Bk,paragraph:iA,table:Ik,text:Xk},sA=$(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Uk).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,eA).getRegex(),cA={...oA,lheading:Jk,table:sA,paragraph:$(Yk).replace(`hr`,Uk).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,sA).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,eA).getRegex()},lA={...oA,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,tA).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:Ik,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(Yk).replace(`hr`,Uk).replace(`heading`,` *#{1,6} *[^
62
+ ]`).replace(`lheading`,qk).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},uA=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,dA=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,fA=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,pA=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mA=/[\p{P}\p{S}]/u,hA=/[\s\p{P}\p{S}]/u,gA=/[^\s\p{P}\p{S}]/u,_A=$(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,hA).getRegex(),vA=/[\p{Pi}\p{Ps}"']/u,yA=/(?!~)[\p{P}\p{S}]/u,bA=/(?!~)[\s\p{P}\p{S}]/u,xA=/(?:[^\s\p{P}\p{S}]|~)/u,SA=$(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Rk?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),CA=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,wA=$(CA,`u`).replace(/punct/g,mA).getRegex(),TA=$(CA,`u`).replace(/punct/g,yA).getRegex(),EA=$(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,vA).replace(/punct/g,mA).getRegex(),DA=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,OA=$(DA,`gu`).replace(/notPunctSpace/g,gA).replace(/punctSpace/g,hA).replace(/punct/g,mA).getRegex(),kA=$(DA,`gu`).replace(/notPunctSpace/g,xA).replace(/punctSpace/g,bA).replace(/punct/g,yA).getRegex(),AA=$(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,gA).replace(/punctSpace/g,hA).replace(/punct/g,mA).getRegex(),jA=$(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,gA).replace(/punctSpace/g,hA).replace(/punct/g,mA).getRegex(),MA=$(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,gA).replace(/punctSpace/g,hA).replace(/punct/g,mA).getRegex(),NA=$(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,mA).getRegex(),PA=$(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,gA).replace(/punctSpace/g,hA).replace(/punct/g,mA).getRegex(),FA=$(/\\(punct)/,`gu`).replace(/punct/g,mA).getRegex(),IA=$(/^<(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(),LA=$(tA).replace(`(?:-->|$)`,`-->`).getRegex(),RA=$(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,LA).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zA=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,BA=$(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,zA).getRegex(),VA=$(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,BA).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),HA=$(/^!?\[(label)\]\[(ref)\]/).replace(`label`,BA).replace(`ref`,Zk).getRegex(),UA=$(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Zk).getRegex(),WA=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,GA=$(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,zA).getRegex(),KA=$(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,$(/^!?\[(label)\]\[(ref)\]/).replace(`label`,GA).replace(`ref`,WA).getRegex()).replace(`nolink`,$(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,WA).getRegex()).getRegex(),qA=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,JA=$(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),YA={_backpedal:Ik,anyPunctuation:FA,autolink:IA,blockSkip:SA,br:fA,code:dA,del:Ik,delLDelim:Ik,delRDelim:Ik,emStrongLDelim:wA,emStrongRDelimAst:OA,emStrongRDelimUnd:jA,escape:uA,link:VA,nolink:UA,punctuation:_A,reflink:HA,reflinkSearch:KA,tag:RA,text:pA,url:Ik},XA={...YA,emStrongLDelim:EA,emStrongRDelimAst:AA,emStrongRDelimUnd:MA,link:$(/^!?\[(label)\]\((.*?)\)/).replace(`label`,BA).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,BA).getRegex()},ZA={...YA,emStrongRDelimAst:kA,emStrongLDelim:TA,delLDelim:NA,delRDelim:PA,url:$(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,JA).replace(`protocol`,qA).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:$(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,qA).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},QA={...ZA,br:$(fA).replace(`{2,}`,`*`).getRegex(),text:$(ZA.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},$A={normal:oA,gfm:cA,pedantic:lA},ej={normal:YA,gfm:ZA,breaks:QA,pedantic:XA},tj={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},nj=e=>tj[e];function rj(e,t){if(t){if(zk.escapeTest.test(e))return e.replace(zk.escapeReplace,nj)}else if(zk.escapeTestNoEncode.test(e))return e.replace(zk.escapeReplaceNoEncode,nj);return e}function ij(e){return e.replace(zk.numericCharacterReference,(e,t,n)=>{let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}function aj(e){try{e=encodeURI(e).replace(zk.percentDecode,`%`)}catch{return null}return e}function oj(e,t){let n=e.replace(zk.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(zk.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(zk.slashPipe,`|`);return n}function sj(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 cj(e){let t=e.split(`
63
+ `),n=t.length-1;for(;n>=0&&zk.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
64
+ `)}function lj(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function uj(e,t){if(e.indexOf(t[0])===-1&&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 dj(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 fj(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function pj(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
65
65
  `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
66
- `)}function pj(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var mj=class{options;rules;lexer;constructor(e){this.options=e||Nk}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=this.options.pedantic?t[0]:sj(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=fj(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=oj(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:oj(t[0],`
67
- `),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:oj(t[0],`
68
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=oj(t[0],`
66
+ `)}function mj(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var hj=class{options;rules;lexer;constructor(e){this.options=e||Pk}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=this.options.pedantic?t[0]:cj(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=pj(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=sj(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:sj(t[0],`
67
+ `),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:sj(t[0],`
68
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=sj(t[0],`
69
69
  `).split(`
70
70
  `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;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(`
71
71
  `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
@@ -80,19 +80,19 @@ ${d.join(`
80
80
  `+e.join(`
81
81
  `),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(`
82
82
  `);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[2].split(`
83
- `,1)[0],l=t[1].length,u=this.options.pedantic?uj(c,l):c.replace(this.rules.other.leadingSpaceTab,e=>uj(e,l)),d=e.split(`
83
+ `,1)[0],l=t[1].length,u=this.options.pedantic?dj(c,l):c.replace(this.rules.other.leadingSpaceTab,e=>dj(e,l)),d=e.split(`
84
84
  `,1)[0],f=!u.trim(),p=0;if(this.options.pedantic?(p=2,s=u.trimStart()):f?p=l+1:(p=u.search(this.rules.other.nonSpaceChar),p=p>4?1:p,s=u.slice(p),p+=l),f&&this.rules.other.blankLine.test(d)&&(r+=d+`
85
85
  `,e=e.substring(d.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),i=this.rules.other.fencesBeginRegex(p),a=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p),c=this.rules.other.blockquoteBeginRegex(p);for(;e;){let l=e.split(`
86
86
  `,1)[0],m;if(d=l,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting,` `),m=d):m=d.replace(this.rules.other.leadingSpaceTab,e=>e.replace(this.rules.other.tabCharGlobal,` `)),i.test(d)||a.test(d)||o.test(d)||c.test(d)||t.test(d)||n.test(d))break;if(m.search(this.rules.other.nonSpaceChar)>=p||!d.trim())s+=`
87
87
  `+m.slice(p);else{if(f||u.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(u)||a.test(u)||n.test(u))break;s+=`
88
88
  `+d}f=!d.trim(),r+=l+`
89
- `,e=e.substring(l.length+1),u=m.slice(p)}}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,[]),!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))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.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 n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.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=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}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){let e=sj(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&lj(t[2],`()`)!==-1)return;let e=cj(t[1]).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:oj(t[0],`
90
- `),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=aj(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
91
- `):[],a={type:`table`,raw:oj(t[0],`
92
- `),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(aj(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){let e=t[1].trim();return{type:`heading`,raw:oj(t[0],`
89
+ `,e=e.substring(l.length+1),u=m.slice(p)}}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,[]),!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))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.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 n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.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=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}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){let e=cj(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&uj(t[2],`()`)!==-1)return;let e=lj(t[1]).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:sj(t[0],`
90
+ `),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=oj(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
91
+ `):[],a={type:`table`,raw:sj(t[0],`
92
+ `),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(oj(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){let e=t[1].trim();return{type:`heading`,raw:sj(t[0],`
93
93
  `),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
94
- `?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){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&pj(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=oj(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=lj(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 i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),dj(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.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 r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&pj(e,n[1],r,this.rules))return;let i=t[cj((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return dj(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,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,autolink:!0,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,autolink:!0,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:e?t[0]:rj(t[0]),escaped:e}}}},hj=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Nk,this.options.tokenizer=this.options.tokenizer||new mj,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:Rk,block:QA.normal,inline:$A.normal};this.options.pedantic?(t.block=QA.pedantic,t.inline=$A.pedantic):this.options.gfm&&(t.block=QA.gfm,t.inline=this.options.breaks?$A.breaks:$A.gfm),this.tokenizer.rules=t}static get rules(){return{block:QA,inline:$A}}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(Rk.carriageReturn,`
95
- `),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){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Rk.tabCharGlobal,` `).replace(Rk.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
94
+ `?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){if(this.lexer.state.linkParenPossible===!1)return;let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&mj(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=sj(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=uj(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 i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),fj(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.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 r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&mj(e,n[1],r,this.rules))return;let i=t[lj((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return fj(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,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,autolink:!0,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,autolink:!0,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:e?t[0]:ij(t[0]),escaped:e}}}},gj=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Pk,this.options.tokenizer=this.options.tokenizer||new hj,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:zk,block:$A.normal,inline:ej.normal};this.options.pedantic?(t.block=$A.pedantic,t.inline=ej.pedantic):this.options.gfm&&(t.block=$A.gfm,t.inline=this.options.breaks?ej.breaks:ej.gfm),this.tokenizer.rules=t}static get rules(){return{block:$A,inline:ej}}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(zk.carriageReturn,`
95
+ `),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){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(zk.tabCharGlobal,` `).replace(zk.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
96
96
  `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
97
97
  `)?``:`
98
98
  `)+i.raw,n.text+=`
@@ -105,9 +105,9 @@ ${d.join(`
105
105
  `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
106
106
  `)?``:`
107
107
  `)+i.raw,n.text+=`
108
- `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,cj(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,cj(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=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&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},gj=class{options;parser;constructor(e){this.options=e||Nk}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Rk.notSpaceStart)?.[0],i=e?e.replace(Rk.endingNewline,``)+`
109
- `:``;return r?`<pre><code class="language-`+nj(r)+`">`+(n?i:nj(i,!0))+`</code></pre>
110
- `:`<pre><code>`+(n?i:nj(i,!0))+`</code></pre>
108
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,lj(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,lj(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=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&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},_j=class{options;parser;constructor(e){this.options=e||Pk}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(zk.notSpaceStart)?.[0],i=e?e.replace(zk.endingNewline,``)+`
109
+ `:``;return r?`<pre><code class="language-`+rj(r)+`">`+(n?i:rj(i,!0))+`</code></pre>
110
+ `:`<pre><code>`+(n?i:rj(i,!0))+`</code></pre>
111
111
  `}blockquote({tokens:e}){return`<blockquote>
112
112
  ${this.parser.parse(e)}</blockquote>
113
113
  `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -123,5 +123,5 @@ ${this.parser.parse(e)}</blockquote>
123
123
  `}tablerow({text:e}){return`<tr>
124
124
  ${e}</tr>
125
125
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
126
- `}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>${nj(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?nj(n,!0):this.parser.parseInline(r),o=ij(e);if(o===null)return a;e=nj(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+nj(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ij(e);if(i===null)return nj(n);e=i;let a=`<img src="${nj(e)}" alt="${nj(n)}"`;return t&&(a+=` title="${nj(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:nj(e.text)}},_j=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}},vj=class e{options;renderer;textRenderer;constructor(e){this.options=e||Nk,this.options.renderer=this.options.renderer||new gj,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _j}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;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`,`checkbox`,`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){this.renderer.parser=this;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`,`checkbox`,`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}},yj=class{options;block;constructor(e){this.options=e||Nk}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(e=this.block){return e?hj.lex:hj.lexInline}provideParser(e=this.block){return e?vj.parse:vj.parseInline}},bj=class{defaults=Mk();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=vj;Renderer=gj;TextRenderer=_j;Lexer=hj;Tokenizer=mj;Hooks=yj;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 gj(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 mj(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 yj;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];t[r]=yj.passThroughHooks.has(n)?e=>{if(this.defaults.async&&yj.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)}:(...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 hj.lex(e,t??this.defaults)}parser(e,t){return vj.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):e?hj.lex:hj.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):e?vj.parse:vj.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):e?hj.lex:hj.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):e?vj.parse:vj.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+=`
127
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+nj(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},xj=new bj;function Sj(e,t){return xj.parse(e,t)}Sj.options=Sj.setOptions=function(e){return xj.setOptions(e),Sj.defaults=xj.defaults,Pk(Sj.defaults),Sj},Sj.getDefaults=Mk,Sj.defaults=Nk;function Cj(...e){return xj.use(...e),Sj.defaults=xj.defaults,Pk(Sj.defaults),Sj}Sj.use=Cj,Sj.walkTokens=function(e,t){return xj.walkTokens(e,t)},Sj.parseInline=xj.parseInline,Sj.Parser=vj,Sj.parser=vj.parse,Sj.Renderer=gj,Sj.TextRenderer=_j,Sj.Lexer=hj,Sj.lexer=hj.lex,Sj.Tokenizer=mj,Sj.Hooks=yj,Sj.parse=Sj,Sj.options,Sj.setOptions,Sj.walkTokens,Sj.parseInline,vj.parse,hj.lex;var wj=/^data:image\/(?:png|jpe?g|gif|webp|avif|bmp|x-icon);base64,[a-z0-9+/=\s]+$/i;jk.addHook(`afterSanitizeAttributes`,e=>{if(e.nodeName.toUpperCase()===`IMG`){let t=e.getAttribute(`src`);if(t){let n=wj.test(t),r=t.startsWith(`/`)&&!t.startsWith(`//`)&&!t.startsWith(`/\\`);!n&&!r&&(e.removeAttribute(`src`),e.setAttribute(`data-okf-blocked-src`,`true`))}}if(e.nodeName.toUpperCase()===`A`){let t=e.getAttribute(`href`);if(t){let n=aD(t,``);n.kind===`invalid`?e.removeAttribute(`href`):n.kind===`external`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}}});function Tj(e){return jk.sanitize(e,{ADD_ATTR:[`target`,`data-okf-cite`,`data-okf-internal`,`data-okf-concept`],FORBID_TAGS:[`style`,`form`,`input`,`button`,`iframe`,`object`,`embed`,`script`,`foreignobject`,`animate`,`set`,`use`],FORBID_ATTR:[`style`]})}function Ej(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Dj(e){if(!e||e.length===0)return``;let t=``;for(let n of e)`tokens`in n&&Array.isArray(n.tokens)?t+=Dj(n.tokens):`text`in n&&typeof n.text==`string`&&(t+=n.text);return t}function Oj(e,t){let n=[],r=[],i=new Set,a=new Map,o=new bj({gfm:!0});o.use({extensions:[{name:`citation`,level:`inline`,start(e){return e.indexOf(`[^`)},tokenizer(e){let t=/^\[\^([^\]\s]+)\](?!:)/.exec(e);if(t?.[1])return{type:`citation`,raw:t[0],label:t[1]}},renderer(e){if(!(`label`in e)||typeof e.label!=`string`)return``;let n=e.label,i=t.sources.find(e=>e.id===n||e.id.toLowerCase()===n.toLowerCase()),o=i?i.id:n,s=r.indexOf(o)+1;if(s===0&&(r.push(o),s=r.length),i)return`<sup class="okf-cite"><a href="#source-${encodeURIComponent(i.id)}" data-okf-cite="${Ej(i.id)}">${s}</a></sup>`;let c=a.get(n.toLowerCase());if(c?.href){let e=aD(c.href,t.conceptId);return e.kind===`external`?`<sup class="okf-cite"><a href="${Ej(e.href)}" target="_blank" rel="noopener noreferrer">${s}</a></sup>`:e.kind===`concept`?`<sup class="okf-cite"><a href="${Ej(`/ui${oD(t.project,e.id)}${e.hash}`)}" data-okf-internal data-okf-concept="${Ej(e.id)}">${s}</a></sup>`:`<sup class="okf-cite"><span class="okf-cite-missing" title="Invalid source">${s}</span></sup>`}return`<sup class="okf-cite"><span class="okf-cite-missing" title="Unknown source">${s}</span></sup>`}}],renderer:{heading(e){let t=e.depth,r=Dj(e.tokens).trim(),a=r.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`heading`,o=a,s=1;for(;i.has(o);)s++,o=`${a}-${s}`;i.add(o),(t===2||t===3)&&n.push({id:o,text:r,depth:t});let c=this.parser.parseInline(e.tokens);return`<h${t} id="${o}"><a class="okf-anchor" href="#${o}" aria-hidden="true">#</a>${c}</h${t}>\n`},code(e){return`<pre class="okf-code" data-lang="${Ej((e.lang||``).match(/^\S*/)?.[0]??``)}"><code>${Ej(e.text)}</code></pre>\n`},link(e){let n=e.href,r=e.title?` title="${Ej(e.title)}"`:``,i=this.parser.parseInline(e.tokens),a=aD(n,t.conceptId);if(a.kind===`concept`){let e=t.outbound.find(e=>e.id===a.id),n=!e||e.exists,o=Ej(`/ui${oD(t.project,a.id)}${a.hash}`),s=Ej(a.id);return n?`<a href="${o}" data-okf-internal data-okf-concept="${s}"${r}>${i}</a>`:`<a href="${o}" data-okf-internal data-okf-concept="${s}" class="okf-broken" title="Missing concept">${i}</a>`}return a.kind===`file`?`<a href="${Ej(`/ui${sD(t.project,a.path)}${a.hash}`)}" data-okf-internal${r}>${i}</a>`:a.kind===`anchor`?`<a href="${Ej(n)}"${r}>${i}</a>`:a.kind===`external`?`<a href="${Ej(a.href)}" target="_blank" rel="noopener noreferrer" class="okf-external"${r}>${i}</a>`:`<span class="okf-broken" title="Broken link">${i}</span>`},image(e){let n=e.href,r=Ej(e.text),i=e.title?` title="${Ej(e.title)}"`:``;if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!n.startsWith(`/\\`)||wj.test(n))return`<img src="${Ej(n)}" alt="${r}"${i}>`;let a=aD(n,t.conceptId);if(a.kind===`external`){let e=r?`[Image: ${r}]`:`[Remote image]`;return`<span class="okf-image-blocked"><a href="${Ej(a.href)}" target="_blank" rel="noopener noreferrer" class="okf-external" title="Remote image blocked to protect IP">${e}</a></span>`}return`<span class="okf-image-missing">${r||`Image`}</span>`}}});let s=o.lexer(e);if(s.links)for(let[e,t]of Object.entries(s.links))e.startsWith(`^`)&&t&&typeof t.href==`string`&&a.set(e.slice(1).toLowerCase(),{href:t.href,title:typeof t.title==`string`?t.title:void 0});for(let e=0;e<s.length;e++){let n=s[e];if(!(n&&n.type===`space`)){n&&n.type===`heading`&&n.depth===1&&(`text`in n&&typeof n.text==`string`?n.text.trim():``).toLowerCase()===t.title.trim().toLowerCase()&&s.splice(e,1);break}}return{html:Tj(o.parser(s)),headings:n,citations:r}}var kj=/^github\.com\/([^/]+)\/([^/]+)\/(.+)$/,Aj=/^gitlab\.com\/([^/]+)\/([^/]+)\/(.+)$/,jj=/^(github|gitlab)\.com\/[^/]+\/[^/]+$/,Mj=/^https?:\/\//i,Nj=/^[a-zA-Z0-9._-]+$/;function Pj(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:null}catch{return null}}var Fj={type:!0,title:!0,description:!0,tags:!0,status:!0,generated:!0,verified:!0,sources:!0,stale_after:!0};function Ij(e){if(!e||typeof e!=`object`)return[];let t=e.sources;if(!Array.isArray(t))return[];let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(!r||typeof r!=`object`||!(`resource`in r)||typeof r.resource!=`string`)continue;let i=r.resource.trim();if(i.length===0)continue;let a=`id`in r&&typeof r.id==`string`&&r.id.trim().length>0?r.id.trim():`source-${e+1}`,o=`commit`in r&&typeof r.commit==`string`&&r.commit.trim().length>0?r.commit.trim():void 0,s=o&&Nj.test(o)?o:void 0,c=s??`HEAD`,l=null,u=i;if(Mj.test(i))l=Pj(i);else{let e=kj.exec(i);if(e?.[1]&&e[2]&&e[3])l=Pj(`https://github.com/${e[1]}/${e[2]}/blob/${c}/${e[3]}`),u=e[3];else{let e=Aj.exec(i);e?.[1]&&e[2]&&e[3]?(l=Pj(`https://gitlab.com/${e[1]}/${e[2]}/-/blob/${c}/${e[3]}`),u=e[3]):jj.test(i)&&(l=Pj(`https://${i}`))}}n.push({id:a,resource:i,...s===void 0?{}:{commit:s},url:l,label:u})}return n}function Lj(e){if(!e||typeof e!=`object`)return[];let t=e.verified;if(t==null)return[];let n=Array.isArray(t)?t:[t],r=[];for(let e of n)if(e&&typeof e==`object`&&`by`in e&&typeof e.by==`string`&&e.by.length>0){let t=`at`in e&&typeof e.at==`string`?e.at:void 0;r.push(t===void 0?{by:e.by}:{by:e.by,at:t})}return r}function Rj(e){return!e||typeof e!=`object`?[]:Object.entries(e).filter(([e])=>!(e in Fj))}function zj({concept:e,conceptId:t,targetRect:n,onMouseEnter:r,onMouseLeave:i}){let a=n.bottom+6,o=Math.max(12,Math.min(n.left,window.innerWidth-332));return(0,h.jsx)(`div`,{role:`tooltip`,style:{top:a,left:o},onMouseEnter:r,onMouseLeave:i,className:`fixed z-50 w-80 max-w-[calc(100vw-24px)] rounded-xl border border-border-strong bg-surface/95 p-3.5 shadow-xl backdrop-blur-md transition-all duration-150`,children:e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(_D,{type:e.derived?.type??null,className:`mt-0.5 shrink-0`,size:16}),(0,h.jsx)(`div`,{className:`min-w-0 flex-1 font-medium text-sm text-fg line-clamp-2 leading-snug`,children:e.derived?.title??e.id})]}),e.derived?.description&&(0,h.jsx)(`p`,{className:`mt-1.5 text-xs text-muted line-clamp-2 leading-relaxed`,children:e.derived.description}),(0,h.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-1.5 pt-1.5 border-t border-border/50`,children:[e.derived?.status&&(0,h.jsx)(XD,{status:e.derived.status}),e.derived?.trustTier&&(0,h.jsx)(ZD,{tier:e.derived.trustTier}),e.derived?.stale&&(0,h.jsx)(QD,{})]})]}):(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`div`,{className:`font-mono text-xs text-muted truncate`,children:t}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-4 rounded-full`}),(0,h.jsx)(Q,{className:`h-4 w-40 rounded-sm`})]}),(0,h.jsx)(Q,{className:`h-3 w-full rounded-sm`}),(0,h.jsx)(Q,{className:`h-3 w-3/4 rounded-sm`}),(0,h.jsxs)(`div`,{className:`flex gap-1 pt-1`,children:[(0,h.jsx)(Q,{className:`h-4 w-12 rounded-full`}),(0,h.jsx)(Q,{className:`h-4 w-16 rounded-full`})]})]})})}function Bj({project:e,concept:t,onHeadings:n,onCitations:r,className:i}){let a=kh(),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(null),l=(0,m.useRef)(void 0),u=(0,m.useRef)(!1),d=(0,m.useMemo)(()=>Oj(t.body,{project:e,conceptId:t.id,title:t.derived?.title??t.id,sources:Ij(t.frontmatter),outbound:t.links.outbound}),[t,e]);return(0,m.useEffect)(()=>{n?.(d.headings),r?.(d.citations)},[d,n,r]),(0,m.useEffect)(()=>{let e=o.current;if(!e)return;let t=!1;return(async()=>{let n=Array.from(e.querySelectorAll(`pre.okf-code`));if(n.length===0)return;let{highlight:r}=await Ag(async()=>{let{highlight:e}=await import(`./highlight-D8LQtOZ_.js`);return{highlight:e}},[]);if(!t)for(let e of n){if(t)break;if(e.getAttribute(`data-okf-processed`)===`true`)continue;e.setAttribute(`data-okf-processed`,`true`);let n=e.getAttribute(`data-lang`)??``,i=e.querySelector(`code`)?.textContent??e.textContent??``,a=null;if(n)try{a=await r(i,n)}catch{}if(t)break;let o=document.createElement(`div`);if(o.className=`relative group not-prose my-4`,a){o.innerHTML=a;let e=o.querySelector(`pre`);e&&e.classList.add(`overflow-x-auto`)}else{let t=e.cloneNode(!0);o.appendChild(t)}let s=document.createElement(`button`);s.type=`button`,s.setAttribute(`aria-label`,`Copy code`),s.title=`Copy code`,s.className=`absolute top-2.5 right-2.5 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity inline-flex items-center gap-1 rounded-md border border-border bg-surface/80 px-2 py-1 text-xs font-medium text-muted backdrop-blur-xs hover:bg-surface-2 hover:text-fg focus-visible:outline-2 outline-accent-500 cursor-pointer select-none`,s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="shrink-0"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,s.addEventListener(`click`,async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(i),s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-emerald-500 shrink-0"><polyline points="20 6 9 17 4 12"/></svg>`,setTimeout(()=>{s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="shrink-0"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`},1500)}catch{}}),o.appendChild(s),e.parentNode?.replaceChild(o,e)}})(),()=>{t=!0}},[d.html]),(0,m.useEffect)(()=>{let e=()=>{clearTimeout(l.current),c(null)};return window.addEventListener(`scroll`,e,{passive:!0}),()=>{window.removeEventListener(`scroll`,e),clearTimeout(l.current)}},[]),(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(`div`,{ref:o,onClick:e=>{let t=e.target;if(!t)return;let n=t.closest(`a[data-okf-cite]`);if(n){e.preventDefault();let t=n.getAttribute(`data-okf-cite`);if(t){let e=document.getElementById(`source-${t}`);e&&(e.scrollIntoView({behavior:`smooth`}),e.classList.remove(`okf-flash`),e.offsetWidth,e.classList.add(`okf-flash`),setTimeout(()=>{e.classList.remove(`okf-flash`)},1600))}return}let r=t.closest(`a[data-okf-internal]`);if(r){if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;e.preventDefault();let t=r.getAttribute(`href`);if(t){let e=t;e.startsWith(`/ui`)&&(e=e.slice(3)||`/`),e.startsWith(`/`)&&!e.startsWith(`//`)&&!e.startsWith(`/\\`)&&!e.includes(`\\`)&&a(e)}}},onMouseOver:t=>{let n=t.target;if(!n)return;let r=n.closest(`a[data-okf-concept]`);if(!r)return;let i=r.getAttribute(`data-okf-concept`);i&&s?.targetEl!==r&&(clearTimeout(l.current),l.current=window.setTimeout(async()=>{let t=r.getBoundingClientRect();try{let n=await T_.fetchQuery({queryKey:E_.concept(e,i),queryFn:()=>v_(e,i)});c({conceptId:i,concept:n,rect:t,targetEl:r})}catch{}},250))},onMouseOut:e=>{let t=e.target;if(!t)return;let n=t.closest(`a[data-okf-concept]`);n&&(clearTimeout(l.current),setTimeout(()=>{u.current||c(e=>e?.targetEl===n?null:e)},100))},className:X(`prose prose-zinc dark:prose-invert max-w-3xl`,i),dangerouslySetInnerHTML:{__html:d.html}}),s&&(0,h.jsx)(zj,{concept:s.concept,conceptId:s.conceptId,targetRect:s.rect,onMouseEnter:()=>{u.current=!0},onMouseLeave:()=>{u.current=!1,c(null)}})]})}function Vj({headings:e,className:t}){let[n,r]=(0,m.useState)(e[0]?.id??``);if((0,m.useEffect)(()=>{if(e.length<3)return;let t=e.map(e=>document.getElementById(e.id)).filter(e=>e!==null);if(t.length===0)return;let n=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&r(t.target.id)},{rootMargin:`0px 0px -70% 0px`,threshold:[0,1]});for(let e of t)n.observe(e);return()=>{n.disconnect()}},[e]),e.length<3)return null;let i=(e,t)=>{e.preventDefault();let n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`}),r(t),window.history.replaceState(null,``,`#${t}`))};return(0,h.jsxs)(`nav`,{"aria-label":`Table of contents`,className:X(`space-y-2`,t),children:[(0,h.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-muted`,children:`On this page`}),(0,h.jsx)(`ul`,{className:`space-y-1 border-l border-border text-xs`,children:e.map(e=>{let t=n===e.id;return(0,h.jsx)(`li`,{className:e.depth===3?`pl-5`:`pl-3`,children:(0,h.jsx)(`a`,{href:`#${e.id}`,onClick:t=>i(t,e.id),className:X(`block py-0.5 transition-colors line-clamp-1`,t?`-ml-px border-l-2 border-accent-500 pl-1 font-medium text-accent-500`:`text-muted hover:text-fg`),children:e.text})},e.id)})})]})}function Hj(){let e=Nh(),t=e.project??``,n=e[`*`]??``,{data:r,isLoading:i,error:a,refetch:o}=A_(t,n),{data:s}=M_(t,{id:n,limit:10}),[c,l]=(0,m.useState)([]),[u,d]=(0,m.useState)([]),[f,p]=(0,m.useState)(!1);(0,m.useEffect)(()=>{r&&fD({project:t,id:r.id,title:r.derived?.title??r.id,type:r.derived?.type??null})},[r,t]);let g=(0,m.useMemo)(()=>{if(!r)return[];let e=Ij(r.frontmatter),t=new Map;for(let n of e)t.set(n.id,n);let n=[],i=new Set;for(let e of u){let r=t.get(e);r&&!i.has(r.id)&&(n.push(r),i.add(r.id))}for(let t of e)i.has(t.id)||(n.push(t),i.add(t.id));return n},[r,u]),_=r?.derived?.title??(n||`Concept`);if(i)return(0,h.jsxs)(fS,{title:_,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6 space-y-6`,children:[(0,h.jsxs)(`div`,{className:`space-y-3 border-b border-border pb-6`,children:[(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(Q,{className:`h-5 w-20 rounded-full`}),(0,h.jsx)(Q,{className:`h-5 w-16 rounded-full`})]}),(0,h.jsx)(Q,{className:`h-9 w-96 rounded-md`}),(0,h.jsx)(Q,{className:`h-5 w-full max-w-xl rounded-md`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col xl:flex-row gap-8`,children:[(0,h.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,h.jsx)(Q,{className:`h-32 w-full rounded-xl`}),(0,h.jsx)(Q,{className:`h-48 w-full rounded-xl`})]}),(0,h.jsxs)(`div`,{className:`w-full xl:w-72 space-y-4`,children:[(0,h.jsx)(Q,{className:`h-40 w-full rounded-xl`}),(0,h.jsx)(Q,{className:`h-40 w-full rounded-xl`})]})]})]});if(a)return(0,h.jsx)(fS,{title:_,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(lS,{error:a,onRetry:o,fullScreen:!0})});if(!r)return(0,h.jsx)(fS,{title:_,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(cS,{title:`Concept not found`,hint:`Could not find concept "${n}" in project "${t}".`})});let v=r.derived?.status?.toLowerCase()===`deprecated`,y=Lj(r.frontmatter),b=Rj(r.frontmatter);return(0,h.jsxs)(fS,{title:`${_} · ${t}`,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6`,children:[(0,h.jsxs)(`header`,{className:`space-y-4 border-b border-border pb-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)($D,{type:r.derived?.type??null}),r.derived?.status&&(0,h.jsx)(XD,{status:r.derived.status}),r.derived?.trustTier&&(0,h.jsx)(ZD,{tier:r.derived.trustTier}),r.derived?.stale&&(0,h.jsx)(QD,{})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:X(`text-3xl font-semibold tracking-tight text-fg`,v&&`line-through opacity-70`),children:r.derived?.title??r.id}),r.derived?.description&&(0,h.jsx)(`p`,{className:`mt-2 text-lg text-muted leading-relaxed`,children:r.derived.description})]}),r.derived?.tags&&r.derived.tags.length>0&&(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:r.derived.tags.map(e=>(0,h.jsxs)($g,{to:`/search?project=${encodeURIComponent(t)}&tag=${encodeURIComponent(e)}`,className:`inline-flex items-center rounded-md bg-surface-2 px-2 py-0.5 text-xs font-medium text-muted hover:text-fg hover:bg-border transition-colors`,children:[`#`,e]},e))}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-2`,children:[(0,h.jsx)(mS,{value:typeof window<`u`?window.location.href:``,label:`Copy link`}),(0,h.jsx)(mS,{value:r.id,label:`Copy ID`}),(0,h.jsxs)(`button`,{type:`button`,onClick:()=>p(e=>!e),"aria-label":`Toggle markdown source`,className:X(`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 outline-accent-500 cursor-pointer`,f?`bg-accent-500/10 text-accent-500 border-accent-500/30`:`bg-surface text-muted hover:bg-surface-2 hover:text-fg`),children:[(0,h.jsx)(Yb,{size:14,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Source`})]})]})]}),(0,h.jsxs)(`div`,{className:`mt-8 flex flex-col xl:flex-row xl:items-start gap-8`,children:[(0,h.jsx)(`div`,{className:`min-w-0 flex-1`,children:f?(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted`,children:[(0,h.jsx)(`span`,{className:`font-mono`,children:`Raw Markdown`}),(0,h.jsx)(mS,{value:r.markdown,label:`Copy markdown`})]}),(0,h.jsx)(eO,{code:r.markdown,lang:`markdown`,lineNumbers:!0,className:`rounded-xl border border-border bg-surface-2 shadow-xs`})]}):(0,h.jsx)(Bj,{project:t,concept:r,onHeadings:l,onCitations:d})}),(0,h.jsxs)(`aside`,{className:`w-full xl:w-72 xl:sticky xl:top-20 shrink-0 space-y-6`,children:[c.length>=3&&(0,h.jsx)(Vj,{headings:c}),(0,h.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsx)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:`Details`}),r.derived?.generatedAt&&(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted shrink-0`,children:`Generated`}),(0,h.jsxs)(`span`,{className:`text-fg text-right font-mono text-[11px]`,title:MD(r.derived.generatedAt),children:[jD(r.derived.generatedAt),r.derived.generatedBy&&` by ${r.derived.generatedBy}`]})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`span`,{className:`text-muted block`,children:`Verified`}),y.length>0?(0,h.jsx)(`div`,{className:`space-y-1.5 pl-1`,children:y.map((e,t)=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-fg`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,h.jsx)(BD,{actor:e.by,size:18}),(0,h.jsx)(`span`,{className:`truncate font-mono text-[11px]`,children:e.by})]}),e.at&&(0,h.jsx)(`span`,{className:`text-muted text-[10px] shrink-0`,title:MD(e.at),children:jD(e.at)})]},`${e.by}-${e.at??t}`))}):(0,h.jsx)(`div`,{className:`text-subtle italic pl-1`,children:`Unverified`})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted`,children:`Stale after`}),(0,h.jsx)(`span`,{className:X(`font-mono text-[11px]`,r.derived?.stale?`text-orange-500 font-semibold`:`text-fg`),children:r.derived?.staleAfter?r.derived.staleAfter.split(`T`)[0]:`—`})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted`,children:`Revision`}),(0,h.jsx)(`span`,{className:`font-mono text-[11px] text-muted`,children:r.revision.slice(0,8)})]})]}),g.length>0&&(0,h.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsxs)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:[`Sources (`,g.length,`)`]}),(0,h.jsx)(`ol`,{className:`space-y-2`,children:g.map((e,t)=>(0,h.jsxs)(`li`,{id:`source-${e.id}`,className:`rounded-lg p-2 transition-colors border border-transparent hover:border-border hover:bg-surface-2/50`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,h.jsxs)(`span`,{className:`font-mono text-muted text-[10px] shrink-0`,children:[t+1,`.`]}),(0,h.jsx)(`span`,{className:`font-mono text-fg text-xs truncate`,title:e.label,children:e.label})]}),e.commit&&(0,h.jsx)(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-surface border border-border text-muted shrink-0`,title:`Commit ${e.commit}`,children:ID(e.commit)})]}),e.url&&(0,h.jsx)(`div`,{className:`mt-1 pl-4`,children:(0,h.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-accent-500 hover:text-accent-400 hover:underline truncate max-w-full`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:e.resource}),(0,h.jsx)(tx,{size:10,className:`shrink-0`})]})})]},e.id))})]}),(0,h.jsx)(nO,{project:t,conceptId:r.id,inbound:r.links.inbound,outbound:r.links.outbound}),(0,h.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsx)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:`History`}),s&&s.length>0?(0,h.jsx)(`div`,{className:`relative pl-4 space-y-4 before:absolute before:left-1.5 before:top-2 before:bottom-2 before:w-px before:bg-border`,children:s.map(e=>(0,h.jsxs)(`div`,{className:`relative space-y-1`,children:[(0,h.jsx)(`div`,{className:`absolute -left-4 top-1.5 h-2 w-2 rounded-full bg-accent-500 ring-2 ring-surface`}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-1 text-[11px]`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,h.jsx)(BD,{actor:e.actor,size:16}),(0,h.jsx)(`span`,{className:`truncate font-mono text-fg`,children:e.actor})]}),(0,h.jsx)(`span`,{className:`text-muted shrink-0 text-[10px]`,title:MD(e.at),children:jD(e.at)})]}),(0,h.jsx)(`p`,{className:`text-fg text-xs break-words`,children:e.subject}),(0,h.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,h.jsx)(mS,{value:e.sha,label:ID(e.sha),className:`px-1.5 py-0.5 text-[10px] font-mono`})})]},e.sha))}):(0,h.jsx)(`div`,{className:`text-subtle italic`,children:`No history available`})]}),r.issues&&r.issues.length>0&&(0,h.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsxs)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:[`Lint issues (`,r.issues.length,`)`]}),(0,h.jsx)(`div`,{className:`space-y-2`,children:r.issues.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded-lg bg-surface border border-border/60`,children:[e.severity===`error`?(0,h.jsx)(Vb,{size:14,className:`text-rose-500 shrink-0 mt-0.5`}):e.severity===`warning`?(0,h.jsx)(rS,{size:14,className:`text-amber-500 shrink-0 mt-0.5`}):(0,h.jsx)(Cx,{size:14,className:`text-sky-500 shrink-0 mt-0.5`}),(0,h.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,h.jsx)(`div`,{className:`font-mono font-semibold text-[11px] text-fg`,children:e.code}),(0,h.jsx)(`p`,{className:`text-muted text-[11px] leading-tight break-words`,children:e.message})]})]},`${e.code}-${e.path}-${e.message}`))})]}),b.length>0&&(0,h.jsxs)(`details`,{className:`group rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold uppercase tracking-wider text-muted hover:text-fg flex items-center justify-between select-none`,children:[(0,h.jsxs)(`span`,{children:[`Extra frontmatter (`,b.length,`)`]}),(0,h.jsx)(Fb,{size:14,className:`transition-transform group-open:rotate-180`})]}),(0,h.jsx)(`div`,{className:`mt-2 space-y-1 overflow-x-auto rounded-lg bg-surface p-2 font-mono text-[11px] border border-border/50`,children:b.map(([e,t])=>(0,h.jsxs)(`div`,{className:`break-all`,children:[(0,h.jsx)(`span`,{className:`text-accent-500`,children:e}),`:`,` `,(0,h.jsx)(`span`,{className:`text-muted`,children:JSON.stringify(t)})]},e))})]})]})]})]})}var Uj={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,json:`json`,yaml:`yaml`,yml:`yaml`,sh:`bash`,bash:`bash`,py:`python`,go:`go`,rs:`rust`,sql:`sql`,md:`markdown`,diff:`diff`,patch:`diff`,toml:`toml`,html:`html`,css:`css`,java:`java`,rb:`ruby`,dockerfile:`dockerfile`};function Wj(e){let t=e.split(`/`).pop()??e;if(t.toLowerCase()===`dockerfile`)return`dockerfile`;let n=t.lastIndexOf(`.`);return n===-1?null:Uj[t.slice(n+1).toLowerCase()]??null}function Gj(){let e=Nh(),t=e.project??``,n=e[`*`]??``,{data:r,isLoading:i,error:a,refetch:o}=j_(t,n),s=n.split(`/`).pop()??n,c=s?`${s} · ${t}`:`File`;if(i)return(0,h.jsxs)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6 space-y-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between border-b border-border pb-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-6 w-64 rounded-md`}),(0,h.jsx)(Q,{className:`h-4 w-28 rounded-md`})]}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(Q,{className:`h-8 w-24 rounded-md`}),(0,h.jsx)(Q,{className:`h-8 w-28 rounded-md`})]})]}),(0,h.jsx)(Q,{className:`h-96 w-full rounded-xl`})]});if(a)return(0,h.jsx)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(lS,{error:a,onRetry:o,fullScreen:!0})});if(!r)return(0,h.jsx)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(cS,{title:`File not found`,hint:`Could not find file "${n}" in project "${t}".`})});let l=()=>{let e=new Blob([r.content],{type:`text/plain;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=s||`file`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},u=Wj(n);return(0,h.jsxs)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6 space-y-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between border-b border-border pb-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,h.jsx)(`h1`,{className:`font-mono text-xl font-semibold text-fg break-all`,children:n}),r.revision&&(0,h.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,h.jsxs)(`span`,{className:`font-mono text-xs px-2 py-0.5 rounded-md bg-surface-2 border border-border text-muted`,children:[`rev: `,r.revision.slice(0,8)]})})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,h.jsx)(mS,{value:r.content,label:`Copy content`}),(0,h.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Download file`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-2.5 py-1 text-xs font-medium text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-2 outline-accent-500 cursor-pointer`,children:[(0,h.jsx)($b,{size:14,className:`shrink-0 text-muted`}),(0,h.jsx)(`span`,{children:`Download`})]})]})]}),(0,h.jsx)(eO,{code:r.content,lang:u,lineNumbers:!0,className:`rounded-xl border border-border bg-surface-2 overflow-hidden shadow-xs`})]})}function Kj(){let e=Nh().project??``,{data:t}=O_(e),n=N_(e),r=P_({project:e,stale:!0,limit:100}),i=P_({project:e,trustTier:`unverified`,limit:100}),a=n.isLoading||r.isLoading||i.isLoading,o=n.isError||r.isError||i.isError,s=n.error||r.error||i.error,c=()=>{n.refetch(),r.refetch(),i.refetch()},l=(0,m.useMemo)(()=>{if(!n.data)return{errors:[],warnings:[],infos:[]};let e=[],t=[],r=[];for(let i of n.data)i.severity===`error`?e.push(i):i.severity===`warning`?t.push(i):r.push(i);return{errors:e,warnings:t,infos:r}},[n.data]),u=t?.title?`${t.title} Health`:`Health`;if(a)return(0,h.jsxs)(fS,{title:u,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-32 rounded-md`}),(0,h.jsx)(Q,{className:`h-8 w-48 rounded-lg`})]}),(0,h.jsx)(`div`,{className:`mt-8 space-y-10`,children:Array.from({length:3}).map((e,t)=>(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(Q,{className:`h-7 w-48 rounded-md`}),(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-4 space-y-3`,children:[(0,h.jsx)(Q,{className:`h-12 w-full rounded-lg`}),(0,h.jsx)(Q,{className:`h-12 w-full rounded-lg`})]})]},t))})]});if(o)return(0,h.jsx)(fS,{title:u,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:s,onRetry:c})});let d=n.data??[],f=r.data??[],p=i.data??[],g=l.errors.length;return(0,h.jsxs)(fS,{title:u,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}`,className:`transition-colors hover:text-fg`,children:t?.title??e}),(0,h.jsx)(`span`,{children:`/`}),(0,h.jsx)(`span`,{className:`text-fg`,children:`Health`})]}),(0,h.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-4`,children:(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg`,children:`Knowledge Base Health`}),(0,h.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`Lint diagnostics, staleness, and verification status for `,t?.title??e]})]})})]}),(0,h.jsxs)(`div`,{className:`space-y-10`,children:[(0,h.jsxs)(`section`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border pb-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`Specification Conformance`}),g===0?(0,h.jsxs)(YD,{className:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`,children:[(0,h.jsx)(Ub,{size:13}),(0,h.jsx)(`span`,{children:`Conformant`})]}):(0,h.jsxs)(YD,{className:`bg-rose-500/10 text-rose-600 dark:text-rose-400 ring-rose-500/20`,children:[(0,h.jsx)(Vb,{size:13}),(0,h.jsxs)(`span`,{children:[g,` `,g===1?`error`:`errors`]})]})]}),(0,h.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,d.length,`)`]})]}),d.length===0?(0,h.jsx)(cS,{icon:Ub,title:`All concepts and files conform`,hint:`No lint or specification issues found in this project.`,className:`py-10`}):(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:[...l.errors,...l.warnings,...l.infos].map((t,n)=>{let r=t.path.endsWith(`.md`)?`/p/${encodeURIComponent(e)}/c/${t.path.slice(0,-3)}`:`/p/${encodeURIComponent(e)}/f/${t.path}`,i=Cx,a=`text-sky-500 bg-sky-500/10 ring-sky-500/20`;return t.severity===`error`?(i=Vb,a=`text-rose-600 dark:text-rose-400 bg-rose-500/10 ring-rose-500/20`):t.severity===`warning`&&(i=rS,a=`text-amber-600 dark:text-amber-400 bg-amber-500/10 ring-amber-500/20`),(0,h.jsx)(`div`,{className:`flex flex-col gap-2 p-4 sm:flex-row sm:items-center sm:justify-between`,children:(0,h.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,h.jsx)(`div`,{className:X(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full ring-1`,a),children:(0,h.jsx)(i,{size:14})}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-mono text-xs font-semibold text-fg`,children:t.code}),(0,h.jsx)(`span`,{className:`text-xs text-muted`,children:`on`}),(0,h.jsx)($g,{to:r,className:`font-mono text-xs text-accent-500 hover:text-accent-600 transition-colors truncate max-w-sm`,title:`Navigate to ${t.path}`,children:t.path})]}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted break-words`,children:t.message})]})]})},n)})})]}),(0,h.jsxs)(`section`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border pb-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`Stale Concepts`}),f.length>0&&(0,h.jsx)(QD,{})]}),(0,h.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,f.length,`)`]})]}),f.length===0?(0,h.jsx)(cS,{icon:qb,title:`No stale concepts`,hint:`All concepts are within their defined freshness interval.`,className:`py-10`}):(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:f.map(t=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e)}/c/${t.id}`,className:`group flex flex-col gap-3 p-4 transition-colors hover:bg-surface-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,h.jsx)(_D,{type:t.type,size:18}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500 truncate`,children:t.title}),(0,h.jsx)(`span`,{className:`font-mono text-xs text-subtle shrink-0`,children:t.id})]}),t.description&&(0,h.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-xs text-muted`,children:t.description})]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-end sm:self-center`,children:[(0,h.jsx)(XD,{status:t.status}),(0,h.jsx)(ZD,{tier:t.trustTier}),(0,h.jsx)(QD,{})]})]},t.id))})]}),(0,h.jsxs)(`section`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border pb-3`,children:[(0,h.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,h.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`Unverified Concepts`})}),(0,h.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,p.length,`)`]})]}),p.length===0?(0,h.jsx)(cS,{icon:Ub,title:`All concepts verified`,hint:`Every concept has been machine-confirmed or human-reviewed.`,className:`py-10`}):(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:p.map(t=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e)}/c/${t.id}`,className:`group flex flex-col gap-3 p-4 transition-colors hover:bg-surface-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,h.jsx)(_D,{type:t.type,size:18}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500 truncate`,children:t.title}),(0,h.jsx)(`span`,{className:`font-mono text-xs text-subtle shrink-0`,children:t.id})]}),t.description&&(0,h.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-xs text-muted`,children:t.description})]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-end sm:self-center`,children:[(0,h.jsx)(XD,{status:t.status}),(0,h.jsx)(ZD,{tier:t.trustTier}),t.stale&&(0,h.jsx)(QD,{})]})]},t.id))})]})]})]})}function qj(){return(0,h.jsxs)(fS,{title:`Page not found`,className:`flex min-h-[70vh] flex-col items-center justify-center p-8 text-center`,children:[(0,h.jsx)(`div`,{className:`text-8xl font-black tracking-tighter bg-gradient-to-br from-accent-500 via-accent-400 to-glow bg-clip-text text-transparent select-none`,children:`404`}),(0,h.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold tracking-tight text-fg`,children:`Nothing here`}),(0,h.jsx)(`p`,{className:`mt-2 text-sm text-muted max-w-sm`,children:`The page you're looking for doesn't exist, has been moved, or you don't have access to it.`}),(0,h.jsx)($g,{to:`/`,className:`mt-6 inline-flex items-center justify-center rounded-lg bg-surface-2 px-4 py-2 text-xs font-medium text-fg ring-1 ring-border hover:bg-surface hover:ring-border-strong transition-colors`,children:`Back to projects`})]})}function Jj({label:e,icon:t,value:n,tone:r=`default`,to:i,children:a,className:o}){let s=r===`warn`,c=X(`rounded-xl border p-4 transition-all`,s?`border-orange-500/30 bg-orange-500/5 dark:border-orange-500/20`:`border-border bg-surface`,i&&`block hover:-translate-y-px hover:border-border-strong`,o),l=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted`,children:e}),t&&(0,h.jsx)(t,{size:16,className:s?`text-orange-600 dark:text-orange-400`:`text-muted shrink-0`})]}),n!==void 0&&(0,h.jsx)(`div`,{className:X(`mt-2 text-2xl font-semibold tracking-tight`,s?`text-orange-600 dark:text-orange-400`:`text-fg`),children:n}),a&&(0,h.jsx)(`div`,{className:`mt-3`,children:a})]});return i?(0,h.jsx)($g,{to:i,className:c,children:l}):(0,h.jsx)(`div`,{className:c,children:l})}function Yj(){let e=Nh().project??``,t=TD(),[n,r]=(0,m.useState)(!1),{data:i,isLoading:a,isError:o,error:s,refetch:c}=O_(e),l=A_(e,`overview`),u=k_(e,``),d=M_(e,{limit:8}),f=(0,m.useMemo)(()=>u.data?u.data.filter(e=>e.kind===`directory`).sort((e,t)=>e.path.localeCompare(t.path)):[],[u.data]),p=(0,m.useMemo)(()=>i?.typeCounts?Object.entries(i.typeCounts).sort(([,e],[,t])=>t-e).slice(0,5):[],[i?.typeCounts]),g=(0,m.useMemo)(()=>{if(!i?.trustTierCounts)return{total:0,human:0,machine:0,unverified:0,proposed:0};let e=i.trustTierCounts[`human-reviewed`]??0,t=i.trustTierCounts[`machine-confirmed`]??0,n=i.trustTierCounts.unverified??0,r=i.trustTierCounts.proposed??0;return{total:e+t+n+r,human:e,machine:t,unverified:n,proposed:r}},[i?.trustTierCounts]);return a?(0,h.jsxs)(fS,{title:e||`Project`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(Q,{className:`h-9 w-64 rounded-lg`}),(0,h.jsx)(Q,{className:`h-5 w-96 rounded-md`})]}),(0,h.jsx)(`div`,{className:`mt-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,h.jsx)(Q,{className:`h-32 rounded-xl`},t))}),(0,h.jsxs)(`div`,{className:`mt-8 grid grid-cols-1 gap-8 lg:grid-cols-12`,children:[(0,h.jsx)(`div`,{className:`lg:col-span-7 xl:col-span-8`,children:(0,h.jsx)(Q,{className:`h-96 rounded-xl`})}),(0,h.jsxs)(`div`,{className:`lg:col-span-5 xl:col-span-4 space-y-6`,children:[(0,h.jsx)(Q,{className:`h-64 rounded-xl`}),(0,h.jsx)(Q,{className:`h-48 rounded-xl`})]})]})]}):o?(0,h.jsx)(fS,{title:e||`Project`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:s,onRetry:()=>void c()})}):i?(0,h.jsxs)(fS,{title:i.title,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 border-b border-border pb-6 sm:flex-row sm:items-start`,children:[(0,h.jsxs)(`div`,{className:`max-w-3xl`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-fg`,children:i.title}),(0,h.jsx)(`span`,{className:`font-mono text-xs text-subtle`,children:i.project})]}),i.description&&(0,h.jsx)(`p`,{className:`mt-2 text-base text-muted`,children:i.description}),i.repositories&&i.repositories.length>0&&(0,h.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:i.repositories.map(e=>{let t=null;try{let n=new URL(`https://${e}`);n.protocol===`https:`&&n.hostname&&(t=n.href)}catch{}if(!t)return null;let n=e.indexOf(`/`),r=n===-1?e:e.slice(n+1);return(0,h.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface-2 px-2 py-1 font-mono text-xs text-muted transition-colors hover:border-border-strong hover:text-fg`,title:`View ${e}`,children:[(0,h.jsx)(hx,{size:13,className:`shrink-0 text-subtle`}),(0,h.jsx)(`span`,{children:r})]},e)})})]}),(0,h.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,h.jsxs)(`button`,{type:`button`,onClick:async()=>{try{r(!0),await w_(e)}catch{}finally{r(!1)}},disabled:n,className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-2 text-sm font-medium text-fg shadow-xs transition-colors hover:bg-surface-2 hover:border-border-strong disabled:opacity-50 focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)($b,{size:15,className:`shrink-0 text-muted`}),(0,h.jsx)(`span`,{children:n?`Exporting…`:`Export .tar.gz`})]})})]}),(0,h.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,h.jsx)(Jj,{label:`Concepts`,icon:sx,value:i.conceptCount,to:`/search?project=${encodeURIComponent(e)}`}),(0,h.jsx)(Jj,{label:`Stale`,icon:qb,value:i.staleCount,tone:i.staleCount>0?`warn`:`default`,to:`/p/${encodeURIComponent(e)}/health`}),(0,h.jsx)(Jj,{label:`Trust`,icon:Yx,children:(0,h.jsxs)(`div`,{className:`mt-1`,children:[(0,h.jsx)(`div`,{className:`flex h-2 w-full overflow-hidden rounded-full bg-surface-2`,children:g.total>0?(0,h.jsxs)(h.Fragment,{children:[g.human>0&&(0,h.jsx)(`div`,{style:{width:`${g.human/g.total*100}%`},className:`bg-emerald-500`,title:`Human-reviewed: ${g.human}`}),g.machine>0&&(0,h.jsx)(`div`,{style:{width:`${g.machine/g.total*100}%`},className:`bg-sky-500`,title:`Machine-confirmed: ${g.machine}`}),g.unverified>0&&(0,h.jsx)(`div`,{style:{width:`${g.unverified/g.total*100}%`},className:`bg-zinc-400 dark:bg-zinc-600`,title:`Unverified: ${g.unverified}`}),g.proposed>0&&(0,h.jsx)(`div`,{style:{width:`${g.proposed/g.total*100}%`},className:`bg-violet-500`,title:`Proposed: ${g.proposed}`})]}):(0,h.jsx)(`div`,{className:`w-full bg-surface-2`})}),(0,h.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-[11px] text-muted`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),(0,h.jsxs)(`span`,{children:[g.human,` human`]})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-sky-500`}),(0,h.jsxs)(`span`,{children:[g.machine,` auto`]})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600`}),(0,h.jsxs)(`span`,{children:[g.unverified,` unverified`]})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-violet-500`}),(0,h.jsxs)(`span`,{children:[g.proposed,` proposed`]})]})]})]})}),(0,h.jsx)(Jj,{label:`Types`,icon:jb,children:p.length>0?(0,h.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:p.map(([t,n])=>(0,h.jsxs)($g,{to:`/search?project=${encodeURIComponent(e)}&type=${encodeURIComponent(t)}`,className:`inline-flex items-center gap-1 rounded-md bg-surface-2 px-1.5 py-0.5 text-xs text-muted transition-colors hover:bg-surface hover:text-fg ring-1 ring-border/50`,children:[(0,h.jsx)(_D,{type:t,size:12}),(0,h.jsx)(`span`,{children:t}),(0,h.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:n})]},t))}):(0,h.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No types recorded`})})]}),(0,h.jsxs)(`div`,{className:`mt-8 grid grid-cols-1 gap-8 lg:grid-cols-12`,children:[(0,h.jsxs)(`div`,{className:`lg:col-span-7 xl:col-span-8`,children:[l.isLoading&&(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-6 space-y-4`,children:[(0,h.jsx)(Q,{className:`h-7 w-48 rounded-md`}),(0,h.jsx)(Q,{className:`h-4 w-full`}),(0,h.jsx)(Q,{className:`h-4 w-5/6`}),(0,h.jsx)(Q,{className:`h-4 w-4/6`})]}),l.data&&(0,h.jsx)(`div`,{className:`rounded-xl border border-border bg-surface p-6 sm:p-8`,children:(0,h.jsx)(Bj,{project:e,concept:l.data})})]}),(0,h.jsxs)(`div`,{className:`space-y-6 lg:col-span-5 xl:col-span-4`,children:[(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-5`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between pb-3 border-b border-border`,children:[(0,h.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold tracking-tight text-fg`,children:[(0,h.jsx)(Vx,{size:16,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Recent activity`})]}),(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}/activity`,className:`text-xs font-medium text-accent-500 transition-colors hover:text-accent-600`,children:`View all`})]}),(0,h.jsxs)(`div`,{className:`mt-3 divide-y divide-border/50`,children:[d.isLoading&&(0,h.jsx)(`div`,{className:`space-y-3 py-2`,children:Array.from({length:4}).map((e,t)=>(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(Q,{className:`h-6 w-6 rounded-full shrink-0`}),(0,h.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,h.jsx)(Q,{className:`h-3.5 w-3/4`}),(0,h.jsx)(Q,{className:`h-3 w-1/2`})]})]},t))}),d.data&&d.data.length>0?d.data.map(e=>{let t=e.actor.startsWith(`human:`)?e.actor.slice(6):e.actor;return(0,h.jsxs)(`div`,{className:`flex items-start gap-3 py-2.5 first:pt-1 last:pb-1`,children:[(0,h.jsx)(BD,{actor:e.actor,size:22,className:`mt-0.5`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`truncate text-xs font-medium text-fg`,title:e.subject,children:e.subject}),(0,h.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-muted`,children:[(0,h.jsx)(`span`,{className:`truncate font-mono text-subtle max-w-[120px]`,children:t}),(0,h.jsx)(`span`,{children:`·`}),(0,h.jsx)(`span`,{title:MD(e.at),children:jD(e.at)})]})]})]},e.sha)}):!d.isLoading&&(0,h.jsx)(`p`,{className:`py-4 text-center text-xs text-muted`,children:`No recent activity`})]})]}),(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-5`,children:[(0,h.jsx)(`div`,{className:`pb-3 border-b border-border`,children:(0,h.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold tracking-tight text-fg`,children:[(0,h.jsx)(px,{size:16,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Browse`})]})}),(0,h.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[u.isLoading&&(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-10 w-full rounded-lg`}),(0,h.jsx)(Q,{className:`h-10 w-full rounded-lg`}),(0,h.jsx)(Q,{className:`h-10 w-full rounded-lg`})]}),f.length>0?f.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>t.reveal(e.path),className:`group flex w-full items-center justify-between rounded-lg border border-border bg-surface-2/50 p-2.5 text-left transition-colors hover:border-border-strong hover:bg-surface-2 focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,h.jsx)(px,{size:16,className:`shrink-0 text-accent-500`}),(0,h.jsx)(`span`,{className:`truncate text-xs font-medium text-fg transition-colors group-hover:text-accent-500`,children:e.path})]}),(0,h.jsxs)(`span`,{className:`ml-2 shrink-0 text-[11px] text-muted`,children:[e.conceptCount,` `,e.conceptCount===1?`concept`:`concepts`]})]},e.path)):!u.isLoading&&(0,h.jsx)(`p`,{className:`py-4 text-center text-xs text-muted`,children:`No directories`})]})]})]})]})]}):null}function Xj(){let{data:e,isLoading:t,isError:n,error:r,refetch:i}=D_(),[a,o]=(0,m.useState)(``),s=(0,m.useMemo)(()=>e?e.reduce((e,t)=>e+t.conceptCount,0):0,[e]),c=(0,m.useMemo)(()=>{if(!e)return[];let t=a.trim().toLowerCase();return[...t?e.filter(e=>e.title.toLowerCase().includes(t)||e.project.toLowerCase().includes(t)||!!e.description?.toLowerCase().includes(t)):e].sort((e,t)=>!e.updatedAt&&!t.updatedAt?0:e.updatedAt?t.updatedAt?new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime():-1:1)},[e,a]);return t?(0,h.jsxs)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(Q,{className:`h-9 w-64 rounded-lg`}),(0,h.jsx)(Q,{className:`h-5 w-48 rounded-md`})]}),(0,h.jsx)(`div`,{className:`mt-6`,children:(0,h.jsx)(Q,{className:`h-10 w-full max-w-sm rounded-lg`})}),(0,h.jsx)(`div`,{className:`mt-8 grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,h.jsxs)(`div`,{className:`flex flex-col justify-between rounded-xl border border-border bg-surface p-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(Q,{className:`h-5 w-32`}),(0,h.jsx)(Q,{className:`h-4 w-20`})]}),(0,h.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-full`}),(0,h.jsx)(Q,{className:`h-4 w-3/4`})]})]}),(0,h.jsxs)(`div`,{className:`mt-6 border-t border-border pt-4 flex items-center justify-between`,children:[(0,h.jsx)(Q,{className:`h-4 w-28`}),(0,h.jsx)(Q,{className:`h-4 w-20`})]})]},t))})]}):n?(0,h.jsx)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:r,onRetry:()=>void i()})}):!e||e.length===0?(0,h.jsxs)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsx)(`h1`,{className:`bg-gradient-to-r from-fg to-muted bg-clip-text text-3xl font-semibold tracking-tight text-transparent`,children:`Knowledge base`}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:`0 projects · 0 concepts`})]}),(0,h.jsx)(cS,{icon:lx,title:`No projects yet`,hint:`Agents create them with create_project, or POST /api/v1/projects.`,className:`mt-6 py-16`})]}):(0,h.jsxs)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`bg-gradient-to-r from-fg to-muted bg-clip-text text-3xl font-semibold tracking-tight text-transparent`,children:`Knowledge base`}),(0,h.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[e.length,` `,e.length===1?`project`:`projects`,` · `,s,` `,s===1?`concept`:`concepts`]})]}),(0,h.jsx)(`div`,{className:`mt-6`,children:(0,h.jsxs)(`div`,{className:`relative max-w-sm`,children:[(0,h.jsx)(qx,{size:16,className:`absolute left-3 top-1/2 -translate-y-1/2 text-subtle`}),(0,h.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Filter projects…`,className:`w-full rounded-lg border border-border bg-surface py-2 pl-9 pr-3 text-sm text-fg placeholder:text-muted transition-colors focus-visible:outline-2 outline-accent-500`})]})}),c.length===0?(0,h.jsx)(cS,{icon:qx,title:`No matching projects`,hint:`No projects match "${a}". Try adjusting your filter.`,className:`mt-8 py-12`}):(0,h.jsx)(`div`,{className:`mt-8 grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:c.map(e=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e.project)}`,className:`group flex flex-col justify-between rounded-xl border border-border bg-surface p-5 transition-all duration-150 hover:-translate-y-px hover:border-border-strong hover:shadow-[0_8px_30px_-12px_rgb(139_92_246/0.35)]`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,h.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500 truncate`,children:e.title}),(0,h.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-subtle`,children:e.project})]}),(0,h.jsx)(`p`,{className:`mt-2 line-clamp-2 text-sm text-muted min-h-[2.5rem]`,children:e.description||`No description provided.`})]}),(0,h.jsxs)(`div`,{className:`mt-5 border-t border-border pt-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,h.jsx)(sx,{size:14,className:`shrink-0 text-subtle`}),(0,h.jsx)(`span`,{children:e.conceptCount})]}),(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5`,e.staleCount>0?`font-medium text-orange-600 dark:text-orange-400`:`text-muted`),children:[(0,h.jsx)(qb,{size:14,className:`shrink-0`}),(0,h.jsxs)(`span`,{children:[e.staleCount,` stale`]})]}),(0,h.jsx)(`span`,{className:`ml-auto text-subtle truncate`,children:e.updatedAt?`Updated ${jD(e.updatedAt)}`:`Never updated`})]}),e.repositories&&e.repositories.length>0&&(0,h.jsx)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-1.5`,children:e.repositories.map(e=>{let t=e.indexOf(`/`),n=t===-1?e:e.slice(t+1);return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted ring-1 ring-border/50`,title:e,children:[(0,h.jsx)(hx,{size:11,className:`shrink-0 text-subtle`}),(0,h.jsx)(`span`,{className:`truncate max-w-[140px]`,children:n})]},e)})})]})]},e.project))})]})}function Zj(){let[e,t]=r_(),n=e.get(`q`)??``,r=e.get(`project`)??``,i=e.get(`type`)??``,a=e.getAll(`tag`),o=e.get(`status`)??``,s=e.get(`trustTier`)??``,c=e.get(`stale`)??``,[l,u]=(0,m.useState)(``),{data:d}=D_(),{data:f}=O_(r),p=(0,m.useMemo)(()=>{if(r&&f?.typeCounts){let e=Object.keys(f.typeCounts);if(e.length>0)return e}return mD},[r,f?.typeCounts]),{data:g,isLoading:_,isError:v,error:y,refetch:b}=P_((0,m.useMemo)(()=>{let e={limit:50};return n.trim()&&(e.q=n.trim()),r&&(e.project=r),i&&(e.type=i),a.length>0&&(e.tag=a),o&&(e.status=o),s&&(e.trustTier=s),c===`true`&&(e.stale=!0),c===`false`&&(e.stale=!1),e},[n,r,i,a,o,s,c])),x=(n,r)=>{let i=new URLSearchParams(e);r?i.set(n,r):i.delete(n),t(i,{replace:!0})},S=n=>{let r=n.trim();if(!r||a.includes(r))return;let i=new URLSearchParams(e);i.append(`tag`,r),t(i,{replace:!0}),u(``)},C=n=>{let r=new URLSearchParams(e);r.delete(`tag`);for(let e of a)e!==n&&r.append(`tag`,e);t(r,{replace:!0})},w=e=>{e.preventDefault(),S(l)},T=!!(r||i||a.length>0||o||s||c);return(0,h.jsxs)(fS,{title:`Search`,className:`mx-auto max-w-6xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg`,children:`Search Knowledge Base`}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:`Find concepts, decisions, conventions, and architectural records across projects.`})]}),(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(qx,{size:20,className:`absolute left-4 top-1/2 -translate-y-1/2 text-subtle`}),(0,h.jsx)(`input`,{type:`text`,value:n,onChange:e=>x(`q`,e.target.value),placeholder:`Search concepts by keyword, text, title…`,className:`w-full rounded-xl border border-border bg-surface py-3.5 pl-12 pr-4 text-base text-fg shadow-xs placeholder:text-muted transition-colors focus-visible:outline-2 outline-accent-500`})]})]}),(0,h.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-2.5 rounded-xl border border-border bg-surface p-3 sm:gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,h.jsx)(Zx,{size:14,className:`text-subtle`}),(0,h.jsx)(`span`,{children:`Filter:`})]}),(0,h.jsxs)(`select`,{value:r,onChange:e=>x(`project`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`All projects`}),d?.map(e=>(0,h.jsx)(`option`,{value:e.project,children:e.title},e.project))]}),(0,h.jsxs)(`select`,{value:i,onChange:e=>x(`type`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`All types`}),p.map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))]}),(0,h.jsxs)(`select`,{value:o,onChange:e=>x(`status`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`Any status`}),(0,h.jsx)(`option`,{value:`draft`,children:`Draft`}),(0,h.jsx)(`option`,{value:`stable`,children:`Stable`}),(0,h.jsx)(`option`,{value:`deprecated`,children:`Deprecated`})]}),(0,h.jsxs)(`select`,{value:s,onChange:e=>x(`trustTier`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`Any trust`}),(0,h.jsx)(`option`,{value:`human-reviewed`,children:`Human-reviewed`}),(0,h.jsx)(`option`,{value:`machine-confirmed`,children:`Machine-confirmed`}),(0,h.jsx)(`option`,{value:`unverified`,children:`Unverified`}),(0,h.jsx)(`option`,{value:`proposed`,children:`Proposed`})]}),(0,h.jsxs)(`select`,{value:c,onChange:e=>x(`stale`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`Any staleness`}),(0,h.jsx)(`option`,{value:`true`,children:`Stale`}),(0,h.jsx)(`option`,{value:`false`,children:`Fresh`})]}),(0,h.jsx)(`form`,{onSubmit:w,className:`flex items-center`,children:(0,h.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`+ tag…`,className:`w-20 rounded-lg border border-border bg-surface-2 px-2 py-1.5 text-xs text-fg placeholder:text-subtle transition-colors focus-visible:outline-2 outline-accent-500`})}),T&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams;n&&e.set(`q`,n),t(e,{replace:!0})},className:`ml-auto text-xs font-medium text-accent-500 hover:text-accent-600 transition-colors`,children:`Clear filters`})]}),a.length>0&&(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,h.jsxs)(`span`,{className:`text-xs text-muted flex items-center gap-1`,children:[(0,h.jsx)(tS,{size:12,className:`text-subtle`}),(0,h.jsx)(`span`,{children:`Tags:`})]}),a.map(e=>(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-accent-500/20 bg-accent-500/10 px-2 py-0.5 font-mono text-xs text-accent-600 dark:text-accent-400`,children:[(0,h.jsxs)(`span`,{children:[`#`,e]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>C(e),className:`hover:text-fg transition-colors`,title:`Remove tag ${e}`,children:(0,h.jsx)(sS,{size:12})})]},e))]}),(0,h.jsxs)(`div`,{className:`mt-8`,children:[_&&(0,h.jsx)(`div`,{className:`space-y-4`,children:Array.from({length:4}).map((e,t)=>(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-5 space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(Q,{className:`h-5 w-40`}),(0,h.jsx)(Q,{className:`h-5 w-20`})]}),(0,h.jsx)(Q,{className:`h-5 w-24`})]}),(0,h.jsx)(Q,{className:`h-4 w-full`}),(0,h.jsx)(Q,{className:`h-4 w-3/4`})]},t))}),v&&(0,h.jsx)(lS,{error:y,onRetry:()=>void b()}),!_&&!v&&g&&g.length===0&&(0,h.jsx)(cS,{icon:qx,title:`No matches`,hint:`Try adjusting your keywords, expanding your project scope, or clearing filters.`,className:`py-16`}),!_&&!v&&g&&g.length>0&&(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`div`,{className:`flex items-center justify-between text-xs text-muted pb-1`,children:(0,h.jsxs)(`span`,{children:[`Found `,g.length,` `,g.length===1?`result`:`results`]})}),g.map(e=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e.project)}/c/${e.id}`,className:`group block rounded-xl border border-border bg-surface p-5 transition-all duration-150 hover:-translate-y-px hover:border-border-strong hover:shadow-[0_8px_30px_-12px_rgb(139_92_246/0.35)]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-baseline sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500`,children:(0,h.jsx)(pD,{text:e.title,query:n})}),(0,h.jsx)($D,{type:e.type}),(0,h.jsxs)(`span`,{className:`font-mono text-xs text-subtle`,children:[e.project,`/`,e.id]})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,h.jsx)(XD,{status:e.status}),(0,h.jsx)(ZD,{tier:e.trustTier}),e.stale&&(0,h.jsx)(QD,{})]})]}),e.snippet?(0,h.jsx)(`p`,{className:`mt-2.5 text-sm text-muted break-words line-clamp-2`,children:(0,h.jsx)(pD,{text:e.snippet,query:n})}):e.description&&(0,h.jsx)(`p`,{className:`mt-2.5 text-sm text-muted break-words line-clamp-2`,children:(0,h.jsx)(pD,{text:e.description,query:n})}),e.tags&&e.tags.length>0&&(0,h.jsx)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-1.5 pt-1`,children:e.tags.map(e=>(0,h.jsxs)(`span`,{className:`rounded-md bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted ring-1 ring-border/50`,children:[`#`,e]},e))})]},`${e.project}/${e.id}`))]})]})]})}var Qj=Xg([{path:`/callback`,element:(0,h.jsx)(JD,{})},{element:(0,h.jsx)(_S,{}),children:[{element:(0,h.jsx)(GD,{}),children:[{index:!0,element:(0,h.jsx)(Xj,{})},{path:`search`,element:(0,h.jsx)(Zj,{})},{path:`p/:project`,element:(0,h.jsx)(Yj,{})},{path:`p/:project/activity`,element:(0,h.jsx)(qD,{})},{path:`p/:project/health`,element:(0,h.jsx)(Kj,{})},{path:`p/:project/c/*`,element:(0,h.jsx)(Hj,{})},{path:`p/:project/f/*`,element:(0,h.jsx)(Gj,{})},{path:`*`,element:(0,h.jsx)(qj,{})}]}]}],{basename:`/ui`});ib();var $j=document.getElementById(`root`);$j&&(0,Tg.createRoot)($j).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:T_,children:(0,h.jsx)(Jy,{children:(0,h.jsx)(cu,{reducedMotion:`user`,children:(0,h.jsx)(l_,{router:Qj})})})})}));export{Ag as n,s as r,jk as t};
126
+ `}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>${rj(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?rj(n,!0):this.parser.parseInline(r),o=aj(e);if(o===null)return a;e=rj(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+rj(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=aj(e);if(i===null)return rj(n);e=i;let a=`<img src="${rj(e)}" alt="${rj(n)}"`;return t&&(a+=` title="${rj(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:rj(e.text)}},vj=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}},yj=class e{options;renderer;textRenderer;constructor(e){this.options=e||Pk,this.options.renderer=this.options.renderer||new _j,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vj}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;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`,`checkbox`,`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){this.renderer.parser=this;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`,`checkbox`,`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}},bj=class{options;block;constructor(e){this.options=e||Pk}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(e=this.block){return e?gj.lex:gj.lexInline}provideParser(e=this.block){return e?yj.parse:yj.parseInline}},xj=class{defaults=Nk();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=yj;Renderer=_j;TextRenderer=vj;Lexer=gj;Tokenizer=hj;Hooks=bj;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 _j(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 hj(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 bj;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];t[r]=bj.passThroughHooks.has(n)?e=>{if(this.defaults.async&&bj.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)}:(...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 gj.lex(e,t??this.defaults)}parser(e,t){return yj.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):e?gj.lex:gj.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):e?yj.parse:yj.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):e?gj.lex:gj.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):e?yj.parse:yj.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+=`
127
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+rj(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Sj=new xj;function Cj(e,t){return Sj.parse(e,t)}Cj.options=Cj.setOptions=function(e){return Sj.setOptions(e),Cj.defaults=Sj.defaults,Fk(Cj.defaults),Cj},Cj.getDefaults=Nk,Cj.defaults=Pk;function wj(...e){return Sj.use(...e),Cj.defaults=Sj.defaults,Fk(Cj.defaults),Cj}Cj.use=wj,Cj.walkTokens=function(e,t){return Sj.walkTokens(e,t)},Cj.parseInline=Sj.parseInline,Cj.Parser=yj,Cj.parser=yj.parse,Cj.Renderer=_j,Cj.TextRenderer=vj,Cj.Lexer=gj,Cj.lexer=gj.lex,Cj.Tokenizer=hj,Cj.Hooks=bj,Cj.parse=Cj,Cj.options,Cj.setOptions,Cj.walkTokens,Cj.parseInline,yj.parse,gj.lex;var Tj=/^data:image\/(?:png|jpe?g|gif|webp|avif|bmp|x-icon);base64,[a-z0-9+/=\s]+$/i;Mk.addHook(`afterSanitizeAttributes`,e=>{if(e.nodeName.toUpperCase()===`IMG`){let t=e.getAttribute(`src`);if(t){let n=Tj.test(t),r=t.startsWith(`/`)&&!t.startsWith(`//`)&&!t.startsWith(`/\\`);!n&&!r&&(e.removeAttribute(`src`),e.setAttribute(`data-okf-blocked-src`,`true`))}}if(e.nodeName.toUpperCase()===`A`){let t=e.getAttribute(`href`);if(t){let n=oD(t,``);n.kind===`invalid`?e.removeAttribute(`href`):n.kind===`external`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}}});function Ej(e){return Mk.sanitize(e,{ADD_ATTR:[`target`,`data-okf-cite`,`data-okf-internal`,`data-okf-concept`,`data-okf-project`],FORBID_TAGS:[`style`,`form`,`input`,`button`,`iframe`,`object`,`embed`,`script`,`foreignobject`,`animate`,`set`,`use`],FORBID_ATTR:[`style`]})}function Dj(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Oj(e){if(!e||e.length===0)return``;let t=``;for(let n of e)`tokens`in n&&Array.isArray(n.tokens)?t+=Oj(n.tokens):`text`in n&&typeof n.text==`string`&&(t+=n.text);return t}function kj(e,t){let n=[],r=[],i=new Set,a=new Map,o=new xj({gfm:!0});o.use({extensions:[{name:`citation`,level:`inline`,start(e){return e.indexOf(`[^`)},tokenizer(e){let t=/^\[\^([^\]\s]+)\](?!:)/.exec(e);if(t?.[1])return{type:`citation`,raw:t[0],label:t[1]}},renderer(e){if(!(`label`in e)||typeof e.label!=`string`)return``;let n=e.label,i=t.sources.find(e=>e.id===n||e.id.toLowerCase()===n.toLowerCase()),o=i?i.id:n,s=r.indexOf(o)+1;if(s===0&&(r.push(o),s=r.length),i)return`<sup class="okf-cite"><a href="#source-${encodeURIComponent(i.id)}" data-okf-cite="${Dj(i.id)}">${s}</a></sup>`;let c=a.get(n.toLowerCase());if(c?.href){let e=oD(c.href,t.conceptId);if(e.kind===`external`)return`<sup class="okf-cite"><a href="${Dj(e.href)}" target="_blank" rel="noopener noreferrer">${s}</a></sup>`;if(e.kind===`concept`){let n=e.project??t.project,r=e.project!==void 0&&e.project!==t.project?e.project:null,i=r?` data-okf-project="${Dj(r)}"`:``;return`<sup class="okf-cite"><a href="${Dj(`/ui${sD(n,e.id)}${e.hash}`)}" data-okf-internal data-okf-concept="${Dj(e.id)}"${i}>${s}</a></sup>`}return`<sup class="okf-cite"><span class="okf-cite-missing" title="Invalid source">${s}</span></sup>`}return`<sup class="okf-cite"><span class="okf-cite-missing" title="Unknown source">${s}</span></sup>`}}],renderer:{heading(e){let t=e.depth,r=Oj(e.tokens).trim(),a=r.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`heading`,o=a,s=1;for(;i.has(o);)s++,o=`${a}-${s}`;i.add(o),(t===2||t===3)&&n.push({id:o,text:r,depth:t});let c=this.parser.parseInline(e.tokens);return`<h${t} id="${o}"><a class="okf-anchor" href="#${o}" aria-hidden="true">#</a>${c}</h${t}>\n`},code(e){return`<pre class="okf-code" data-lang="${Dj((e.lang||``).match(/^\S*/)?.[0]??``)}"><code>${Dj(e.text)}</code></pre>\n`},link(e){let n=e.href,r=e.title?` title="${Dj(e.title)}"`:``,i=this.parser.parseInline(e.tokens),a=oD(n,t.conceptId);if(a.kind===`concept`){let e=a.project??t.project,n=a.project!==void 0&&a.project!==t.project?a.project:null,o=t.outbound.find(n=>(n.project?n.project===e:e===t.project)&&n.id===a.id),s=!o||o.exists,c=Dj(`/ui${sD(e,a.id)}${a.hash}`),l=Dj(a.id),u=n?` data-okf-project="${Dj(n)}"`:``;return s?`<a href="${c}" data-okf-internal data-okf-concept="${l}"${u}${r}>${i}</a>`:`<a href="${c}" data-okf-internal data-okf-concept="${l}"${u} class="okf-broken" title="Missing concept">${i}</a>`}return a.kind===`file`?`<a href="${Dj(`/ui${cD(t.project,a.path)}${a.hash}`)}" data-okf-internal${r}>${i}</a>`:a.kind===`anchor`?`<a href="${Dj(n)}"${r}>${i}</a>`:a.kind===`external`?`<a href="${Dj(a.href)}" target="_blank" rel="noopener noreferrer" class="okf-external"${r}>${i}</a>`:`<span class="okf-broken" title="Broken link">${i}</span>`},image(e){let n=e.href,r=Dj(e.text),i=e.title?` title="${Dj(e.title)}"`:``;if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!n.startsWith(`/\\`)||Tj.test(n))return`<img src="${Dj(n)}" alt="${r}"${i}>`;let a=oD(n,t.conceptId);if(a.kind===`external`){let e=r?`[Image: ${r}]`:`[Remote image]`;return`<span class="okf-image-blocked"><a href="${Dj(a.href)}" target="_blank" rel="noopener noreferrer" class="okf-external" title="Remote image blocked to protect IP">${e}</a></span>`}return`<span class="okf-image-missing">${r||`Image`}</span>`}}});let s=o.lexer(e);if(s.links)for(let[e,t]of Object.entries(s.links))e.startsWith(`^`)&&t&&typeof t.href==`string`&&a.set(e.slice(1).toLowerCase(),{href:t.href,title:typeof t.title==`string`?t.title:void 0});for(let e=0;e<s.length;e++){let n=s[e];if(!(n&&n.type===`space`)){n&&n.type===`heading`&&n.depth===1&&(`text`in n&&typeof n.text==`string`?n.text.trim():``).toLowerCase()===t.title.trim().toLowerCase()&&s.splice(e,1);break}}return{html:Ej(o.parser(s)),headings:n,citations:r}}var Aj=/^github\.com\/([^/]+)\/([^/]+)\/(.+)$/,jj=/^gitlab\.com\/([^/]+)\/([^/]+)\/(.+)$/,Mj=/^(github|gitlab)\.com\/[^/]+\/[^/]+$/,Nj=/^https?:\/\//i,Pj=/^[a-zA-Z0-9._-]+$/;function Fj(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:null}catch{return null}}var Ij={type:!0,title:!0,description:!0,tags:!0,status:!0,generated:!0,verified:!0,sources:!0,stale_after:!0};function Lj(e){if(!e||typeof e!=`object`)return[];let t=e.sources;if(!Array.isArray(t))return[];let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(!r||typeof r!=`object`||!(`resource`in r)||typeof r.resource!=`string`)continue;let i=r.resource.trim();if(i.length===0)continue;let a=`id`in r&&typeof r.id==`string`&&r.id.trim().length>0?r.id.trim():`source-${e+1}`,o=`commit`in r&&typeof r.commit==`string`&&r.commit.trim().length>0?r.commit.trim():void 0,s=o&&Pj.test(o)?o:void 0,c=s??`HEAD`,l=null,u=i;if(Nj.test(i))l=Fj(i);else{let e=Aj.exec(i);if(e?.[1]&&e[2]&&e[3])l=Fj(`https://github.com/${e[1]}/${e[2]}/blob/${c}/${e[3]}`),u=e[3];else{let e=jj.exec(i);e?.[1]&&e[2]&&e[3]?(l=Fj(`https://gitlab.com/${e[1]}/${e[2]}/-/blob/${c}/${e[3]}`),u=e[3]):Mj.test(i)&&(l=Fj(`https://${i}`))}}n.push({id:a,resource:i,...s===void 0?{}:{commit:s},url:l,label:u})}return n}function Rj(e){if(!e||typeof e!=`object`)return[];let t=e.verified;if(t==null)return[];let n=Array.isArray(t)?t:[t],r=[];for(let e of n)if(e&&typeof e==`object`&&`by`in e&&typeof e.by==`string`&&e.by.length>0){let t=`at`in e&&typeof e.at==`string`?e.at:void 0;r.push(t===void 0?{by:e.by}:{by:e.by,at:t})}return r}function zj(e){return!e||typeof e!=`object`?[]:Object.entries(e).filter(([e])=>!(e in Ij))}function Bj({concept:e,conceptId:t,targetRect:n,onMouseEnter:r,onMouseLeave:i}){let a=n.bottom+6,o=Math.max(12,Math.min(n.left,window.innerWidth-332));return(0,h.jsx)(`div`,{role:`tooltip`,style:{top:a,left:o},onMouseEnter:r,onMouseLeave:i,className:`fixed z-50 w-80 max-w-[calc(100vw-24px)] rounded-xl border border-border-strong bg-surface/95 p-3.5 shadow-xl backdrop-blur-md transition-all duration-150`,children:e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(vD,{type:e.derived?.type??null,className:`mt-0.5 shrink-0`,size:16}),(0,h.jsx)(`div`,{className:`min-w-0 flex-1 font-medium text-sm text-fg line-clamp-2 leading-snug`,children:e.derived?.title??e.id})]}),e.derived?.description&&(0,h.jsx)(`p`,{className:`mt-1.5 text-xs text-muted line-clamp-2 leading-relaxed`,children:e.derived.description}),(0,h.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-1.5 pt-1.5 border-t border-border/50`,children:[e.derived?.status&&(0,h.jsx)(ZD,{status:e.derived.status}),e.derived?.trustTier&&(0,h.jsx)(QD,{tier:e.derived.trustTier}),e.derived?.stale&&(0,h.jsx)($D,{})]})]}):(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`div`,{className:`font-mono text-xs text-muted truncate`,children:t}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-4 rounded-full`}),(0,h.jsx)(Q,{className:`h-4 w-40 rounded-sm`})]}),(0,h.jsx)(Q,{className:`h-3 w-full rounded-sm`}),(0,h.jsx)(Q,{className:`h-3 w-3/4 rounded-sm`}),(0,h.jsxs)(`div`,{className:`flex gap-1 pt-1`,children:[(0,h.jsx)(Q,{className:`h-4 w-12 rounded-full`}),(0,h.jsx)(Q,{className:`h-4 w-16 rounded-full`})]})]})})}function Vj({project:e,concept:t,onHeadings:n,onCitations:r,className:i}){let a=kh(),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(null),l=(0,m.useRef)(void 0),u=(0,m.useRef)(!1),d=(0,m.useMemo)(()=>kj(t.body,{project:e,conceptId:t.id,title:t.derived?.title??t.id,sources:Lj(t.frontmatter),outbound:t.links.outbound}),[t,e]);return(0,m.useEffect)(()=>{n?.(d.headings),r?.(d.citations)},[d,n,r]),(0,m.useEffect)(()=>{let e=o.current;if(!e)return;let t=!1;return(async()=>{let n=Array.from(e.querySelectorAll(`pre.okf-code`));if(n.length===0)return;let{highlight:r}=await Ag(async()=>{let{highlight:e}=await import(`./highlight-CpEbRnLL.js`);return{highlight:e}},[]);if(!t)for(let e of n){if(t)break;if(e.getAttribute(`data-okf-processed`)===`true`)continue;e.setAttribute(`data-okf-processed`,`true`);let n=e.getAttribute(`data-lang`)??``,i=e.querySelector(`code`)?.textContent??e.textContent??``,a=null;if(n)try{a=await r(i,n)}catch{}if(t)break;let o=document.createElement(`div`);if(o.className=`relative group not-prose my-4`,a){o.innerHTML=a;let e=o.querySelector(`pre`);e&&e.classList.add(`overflow-x-auto`)}else{let t=e.cloneNode(!0);o.appendChild(t)}let s=document.createElement(`button`);s.type=`button`,s.setAttribute(`aria-label`,`Copy code`),s.title=`Copy code`,s.className=`absolute top-2.5 right-2.5 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity inline-flex items-center gap-1 rounded-md border border-border bg-surface/80 px-2 py-1 text-xs font-medium text-muted backdrop-blur-xs hover:bg-surface-2 hover:text-fg focus-visible:outline-2 outline-accent-500 cursor-pointer select-none`,s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="shrink-0"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,s.addEventListener(`click`,async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(i),s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="text-emerald-500 shrink-0"><polyline points="20 6 9 17 4 12"/></svg>`,setTimeout(()=>{s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="shrink-0"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`},1500)}catch{}}),o.appendChild(s),e.parentNode?.replaceChild(o,e)}})(),()=>{t=!0}},[d.html]),(0,m.useEffect)(()=>{let e=()=>{clearTimeout(l.current),c(null)};return window.addEventListener(`scroll`,e,{passive:!0}),()=>{window.removeEventListener(`scroll`,e),clearTimeout(l.current)}},[]),(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(`div`,{ref:o,onClick:e=>{let t=e.target;if(!t)return;let n=t.closest(`a[data-okf-cite]`);if(n){e.preventDefault();let t=n.getAttribute(`data-okf-cite`);if(t){let e=document.getElementById(`source-${t}`);e&&(e.scrollIntoView({behavior:`smooth`}),e.classList.remove(`okf-flash`),e.offsetWidth,e.classList.add(`okf-flash`),setTimeout(()=>{e.classList.remove(`okf-flash`)},1600))}return}let r=t.closest(`a[data-okf-internal]`);if(r){if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;e.preventDefault();let t=r.getAttribute(`href`);if(t){let e=t;e.startsWith(`/ui`)&&(e=e.slice(3)||`/`),e.startsWith(`/`)&&!e.startsWith(`//`)&&!e.startsWith(`/\\`)&&!e.includes(`\\`)&&a(e)}}},onMouseOver:t=>{let n=t.target;if(!n)return;let r=n.closest(`a[data-okf-concept]`);if(!r)return;let i=r.getAttribute(`data-okf-concept`);if(!i)return;let a=r.getAttribute(`data-okf-project`)??e;s?.targetEl!==r&&(clearTimeout(l.current),l.current=window.setTimeout(async()=>{let e=r.getBoundingClientRect();try{let t=await T_.fetchQuery({queryKey:E_.concept(a,i),queryFn:()=>v_(a,i)});c({conceptId:i,concept:t,rect:e,targetEl:r})}catch{}},250))},onMouseOut:e=>{let t=e.target;if(!t)return;let n=t.closest(`a[data-okf-concept]`);n&&(clearTimeout(l.current),setTimeout(()=>{u.current||c(e=>e?.targetEl===n?null:e)},100))},className:X(`prose prose-zinc dark:prose-invert max-w-3xl`,i),dangerouslySetInnerHTML:{__html:d.html}}),s&&(0,h.jsx)(Bj,{concept:s.concept,conceptId:s.conceptId,targetRect:s.rect,onMouseEnter:()=>{u.current=!0},onMouseLeave:()=>{u.current=!1,c(null)}})]})}function Hj({headings:e,className:t}){let[n,r]=(0,m.useState)(e[0]?.id??``);if((0,m.useEffect)(()=>{if(e.length<3)return;let t=e.map(e=>document.getElementById(e.id)).filter(e=>e!==null);if(t.length===0)return;let n=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&r(t.target.id)},{rootMargin:`0px 0px -70% 0px`,threshold:[0,1]});for(let e of t)n.observe(e);return()=>{n.disconnect()}},[e]),e.length<3)return null;let i=(e,t)=>{e.preventDefault();let n=document.getElementById(t);n&&(n.scrollIntoView({behavior:`smooth`}),r(t),window.history.replaceState(null,``,`#${t}`))};return(0,h.jsxs)(`nav`,{"aria-label":`Table of contents`,className:X(`space-y-2`,t),children:[(0,h.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-muted`,children:`On this page`}),(0,h.jsx)(`ul`,{className:`space-y-1 border-l border-border text-xs`,children:e.map(e=>{let t=n===e.id;return(0,h.jsx)(`li`,{className:e.depth===3?`pl-5`:`pl-3`,children:(0,h.jsx)(`a`,{href:`#${e.id}`,onClick:t=>i(t,e.id),className:X(`block py-0.5 transition-colors line-clamp-1`,t?`-ml-px border-l-2 border-accent-500 pl-1 font-medium text-accent-500`:`text-muted hover:text-fg`),children:e.text})},e.id)})})]})}function Uj(){let e=Nh(),t=e.project??``,n=e[`*`]??``,{data:r,isLoading:i,error:a,refetch:o}=A_(t,n),{data:s}=M_(t,{id:n,limit:10}),[c,l]=(0,m.useState)([]),[u,d]=(0,m.useState)([]),[f,p]=(0,m.useState)(!1);(0,m.useEffect)(()=>{r&&pD({project:t,id:r.id,title:r.derived?.title??r.id,type:r.derived?.type??null})},[r,t]);let g=(0,m.useMemo)(()=>{if(!r)return[];let e=Lj(r.frontmatter),t=new Map;for(let n of e)t.set(n.id,n);let n=[],i=new Set;for(let e of u){let r=t.get(e);r&&!i.has(r.id)&&(n.push(r),i.add(r.id))}for(let t of e)i.has(t.id)||(n.push(t),i.add(t.id));return n},[r,u]),_=r?.derived?.title??(n||`Concept`);if(i)return(0,h.jsxs)(fS,{title:_,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6 space-y-6`,children:[(0,h.jsxs)(`div`,{className:`space-y-3 border-b border-border pb-6`,children:[(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(Q,{className:`h-5 w-20 rounded-full`}),(0,h.jsx)(Q,{className:`h-5 w-16 rounded-full`})]}),(0,h.jsx)(Q,{className:`h-9 w-96 rounded-md`}),(0,h.jsx)(Q,{className:`h-5 w-full max-w-xl rounded-md`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col xl:flex-row gap-8`,children:[(0,h.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[(0,h.jsx)(Q,{className:`h-32 w-full rounded-xl`}),(0,h.jsx)(Q,{className:`h-48 w-full rounded-xl`})]}),(0,h.jsxs)(`div`,{className:`w-full xl:w-72 space-y-4`,children:[(0,h.jsx)(Q,{className:`h-40 w-full rounded-xl`}),(0,h.jsx)(Q,{className:`h-40 w-full rounded-xl`})]})]})]});if(a)return(0,h.jsx)(fS,{title:_,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(lS,{error:a,onRetry:o,fullScreen:!0})});if(!r)return(0,h.jsx)(fS,{title:_,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(cS,{title:`Concept not found`,hint:`Could not find concept "${n}" in project "${t}".`})});let v=r.derived?.status?.toLowerCase()===`deprecated`,y=Rj(r.frontmatter),b=zj(r.frontmatter);return(0,h.jsxs)(fS,{title:`${_} · ${t}`,className:`max-w-7xl mx-auto px-4 sm:px-6 py-6`,children:[(0,h.jsxs)(`header`,{className:`space-y-4 border-b border-border pb-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(eO,{type:r.derived?.type??null}),r.derived?.status&&(0,h.jsx)(ZD,{status:r.derived.status}),r.derived?.trustTier&&(0,h.jsx)(QD,{tier:r.derived.trustTier}),r.derived?.stale&&(0,h.jsx)($D,{})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:X(`text-3xl font-semibold tracking-tight text-fg`,v&&`line-through opacity-70`),children:r.derived?.title??r.id}),r.derived?.description&&(0,h.jsx)(`p`,{className:`mt-2 text-lg text-muted leading-relaxed`,children:r.derived.description})]}),r.derived?.tags&&r.derived.tags.length>0&&(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:r.derived.tags.map(e=>(0,h.jsxs)($g,{to:`/search?project=${encodeURIComponent(t)}&tag=${encodeURIComponent(e)}`,className:`inline-flex items-center rounded-md bg-surface-2 px-2 py-0.5 text-xs font-medium text-muted hover:text-fg hover:bg-border transition-colors`,children:[`#`,e]},e))}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-2`,children:[(0,h.jsx)(mS,{value:typeof window<`u`?window.location.href:``,label:`Copy link`}),(0,h.jsx)(mS,{value:r.id,label:`Copy ID`}),(0,h.jsxs)(`button`,{type:`button`,onClick:()=>p(e=>!e),"aria-label":`Toggle markdown source`,className:X(`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 outline-accent-500 cursor-pointer`,f?`bg-accent-500/10 text-accent-500 border-accent-500/30`:`bg-surface text-muted hover:bg-surface-2 hover:text-fg`),children:[(0,h.jsx)(Yb,{size:14,className:`shrink-0`}),(0,h.jsx)(`span`,{children:`Source`})]})]})]}),(0,h.jsxs)(`div`,{className:`mt-8 flex flex-col xl:flex-row xl:items-start gap-8`,children:[(0,h.jsx)(`div`,{className:`min-w-0 flex-1`,children:f?(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted`,children:[(0,h.jsx)(`span`,{className:`font-mono`,children:`Raw Markdown`}),(0,h.jsx)(mS,{value:r.markdown,label:`Copy markdown`})]}),(0,h.jsx)(tO,{code:r.markdown,lang:`markdown`,lineNumbers:!0,className:`rounded-xl border border-border bg-surface-2 shadow-xs`})]}):(0,h.jsx)(Vj,{project:t,concept:r,onHeadings:l,onCitations:d})}),(0,h.jsxs)(`aside`,{className:`w-full xl:w-72 xl:sticky xl:top-20 shrink-0 space-y-6`,children:[c.length>=3&&(0,h.jsx)(Hj,{headings:c}),(0,h.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsx)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:`Details`}),r.derived?.generatedAt&&(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted shrink-0`,children:`Generated`}),(0,h.jsxs)(`span`,{className:`text-fg text-right font-mono text-[11px]`,title:ND(r.derived.generatedAt),children:[MD(r.derived.generatedAt),r.derived.generatedBy&&` by ${r.derived.generatedBy}`]})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`span`,{className:`text-muted block`,children:`Verified`}),y.length>0?(0,h.jsx)(`div`,{className:`space-y-1.5 pl-1`,children:y.map((e,t)=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-fg`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,h.jsx)(VD,{actor:e.by,size:18}),(0,h.jsx)(`span`,{className:`truncate font-mono text-[11px]`,children:e.by})]}),e.at&&(0,h.jsx)(`span`,{className:`text-muted text-[10px] shrink-0`,title:ND(e.at),children:MD(e.at)})]},`${e.by}-${e.at??t}`))}):(0,h.jsx)(`div`,{className:`text-subtle italic pl-1`,children:`Unverified`})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted`,children:`Stale after`}),(0,h.jsx)(`span`,{className:X(`font-mono text-[11px]`,r.derived?.stale?`text-orange-500 font-semibold`:`text-fg`),children:r.derived?.staleAfter?r.derived.staleAfter.split(`T`)[0]:`—`})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-muted`,children:`Revision`}),(0,h.jsx)(`span`,{className:`font-mono text-[11px] text-muted`,children:r.revision.slice(0,8)})]})]}),g.length>0&&(0,h.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsxs)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:[`Sources (`,g.length,`)`]}),(0,h.jsx)(`ol`,{className:`space-y-2`,children:g.map((e,t)=>(0,h.jsxs)(`li`,{id:`source-${e.id}`,className:`rounded-lg p-2 transition-colors border border-transparent hover:border-border hover:bg-surface-2/50`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,h.jsxs)(`span`,{className:`font-mono text-muted text-[10px] shrink-0`,children:[t+1,`.`]}),(0,h.jsx)(`span`,{className:`font-mono text-fg text-xs truncate`,title:e.label,children:e.label})]}),e.commit&&(0,h.jsx)(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-surface border border-border text-muted shrink-0`,title:`Commit ${e.commit}`,children:LD(e.commit)})]}),e.url&&(0,h.jsx)(`div`,{className:`mt-1 pl-4`,children:(0,h.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-accent-500 hover:text-accent-400 hover:underline truncate max-w-full`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:e.resource}),(0,h.jsx)(tx,{size:10,className:`shrink-0`})]})})]},e.id))})]}),(0,h.jsx)(rO,{project:t,conceptId:r.id,inbound:r.links.inbound,outbound:r.links.outbound}),(0,h.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsx)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:`History`}),s&&s.length>0?(0,h.jsx)(`div`,{className:`relative pl-4 space-y-4 before:absolute before:left-1.5 before:top-2 before:bottom-2 before:w-px before:bg-border`,children:s.map(e=>(0,h.jsxs)(`div`,{className:`relative space-y-1`,children:[(0,h.jsx)(`div`,{className:`absolute -left-4 top-1.5 h-2 w-2 rounded-full bg-accent-500 ring-2 ring-surface`}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-1 text-[11px]`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,h.jsx)(VD,{actor:e.actor,size:16}),(0,h.jsx)(`span`,{className:`truncate font-mono text-fg`,children:e.actor})]}),(0,h.jsx)(`span`,{className:`text-muted shrink-0 text-[10px]`,title:ND(e.at),children:MD(e.at)})]}),(0,h.jsx)(`p`,{className:`text-fg text-xs break-words`,children:e.subject}),(0,h.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,h.jsx)(mS,{value:e.sha,label:LD(e.sha),className:`px-1.5 py-0.5 text-[10px] font-mono`})})]},e.sha))}):(0,h.jsx)(`div`,{className:`text-subtle italic`,children:`No history available`})]}),r.issues&&r.issues.length>0&&(0,h.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsxs)(`div`,{className:`font-semibold uppercase tracking-wider text-muted`,children:[`Lint issues (`,r.issues.length,`)`]}),(0,h.jsx)(`div`,{className:`space-y-2`,children:r.issues.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded-lg bg-surface border border-border/60`,children:[e.severity===`error`?(0,h.jsx)(Vb,{size:14,className:`text-rose-500 shrink-0 mt-0.5`}):e.severity===`warning`?(0,h.jsx)(rS,{size:14,className:`text-amber-500 shrink-0 mt-0.5`}):(0,h.jsx)(Cx,{size:14,className:`text-sky-500 shrink-0 mt-0.5`}),(0,h.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,h.jsx)(`div`,{className:`font-mono font-semibold text-[11px] text-fg`,children:e.code}),(0,h.jsx)(`p`,{className:`text-muted text-[11px] leading-tight break-words`,children:e.message})]})]},`${e.code}-${e.path}-${e.message}`))})]}),b.length>0&&(0,h.jsxs)(`details`,{className:`group rounded-xl border border-border bg-surface-2/30 p-3.5 text-xs`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold uppercase tracking-wider text-muted hover:text-fg flex items-center justify-between select-none`,children:[(0,h.jsxs)(`span`,{children:[`Extra frontmatter (`,b.length,`)`]}),(0,h.jsx)(Fb,{size:14,className:`transition-transform group-open:rotate-180`})]}),(0,h.jsx)(`div`,{className:`mt-2 space-y-1 overflow-x-auto rounded-lg bg-surface p-2 font-mono text-[11px] border border-border/50`,children:b.map(([e,t])=>(0,h.jsxs)(`div`,{className:`break-all`,children:[(0,h.jsx)(`span`,{className:`text-accent-500`,children:e}),`:`,` `,(0,h.jsx)(`span`,{className:`text-muted`,children:JSON.stringify(t)})]},e))})]})]})]})]})}var Wj={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,json:`json`,yaml:`yaml`,yml:`yaml`,sh:`bash`,bash:`bash`,py:`python`,go:`go`,rs:`rust`,sql:`sql`,md:`markdown`,diff:`diff`,patch:`diff`,toml:`toml`,html:`html`,css:`css`,java:`java`,rb:`ruby`,dockerfile:`dockerfile`};function Gj(e){let t=e.split(`/`).pop()??e;if(t.toLowerCase()===`dockerfile`)return`dockerfile`;let n=t.lastIndexOf(`.`);return n===-1?null:Wj[t.slice(n+1).toLowerCase()]??null}function Kj(){let e=Nh(),t=e.project??``,n=e[`*`]??``,{data:r,isLoading:i,error:a,refetch:o}=j_(t,n),s=n.split(`/`).pop()??n,c=s?`${s} · ${t}`:`File`;if(i)return(0,h.jsxs)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6 space-y-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between border-b border-border pb-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-6 w-64 rounded-md`}),(0,h.jsx)(Q,{className:`h-4 w-28 rounded-md`})]}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(Q,{className:`h-8 w-24 rounded-md`}),(0,h.jsx)(Q,{className:`h-8 w-28 rounded-md`})]})]}),(0,h.jsx)(Q,{className:`h-96 w-full rounded-xl`})]});if(a)return(0,h.jsx)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(lS,{error:a,onRetry:o,fullScreen:!0})});if(!r)return(0,h.jsx)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6`,children:(0,h.jsx)(cS,{title:`File not found`,hint:`Could not find file "${n}" in project "${t}".`})});let l=()=>{let e=new Blob([r.content],{type:`text/plain;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=s||`file`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},u=Gj(n);return(0,h.jsxs)(fS,{title:c,className:`max-w-6xl mx-auto px-4 sm:px-6 py-6 space-y-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between border-b border-border pb-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,h.jsx)(`h1`,{className:`font-mono text-xl font-semibold text-fg break-all`,children:n}),r.revision&&(0,h.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,h.jsxs)(`span`,{className:`font-mono text-xs px-2 py-0.5 rounded-md bg-surface-2 border border-border text-muted`,children:[`rev: `,r.revision.slice(0,8)]})})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,h.jsx)(mS,{value:r.content,label:`Copy content`}),(0,h.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Download file`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-2.5 py-1 text-xs font-medium text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-2 outline-accent-500 cursor-pointer`,children:[(0,h.jsx)($b,{size:14,className:`shrink-0 text-muted`}),(0,h.jsx)(`span`,{children:`Download`})]})]})]}),(0,h.jsx)(tO,{code:r.content,lang:u,lineNumbers:!0,className:`rounded-xl border border-border bg-surface-2 overflow-hidden shadow-xs`})]})}function qj(){let e=Nh().project??``,{data:t}=O_(e),n=N_(e),r=P_({project:e,stale:!0,limit:100}),i=P_({project:e,trustTier:`unverified`,limit:100}),a=n.isLoading||r.isLoading||i.isLoading,o=n.isError||r.isError||i.isError,s=n.error||r.error||i.error,c=()=>{n.refetch(),r.refetch(),i.refetch()},l=(0,m.useMemo)(()=>{if(!n.data)return{errors:[],warnings:[],infos:[]};let e=[],t=[],r=[];for(let i of n.data)i.severity===`error`?e.push(i):i.severity===`warning`?t.push(i):r.push(i);return{errors:e,warnings:t,infos:r}},[n.data]),u=t?.title?`${t.title} Health`:`Health`;if(a)return(0,h.jsxs)(fS,{title:u,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-32 rounded-md`}),(0,h.jsx)(Q,{className:`h-8 w-48 rounded-lg`})]}),(0,h.jsx)(`div`,{className:`mt-8 space-y-10`,children:Array.from({length:3}).map((e,t)=>(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(Q,{className:`h-7 w-48 rounded-md`}),(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-4 space-y-3`,children:[(0,h.jsx)(Q,{className:`h-12 w-full rounded-lg`}),(0,h.jsx)(Q,{className:`h-12 w-full rounded-lg`})]})]},t))})]});if(o)return(0,h.jsx)(fS,{title:u,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:s,onRetry:c})});let d=n.data??[],f=r.data??[],p=i.data??[],g=l.errors.length;return(0,h.jsxs)(fS,{title:u,className:`mx-auto max-w-5xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}`,className:`transition-colors hover:text-fg`,children:t?.title??e}),(0,h.jsx)(`span`,{children:`/`}),(0,h.jsx)(`span`,{className:`text-fg`,children:`Health`})]}),(0,h.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-4`,children:(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg`,children:`Knowledge Base Health`}),(0,h.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`Lint diagnostics, staleness, and verification status for `,t?.title??e]})]})})]}),(0,h.jsxs)(`div`,{className:`space-y-10`,children:[(0,h.jsxs)(`section`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border pb-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`Specification Conformance`}),g===0?(0,h.jsxs)(XD,{className:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`,children:[(0,h.jsx)(Ub,{size:13}),(0,h.jsx)(`span`,{children:`Conformant`})]}):(0,h.jsxs)(XD,{className:`bg-rose-500/10 text-rose-600 dark:text-rose-400 ring-rose-500/20`,children:[(0,h.jsx)(Vb,{size:13}),(0,h.jsxs)(`span`,{children:[g,` `,g===1?`error`:`errors`]})]})]}),(0,h.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,d.length,`)`]})]}),d.length===0?(0,h.jsx)(cS,{icon:Ub,title:`All concepts and files conform`,hint:`No lint or specification issues found in this project.`,className:`py-10`}):(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:[...l.errors,...l.warnings,...l.infos].map((t,n)=>{let r=t.path.endsWith(`.md`)?`/p/${encodeURIComponent(e)}/c/${t.path.slice(0,-3)}`:`/p/${encodeURIComponent(e)}/f/${t.path}`,i=Cx,a=`text-sky-500 bg-sky-500/10 ring-sky-500/20`;return t.severity===`error`?(i=Vb,a=`text-rose-600 dark:text-rose-400 bg-rose-500/10 ring-rose-500/20`):t.severity===`warning`&&(i=rS,a=`text-amber-600 dark:text-amber-400 bg-amber-500/10 ring-amber-500/20`),(0,h.jsx)(`div`,{className:`flex flex-col gap-2 p-4 sm:flex-row sm:items-center sm:justify-between`,children:(0,h.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,h.jsx)(`div`,{className:X(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full ring-1`,a),children:(0,h.jsx)(i,{size:14})}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-mono text-xs font-semibold text-fg`,children:t.code}),(0,h.jsx)(`span`,{className:`text-xs text-muted`,children:`on`}),(0,h.jsx)($g,{to:r,className:`font-mono text-xs text-accent-500 hover:text-accent-600 transition-colors truncate max-w-sm`,title:`Navigate to ${t.path}`,children:t.path})]}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted break-words`,children:t.message})]})]})},n)})})]}),(0,h.jsxs)(`section`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border pb-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`Stale Concepts`}),f.length>0&&(0,h.jsx)($D,{})]}),(0,h.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,f.length,`)`]})]}),f.length===0?(0,h.jsx)(cS,{icon:qb,title:`No stale concepts`,hint:`All concepts are within their defined freshness interval.`,className:`py-10`}):(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:f.map(t=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e)}/c/${t.id}`,className:`group flex flex-col gap-3 p-4 transition-colors hover:bg-surface-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,h.jsx)(vD,{type:t.type,size:18}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500 truncate`,children:t.title}),(0,h.jsx)(`span`,{className:`font-mono text-xs text-subtle shrink-0`,children:t.id})]}),t.description&&(0,h.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-xs text-muted`,children:t.description})]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-end sm:self-center`,children:[(0,h.jsx)(ZD,{status:t.status}),(0,h.jsx)(QD,{tier:t.trustTier}),(0,h.jsx)($D,{})]})]},t.id))})]}),(0,h.jsxs)(`section`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border pb-3`,children:[(0,h.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,h.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`Unverified Concepts`})}),(0,h.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,p.length,`)`]})]}),p.length===0?(0,h.jsx)(cS,{icon:Ub,title:`All concepts verified`,hint:`Every concept has been machine-confirmed or human-reviewed.`,className:`py-10`}):(0,h.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border bg-surface divide-y divide-border`,children:p.map(t=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e)}/c/${t.id}`,className:`group flex flex-col gap-3 p-4 transition-colors hover:bg-surface-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,h.jsx)(vD,{type:t.type,size:18}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500 truncate`,children:t.title}),(0,h.jsx)(`span`,{className:`font-mono text-xs text-subtle shrink-0`,children:t.id})]}),t.description&&(0,h.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-xs text-muted`,children:t.description})]})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-end sm:self-center`,children:[(0,h.jsx)(ZD,{status:t.status}),(0,h.jsx)(QD,{tier:t.trustTier}),t.stale&&(0,h.jsx)($D,{})]})]},t.id))})]})]})]})}function Jj(){return(0,h.jsxs)(fS,{title:`Page not found`,className:`flex min-h-[70vh] flex-col items-center justify-center p-8 text-center`,children:[(0,h.jsx)(`div`,{className:`text-8xl font-black tracking-tighter bg-gradient-to-br from-accent-500 via-accent-400 to-glow bg-clip-text text-transparent select-none`,children:`404`}),(0,h.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold tracking-tight text-fg`,children:`Nothing here`}),(0,h.jsx)(`p`,{className:`mt-2 text-sm text-muted max-w-sm`,children:`The page you're looking for doesn't exist, has been moved, or you don't have access to it.`}),(0,h.jsx)($g,{to:`/`,className:`mt-6 inline-flex items-center justify-center rounded-lg bg-surface-2 px-4 py-2 text-xs font-medium text-fg ring-1 ring-border hover:bg-surface hover:ring-border-strong transition-colors`,children:`Back to projects`})]})}function Yj({label:e,icon:t,value:n,tone:r=`default`,to:i,children:a,className:o}){let s=r===`warn`,c=X(`rounded-xl border p-4 transition-all`,s?`border-orange-500/30 bg-orange-500/5 dark:border-orange-500/20`:`border-border bg-surface`,i&&`block hover:-translate-y-px hover:border-border-strong`,o),l=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted`,children:e}),t&&(0,h.jsx)(t,{size:16,className:s?`text-orange-600 dark:text-orange-400`:`text-muted shrink-0`})]}),n!==void 0&&(0,h.jsx)(`div`,{className:X(`mt-2 text-2xl font-semibold tracking-tight`,s?`text-orange-600 dark:text-orange-400`:`text-fg`),children:n}),a&&(0,h.jsx)(`div`,{className:`mt-3`,children:a})]});return i?(0,h.jsx)($g,{to:i,className:c,children:l}):(0,h.jsx)(`div`,{className:c,children:l})}function Xj(){let e=Nh().project??``,t=ED(),[n,r]=(0,m.useState)(!1),{data:i,isLoading:a,isError:o,error:s,refetch:c}=O_(e),l=A_(e,`overview`),u=k_(e,``),d=M_(e,{limit:8}),f=(0,m.useMemo)(()=>u.data?u.data.filter(e=>e.kind===`directory`).sort((e,t)=>e.path.localeCompare(t.path)):[],[u.data]),p=(0,m.useMemo)(()=>i?.typeCounts?Object.entries(i.typeCounts).sort(([,e],[,t])=>t-e).slice(0,5):[],[i?.typeCounts]),g=(0,m.useMemo)(()=>{if(!i?.trustTierCounts)return{total:0,human:0,machine:0,unverified:0,proposed:0};let e=i.trustTierCounts[`human-reviewed`]??0,t=i.trustTierCounts[`machine-confirmed`]??0,n=i.trustTierCounts.unverified??0,r=i.trustTierCounts.proposed??0;return{total:e+t+n+r,human:e,machine:t,unverified:n,proposed:r}},[i?.trustTierCounts]);return a?(0,h.jsxs)(fS,{title:e||`Project`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(Q,{className:`h-9 w-64 rounded-lg`}),(0,h.jsx)(Q,{className:`h-5 w-96 rounded-md`})]}),(0,h.jsx)(`div`,{className:`mt-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,h.jsx)(Q,{className:`h-32 rounded-xl`},t))}),(0,h.jsxs)(`div`,{className:`mt-8 grid grid-cols-1 gap-8 lg:grid-cols-12`,children:[(0,h.jsx)(`div`,{className:`lg:col-span-7 xl:col-span-8`,children:(0,h.jsx)(Q,{className:`h-96 rounded-xl`})}),(0,h.jsxs)(`div`,{className:`lg:col-span-5 xl:col-span-4 space-y-6`,children:[(0,h.jsx)(Q,{className:`h-64 rounded-xl`}),(0,h.jsx)(Q,{className:`h-48 rounded-xl`})]})]})]}):o?(0,h.jsx)(fS,{title:e||`Project`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:s,onRetry:()=>void c()})}):i?(0,h.jsxs)(fS,{title:i.title,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 border-b border-border pb-6 sm:flex-row sm:items-start`,children:[(0,h.jsxs)(`div`,{className:`max-w-3xl`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-fg`,children:i.title}),(0,h.jsx)(`span`,{className:`font-mono text-xs text-subtle`,children:i.project})]}),i.description&&(0,h.jsx)(`p`,{className:`mt-2 text-base text-muted`,children:i.description}),i.repositories&&i.repositories.length>0&&(0,h.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:i.repositories.map(e=>{let t=null;try{let n=new URL(`https://${e}`);n.protocol===`https:`&&n.hostname&&(t=n.href)}catch{}if(!t)return null;let n=e.indexOf(`/`),r=n===-1?e:e.slice(n+1);return(0,h.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface-2 px-2 py-1 font-mono text-xs text-muted transition-colors hover:border-border-strong hover:text-fg`,title:`View ${e}`,children:[(0,h.jsx)(hx,{size:13,className:`shrink-0 text-subtle`}),(0,h.jsx)(`span`,{children:r})]},e)})})]}),(0,h.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,h.jsxs)(`button`,{type:`button`,onClick:async()=>{try{r(!0),await w_(e)}catch{}finally{r(!1)}},disabled:n,className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-2 text-sm font-medium text-fg shadow-xs transition-colors hover:bg-surface-2 hover:border-border-strong disabled:opacity-50 focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)($b,{size:15,className:`shrink-0 text-muted`}),(0,h.jsx)(`span`,{children:n?`Exporting…`:`Export .tar.gz`})]})})]}),(0,h.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,h.jsx)(Yj,{label:`Concepts`,icon:sx,value:i.conceptCount,to:`/search?project=${encodeURIComponent(e)}`}),(0,h.jsx)(Yj,{label:`Stale`,icon:qb,value:i.staleCount,tone:i.staleCount>0?`warn`:`default`,to:`/p/${encodeURIComponent(e)}/health`}),(0,h.jsx)(Yj,{label:`Trust`,icon:Yx,children:(0,h.jsxs)(`div`,{className:`mt-1`,children:[(0,h.jsx)(`div`,{className:`flex h-2 w-full overflow-hidden rounded-full bg-surface-2`,children:g.total>0?(0,h.jsxs)(h.Fragment,{children:[g.human>0&&(0,h.jsx)(`div`,{style:{width:`${g.human/g.total*100}%`},className:`bg-emerald-500`,title:`Human-reviewed: ${g.human}`}),g.machine>0&&(0,h.jsx)(`div`,{style:{width:`${g.machine/g.total*100}%`},className:`bg-sky-500`,title:`Machine-confirmed: ${g.machine}`}),g.unverified>0&&(0,h.jsx)(`div`,{style:{width:`${g.unverified/g.total*100}%`},className:`bg-zinc-400 dark:bg-zinc-600`,title:`Unverified: ${g.unverified}`}),g.proposed>0&&(0,h.jsx)(`div`,{style:{width:`${g.proposed/g.total*100}%`},className:`bg-violet-500`,title:`Proposed: ${g.proposed}`})]}):(0,h.jsx)(`div`,{className:`w-full bg-surface-2`})}),(0,h.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-[11px] text-muted`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),(0,h.jsxs)(`span`,{children:[g.human,` human`]})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-sky-500`}),(0,h.jsxs)(`span`,{children:[g.machine,` auto`]})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600`}),(0,h.jsxs)(`span`,{children:[g.unverified,` unverified`]})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-violet-500`}),(0,h.jsxs)(`span`,{children:[g.proposed,` proposed`]})]})]})]})}),(0,h.jsx)(Yj,{label:`Types`,icon:jb,children:p.length>0?(0,h.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:p.map(([t,n])=>(0,h.jsxs)($g,{to:`/search?project=${encodeURIComponent(e)}&type=${encodeURIComponent(t)}`,className:`inline-flex items-center gap-1 rounded-md bg-surface-2 px-1.5 py-0.5 text-xs text-muted transition-colors hover:bg-surface hover:text-fg ring-1 ring-border/50`,children:[(0,h.jsx)(vD,{type:t,size:12}),(0,h.jsx)(`span`,{children:t}),(0,h.jsx)(`span`,{className:`font-mono text-[10px] text-subtle`,children:n})]},t))}):(0,h.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No types recorded`})})]}),(0,h.jsxs)(`div`,{className:`mt-8 grid grid-cols-1 gap-8 lg:grid-cols-12`,children:[(0,h.jsxs)(`div`,{className:`lg:col-span-7 xl:col-span-8`,children:[l.isLoading&&(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-6 space-y-4`,children:[(0,h.jsx)(Q,{className:`h-7 w-48 rounded-md`}),(0,h.jsx)(Q,{className:`h-4 w-full`}),(0,h.jsx)(Q,{className:`h-4 w-5/6`}),(0,h.jsx)(Q,{className:`h-4 w-4/6`})]}),l.data&&(0,h.jsx)(`div`,{className:`rounded-xl border border-border bg-surface p-6 sm:p-8`,children:(0,h.jsx)(Vj,{project:e,concept:l.data})})]}),(0,h.jsxs)(`div`,{className:`space-y-6 lg:col-span-5 xl:col-span-4`,children:[(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-5`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between pb-3 border-b border-border`,children:[(0,h.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold tracking-tight text-fg`,children:[(0,h.jsx)(Vx,{size:16,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Recent activity`})]}),(0,h.jsx)($g,{to:`/p/${encodeURIComponent(e)}/activity`,className:`text-xs font-medium text-accent-500 transition-colors hover:text-accent-600`,children:`View all`})]}),(0,h.jsxs)(`div`,{className:`mt-3 divide-y divide-border/50`,children:[d.isLoading&&(0,h.jsx)(`div`,{className:`space-y-3 py-2`,children:Array.from({length:4}).map((e,t)=>(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(Q,{className:`h-6 w-6 rounded-full shrink-0`}),(0,h.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,h.jsx)(Q,{className:`h-3.5 w-3/4`}),(0,h.jsx)(Q,{className:`h-3 w-1/2`})]})]},t))}),d.data&&d.data.length>0?d.data.map(e=>{let t=e.actor.startsWith(`human:`)?e.actor.slice(6):e.actor;return(0,h.jsxs)(`div`,{className:`flex items-start gap-3 py-2.5 first:pt-1 last:pb-1`,children:[(0,h.jsx)(VD,{actor:e.actor,size:22,className:`mt-0.5`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`truncate text-xs font-medium text-fg`,title:e.subject,children:e.subject}),(0,h.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-muted`,children:[(0,h.jsx)(`span`,{className:`truncate font-mono text-subtle max-w-[120px]`,children:t}),(0,h.jsx)(`span`,{children:`·`}),(0,h.jsx)(`span`,{title:ND(e.at),children:MD(e.at)})]})]})]},e.sha)}):!d.isLoading&&(0,h.jsx)(`p`,{className:`py-4 text-center text-xs text-muted`,children:`No recent activity`})]})]}),(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-5`,children:[(0,h.jsx)(`div`,{className:`pb-3 border-b border-border`,children:(0,h.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold tracking-tight text-fg`,children:[(0,h.jsx)(px,{size:16,className:`text-muted`}),(0,h.jsx)(`span`,{children:`Browse`})]})}),(0,h.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[u.isLoading&&(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Q,{className:`h-10 w-full rounded-lg`}),(0,h.jsx)(Q,{className:`h-10 w-full rounded-lg`}),(0,h.jsx)(Q,{className:`h-10 w-full rounded-lg`})]}),f.length>0?f.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>t.reveal(e.path),className:`group flex w-full items-center justify-between rounded-lg border border-border bg-surface-2/50 p-2.5 text-left transition-colors hover:border-border-strong hover:bg-surface-2 focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,h.jsx)(px,{size:16,className:`shrink-0 text-accent-500`}),(0,h.jsx)(`span`,{className:`truncate text-xs font-medium text-fg transition-colors group-hover:text-accent-500`,children:e.path})]}),(0,h.jsxs)(`span`,{className:`ml-2 shrink-0 text-[11px] text-muted`,children:[e.conceptCount,` `,e.conceptCount===1?`concept`:`concepts`]})]},e.path)):!u.isLoading&&(0,h.jsx)(`p`,{className:`py-4 text-center text-xs text-muted`,children:`No directories`})]})]})]})]})]}):null}function Zj(){let{data:e,isLoading:t,isError:n,error:r,refetch:i}=D_(),[a,o]=(0,m.useState)(``),s=(0,m.useMemo)(()=>e?e.reduce((e,t)=>e+t.conceptCount,0):0,[e]),c=(0,m.useMemo)(()=>{if(!e)return[];let t=a.trim().toLowerCase();return[...t?e.filter(e=>e.title.toLowerCase().includes(t)||e.project.toLowerCase().includes(t)||!!e.description?.toLowerCase().includes(t)):e].sort((e,t)=>!e.updatedAt&&!t.updatedAt?0:e.updatedAt?t.updatedAt?new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime():-1:1)},[e,a]);return t?(0,h.jsxs)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(Q,{className:`h-9 w-64 rounded-lg`}),(0,h.jsx)(Q,{className:`h-5 w-48 rounded-md`})]}),(0,h.jsx)(`div`,{className:`mt-6`,children:(0,h.jsx)(Q,{className:`h-10 w-full max-w-sm rounded-lg`})}),(0,h.jsx)(`div`,{className:`mt-8 grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,h.jsxs)(`div`,{className:`flex flex-col justify-between rounded-xl border border-border bg-surface p-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,h.jsx)(Q,{className:`h-5 w-32`}),(0,h.jsx)(Q,{className:`h-4 w-20`})]}),(0,h.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,h.jsx)(Q,{className:`h-4 w-full`}),(0,h.jsx)(Q,{className:`h-4 w-3/4`})]})]}),(0,h.jsxs)(`div`,{className:`mt-6 border-t border-border pt-4 flex items-center justify-between`,children:[(0,h.jsx)(Q,{className:`h-4 w-28`}),(0,h.jsx)(Q,{className:`h-4 w-20`})]})]},t))})]}):n?(0,h.jsx)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:(0,h.jsx)(lS,{error:r,onRetry:()=>void i()})}):!e||e.length===0?(0,h.jsxs)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsx)(`h1`,{className:`bg-gradient-to-r from-fg to-muted bg-clip-text text-3xl font-semibold tracking-tight text-transparent`,children:`Knowledge base`}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:`0 projects · 0 concepts`})]}),(0,h.jsx)(cS,{icon:lx,title:`No projects yet`,hint:`Agents create them with create_project, or POST /api/v1/projects.`,className:`mt-6 py-16`})]}):(0,h.jsxs)(fS,{title:`Projects`,className:`mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`bg-gradient-to-r from-fg to-muted bg-clip-text text-3xl font-semibold tracking-tight text-transparent`,children:`Knowledge base`}),(0,h.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[e.length,` `,e.length===1?`project`:`projects`,` · `,s,` `,s===1?`concept`:`concepts`]})]}),(0,h.jsx)(`div`,{className:`mt-6`,children:(0,h.jsxs)(`div`,{className:`relative max-w-sm`,children:[(0,h.jsx)(qx,{size:16,className:`absolute left-3 top-1/2 -translate-y-1/2 text-subtle`}),(0,h.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Filter projects…`,className:`w-full rounded-lg border border-border bg-surface py-2 pl-9 pr-3 text-sm text-fg placeholder:text-muted transition-colors focus-visible:outline-2 outline-accent-500`})]})}),c.length===0?(0,h.jsx)(cS,{icon:qx,title:`No matching projects`,hint:`No projects match "${a}". Try adjusting your filter.`,className:`mt-8 py-12`}):(0,h.jsx)(`div`,{className:`mt-8 grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:c.map(e=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e.project)}`,className:`group flex flex-col justify-between rounded-xl border border-border bg-surface p-5 transition-all duration-150 hover:-translate-y-px hover:border-border-strong hover:shadow-[0_8px_30px_-12px_rgb(139_92_246/0.35)]`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,h.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500 truncate`,children:e.title}),(0,h.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-subtle`,children:e.project})]}),(0,h.jsx)(`p`,{className:`mt-2 line-clamp-2 text-sm text-muted min-h-[2.5rem]`,children:e.description||`No description provided.`})]}),(0,h.jsxs)(`div`,{className:`mt-5 border-t border-border pt-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,h.jsx)(sx,{size:14,className:`shrink-0 text-subtle`}),(0,h.jsx)(`span`,{children:e.conceptCount})]}),(0,h.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5`,e.staleCount>0?`font-medium text-orange-600 dark:text-orange-400`:`text-muted`),children:[(0,h.jsx)(qb,{size:14,className:`shrink-0`}),(0,h.jsxs)(`span`,{children:[e.staleCount,` stale`]})]}),(0,h.jsx)(`span`,{className:`ml-auto text-subtle truncate`,children:e.updatedAt?`Updated ${MD(e.updatedAt)}`:`Never updated`})]}),e.repositories&&e.repositories.length>0&&(0,h.jsx)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-1.5`,children:e.repositories.map(e=>{let t=e.indexOf(`/`),n=t===-1?e:e.slice(t+1);return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted ring-1 ring-border/50`,title:e,children:[(0,h.jsx)(hx,{size:11,className:`shrink-0 text-subtle`}),(0,h.jsx)(`span`,{className:`truncate max-w-[140px]`,children:n})]},e)})})]})]},e.project))})]})}function Qj(){let[e,t]=r_(),n=e.get(`q`)??``,r=e.get(`project`)??``,i=e.get(`type`)??``,a=e.getAll(`tag`),o=e.get(`status`)??``,s=e.get(`trustTier`)??``,c=e.get(`stale`)??``,[l,u]=(0,m.useState)(``),{data:d}=D_(),{data:f}=O_(r),p=(0,m.useMemo)(()=>{if(r&&f?.typeCounts){let e=Object.keys(f.typeCounts);if(e.length>0)return e}return hD},[r,f?.typeCounts]),{data:g,isLoading:_,isError:v,error:y,refetch:b}=P_((0,m.useMemo)(()=>{let e={limit:50};return n.trim()&&(e.q=n.trim()),r&&(e.project=r),i&&(e.type=i),a.length>0&&(e.tag=a),o&&(e.status=o),s&&(e.trustTier=s),c===`true`&&(e.stale=!0),c===`false`&&(e.stale=!1),e},[n,r,i,a,o,s,c])),x=(n,r)=>{let i=new URLSearchParams(e);r?i.set(n,r):i.delete(n),t(i,{replace:!0})},S=n=>{let r=n.trim();if(!r||a.includes(r))return;let i=new URLSearchParams(e);i.append(`tag`,r),t(i,{replace:!0}),u(``)},C=n=>{let r=new URLSearchParams(e);r.delete(`tag`);for(let e of a)e!==n&&r.append(`tag`,e);t(r,{replace:!0})},w=e=>{e.preventDefault(),S(l)},T=!!(r||i||a.length>0||o||s||c);return(0,h.jsxs)(fS,{title:`Search`,className:`mx-auto max-w-6xl px-4 py-8 sm:px-6 lg:px-8`,children:[(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg`,children:`Search Knowledge Base`}),(0,h.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:`Find concepts, decisions, conventions, and architectural records across projects.`})]}),(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(qx,{size:20,className:`absolute left-4 top-1/2 -translate-y-1/2 text-subtle`}),(0,h.jsx)(`input`,{type:`text`,value:n,onChange:e=>x(`q`,e.target.value),placeholder:`Search concepts by keyword, text, title…`,className:`w-full rounded-xl border border-border bg-surface py-3.5 pl-12 pr-4 text-base text-fg shadow-xs placeholder:text-muted transition-colors focus-visible:outline-2 outline-accent-500`})]})]}),(0,h.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-2.5 rounded-xl border border-border bg-surface p-3 sm:gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,h.jsx)(Zx,{size:14,className:`text-subtle`}),(0,h.jsx)(`span`,{children:`Filter:`})]}),(0,h.jsxs)(`select`,{value:r,onChange:e=>x(`project`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`All projects`}),d?.map(e=>(0,h.jsx)(`option`,{value:e.project,children:e.title},e.project))]}),(0,h.jsxs)(`select`,{value:i,onChange:e=>x(`type`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`All types`}),p.map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))]}),(0,h.jsxs)(`select`,{value:o,onChange:e=>x(`status`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`Any status`}),(0,h.jsx)(`option`,{value:`draft`,children:`Draft`}),(0,h.jsx)(`option`,{value:`stable`,children:`Stable`}),(0,h.jsx)(`option`,{value:`deprecated`,children:`Deprecated`})]}),(0,h.jsxs)(`select`,{value:s,onChange:e=>x(`trustTier`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`Any trust`}),(0,h.jsx)(`option`,{value:`human-reviewed`,children:`Human-reviewed`}),(0,h.jsx)(`option`,{value:`machine-confirmed`,children:`Machine-confirmed`}),(0,h.jsx)(`option`,{value:`unverified`,children:`Unverified`}),(0,h.jsx)(`option`,{value:`proposed`,children:`Proposed`})]}),(0,h.jsxs)(`select`,{value:c,onChange:e=>x(`stale`,e.target.value),className:`rounded-lg border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-fg transition-colors hover:border-border-strong focus-visible:outline-2 outline-accent-500`,children:[(0,h.jsx)(`option`,{value:``,children:`Any staleness`}),(0,h.jsx)(`option`,{value:`true`,children:`Stale`}),(0,h.jsx)(`option`,{value:`false`,children:`Fresh`})]}),(0,h.jsx)(`form`,{onSubmit:w,className:`flex items-center`,children:(0,h.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`+ tag…`,className:`w-20 rounded-lg border border-border bg-surface-2 px-2 py-1.5 text-xs text-fg placeholder:text-subtle transition-colors focus-visible:outline-2 outline-accent-500`})}),T&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams;n&&e.set(`q`,n),t(e,{replace:!0})},className:`ml-auto text-xs font-medium text-accent-500 hover:text-accent-600 transition-colors`,children:`Clear filters`})]}),a.length>0&&(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,h.jsxs)(`span`,{className:`text-xs text-muted flex items-center gap-1`,children:[(0,h.jsx)(tS,{size:12,className:`text-subtle`}),(0,h.jsx)(`span`,{children:`Tags:`})]}),a.map(e=>(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-accent-500/20 bg-accent-500/10 px-2 py-0.5 font-mono text-xs text-accent-600 dark:text-accent-400`,children:[(0,h.jsxs)(`span`,{children:[`#`,e]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>C(e),className:`hover:text-fg transition-colors`,title:`Remove tag ${e}`,children:(0,h.jsx)(sS,{size:12})})]},e))]}),(0,h.jsxs)(`div`,{className:`mt-8`,children:[_&&(0,h.jsx)(`div`,{className:`space-y-4`,children:Array.from({length:4}).map((e,t)=>(0,h.jsxs)(`div`,{className:`rounded-xl border border-border bg-surface p-5 space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(Q,{className:`h-5 w-40`}),(0,h.jsx)(Q,{className:`h-5 w-20`})]}),(0,h.jsx)(Q,{className:`h-5 w-24`})]}),(0,h.jsx)(Q,{className:`h-4 w-full`}),(0,h.jsx)(Q,{className:`h-4 w-3/4`})]},t))}),v&&(0,h.jsx)(lS,{error:y,onRetry:()=>void b()}),!_&&!v&&g&&g.length===0&&(0,h.jsx)(cS,{icon:qx,title:`No matches`,hint:`Try adjusting your keywords, expanding your project scope, or clearing filters.`,className:`py-16`}),!_&&!v&&g&&g.length>0&&(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`div`,{className:`flex items-center justify-between text-xs text-muted pb-1`,children:(0,h.jsxs)(`span`,{children:[`Found `,g.length,` `,g.length===1?`result`:`results`]})}),g.map(e=>(0,h.jsxs)($g,{to:`/p/${encodeURIComponent(e.project)}/c/${e.id}`,className:`group block rounded-xl border border-border bg-surface p-5 transition-all duration-150 hover:-translate-y-px hover:border-border-strong hover:shadow-[0_8px_30px_-12px_rgb(139_92_246/0.35)]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-baseline sm:justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg transition-colors group-hover:text-accent-500`,children:(0,h.jsx)(mD,{text:e.title,query:n})}),(0,h.jsx)(eO,{type:e.type}),(0,h.jsxs)(`span`,{className:`font-mono text-xs text-subtle`,children:[e.project,`/`,e.id]})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,h.jsx)(ZD,{status:e.status}),(0,h.jsx)(QD,{tier:e.trustTier}),e.stale&&(0,h.jsx)($D,{})]})]}),e.snippet?(0,h.jsx)(`p`,{className:`mt-2.5 text-sm text-muted break-words line-clamp-2`,children:(0,h.jsx)(mD,{text:e.snippet,query:n})}):e.description&&(0,h.jsx)(`p`,{className:`mt-2.5 text-sm text-muted break-words line-clamp-2`,children:(0,h.jsx)(mD,{text:e.description,query:n})}),e.tags&&e.tags.length>0&&(0,h.jsx)(`div`,{className:`mt-3.5 flex flex-wrap items-center gap-1.5 pt-1`,children:e.tags.map(e=>(0,h.jsxs)(`span`,{className:`rounded-md bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted ring-1 ring-border/50`,children:[`#`,e]},e))})]},`${e.project}/${e.id}`))]})]})]})}var $j=Xg([{path:`/callback`,element:(0,h.jsx)(YD,{})},{element:(0,h.jsx)(_S,{}),children:[{element:(0,h.jsx)(KD,{}),children:[{index:!0,element:(0,h.jsx)(Zj,{})},{path:`search`,element:(0,h.jsx)(Qj,{})},{path:`p/:project`,element:(0,h.jsx)(Xj,{})},{path:`p/:project/activity`,element:(0,h.jsx)(JD,{})},{path:`p/:project/health`,element:(0,h.jsx)(qj,{})},{path:`p/:project/c/*`,element:(0,h.jsx)(Uj,{})},{path:`p/:project/f/*`,element:(0,h.jsx)(Kj,{})},{path:`*`,element:(0,h.jsx)(Jj,{})}]}]}],{basename:`/ui`});ib();var eM=document.getElementById(`root`);eM&&(0,Tg.createRoot)(eM).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:T_,children:(0,h.jsx)(Jy,{children:(0,h.jsx)(cu,{reducedMotion:`user`,children:(0,h.jsx)(l_,{router:$j})})})})}));export{Ag as n,s as r,Mk as t};