@inkeep/open-knowledge 0.0.0-dev-20260423193928 → 0.0.0-dev-20260423224129
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.
- package/dist/cli.mjs +8 -8
- package/dist/constants-p2mrQUZK.mjs +2 -0
- package/dist/index.d.mts +171 -1
- package/dist/index.mjs +1 -1
- package/dist/init-DJzYkC45.mjs +1 -0
- package/dist/{init-Cr5zNjLr.mjs → init-DsaVseaZ.mjs} +2 -2
- package/dist/init-P1I9tsCc.mjs +1 -0
- package/dist/init-RBK7HHVy.mjs +5 -0
- package/dist/loader-DzbVFAz5.mjs +1 -0
- package/dist/{loader-BjvYg6bR.mjs → loader-lj28Sw6t.mjs} +2 -2
- package/dist/paths-CJMOZlvG.mjs +1 -0
- package/dist/{paths-Dcbxj9qp.mjs → paths-DreD7ab4.mjs} +2 -2
- package/dist/{preview-B7p7jyyl.mjs → preview-B55OlWJc.mjs} +2 -2
- package/dist/preview-CfQP5PHw.mjs +1 -0
- package/dist/public/assets/{GraphPanel-D2JBM6nD.js → GraphPanel-nbYklZ9C.js} +2 -2
- package/dist/public/assets/McpConsentDialogBody-BTLTOjWM.js +1 -0
- package/dist/public/assets/SourceEditor-CEqBKP5f.js +3 -0
- package/dist/public/assets/button-BuHZQnlF.js +1 -0
- package/dist/public/assets/clipboard-ZQ-AEssh.js +36 -0
- package/dist/public/assets/dialog-C2kd-BJI.js +45 -0
- package/dist/public/assets/{dist-B2YW_ZWG.js → dist-1RA1Ivz5.js} +1 -1
- package/dist/public/assets/{dist-k7VFO_3K.js → dist-B90Tbt-G.js} +1 -1
- package/dist/public/assets/{dist-CQbn9Fxc.js → dist-BJa-wTjR.js} +1 -1
- package/dist/public/assets/{dist-X189qk_S.js → dist-CsuK1sJe.js} +1 -1
- package/dist/public/assets/{dist-Dm75HY2n.js → dist-D96Jocj9.js} +1 -1
- package/dist/public/assets/{dist-Bx72hMUu.js → dist-DQmXHI9Z.js} +1 -1
- package/dist/public/assets/{dist-DVEMi7bH.js → dist-yRCb9u34.js} +1 -1
- package/dist/public/assets/index-CGTgnYOo.css +1 -0
- package/dist/public/assets/index-DUIfxmm6.js +21 -0
- package/dist/public/assets/panel-CnHxXki4.js +240 -0
- package/dist/public/assets/toggle-group-BNTPJpXY.js +1 -0
- package/dist/public/index.html +11 -9
- package/dist/server-lock-BI-SqMWk.mjs +2 -0
- package/dist/server-lock-zOHsiWX-.mjs +1 -0
- package/dist/src-BFFb00v4.mjs +1 -0
- package/dist/src-DHnGx64r.mjs +1 -0
- package/dist/{src-skP-DoiW.mjs → src-rqPIkHTi.mjs} +3 -3
- package/dist/start-B6-KWyei.mjs +1 -0
- package/dist/{start-zmc8Anu_.mjs → start-BufFj0pL.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-oa8rklCf.mjs +0 -2
- package/dist/init-1srg7AC9.mjs +0 -5
- package/dist/init-B7uATxQD.mjs +0 -1
- package/dist/init-DSYBjbGB.mjs +0 -1
- package/dist/loader-CVOTHZaY.mjs +0 -1
- package/dist/paths-5vJ24bHl.mjs +0 -1
- package/dist/preview-CFVO89Px.mjs +0 -1
- package/dist/public/assets/SourceEditor-BKyWQ7mW.js +0 -3
- package/dist/public/assets/clipboard-CdKkyvy1.js +0 -80
- package/dist/public/assets/index-Bfb7OhfE.js +0 -21
- package/dist/public/assets/index-DHlHPMwL.css +0 -1
- package/dist/public/assets/panel-DTlG8EiB.js +0 -240
- package/dist/public/assets/toggle-group-BFNw1DkB.js +0 -1
- package/dist/server-lock-B4frNnOB.mjs +0 -2
- package/dist/server-lock-CPmOhzSz.mjs +0 -1
- package/dist/src-CQRey-Fm.mjs +0 -1
- package/dist/src-DB3pnkMU.mjs +0 -1
- package/dist/start-CsGsfw3C.mjs +0 -1
- /package/dist/public/assets/{go-IODVg4Ok.js → go-C_J4XPHz.js} +0 -0
- /package/dist/public/assets/{shell-COsTRxlr.js → shell-Cp2AENBi.js} +0 -0
- /package/dist/public/assets/{w3c-keyname-DLDSJn4E.js → w3c-keyname-DGDXsZN5.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,O as t,S as n,T as r,_ as i,a,b as o,c as s,f as c,g as l,i as u,l as d,n as f,o as p,p as m,r as h,s as g,u as _,w as v,x as y,y as b}from"./button-BuHZQnlF.js";import{$ as x,Bt as S,Gt as C,Ht as w,Kt as T,Lt as E,Vt as D,Wt as O,qt as k,zt as A}from"./panel-CnHxXki4.js";var j=y(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),M=y(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),N=y(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),P=y(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ee=t(e(),1),F=t(r(),1),I=v(),te=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),ne=`VisuallyHidden`,L=F.forwardRef((e,t)=>(0,I.jsx)(m.span,{...e,ref:t,style:{...te,...e.style}}));L.displayName=ne;var R=L;function z(e){let t=e+`CollectionProvider`,[n,r]=c(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=F.useRef(null),a=F.useRef(new Map).current;return(0,I.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,u=l(s),d=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(u,{ref:b(t,a(s,n).collectionRef),children:r})});d.displayName=s;let f=e+`CollectionItemSlot`,p=`data-radix-collection-item`,m=l(f),h=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=b(t,o),c=a(f,n);return F.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,I.jsx)(m,{[p]:``,ref:s,children:r})});h.displayName=f;function g(t){let n=a(e+`CollectionConsumer`,t);return F.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${p}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:d,ItemSlot:h},g,r]}var re=F.createContext(void 0);function B(e){let t=F.useContext(re);return e||t||`ltr`}function ie(e){let[t,n]=F.useState(void 0);return d(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var V=typeof document<`u`?F.useLayoutEffect:function(){};function H(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!H(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!H(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ae(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oe(e,t){let n=ae(e);return Math.round(t*n)/n}function U(e){let t=F.useRef(e);return V(()=>{t.current=e}),t}function se(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=F.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=F.useState(r);H(f,r)||p(r);let[m,h]=F.useState(null),[g,_]=F.useState(null),v=F.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),y=F.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),b=a||m,x=o||g,C=F.useRef(null),w=F.useRef(null),T=F.useRef(u),E=c!=null,D=U(c),O=U(i),k=U(l),A=F.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),S(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!H(T.current,t)&&(T.current=t,ee.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);V(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=F.useRef(!1);V(()=>(j.current=!0,()=>{j.current=!1}),[]),V(()=>{if(b&&(C.current=b),x&&(w.current=x),b&&x){if(D.current)return D.current(b,x,A);A()}},[b,x,A,D,E]);let M=F.useMemo(()=>({reference:C,floating:w,setReference:v,setFloating:y}),[v,y]),N=F.useMemo(()=>({reference:b,floating:x}),[b,x]),P=F.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=oe(N.floating,u.x),r=oe(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ae(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return F.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var ce=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:E({element:r.current,padding:i}).fn(n):r?E({element:r,padding:i}).fn(n):{}}}},le=(e,t)=>{let n=C(e);return{name:n.name,fn:n.fn,options:[e,t]}},ue=(e,t)=>{let n=T(e);return{name:n.name,fn:n.fn,options:[e,t]}},de=(e,t)=>({fn:O(e).fn,options:[e,t]}),fe=(e,t)=>{let n=D(e);return{name:n.name,fn:n.fn,options:[e,t]}},pe=(e,t)=>{let n=k(e);return{name:n.name,fn:n.fn,options:[e,t]}},me=(e,t)=>{let n=w(e);return{name:n.name,fn:n.fn,options:[e,t]}},he=(e,t)=>{let n=ce(e);return{name:n.name,fn:n.fn,options:[e,t]}},ge=`Arrow`,_e=F.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,I.jsx)(m.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,I.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});_e.displayName=ge;var ve=_e,ye=`Popper`,[be,xe]=c(ye),[Se,Ce]=be(ye),we=e=>{let{__scopePopper:t,children:n}=e,[r,i]=F.useState(null);return(0,I.jsx)(Se,{scope:t,anchor:r,onAnchorChange:i,children:n})};we.displayName=ye;var Te=`PopperAnchor`,Ee=F.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Ce(Te,n),o=F.useRef(null),s=b(t,o),c=F.useRef(null);return F.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,I.jsx)(m.div,{...i,ref:s})});Ee.displayName=Te;var W=`PopperContent`,[De,Oe]=be(W),ke=F.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:o=`center`,alignOffset:s=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:p=`partial`,hideWhenDetached:h=!1,updatePositionStrategy:g=`optimized`,onPlaced:_,...v}=e,y=Ce(W,n),[x,S]=F.useState(null),C=b(t,e=>S(e)),[w,T]=F.useState(null),E=ie(w),D=E?.width??0,O=E?.height??0,k=r+(o===`center`?``:`-`+o),j=typeof f==`number`?f:{top:0,right:0,bottom:0,left:0,...f},M=Array.isArray(u)?u:[u],N=M.length>0,P={padding:j,boundary:M.filter(Ne),altBoundary:N},{refs:ee,floatingStyles:te,placement:ne,isPositioned:L,middlewareData:R}=se({strategy:`fixed`,placement:k,whileElementsMounted:(...e)=>A(...e,{animationFrame:g===`always`}),elements:{reference:y.anchor},middleware:[le({mainAxis:i+O,alignmentAxis:s}),l&&ue({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?de():void 0,...P}),l&&fe({...P}),pe({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),w&&he({element:w,padding:c}),Pe({arrowWidth:D,arrowHeight:O}),h&&me({strategy:`referenceHidden`,...P})]}),[z,re]=Fe(ne),B=a(_);d(()=>{L&&B?.()},[L,B]);let V=R.arrow?.x,H=R.arrow?.y,ae=R.arrow?.centerOffset!==0,[oe,U]=F.useState();return d(()=>{x&&U(window.getComputedStyle(x).zIndex)},[x]),(0,I.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:L?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[R.transformOrigin?.x,R.transformOrigin?.y].join(` `),...R.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,I.jsx)(De,{scope:n,placedSide:z,onArrowChange:T,arrowX:V,arrowY:H,shouldHideArrow:ae,children:(0,I.jsx)(m.div,{"data-side":z,"data-align":re,...v,ref:C,style:{...v.style,animation:L?void 0:`none`}})})})});ke.displayName=W;var Ae=`PopperArrow`,je={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Me=F.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Oe(Ae,n),a=je[i.placedSide];return(0,I.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,I.jsx)(ve,{...r,ref:t,style:{...r.style,display:`block`}})})});Me.displayName=Ae;function Ne(e){return e!==null}var Pe=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Fe(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Fe(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Ie=we,Le=Ee,Re=ke,ze=Me,Be=`rovingFocusGroup.onEntryFocus`,Ve={bubbles:!1,cancelable:!0},G=`RovingFocusGroup`,[He,Ue,We]=z(G),[Ge,Ke]=c(G,[We]),[qe,Je]=Ge(G),Ye=F.forwardRef((e,t)=>(0,I.jsx)(He.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,I.jsx)(He.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,I.jsx)(Xe,{...e,ref:t})})}));Ye.displayName=G;var Xe=F.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:c,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,h=F.useRef(null),g=b(t,h),v=B(o),[y,x]=s({prop:c,defaultProp:l??null,onChange:u,caller:G}),[S,C]=F.useState(!1),w=a(d),T=Ue(n),E=F.useRef(!1),[D,O]=F.useState(0);return F.useEffect(()=>{let e=h.current;if(e)return e.addEventListener(Be,w),()=>e.removeEventListener(Be,w)},[w]),(0,I.jsx)(qe,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:y,onItemFocus:F.useCallback(e=>x(e),[x]),onItemShiftTab:F.useCallback(()=>C(!0),[]),onFocusableItemAdd:F.useCallback(()=>O(e=>e+1),[]),onFocusableItemRemove:F.useCallback(()=>O(e=>e-1),[]),children:(0,I.jsx)(m.div,{tabIndex:S||D===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:`none`,...e.style},onMouseDown:_(e.onMouseDown,()=>{E.current=!0}),onFocus:_(e.onFocus,e=>{let t=!E.current;if(e.target===e.currentTarget&&t&&!S){let t=new CustomEvent(Be,Ve);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=T().filter(e=>e.focusable);nt([e.find(e=>e.active),e.find(e=>e.id===y),...e].filter(Boolean).map(e=>e.ref.current),f)}}E.current=!1}),onBlur:_(e.onBlur,()=>C(!1))})})}),Ze=`RovingFocusGroupItem`,Qe=F.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=p(),l=a||c,u=Je(Ze,n),d=u.currentTabStopId===l,f=Ue(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:v}=u;return F.useEffect(()=>{if(r)return h(),()=>g()},[r,h,g]),(0,I.jsx)(He.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,I.jsx)(m.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:_(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:_(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:_(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=tt(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?rt(n,r+1):n.slice(r+1)}setTimeout(()=>nt(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});Qe.displayName=Ze;var $e={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function et(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function tt(e,t,n){let r=et(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return $e[r]}function nt(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function rt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var it=Ye,at=Qe,ot=`Toggle`,st=F.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,c]=s({prop:n,onChange:i,defaultProp:r??!1,caller:ot});return(0,I.jsx)(m.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:_(e.onClick,()=>{e.disabled||c(!o)})})});st.displayName=ot;var K=`ToggleGroup`,[ct,lt]=c(K,[Ke]),ut=Ke(),dt=F.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,I.jsx)(mt,{...r,ref:t});if(n===`multiple`)return(0,I.jsx)(ht,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${K}\``)});dt.displayName=K;var[ft,pt]=ct(K),mt=F.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,c]=s({prop:n,defaultProp:r??``,onChange:i,caller:K});return(0,I.jsx)(ft,{scope:e.__scopeToggleGroup,type:`single`,value:F.useMemo(()=>o?[o]:[],[o]),onItemActivate:c,onItemDeactivate:F.useCallback(()=>c(``),[c]),children:(0,I.jsx)(vt,{...a,ref:t})})}),ht=F.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,c]=s({prop:n,defaultProp:r??[],onChange:i,caller:K}),l=F.useCallback(e=>c((t=[])=>[...t,e]),[c]),u=F.useCallback(e=>c((t=[])=>t.filter(t=>t!==e)),[c]);return(0,I.jsx)(ft,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:l,onItemDeactivate:u,children:(0,I.jsx)(vt,{...a,ref:t})})});dt.displayName=K;var[gt,_t]=ct(K),vt=F.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=ut(n),u=B(o),d={role:`group`,dir:u,...c};return(0,I.jsx)(gt,{scope:n,rovingFocus:i,disabled:r,children:i?(0,I.jsx)(it,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,I.jsx)(m.div,{...d,ref:t})}):(0,I.jsx)(m.div,{...d,ref:t})})}),q=`ToggleGroupItem`,yt=F.forwardRef((e,t)=>{let n=pt(q,e.__scopeToggleGroup),r=_t(q,e.__scopeToggleGroup),i=ut(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=F.useRef(null);return r.rovingFocus?(0,I.jsx)(at,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,I.jsx)(bt,{...s,ref:t})}):(0,I.jsx)(bt,{...s,ref:t})});yt.displayName=q;var bt=F.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=pt(q,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,I.jsx)(st,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),xt=dt,St=yt,[J,Ct]=c(`Tooltip`,[xe]),Y=xe(),wt=`TooltipProvider`,Tt=700,Et=`tooltip.open`,[Dt,Ot]=J(wt),kt=e=>{let{__scopeTooltip:t,delayDuration:n=Tt,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=F.useRef(!0),s=F.useRef(!1),c=F.useRef(0);return F.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,I.jsx)(Dt,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:F.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:F.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:F.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};kt.displayName=wt;var X=`Tooltip`,[At,Z]=J(X),jt=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:c}=e,l=Ot(X,e.__scopeTooltip),u=Y(t),[d,f]=F.useState(null),m=p(),h=F.useRef(0),g=o??l.disableHoverableContent,_=c??l.delayDuration,v=F.useRef(!1),[y,b]=s({prop:r,defaultProp:i??!1,onChange:e=>{e?(l.onOpen(),document.dispatchEvent(new CustomEvent(Et))):l.onClose(),a?.(e)},caller:X}),x=F.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=F.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=F.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=F.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);return F.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]),(0,I.jsx)(Ie,{...u,children:(0,I.jsx)(At,{scope:t,contentId:m,open:y,stateAttribute:x,trigger:d,onTriggerChange:f,onTriggerEnter:F.useCallback(()=>{l.isOpenDelayedRef.current?w():S()},[l.isOpenDelayedRef,w,S]),onTriggerLeave:F.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})};jt.displayName=X;var Mt=`TooltipTrigger`,Nt=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Z(Mt,n),a=Ot(Mt,n),o=Y(n),s=b(t,F.useRef(null),i.onTriggerChange),c=F.useRef(!1),l=F.useRef(!1),u=F.useCallback(()=>c.current=!1,[]);return F.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,I.jsx)(Le,{asChild:!0,...o,children:(0,I.jsx)(m.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:_(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:_(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:_(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:_(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:_(e.onBlur,i.onClose),onClick:_(e.onClick,i.onClose)})})});Nt.displayName=Mt;var Pt=`TooltipPortal`,[Ft,It]=J(Pt,{forceMount:void 0}),Lt=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Z(Pt,t);return(0,I.jsx)(Ft,{scope:t,forceMount:n,children:(0,I.jsx)(g,{present:n||a.open,children:(0,I.jsx)(h,{asChild:!0,container:i,children:r})})})};Lt.displayName=Pt;var Q=`TooltipContent`,Rt=F.forwardRef((e,t)=>{let n=It(Q,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Z(Q,e.__scopeTooltip);return(0,I.jsx)(g,{present:r||o.open,children:o.disableHoverableContent?(0,I.jsx)(Ut,{side:i,...a,ref:t}):(0,I.jsx)(zt,{side:i,...a,ref:t})})}),zt=F.forwardRef((e,t)=>{let n=Z(Q,e.__scopeTooltip),r=Ot(Q,e.__scopeTooltip),i=F.useRef(null),a=b(t,i),[o,s]=F.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=F.useCallback(()=>{s(null),d(!1)},[d]),p=F.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=qt(r,Kt(r,n.getBoundingClientRect())),a=Jt(t.getBoundingClientRect());s(Xt([...i,...a])),d(!0)},[d]);return F.useEffect(()=>()=>f(),[f]),F.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),F.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Yt(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,I.jsx)(Ut,{...e,ref:a})}),[Bt,Vt]=J(X,{isInside:!1}),Ht=i(`TooltipContent`),Ut=F.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Z(Q,n),l=Y(n),{onClose:d}=c;return F.useEffect(()=>(document.addEventListener(Et,d),()=>document.removeEventListener(Et,d)),[d]),F.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&d()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,d]),(0,I.jsx)(u,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,I.jsxs)(Re,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,I.jsx)(Ht,{children:r}),(0,I.jsx)(Bt,{scope:n,isInside:!0,children:(0,I.jsx)(R,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Rt.displayName=Q;var Wt=`TooltipArrow`,Gt=F.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Y(n);return Vt(Wt,n).isInside?null:(0,I.jsx)(ze,{...i,...r,ref:t})});Gt.displayName=Wt;function Kt(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function qt(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Jt(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Yt(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Xt(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Zt(t)}function Zt(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Qt=kt,$t=jt,en=Nt,tn=Lt,nn=Rt,rn=Gt,$=n();function an(e){let t=(0,$.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({delayDuration:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let i=r===void 0?0:r,a;return t[3]!==i||t[4]!==n?(a=(0,I.jsx)(Qt,{"data-slot":`tooltip-provider`,delayDuration:i,...n}),t[3]=i,t[4]=n,t[5]=a):a=t[5],a}function on(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,I.jsx)($t,{"data-slot":`tooltip`,...n}),t[2]=n,t[3]=r),r}function sn(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,I.jsx)(en,{"data-slot":`tooltip-trigger`,...n}),t[2]=n,t[3]=r),r}function cn(e){let t=(0,$.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,sideOffset:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?0:a,s;t[5]===r?s=t[6]:(s=f(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,r),t[5]=r,t[6]=s);let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,I.jsx)(rn,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`}),t[7]=c):c=t[7];let l;return t[8]!==n||t[9]!==i||t[10]!==o||t[11]!==s?(l=(0,I.jsx)(tn,{children:(0,I.jsxs)(nn,{"data-slot":`tooltip-content`,sideOffset:o,className:s,...i,children:[n,c]})}),t[8]=n,t[9]=i,t[10]=o,t[11]=s,t[12]=l):l=t[12],l}function ln(e){switch(e.kind){case`doc`:return`doc`;case`folder`:case`folder-index`:return`folder`;case`missing`:return`missing`}}function un(e,t){let n=x(e,t);return{resolvedTarget:n,hashDocName:n.target,displayState:ln(n)}}var dn=o(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`,segmented:`text-muted-foreground hover:bg-muted-foreground/10 data-[state=on]:bg-background data-[state=on]:shadow-sm data-[state=on]:text-foreground dark:data-[state=on]:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),fn=F.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function pn(e){let t=(0,$.c)(29),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({className:r,variant:c,size:a,spacing:o,orientation:s,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?0:o,u=s===void 0?`horizontal`:s,d;t[8]===l?d=t[9]:(d={"--gap":l},t[8]=l,t[9]=d);let p=d,m;t[10]===r?m=t[11]:(m=f(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,r),t[10]=r,t[11]=m);let h;t[12]!==u||t[13]!==a||t[14]!==l||t[15]!==c?(h={variant:c,size:a,spacing:l,orientation:u},t[12]=u,t[13]=a,t[14]=l,t[15]=c,t[16]=h):h=t[16];let g;t[17]!==n||t[18]!==h?(g=(0,I.jsx)(fn.Provider,{value:h,children:n}),t[17]=n,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==u||t[21]!==i||t[22]!==a||t[23]!==l||t[24]!==p||t[25]!==m||t[26]!==g||t[27]!==c?(_=(0,I.jsx)(xt,{"data-slot":`toggle-group`,"data-variant":c,"data-size":a,"data-spacing":l,"data-orientation":u,style:p,className:m,...i,children:g}),t[20]=u,t[21]=i,t[22]=a,t[23]=l,t[24]=p,t[25]=m,t[26]=g,t[27]=c,t[28]=_):_=t[28],_}function mn(e){let t=(0,$.c)(19),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:a,size:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`default`:a,c=o===void 0?`default`:o,l=F.use(fn),u=l.variant||s,d=l.size||c,p=l.spacing,m;t[6]!==r||t[7]!==l.size||t[8]!==l.variant||t[9]!==c||t[10]!==s?(m=f(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t text-muted-foreground data-[state=on]:text-foreground`,dn({variant:l.variant||s,size:l.size||c}),r),t[6]=r,t[7]=l.size,t[8]=l.variant,t[9]=c,t[10]=s,t[11]=m):m=t[11];let h;return t[12]!==n||t[13]!==l.spacing||t[14]!==i||t[15]!==u||t[16]!==d||t[17]!==m?(h=(0,I.jsx)(St,{"data-slot":`toggle-group-item`,"data-variant":u,"data-size":d,"data-spacing":p,className:m,...i,children:n}),t[12]=n,t[13]=l.spacing,t[14]=i,t[15]=u,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}export{j as S,B as _,cn as a,N as b,at as c,Le as d,ze as f,ie as g,xe as h,on as i,it as l,Ie as m,mn as n,an as o,Re as p,un as r,sn as s,pn as t,Ke as u,z as v,M as x,P as y};
|
package/dist/public/index.html
CHANGED
|
@@ -20,15 +20,17 @@
|
|
|
20
20
|
nothing for the formatter to reindent.
|
|
21
21
|
-->
|
|
22
22
|
<script>(() => { let mode = 'wysiwyg'; try { const raw = localStorage.getItem('ok-editor-mode-v1'); if (raw === 'wysiwyg' || raw === 'source') mode = raw; } catch {} window.__OK_EDITOR_MODE__ = mode; })();</script>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
24
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
25
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
26
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
27
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
28
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
29
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
30
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
31
|
-
<link rel="
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-DUIfxmm6.js"></script>
|
|
24
|
+
<link rel="modulepreload" crossorigin href="/assets/button-BuHZQnlF.js">
|
|
25
|
+
<link rel="modulepreload" crossorigin href="/assets/w3c-keyname-DGDXsZN5.js">
|
|
26
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-1RA1Ivz5.js">
|
|
27
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-B90Tbt-G.js">
|
|
28
|
+
<link rel="modulepreload" crossorigin href="/assets/panel-CnHxXki4.js">
|
|
29
|
+
<link rel="modulepreload" crossorigin href="/assets/dist-BJa-wTjR.js">
|
|
30
|
+
<link rel="modulepreload" crossorigin href="/assets/dialog-C2kd-BJI.js">
|
|
31
|
+
<link rel="modulepreload" crossorigin href="/assets/clipboard-ZQ-AEssh.js">
|
|
32
|
+
<link rel="modulepreload" crossorigin href="/assets/toggle-group-BNTPJpXY.js">
|
|
33
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CGTgnYOo.css">
|
|
32
34
|
</head>
|
|
33
35
|
|
|
34
36
|
<body class="antialiased">
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{closeSync as e,existsSync as t,mkdirSync as n,openSync as r,readFileSync as i,unlinkSync as a,writeFileSync as o,writeSync as s}from"node:fs";import{hostname as c}from"node:os";import{resolve as l}from"node:path";function u(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}var d=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function f(e,t){return l(e,`${t}.lock`)}const p=new Map;function m(e){p.set(e,(p.get(e)??0)+1)}function h(e){let t=p.get(e);return t===void 0||t<=1?(p.delete(e),!0):(p.set(e,t-1),!1)}function g(e,t){try{let n=JSON.parse(i(e,`utf-8`));return n&&typeof n==`object`&&typeof n.pid==`number`?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function _(i){let{lockName:l,lockDir:p,metadata:h}=i,_=`[${l}-lock]`;n(p,{recursive:!0});let y=f(p,l),b={pid:process.pid,hostname:c(),port:h.port,startedAt:new Date().toISOString(),worktreeRoot:h.worktreeRoot},x=JSON.stringify(b,null,2);for(let n=0;n<3;n++){if(!t(y))try{let t=r(y,`wx`,384);try{s(t,x)}finally{e(t)}return m(y),v({lockName:l,lockDir:p,lockPath:y})}catch(e){if(e.code!==`EEXIST`)throw e}let n=g(y,_);if(n){let e=n.hostname===c();if(e&&n.pid===process.pid)return o(y,x,{encoding:`utf-8`,mode:384}),m(y),v({lockName:l,lockDir:p,lockPath:y});if(e&&u(n.pid))throw new d(n,y,l);console.warn(`${_} Stale lock detected (pid=${n.pid}, host=${n.hostname}) — replacing`)}try{a(y)}catch{}}throw Error(`${_} Failed to acquire ${y} after 3 attempts (concurrent acquire contention).`)}function v(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>x({lockName:t,lockDir:n}),updatePort:e=>y({lockName:t,lockDir:n,port:e})}}function y(e){let{lockName:n,lockDir:r,port:a}=e,s=`[${n}-lock]`,l=f(r,n);if(!t(l)){console.warn(`${s} Lock file missing at ${l} during port update — skipping`);return}let u;try{let e=JSON.parse(i(l,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`){console.warn(`${s} Corrupt lock at ${l} during port update — skipping`);return}u=e}catch{console.warn(`${s} Unreadable lock at ${l} during port update — skipping`);return}if(u.pid===process.pid&&!(typeof u.hostname==`string`&&u.hostname!==c())){u.port=a;try{o(l,JSON.stringify(u,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${s} Failed to update port in ${l}: ${e instanceof Error?e.message:String(e)}`)}}}function b(e){let{lockName:n,lockDir:r}=e,o=f(r,n);if(!t(o))return null;let s;try{let e=JSON.parse(i(o,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`)return null;s=e}catch{return null}if(s.hostname!==c())return null;if(!u(s.pid)){try{a(o)}catch{}return null}return s}function x(e){let{lockName:n,lockDir:r}=e,o=`[${n}-lock]`,s=f(r,n);if(h(s)&&t(s))try{let e=JSON.parse(i(s,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==c())return;a(s)}catch(e){console.warn(`${o} Failed to release ${s}: ${e instanceof Error?e.message:String(e)}`)}}var S=class extends d{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function C(e,t){try{return _({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof d&&e.lockName===`server`?new S(e.existing,e.lockPath):e}}function w(e,t){y({lockName:`server`,lockDir:e,port:t})}function T(e){return b({lockName:`server`,lockDir:e})}function E(e){x({lockName:`server`,lockDir:e})}export{w as a,f as c,y as d,u as f,E as i,b as l,C as n,d as o,T as r,_ as s,S as t,x as u};
|
|
2
|
+
//# sourceMappingURL=server-lock-BI-SqMWk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./server-lock-BI-SqMWk.mjs";export{e as updateServerLockPort};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./init-RBK7HHVy.mjs";import"./loader-lj28Sw6t.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-CQw-HNNM.mjs";import{Tt as e,et as t,it as n,n as r,nt as i,r as a,rt as o,t as s,tt as c}from"./src-rqPIkHTi.mjs";import{f as l,r as u}from"./server-lock-BI-SqMWk.mjs";export{s as ProjectGitInitError,t as UiLockCollisionError,c as acquireUiLock,a as bootServer,r as ensureProjectGit,e as getLogger,l as isProcessAlive,u as readServerLock,i as readUiLock,o as releaseUiLock,n as updateUiLockPort};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,r as t,t as n}from"./chunk-tuRmWmEN.mjs";import{A as r,C as i,D as a,E as o,M as s,O as c,S as l,T as u,_ as d,a as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,j as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k,v as A,w as j,x as M,y as N}from"./src-CQw-HNNM.mjs";import{d as P,f as ee,i as te,l as ne,n as re,o as F,r as ie,s as ae,u as I}from"./server-lock-
|
|
1
|
+
import{i as e,r as t,t as n}from"./chunk-tuRmWmEN.mjs";import{A as r,C as i,D as a,E as o,M as s,O as c,S as l,T as u,_ as d,a as f,b as p,c as m,d as h,f as g,g as _,h as v,i as y,j as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k,v as A,w as j,x as M,y as N}from"./src-CQw-HNNM.mjs";import{d as P,f as ee,i as te,l as ne,n as re,o as F,r as ie,s as ae,u as I}from"./server-lock-BI-SqMWk.mjs";import{n as oe,t as L}from"./git-handle-C_GYoScT.mjs";import{createRequire as se}from"node:module";import{closeSync as ce,existsSync as R,lstatSync as le,mkdirSync as ue,openSync as de,readFileSync as z,readdirSync as fe,realpathSync as pe,renameSync as me,rmSync as he,statSync as ge,unlinkSync as _e,writeFileSync as B,writeSync as ve}from"node:fs";import{homedir as ye,hostname as be,tmpdir as xe}from"node:os";import{dirname as Se,extname as Ce,join as V,posix as we,relative as Te,resolve as H,sep as Ee}from"node:path";import{URLSearchParams as De}from"node:url";import Oe,{createHash as ke,randomUUID as Ae,webcrypto as je}from"node:crypto";import{execFile as Me,spawn as Ne,spawnSync as Pe}from"node:child_process";import Fe from"simple-git";import{mkdir as Ie,readFile as Le,realpath as Re,rename as ze,writeFile as Be}from"node:fs/promises";import"node:http";import Ve from"picomatch";import{promisify as He}from"node:util";var Ue=n(((e,t)=>{let n=e=>e&&typeof e.message==`string`,r=e=>{if(!e)return;let t=e.cause;if(typeof t==`function`){let t=e.cause();return n(t)?t:void 0}else return n(t)?t:void 0},i=(e,t)=>{if(!n(e))return``;let a=e.stack||``;if(t.has(e))return a+`
|
|
2
2
|
causes have become circular...`;let o=r(e);return o?(t.add(e),a+`
|
|
3
3
|
caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?``:e.message||``;if(t.has(e))return a+`: ...`;let s=r(e);if(s){t.add(e);let n=typeof e.cause==`function`;return a+(n?``:`: `)+o(s,t,n)}else return a};t.exports={isErrorLike:n,getErrorCause:r,stackWithCauses:a,messageWithCauses:e=>o(e,new Set)}})),We=n(((e,t)=>{let n=Symbol(`circular-ref-tag`),r=Symbol(`pino-raw-err-ref`),i=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[r]},set:function(e){this[r]=e}}});Object.defineProperty(i,r,{writable:!0,value:{}}),t.exports={pinoErrProto:i,pinoErrorSymbols:{seen:n,rawSymbol:r}}})),Ge=n(((e,t)=>{t.exports=l;let{messageWithCauses:n,stackWithCauses:r,isErrorLike:i}=Ue(),{pinoErrProto:a,pinoErrorSymbols:o}=We(),{seen:s}=o,{toString:c}=Object.prototype;function l(e){if(!i(e))return e;e[s]=void 0;let t=Object.create(a);t.type=c.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=n(e),t.stack=r(e),Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>l(e)));for(let n in e)if(t[n]===void 0){let r=e[n];i(r)?n!==`cause`&&!Object.prototype.hasOwnProperty.call(r,s)&&(t[n]=l(r)):t[n]=r}return delete e[s],t.raw=e,t}})),Ke=n(((e,t)=>{t.exports=s;let{isErrorLike:n}=Ue(),{pinoErrProto:r,pinoErrorSymbols:i}=We(),{seen:a}=i,{toString:o}=Object.prototype;function s(e){if(!n(e))return e;e[a]=void 0;let t=Object.create(r);t.type=o.call(e.constructor)===`[object Function]`?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack,Array.isArray(e.errors)&&(t.aggregateErrors=e.errors.map(e=>s(e))),n(e.cause)&&!Object.prototype.hasOwnProperty.call(e.cause,a)&&(t.cause=s(e.cause));for(let r in e)if(t[r]===void 0){let i=e[r];n(i)?Object.prototype.hasOwnProperty.call(i,a)||(t[r]=s(i)):t[r]=i}return delete e[a],t.raw=e,t}})),qe=n(((e,t)=>{t.exports={mapHttpRequest:a,reqSerializer:i};let n=Symbol(`pino-raw-req-ref`),r=Object.create({},{id:{enumerable:!0,writable:!0,value:``},method:{enumerable:!0,writable:!0,value:``},url:{enumerable:!0,writable:!0,value:``},query:{enumerable:!0,writable:!0,value:``},params:{enumerable:!0,writable:!0,value:``},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:``},remotePort:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=e.info||e.socket,n=Object.create(r);if(n.id=typeof e.id==`function`?e.id():e.id||(e.info?e.info.id:void 0),n.method=e.method,e.originalUrl)n.url=e.originalUrl;else{let t=e.path;n.url=typeof t==`string`?t:e.url?e.url.path||e.url:void 0}return e.query&&(n.query=e.query),e.params&&(n.params=e.params),n.headers=e.headers,n.remoteAddress=t&&t.remoteAddress,n.remotePort=t&&t.remotePort,n.raw=e.raw||e,n}function a(e){return{req:i(e)}}})),Je=n(((e,t)=>{t.exports={mapHttpResponse:a,resSerializer:i};let n=Symbol(`pino-raw-res-ref`),r=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:``},raw:{enumerable:!1,get:function(){return this[n]},set:function(e){this[n]=e}}});Object.defineProperty(r,n,{writable:!0,value:{}});function i(e){let t=Object.create(r);return t.statusCode=e.headersSent?e.statusCode:null,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function a(e){return{res:i(e)}}})),Ye=n(((e,t)=>{let n=Ge(),r=Ke(),i=qe(),a=Je();t.exports={err:n,errWithCause:r,mapHttpRequest:i.mapHttpRequest,mapHttpResponse:a.mapHttpResponse,req:i.reqSerializer,res:a.resSerializer,wrapErrorSerializer:function(e){return e===n?e:function(t){return e(n(t))}},wrapRequestSerializer:function(e){return e===i.reqSerializer?e:function(t){return e(i.reqSerializer(t))}},wrapResponseSerializer:function(e){return e===a.resSerializer?e:function(t){return e(a.resSerializer(t))}}}})),Xe=n(((e,t)=>{function n(e,t){return t}t.exports=function(){let e=Error.prepareStackTrace;Error.prepareStackTrace=n;let t=Error().stack;if(Error.prepareStackTrace=e,!Array.isArray(t))return;let r=t.slice(2),i=[];for(let e of r)e&&i.push(e.getFileName());return i}})),Ze=n(((e,t)=>{function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){let t=[];for(let r=0;r<e.length;r++)t[r]=n(e[r]);return t}if(typeof e==`object`){let t=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=n(e[r]));return t}return e}function r(e){let t=[],n=``,r=!1,i=!1,a=``;for(let o=0;o<e.length;o++){let s=e[o];!r&&s===`.`?n&&=(t.push(n),``):s===`[`?(n&&=(t.push(n),``),r=!0):s===`]`&&r?(t.push(n),n=``,r=!1,i=!1):(s===`"`||s===`'`)&&r?i?s===a?(i=!1,a=``):n+=s:(i=!0,a=s):n+=s}return n&&t.push(n),t}function i(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(typeof r!=`object`||!r||!(n in r)||typeof r[n]!=`object`||r[n]===null)return!1;r=r[n]}let i=t[t.length-1];if(i===`*`){if(Array.isArray(r))for(let e=0;e<r.length;e++)r[e]=n;else if(typeof r==`object`&&r)for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=n)}else typeof r==`object`&&r&&i in r&&Object.prototype.hasOwnProperty.call(r,i)&&(r[i]=n);return!0}function a(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(typeof n!=`object`||!n||!(r in n)||typeof n[r]!=`object`||n[r]===null)return!1;n=n[r]}let r=t[t.length-1];if(r===`*`){if(Array.isArray(n))for(let e=0;e<n.length;e++)n[e]=void 0;else if(typeof n==`object`&&n)for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&delete n[e]}else typeof n==`object`&&n&&r in n&&Object.prototype.hasOwnProperty.call(n,r)&&delete n[r];return!0}let o=Symbol(`PATH_NOT_FOUND`);function s(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n||!(e in n))return o;n=n[e]}return n}function c(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||!n)return;n=n[e]}return n}function l(e,t,n,c=!1){for(let l of t){let t=r(l);if(t.includes(`*`))u(e,t,n,l,c);else if(c)a(e,t);else{let r=s(e,t);if(r===o)continue;i(e,t,typeof n==`function`?n(r,t):n)}}}function u(e,t,n,r,i=!1){let a=t.indexOf(`*`);if(a===t.length-1){let r=t.slice(0,-1),a=e;for(let e of r){if(typeof a!=`object`||!a||!a)return;a=a[e]}if(Array.isArray(a))if(i)for(let e=0;e<a.length;e++)a[e]=void 0;else for(let e=0;e<a.length;e++){let t=[...r,e.toString()],i=typeof n==`function`?n(a[e],t):n;a[e]=i}else if(typeof a==`object`&&a)if(i){let e=[];for(let t in a)Object.prototype.hasOwnProperty.call(a,t)&&e.push(t);for(let t of e)delete a[t]}else for(let e in a){let t=[...r,e],i=typeof n==`function`?n(a[e],t):n;a[e]=i}}else d(e,t,n,a,r,i)}function d(e,t,n,r,o,s=!1){let l=t.slice(0,r),d=t.slice(r+1),f=[];function p(e,t){if(t===l.length){if(Array.isArray(e))for(let n=0;n<e.length;n++)f[t]=n.toString(),p(e[n],t+1);else if(typeof e==`object`&&e)for(let n in e)f[t]=n,p(e[n],t+1)}else if(t<l.length){let n=l[t];e&&typeof e==`object`&&e&&n in e&&(f[t]=n,p(e[n],t+1))}else d.includes(`*`)?u(e,d,typeof n==`function`?(e,r)=>n(e,[...f.slice(0,t),...r]):n,o,s):s?a(e,d):i(e,d,typeof n==`function`?n(c(e,d),[...f.slice(0,t),...d]):n)}if(l.length===0)p(e,0);else{let t=e;for(let e=0;e<l.length;e++){let n=l[e];if(typeof t!=`object`||!t||!t)return;t=t[n],f[e]=n}t!=null&&p(t,l.length)}}function f(e){if(e.length===0)return null;let t=new Map;for(let n of e){let e=r(n),i=t;for(let t=0;t<e.length;t++){let n=e[t];i.has(n)||i.set(n,new Map),i=i.get(n)}}return t}function p(e,t){if(!t)return e;function n(e,t,r=0){if(!t||t.size===0||typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let r=[];for(let i=0;i<e.length;i++){let a=i.toString();t.has(a)||t.has(`*`)?r[i]=n(e[i],t.get(a)||t.get(`*`)):r[i]=e[i]}return r}let i=Object.create(Object.getPrototypeOf(e));for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t.has(r)||t.has(`*`)?i[r]=n(e[r],t.get(r)||t.get(`*`)):i[r]=e[r]);return i}return n(e,t)}function m(e){if(typeof e!=`string`)throw Error(`Paths must be (non-empty) strings`);if(e===``)throw Error(`Invalid redaction path ()`);if(e.includes(`..`)||e.includes(`,`))throw Error(`Invalid redaction path (${e})`);let t=0,n=!1,r=``;for(let i=0;i<e.length;i++){let a=e[i];if((a===`"`||a===`'`)&&t>0)n?a===r&&(n=!1,r=``):(n=!0,r=a);else if(a===`[`&&!n)t++;else if(a===`]`&&!n&&(t--,t<0))throw Error(`Invalid redaction path (${e})`)}if(t!==0)throw Error(`Invalid redaction path (${e})`)}function h(e){if(!Array.isArray(e))throw TypeError(`paths must be an array`);for(let t of e)m(t)}function g(e={}){let{paths:t=[],censor:r=`[REDACTED]`,serialize:i=JSON.stringify,strict:a=!0,remove:o=!1}=e;h(t);let s=f(t);return function(e){if(a&&(typeof e!=`object`||!e)&&(typeof e!=`object`||!e))return i?i(e):e;let c=p(e,s),u=e,d=r;return typeof r==`function`&&(d=r),l(c,t,d,o),i===!1?(c.restore=function(){return n(u)},c):typeof i==`function`?i(c):JSON.stringify(c)}}t.exports=g})),Qe=n(((e,t)=>{let n=Symbol(`pino.setLevel`),r=Symbol(`pino.getLevel`),i=Symbol(`pino.levelVal`),a=Symbol(`pino.levelComp`),o=Symbol(`pino.useLevelLabels`),s=Symbol(`pino.useOnlyCustomLevels`),c=Symbol(`pino.mixin`),l=Symbol(`pino.lsCache`),u=Symbol(`pino.chindings`),d=Symbol(`pino.asJson`),f=Symbol(`pino.write`),p=Symbol(`pino.redactFmt`),m=Symbol(`pino.time`),h=Symbol(`pino.timeSliceIndex`),g=Symbol(`pino.stream`),_=Symbol(`pino.stringify`),v=Symbol(`pino.stringifySafe`),y=Symbol(`pino.stringifiers`),b=Symbol(`pino.end`),x=Symbol(`pino.formatOpts`),S=Symbol(`pino.messageKey`),C=Symbol(`pino.errorKey`),w=Symbol(`pino.nestedKey`),T=Symbol(`pino.nestedKeyStr`),E=Symbol(`pino.mixinMergeStrategy`),D=Symbol(`pino.msgPrefix`),O=Symbol(`pino.wildcardFirst`),k=Symbol.for(`pino.serializers`),A=Symbol.for(`pino.formatters`),j=Symbol.for(`pino.hooks`);t.exports={setLevelSym:n,getLevelSym:r,levelValSym:i,levelCompSym:a,useLevelLabelsSym:o,mixinSym:c,lsCacheSym:l,chindingsSym:u,asJsonSym:d,writeSym:f,serializersSym:k,redactFmtSym:p,timeSym:m,timeSliceIndexSym:h,streamSym:g,stringifySym:_,stringifySafeSym:v,stringifiersSym:y,endSym:b,formatOptsSym:x,messageKeySym:S,errorKeySym:C,nestedKeySym:w,wildcardFirstSym:O,needsMetadataGsym:Symbol.for(`pino.metadata`),useOnlyCustomLevelsSym:s,formattersSym:A,hooksSym:j,nestedKeyStrSym:T,mixinMergeStrategySym:E,msgPrefixSym:D}})),$e=n(((e,t)=>{let n=Ze(),{redactFmtSym:r,wildcardFirstSym:i}=Qe(),a=/[^.[\]]+|\[([^[\]]*?)\]/g,o=`[Redacted]`;function s(e,t){let{paths:o,censor:s,remove:l}=c(e),u=o.reduce((e,t)=>{a.lastIndex=0;let n=a.exec(t),r=a.exec(t),o=n[1]===void 0?n[0]:n[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,`$1`);if(o===`*`&&(o=i),r===null)return e[o]=null,e;if(e[o]===null)return e;let{index:s}=r,c=`${t.substr(s,t.length-1)}`;return e[o]=e[o]||[],o!==i&&e[o].length===0&&e[o].push(...e[i]||[]),o===i&&Object.keys(e).forEach(function(t){e[t]&&e[t].push(c)}),e[o].push(c),e},{}),d={[r]:n({paths:o,censor:s,serialize:t,strict:!1,remove:l})},f=(...e)=>t(typeof s==`function`?s(...e):s);return[...Object.keys(u),...Object.getOwnPropertySymbols(u)].reduce((e,r)=>{if(u[r]===null)e[r]=e=>f(e,[r]);else{let i=typeof s==`function`?(e,t)=>s(e,[r,...t]):s;e[r]=n({paths:u[r],censor:i,serialize:t,strict:!1,remove:l})}return e},d)}function c(e){if(Array.isArray(e))return e={paths:e,censor:o},e;let{paths:t,censor:n=o,remove:r}=e;if(Array.isArray(t)===!1)throw Error(`pino – redact must contain an array of strings`);return r===!0&&(n=void 0),{paths:t,censor:n,remove:r}}t.exports=s})),et=n(((e,t)=>{let n=()=>``,r=()=>`,"time":${Date.now()}`,i=()=>`,"time":${Math.round(Date.now()/1e3)}`,a=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,o=1000000000n,s=BigInt(Date.now())*1000000n,c=process.hrtime.bigint();t.exports={nullTime:n,epochTime:r,unixTime:i,isoTime:a,isoTimeNano:()=>{let e=s+(process.hrtime.bigint()-c),t=e/o,n=e%o,r=Number(t*1000n+n/1000000n),i=new Date(r);return`,"time":"${i.getUTCFullYear()}-${(i.getUTCMonth()+1).toString().padStart(2,`0`)}-${i.getUTCDate().toString().padStart(2,`0`)}T${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}:${i.getUTCSeconds().toString().padStart(2,`0`)}.${n.toString().padStart(9,`0`)}Z"`}}})),tt=n(((e,t)=>{function n(e){try{return JSON.stringify(e)}catch{return`"[Circular]"`}}t.exports=r;function r(e,t,r){var i=r&&r.stringify||n,a=1;if(typeof e==`object`&&e){var o=t.length+a;if(o===1)return e;var s=Array(o);s[0]=i(e);for(var c=1;c<o;c++)s[c]=i(t[c]);return s.join(` `)}if(typeof e!=`string`)return e;var l=t.length;if(l===0)return e;for(var u=``,d=1-a,f=-1,p=e&&e.length||0,m=0;m<p;){if(e.charCodeAt(m)===37&&m+1<p){switch(f=f>-1?f:0,e.charCodeAt(m+1)){case 100:case 102:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Number(t[d]),f=m+2,m++;break;case 105:if(d>=l||t[d]==null)break;f<m&&(u+=e.slice(f,m)),u+=Math.floor(Number(t[d])),f=m+2,m++;break;case 79:case 111:case 106:if(d>=l||t[d]===void 0)break;f<m&&(u+=e.slice(f,m));var h=typeof t[d];if(h===`string`){u+=`'`+t[d]+`'`,f=m+2,m++;break}if(h===`function`){u+=t[d].name||`<anonymous>`,f=m+2,m++;break}u+=i(t[d]),f=m+2,m++;break;case 115:if(d>=l)break;f<m&&(u+=e.slice(f,m)),u+=String(t[d]),f=m+2,m++;break;case 37:f<m&&(u+=e.slice(f,m)),u+=`%`,f=m+2,m++,d--;break}++d}++m}return f===-1?e:(f<p&&(u+=e.slice(f)),u)}})),nt=n(((e,t)=>{if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`){let e=new Int32Array(new SharedArrayBuffer(4));function n(t){if(!(t>0&&t<1/0))throw typeof t!=`number`&&typeof t!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);Atomics.wait(e,0,0,Number(t))}t.exports=n}else{function e(e){if(!(e>0&&e<1/0))throw typeof e!=`number`&&typeof e!=`bigint`?TypeError(`sleep: ms must be a number`):RangeError(`sleep: ms must be a number that is greater than 0 but less than Infinity`);let t=Date.now()+Number(e);for(;t>Date.now(););}t.exports=e}})),rt=n(((e,n)=>{let r=t(`fs`),i=t(`events`),a=t(`util`).inherits,o=t(`path`),s=nt(),c=t(`assert`),l=Buffer.allocUnsafe(0),u=`buffer`,d=`utf8`,[f,p]=(process.versions.node||`0.0`).split(`.`).map(Number),m=f>=22&&p>=7;function h(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function n(n,r){if(n){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount(`error`)>0&&t.emit(`error`,n)}):t.emit(`error`,n);return}let i=t._reopening;t.fd=r,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit(`ready`)):t.emit(`ready`),!t.destroyed&&(!t._writing&&t._len>t.minLength||t._flushPending?t._actualWrite():i&&process.nextTick(()=>t.emit(`drain`)))}let i=t.append?`a`:`w`,a=t.mode;if(t.sync)try{t.mkdir&&r.mkdirSync(o.dirname(e),{recursive:!0}),n(null,r.openSync(e,i,a))}catch(e){throw n(e),e}else t.mkdir?r.mkdir(o.dirname(e),{recursive:!0},t=>{if(t)return n(t);r.open(e,i,a,n)}):r.open(e,i,a,n)}function g(e){if(!(this instanceof g))return new g(e);let{fd:t,dest:n,minLength:i,maxLength:a,maxWrite:o,periodicFlush:c,sync:f,append:p=!0,mkdir:m,retryEAGAIN:y,fsync:S,contentMode:A,mode:j}=e||{};t||=n,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(i||0,16387),this.file=null,this.destroyed=!1,this.minLength=i||0,this.maxLength=a||0,this.maxWrite=o||16384,this._periodicFlush=c||0,this._periodicFlushTimer=void 0,this.sync=f||!1,this.writable=!0,this._fsync=S||!1,this.append=p||!1,this.mode=j,this.retryEAGAIN=y||(()=>!0),this.mkdir=m||!1;let M,N;if(A===u)this._writingBuf=l,this.write=x,this.flush=w,this.flushSync=E,this._actualWrite=O,M=()=>r.writeSync(this.fd,this._writingBuf),N=()=>r.write(this.fd,this._writingBuf,this.release);else if(A===void 0||A===d)this._writingBuf=``,this.write=b,this.flush=C,this.flushSync=T,this._actualWrite=D,M=()=>Buffer.isBuffer(this._writingBuf)?r.writeSync(this.fd,this._writingBuf):r.writeSync(this.fd,this._writingBuf,`utf8`),N=()=>Buffer.isBuffer(this._writingBuf)?r.write(this.fd,this._writingBuf,this.release):r.write(this.fd,this._writingBuf,`utf8`,this.release);else throw Error(`SonicBoom supports "${d}" and "${u}", but passed ${A}`);if(typeof t==`number`)this.fd=t,process.nextTick(()=>this.emit(`ready`));else if(typeof t==`string`)h(t,this);else throw Error(`SonicBoom supports only file descriptors and files`);if(this.minLength>=this.maxWrite)throw Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(e,t)=>{if(e){if((e.code===`EAGAIN`||e.code===`EBUSY`)&&this.retryEAGAIN(e,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{s(100),this.release(void 0,0)}catch(e){this.release(e)}else setTimeout(N,100);else this._writing=!1,this.emit(`error`,e);return}this.emit(`write`,t);let n=_(this._writingBuf,this._len,t);if(this._len=n.len,this._writingBuf=n.writingBuf,this._writingBuf.length){if(!this.sync){N();return}try{do{let e=M(),t=_(this._writingBuf,this._len,e);this._len=t.len,this._writingBuf=t.writingBuf}while(this._writingBuf.length)}catch(e){this.release(e);return}}this._fsync&&r.fsyncSync(this.fd);let i=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):i>this.minLength?this._actualWrite():this._ending?i>0?this._actualWrite():(this._writing=!1,k(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(v,this)):this.emit(`drain`))},this.on(`newListener`,function(e){e===`drain`&&(this._asyncDrainScheduled=!1)}),this._periodicFlush!==0&&(this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref())}function _(e,t,n){return typeof e==`string`&&(e=Buffer.from(e)),t=Math.max(t-n,0),e=e.subarray(n),{writingBuf:e,len:t}}function v(e){e.listenerCount(`drain`)>0&&(e._asyncDrainScheduled=!1,e.emit(`drain`))}a(g,i);function y(e,t){return e.length===0?l:e.length===1?e[0]:Buffer.concat(e,t)}function b(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);e=``+e;let t=Buffer.byteLength(e),n=this._len+t,r=this._bufs;return this.maxLength&&n>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(r.length===0||Buffer.byteLength(r[r.length-1])+t>this.maxWrite?r.push(e):r[r.length-1]+=e,this._len=n,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function x(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);let t=this._len+e.length,n=this._bufs,r=this._lens;return this.maxLength&&t>this.maxLength?(this.emit(`drop`,e),this._len<this._hwm):(n.length===0||r[r.length-1]+e.length>this.maxWrite?(n.push([e]),r.push(e.length)):(n[n.length-1].push(e),r[r.length-1]+=e.length),this._len=t,!this._writing&&this._len>=this.minLength&&this._actualWrite(),this._len<this._hwm)}function S(e){this._flushPending=!0;let t=()=>{if(this._fsync)this._flushPending=!1,e();else try{r.fsync(this.fd,t=>{this._flushPending=!1,e(t)})}catch(t){e(t)}this.off(`error`,n)},n=n=>{this._flushPending=!1,e(n),this.off(`drain`,t)};this.once(`drain`,t),this.once(`error`,n)}function C(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&S.call(this,e),!this._writing&&(this._bufs.length===0&&this._bufs.push(``),this._actualWrite())}function w(e){if(e!=null&&typeof e!=`function`)throw Error(`flush cb must be a function`);if(this.destroyed){let t=Error(`SonicBoom destroyed`);if(e){e(t);return}throw t}if(this.minLength<=0){e?.();return}e&&S.call(this,e),!this._writing&&(this._bufs.length===0&&(this._bufs.push([]),this._lens.push(0)),this._actualWrite())}g.prototype.reopen=function(e){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.reopen(e)});return}if(this._ending)return;if(!this.file)throw Error(`Unable to reopen a file descriptor, you must pass a file to SonicBoom`);if(e&&(this.file=e),this._reopening=!0,this._writing)return;let t=this.fd;this.once(`ready`,()=>{t!==this.fd&&r.close(t,e=>{if(e)return this.emit(`error`,e)})}),h(this.file,this)},g.prototype.end=function(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this._opening){this.once(`ready`,()=>{this.end()});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?this._actualWrite():k(this)))};function T(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf=``);let e=``;for(;this._bufs.length||e.length;){e.length<=0&&(e=this._bufs[0]);try{let t=Buffer.isBuffer(e)?r.writeSync(this.fd,e):r.writeSync(this.fd,e,`utf8`),n=_(e,this._len,t);e=n.writingBuf,this._len=n.len,e.length<=0&&this._bufs.shift()}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;s(100)}}try{r.fsyncSync(this.fd)}catch{}}function E(){if(this.destroyed)throw Error(`SonicBoom destroyed`);if(this.fd<0)throw Error(`sonic boom is not ready yet`);!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift([this._writingBuf]),this._writingBuf=l);let e=l;for(;this._bufs.length||e.length;){e.length<=0&&(e=y(this._bufs[0],this._lens[0]));try{let t=r.writeSync(this.fd,e);e=e.subarray(t),this._len=Math.max(this._len-t,0),e.length<=0&&(this._bufs.shift(),this._lens.shift())}catch(t){if((t.code===`EAGAIN`||t.code===`EBUSY`)&&!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;s(100)}}}g.prototype.destroy=function(){this.destroyed||k(this)};function D(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||``,this.sync)try{e(null,Buffer.isBuffer(this._writingBuf)?r.writeSync(this.fd,this._writingBuf):r.writeSync(this.fd,this._writingBuf,`utf8`))}catch(t){e(t)}else r.write(this.fd,this._writingBuf,e)}function O(){let e=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:y(this._bufs.shift(),this._lens.shift()),this.sync)try{e(null,r.writeSync(this.fd,this._writingBuf))}catch(t){e(t)}else m&&(this._writingBuf=Buffer.from(this._writingBuf)),r.write(this.fd,this._writingBuf,e)}function k(e){if(e.fd===-1){e.once(`ready`,k.bind(null,e));return}e._periodicFlushTimer!==void 0&&clearInterval(e._periodicFlushTimer),e.destroyed=!0,e._bufs=[],e._lens=[],c(typeof e.fd==`number`,`sonic.fd must be a number, got ${typeof e.fd}`);try{r.fsync(e.fd,t)}catch{}function t(){e.fd!==1&&e.fd!==2?r.close(e.fd,n):n()}function n(t){if(t){e.emit(`error`,t);return}e._ending&&!e._writing&&e.emit(`finish`),e.emit(`close`)}}g.SonicBoom=g,g.default=g,n.exports=g})),it=n(((e,t)=>{let n={exit:[],beforeExit:[]},r={exit:c,beforeExit:l},i;function a(){i===void 0&&(i=new FinalizationRegistry(d))}function o(e){n[e].length>0||process.on(e,r[e])}function s(e){n[e].length>0||(process.removeListener(e,r[e]),n.exit.length===0&&n.beforeExit.length===0&&(i=void 0))}function c(){u(`exit`)}function l(){u(`beforeExit`)}function u(e){for(let t of n[e]){let n=t.deref(),r=t.fn;n!==void 0&&r(n,e)}n[e]=[]}function d(e){for(let t of[`exit`,`beforeExit`]){let r=n[t].indexOf(e);n[t].splice(r,r+1),s(t)}}function f(e,t,r){if(t===void 0)throw Error(`the object can't be undefined`);o(e);let s=new WeakRef(t);s.fn=r,a(),i.register(t,s),n[e].push(s)}function p(e,t){f(`exit`,e,t)}function m(e,t){f(`beforeExit`,e,t)}function h(e){if(i!==void 0){i.unregister(e);for(let t of[`exit`,`beforeExit`])n[t]=n[t].filter(t=>{let n=t.deref();return n&&n!==e}),s(t)}}t.exports={register:p,registerBeforeExit:m,unregister:h}})),at=n(((e,t)=>{t.exports={name:`thread-stream`,version:`4.0.0`,description:`A streaming way to send data to a Node.js Worker Thread`,main:`index.js`,types:`index.d.ts`,engines:{node:`>=20`},dependencies:{"real-require":`^0.2.0`},devDependencies:{"@types/node":`^22.0.0`,"@yao-pkg/pkg":`^6.0.0`,borp:`^0.21.0`,desm:`^1.3.0`,eslint:`^9.39.1`,fastbench:`^1.0.1`,husky:`^9.0.6`,neostandard:`^0.12.2`,"pino-elasticsearch":`^8.0.0`,"sonic-boom":`^4.0.1`,"ts-node":`^10.8.0`,typescript:`~5.7.3`},scripts:{build:`tsc --noEmit`,lint:`eslint`,test:`npm run lint && npm run build && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'`,"test:ci":`npm run lint && npm run transpile && borp --pattern 'test/*.test.{js,mjs}'`,"test:yarn":`npm run transpile && borp --pattern 'test/*.test.js'`,transpile:`sh ./test/ts/transpile.sh`,prepare:`husky install`},repository:{type:`git`,url:`git+https://github.com/mcollina/thread-stream.git`},keywords:[`worker`,`thread`,`threads`,`stream`],author:`Matteo Collina <hello@matteocollina.com>`,license:`MIT`,bugs:{url:`https://github.com/mcollina/thread-stream/issues`},homepage:`https://github.com/mcollina/thread-stream#readme`}})),ot=n(((e,t)=>{let n=1e4;function r(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{let i=Atomics.load(e,t);if(i===r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let c=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),l=Atomics.waitAsync(e,t,i,c);l.async?l.value.then(s):setImmediate(s)};s()}function i(e,t,r,i,a){let o=i===1/0?1/0:Date.now()+i,s=()=>{if(Atomics.load(e,t)!==r){a(null,`ok`);return}if(o!==1/0&&Date.now()>o){a(null,`timed-out`);return}let i=o===1/0?n:Math.min(n,Math.max(1,o-Date.now())),c=Atomics.waitAsync(e,t,r,i);c.async?c.value.then(s):setImmediate(s)};s()}t.exports={wait:r,waitDiff:i}})),st=n(((e,t)=>{t.exports={WRITE_INDEX:4,READ_INDEX:8}})),ct=n(((e,n)=>{let{version:r}=at(),{EventEmitter:i}=t(`events`),{Worker:a}=t(`worker_threads`),{join:o}=t(`path`),{pathToFileURL:s}=t(`url`),{wait:c}=ot(),{WRITE_INDEX:l,READ_INDEX:u}=st(),d=t(`buffer`),f=t(`assert`),p=Symbol(`kImpl`),m=d.constants.MAX_STRING_LENGTH;var h=class{constructor(e){this._value=e}deref(){return this._value}},g=class{register(){}unregister(){}};let _=process.env.NODE_V8_COVERAGE?g:global.FinalizationRegistry||g,v=process.env.NODE_V8_COVERAGE?h:global.WeakRef||h,y=new _(e=>{e.exited||e.terminate()});function b(e,t){let{filename:n,workerData:i}=t,c=new a((`__bundlerPathsOverrides`in globalThis?globalThis.__bundlerPathsOverrides:{})[`thread-stream-worker`]||o(__dirname,`lib`,`worker.js`),{...t.workerOpts,trackUnmanagedFds:!1,workerData:{filename:n.indexOf(`file://`)===0?n:s(n).href,dataBuf:e[p].dataBuf,stateBuf:e[p].stateBuf,workerData:{$context:{threadStreamVersion:r},...i}}});return c.stream=new h(e),c.on(`message`,C),c.on(`exit`,w),y.register(e,c),c}function x(e){f(!e[p].sync),e[p].needDrain&&(e[p].needDrain=!1,e.emit(`drain`))}function S(e){let t=Atomics.load(e[p].state,l),n=e[p].data.length-t;if(n>0){if(e[p].buf.length===0){e[p].flushing=!1,e[p].ending?k(e):e[p].needDrain&&process.nextTick(x,e);return}let t=e[p].buf.slice(0,n),r=Buffer.byteLength(t);r<=n?(e[p].buf=e[p].buf.slice(n),O(e,t,S.bind(null,e))):e.flush(()=>{if(!e.destroyed){for(Atomics.store(e[p].state,u,0),Atomics.store(e[p].state,l,0),Atomics.notify(e[p].state,u);r>e[p].data.length;)n/=2,t=e[p].buf.slice(0,n),r=Buffer.byteLength(t);e[p].buf=e[p].buf.slice(n),O(e,t,S.bind(null,e))}})}else if(n===0){if(t===0&&e[p].buf.length===0)return;e.flush(()=>{Atomics.store(e[p].state,u,0),Atomics.store(e[p].state,l,0),Atomics.notify(e[p].state,u),S(e)})}else D(e,Error(`overwritten`))}function C(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}switch(e.code){case`READY`:this.stream=new v(t),t.flush(()=>{t[p].ready=!0,t.emit(`ready`)});break;case`ERROR`:D(t,e.err);break;case`EVENT`:Array.isArray(e.args)?t.emit(e.name,...e.args):t.emit(e.name,e.args);break;case`WARNING`:process.emitWarning(e.err);break;default:D(t,Error(`this should not happen: `+e.code))}}function w(e){let t=this.stream.deref();t!==void 0&&(y.unregister(t),t.worker.exited=!0,t.worker.off(`exit`,w),D(t,e===0?null:Error(`the worker thread exited`)))}var T=class extends i{constructor(e={}){if(super(),e.bufferSize<4)throw Error(`bufferSize must at least fit a 4-byte utf-8 char`);this[p]={},this[p].stateBuf=new SharedArrayBuffer(128),this[p].state=new Int32Array(this[p].stateBuf),this[p].dataBuf=new SharedArrayBuffer(e.bufferSize||4*1024*1024),this[p].data=Buffer.from(this[p].dataBuf),this[p].sync=e.sync||!1,this[p].ending=!1,this[p].ended=!1,this[p].needDrain=!1,this[p].destroyed=!1,this[p].flushing=!1,this[p].ready=!1,this[p].finished=!1,this[p].errored=null,this[p].closed=!1,this[p].buf=``,this.worker=b(this,e),this.on(`message`,(e,t)=>{this.worker.postMessage(e,t)})}write(e){if(this[p].destroyed)return E(this,Error(`the worker has exited`)),!1;if(this[p].ending)return E(this,Error(`the worker is ending`)),!1;if(this[p].flushing&&this[p].buf.length+e.length>=m)try{A(this),this[p].flushing=!0}catch(e){return D(this,e),!1}if(this[p].buf+=e,this[p].sync)try{return A(this),!0}catch(e){return D(this,e),!1}return this[p].flushing||(this[p].flushing=!0,setImmediate(S,this)),this[p].needDrain=this[p].data.length-this[p].buf.length-Atomics.load(this[p].state,l)<=0,!this[p].needDrain}end(){this[p].destroyed||(this[p].ending=!0,k(this))}flush(e){if(this[p].destroyed){typeof e==`function`&&process.nextTick(e,Error(`the worker has exited`));return}let t=Atomics.load(this[p].state,l);c(this[p].state,u,t,1/0,(t,n)=>{if(t){D(this,t),process.nextTick(e,t);return}if(n===`not-equal`){this.flush(e);return}process.nextTick(e)})}flushSync(){this[p].destroyed||(A(this),j(this))}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[p].ready}get destroyed(){return this[p].destroyed}get closed(){return this[p].closed}get writable(){return!this[p].destroyed&&!this[p].ending}get writableEnded(){return this[p].ending}get writableFinished(){return this[p].finished}get writableNeedDrain(){return this[p].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[p].errored}};function E(e,t){setImmediate(()=>{e.emit(`error`,t)})}function D(e,t){e[p].destroyed||(e[p].destroyed=!0,t&&(e[p].errored=t,E(e,t)),e.worker.exited?setImmediate(()=>{e[p].closed=!0,e.emit(`close`)}):e.worker.terminate().catch(()=>{}).then(()=>{e[p].closed=!0,e.emit(`close`)}))}function O(e,t,n){let r=Atomics.load(e[p].state,l),i=Buffer.byteLength(t);return e[p].data.write(t,r),Atomics.store(e[p].state,l,r+i),Atomics.notify(e[p].state,l),n(),!0}function k(e){if(!(e[p].ended||!e[p].ending||e[p].flushing)){e[p].ended=!0;try{e.flushSync();let t=Atomics.load(e[p].state,u);Atomics.store(e[p].state,l,-1),Atomics.notify(e[p].state,l);let n=0;for(;t!==-1;){if(Atomics.wait(e[p].state,u,t,1e3),t=Atomics.load(e[p].state,u),t===-2){D(e,Error(`end() failed`));return}if(++n===10){D(e,Error(`end() took too long (10s)`));return}}process.nextTick(()=>{e[p].finished=!0,e.emit(`finish`)})}catch(t){D(e,t)}}}function A(e){let t=()=>{e[p].ending?k(e):e[p].needDrain&&process.nextTick(x,e)};for(e[p].flushing=!1;e[p].buf.length!==0;){let n=Atomics.load(e[p].state,l),r=e[p].data.length-n;if(r===0){j(e),Atomics.store(e[p].state,u,0),Atomics.store(e[p].state,l,0),Atomics.notify(e[p].state,u);continue}else if(r<0)throw Error(`overwritten`);let i=e[p].buf.slice(0,r),a=Buffer.byteLength(i);if(a<=r)e[p].buf=e[p].buf.slice(r),O(e,i,t);else{for(j(e),Atomics.store(e[p].state,u,0),Atomics.store(e[p].state,l,0),Atomics.notify(e[p].state,u);a>e[p].buf.length;)r/=2,i=e[p].buf.slice(0,r),a=Buffer.byteLength(i);e[p].buf=e[p].buf.slice(r),O(e,i,t)}}}function j(e){if(e[p].flushing)throw Error(`unable to flush while flushing`);let t=Atomics.load(e[p].state,l),n=0;for(;;){let r=Atomics.load(e[p].state,u);if(r===-2)throw Error(`_flushSync failed`);if(r!==t)Atomics.wait(e[p].state,u,r,1e3);else break;if(++n===10)throw Error(`_flushSync took too long (10s)`)}}n.exports=T})),lt=n(((e,n)=>{let{createRequire:r}=t(`module`),{existsSync:i}=t(`node:fs`),a=Xe(),{join:o,isAbsolute:s,sep:c}=t(`node:path`),{fileURLToPath:l}=t(`node:url`),u=nt(),d=it(),f=ct();function p(e){d.register(e,y),d.registerBeforeExit(e,b),e.on(`close`,function(){d.unregister(e)})}function m(){let e=process.execArgv;for(let t=0;t<e.length;t++){let n=e[t];if(n===`--import`||n===`--require`||n===`-r`||n.startsWith(`--import=`)||n.startsWith(`--require=`)||n.startsWith(`-r=`))return!0}return!1}function h(e){let t=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!t)return e;let n=[],r=!1;for(let e=0;e<t.length;e++){let i=t[e];if(i===`--require`||i===`-r`||i===`--import`){let a=t[e+1];if(a&&g(a)){r=!0,e++;continue}n.push(i),a&&(n.push(a),e++);continue}if((i.startsWith(`--require=`)||i.startsWith(`-r=`)||i.startsWith(`--import=`))&&g(i.slice(i.indexOf(`=`)+1))){r=!0;continue}n.push(i)}return r?n.join(` `):e}function g(e){let t=_(e);if(!t)return!1;let n=t;if(n.startsWith(`file://`))try{n=l(n)}catch{return!1}return s(n)&&!i(n)}function _(e){let t=e[0],n=e[e.length-1];return t===`"`&&n===`"`||t===`'`&&n===`'`?e.slice(1,-1):e}function v(e,n,r,i,a){if(!r.execArgv&&m()&&t.main===void 0&&(r={...r,execArgv:[]}),!r.env&&process.env.NODE_OPTIONS){let e=h(process.env.NODE_OPTIONS);e!==process.env.NODE_OPTIONS&&(r={...r,env:{...process.env,NODE_OPTIONS:e}})}r={...r,name:a};let o=new f({filename:e,workerData:n,workerOpts:r,sync:i});o.on(`ready`,s),o.on(`close`,function(){process.removeListener(`exit`,c)}),process.on(`exit`,c);function s(){process.removeListener(`exit`,c),o.unref(),r.autoEnd!==!1&&p(o)}function c(){o.closed||(o.flushSync(),u(100),o.end())}return o}function y(e){e.ref(),e.flushSync(),e.end(),e.once(`close`,function(){e.unref()})}function b(e){e.flushSync()}function x(e){let{pipeline:t,targets:n,levels:i,dedupe:l,worker:u={},caller:d=a(),sync:f=!1}=e,p={...e.options},m=typeof d==`string`?[d]:d,h=typeof globalThis==`object`&&Object.prototype.hasOwnProperty.call(globalThis,`__bundlerPathsOverrides`)&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==`object`?globalThis.__bundlerPathsOverrides:Object.create(null),g=e.target;if(g&&n)throw Error(`only one of target or targets can be specified`);n?(g=h[`pino-worker`]||o(__dirname,`worker.js`),p.targets=n.filter(e=>e.target).map(e=>({...e,target:y(e.target)})),p.pipelines=n.filter(e=>e.pipeline).map(e=>e.pipeline.map(t=>({...t,level:e.level,target:y(t.target)})))):t&&(g=h[`pino-worker`]||o(__dirname,`worker.js`),p.pipelines=[t.map(e=>({...e,target:y(e.target)}))]),i&&(p.levels=i),l&&(p.dedupe=l),p.pinoWillSendConfig=!0;let _=n||t?`pino.transport`:g;return v(y(g),p,u,f,_);function y(e){if(e=h[e]||e,s(e)||e.indexOf(`file://`)===0)return e;if(e===`pino/file`)return o(__dirname,`..`,`file.js`);let t;for(let n of m)try{t=r(n===`node:repl`?process.cwd()+c:n).resolve(e);break}catch{continue}if(!t)throw Error(`unable to determine transport target for "${e}"`);return t}}n.exports=x})),ut=n(((e,n)=>{let r=t(`node:diagnostics_channel`),i=tt(),{mapHttpRequest:a,mapHttpResponse:o}=Ye(),s=rt(),c=it(),{lsCacheSym:l,chindingsSym:u,writeSym:d,serializersSym:f,formatOptsSym:p,endSym:m,stringifiersSym:h,stringifySym:g,stringifySafeSym:_,wildcardFirstSym:v,nestedKeySym:y,formattersSym:b,messageKeySym:x,errorKeySym:S,nestedKeyStrSym:C,msgPrefixSym:w}=Qe(),{isMainThread:T}=t(`worker_threads`),E=lt(),[D]=process.versions.node.split(`.`).map(e=>Number(e)),O=r.tracingChannel(`pino_asJson`),k=D>=25?e=>JSON.stringify(e):M;function A(){}function j(e,t){if(!t)return n;return function(...r){t.call(this,r,n,e)};function n(t,...n){if(typeof t==`object`){let r=t;t!==null&&(t.method&&t.headers&&t.socket?t=a(t):typeof t.setHeader==`function`&&(t=o(t)));let s;r===null&&n.length===0?s=[null]:(r=n.shift(),s=n),typeof this[w]==`string`&&r!=null&&(r=this[w]+r),this[d](t,i(r,s,this[p]),e)}else{let r=t===void 0?n.shift():t;typeof this[w]==`string`&&r!=null&&(r=this[w]+r),this[d](null,i(r,n,this[p]),e)}}}function M(e){let t=``,n=0,r=!1,i=255,a=e.length;if(a>100)return JSON.stringify(e);for(var o=0;o<a&&i>=32;o++)i=e.charCodeAt(o),(i===34||i===92)&&(t+=e.slice(n,o)+`\\`,n=o,r=!0);return r?t+=e.slice(n):t=e,i<32?JSON.stringify(e):`"`+t+`"`}function N(e,t,n,r){if(O.hasSubscribers===!1)return P.call(this,e,t,n,r);let i={instance:this,arguments};return O.traceSync(P,i,this,e,t,n,r)}function P(e,t,n,r){let i=this[g],a=this[_],o=this[h],s=this[m],c=this[u],d=this[f],p=this[b],w=this[x],T=this[S],E=this[l][n]+r;E+=c;let D;p.log&&(e=p.log(e));let O=o[v],A=``;for(let t in e)if(D=e[t],Object.prototype.hasOwnProperty.call(e,t)&&D!==void 0){d[t]?D=d[t](D):t===T&&d.err&&(D=d.err(D));let e=o[t]||O;switch(typeof D){case`undefined`:case`function`:continue;case`number`:Number.isFinite(D)===!1&&(D=null);case`boolean`:e&&(D=e(D));break;case`string`:D=(e||k)(D);break;default:D=(e||i)(D,a)}if(D===void 0)continue;let n=k(t);A+=`,`+n+`:`+D}let j=``;if(t!==void 0){D=d[w]?d[w](t):t;let e=o[w]||O;switch(typeof D){case`function`:break;case`number`:Number.isFinite(D)===!1&&(D=null);case`boolean`:e&&(D=e(D)),j=`,"`+w+`":`+D;break;case`string`:D=(e||k)(D),j=`,"`+w+`":`+D;break;default:D=(e||i)(D,a),j=`,"`+w+`":`+D}}return this[y]&&A?E+this[C]+A.slice(1)+`}`+j+s:E+A+j+s}function ee(e,t){let n,r=e[u],i=e[g],a=e[_],o=e[h],s=o[v],c=e[f],l=e[b].bindings;t=l(t);for(let e in t)if(n=t[e],((e.length<5||e!==`level`&&e!==`serializers`&&e!==`formatters`&&e!==`customLevels`)&&t.hasOwnProperty(e)&&n!==void 0)===!0){if(n=c[e]?c[e](n):n,n=(o[e]||s||i)(n,a),n===void 0)continue;r+=`,"`+e+`":`+n}return r}function te(e){return e.write!==e.constructor.prototype.write}function ne(e){let t=new s(e);return t.on(`error`,n),!e.sync&&T&&(c.register(t,re),t.on(`close`,function(){c.unregister(t)})),t;function n(e){if(e.code===`EPIPE`){t.write=A,t.end=A,t.flushSync=A,t.destroy=A;return}t.removeListener(`error`,n),t.emit(`error`,e)}}function re(e,t){e.destroyed||(t===`beforeExit`?(e.flush(),e.on(`drain`,function(){e.end()})):e.flushSync())}function F(e){return function(t,n,r={},i){if(typeof r==`string`)i=ne({dest:r}),r={};else if(typeof i==`string`){if(r&&r.transport)throw Error(`only one of option.transport or stream can be specified`);i=ne({dest:i})}else if(r instanceof s||r.writable||r._writableState)i=r,r={};else if(r.transport){if(r.transport instanceof s||r.transport.writable||r.transport._writableState)throw Error(`option.transport do not allow stream, please pass to option directly. e.g. pino(transport)`);if(r.transport.targets&&r.transport.targets.length&&r.formatters&&typeof r.formatters.level==`function`)throw Error(`option.transport.targets do not allow custom level formatters`);let e;r.customLevels&&(e=r.useOnlyCustomLevels?r.customLevels:Object.assign({},r.levels,r.customLevels)),i=E({caller:n,...r.transport,levels:e})}if(r=Object.assign({},e,r),r.serializers=Object.assign({},e.serializers,r.serializers),r.formatters=Object.assign({},e.formatters,r.formatters),r.prettyPrint)throw Error(`prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)`);let{enabled:a,onChild:o}=r;return a===!1&&(r.level=`silent`),o||(r.onChild=A),i||=te(process.stdout)?process.stdout:ne({fd:process.stdout.fd||1}),{opts:r,stream:i}}}function ie(e,t){try{return JSON.stringify(e)}catch{try{return(t||this[_])(e)}catch{return`"[unable to serialize, circular reference is too complex to analyze]"`}}}function ae(e,t,n){return{level:e,bindings:t,log:n}}function I(e){let t=Number(e);return typeof e==`string`&&Number.isFinite(t)?t:e===void 0?1:e}n.exports={noop:A,buildSafeSonicBoom:ne,asChindings:ee,asJson:N,genLog:j,createArgsNormalizer:F,stringify:ie,buildFormatters:ae,normalizeDestFileDescriptor:I}})),dt=n(((e,t)=>{t.exports={DEFAULT_LEVELS:{trace:10,debug:20,info:30,warn:40,error:50,fatal:60},SORTING_ORDER:{ASC:`ASC`,DESC:`DESC`}}})),ft=n(((e,t)=>{let{lsCacheSym:n,levelValSym:r,useOnlyCustomLevelsSym:i,streamSym:a,formattersSym:o,hooksSym:s,levelCompSym:c}=Qe(),{noop:l,genLog:u}=ut(),{DEFAULT_LEVELS:d,SORTING_ORDER:f}=dt(),p={fatal:e=>{let t=u(d.fatal,e);return function(...e){let n=this[a];if(t.call(this,...e),typeof n.flushSync==`function`)try{n.flushSync()}catch{}}},error:e=>u(d.error,e),warn:e=>u(d.warn,e),info:e=>u(d.info,e),debug:e=>u(d.debug,e),trace:e=>u(d.trace,e)},m=Object.keys(d).reduce((e,t)=>(e[d[t]]=t,e),{}),h=Object.keys(m).reduce((e,t)=>(e[t]=`{"level":`+Number(t),e),{});function g(e){let t=e[o].level,{labels:r}=e.levels,i={};for(let e in r){let n=t(r[e],Number(e));i[e]=JSON.stringify(n).slice(0,-1)}return e[n]=i,e}function _(e,t){if(t)return!1;switch(e){case`fatal`:case`error`:case`warn`:case`info`:case`debug`:case`trace`:return!0;default:return!1}}function v(e){let{labels:t,values:n}=this.levels;if(typeof e==`number`){if(t[e]===void 0)throw Error(`unknown level value`+e);e=t[e]}if(n[e]===void 0)throw Error(`unknown level `+e);let a=this[r],o=this[r]=n[e],d=this[i],f=this[c],m=this[s].logMethod;for(let e in n){if(f(n[e],o)===!1){this[e]=l;continue}this[e]=_(e,d)?p[e](m):u(n[e],m)}this.emit(`level-change`,e,o,t[a],a,this)}function y(e){let{levels:t,levelVal:n}=this;return t&&t.labels?t.labels[n]:``}function b(e){let{values:t}=this.levels,n=t[e];return n!==void 0&&this[c](n,this[r])}function x(e,t,n){return e===f.DESC?t<=n:t>=n}function S(e){return typeof e==`string`?x.bind(null,e):e}function C(e=null,t=!1){let n=e?Object.keys(e).reduce((t,n)=>(t[e[n]]=n,t),{}):null;return{labels:Object.assign(Object.create(Object.prototype,{Infinity:{value:`silent`}}),t?null:m,n),values:Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:d,e)}}function w(e,t,n){if(typeof e==`number`){if(![].concat(Object.keys(t||{}).map(e=>t[e]),n?[]:Object.keys(m).map(e=>+e),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}if(!(e in Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),n?null:d,t)))throw Error(`default level:${e} must be included in custom levels`)}function T(e,t){let{labels:n,values:r}=e;for(let e in t){if(e in r)throw Error(`levels cannot be overridden`);if(t[e]in n)throw Error(`pre-existing level values cannot be used for new levels`)}}function E(e){if(typeof e!=`function`&&!(typeof e==`string`&&Object.values(f).includes(e)))throw Error(`Levels comparison should be one of "ASC", "DESC" or "function" type`)}t.exports={initialLsCache:h,genLsCache:g,levelMethods:p,getLevel:y,setLevel:v,isLevelEnabled:b,mappings:C,assertNoLevelCollisions:T,assertDefaultLevelFound:w,genLevelComparison:S,assertLevelComparison:E}})),pt=n(((e,t)=>{t.exports={version:`10.3.1`}})),mt=n(((e,n)=>{let{EventEmitter:r}=t(`node:events`),{lsCacheSym:i,levelValSym:a,setLevelSym:o,getLevelSym:s,chindingsSym:c,mixinSym:l,asJsonSym:u,writeSym:d,mixinMergeStrategySym:f,timeSym:p,timeSliceIndexSym:m,streamSym:h,serializersSym:g,formattersSym:_,errorKeySym:v,messageKeySym:y,useOnlyCustomLevelsSym:b,needsMetadataGsym:x,redactFmtSym:S,stringifySym:C,formatOptsSym:w,stringifiersSym:T,msgPrefixSym:E,hooksSym:D}=Qe(),{getLevel:O,setLevel:k,isLevelEnabled:A,mappings:j,initialLsCache:M,genLsCache:N,assertNoLevelCollisions:P}=ft(),{asChindings:ee,asJson:te,buildFormatters:ne,stringify:re,noop:F}=ut(),{version:ie}=pt(),ae=$e(),I={constructor:class{},child:L,bindings:se,setBindings:ce,flush:ue,isLevelEnabled:A,version:ie,get level(){return this[s]()},set level(e){this[o](e)},get levelVal(){return this[a]},set levelVal(e){throw Error(`levelVal is read-only`)},get msgPrefix(){return this[E]},get[Symbol.toStringTag](){return`Pino`},[i]:M,[d]:le,[u]:te,[s]:O,[o]:k};Object.setPrototypeOf(I,r.prototype),n.exports=function(){return Object.create(I)};let oe=e=>e;function L(e,t){if(!e)throw Error(`missing bindings for child Pino`);let n=this[g],r=this[_],i=Object.create(this);if(t==null)return i[_].bindings!==oe&&(i[_]=ne(r.level,oe,r.log)),i[c]=ee(i,e),this.onChild!==F&&this.onChild(i),i;if(t.hasOwnProperty(`serializers`)===!0){i[g]=Object.create(null);for(let e in n)i[g][e]=n[e];let e=Object.getOwnPropertySymbols(n);for(var a=0;a<e.length;a++){let t=e[a];i[g][t]=n[t]}for(let e in t.serializers)i[g][e]=t.serializers[e];let r=Object.getOwnPropertySymbols(t.serializers);for(var s=0;s<r.length;s++){let e=r[s];i[g][e]=t.serializers[e]}}else i[g]=n;if(t.hasOwnProperty(`formatters`)){let{level:e,bindings:n,log:a}=t.formatters;i[_]=ne(e||r.level,n||oe,a||r.log)}else i[_]=ne(r.level,oe,r.log);if(t.hasOwnProperty(`customLevels`)===!0&&(P(this.levels,t.customLevels),i.levels=j(t.customLevels,i[b]),N(i)),typeof t.redact==`object`&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let e=ae(i.redact,re),n={stringify:e[S]};i[C]=re,i[T]=e,i[w]=n}if(typeof t.msgPrefix==`string`&&(i[E]=(this[E]||``)+t.msgPrefix),i[c]=ee(i,e),t.level!==void 0&&t.level!==this.level||t.hasOwnProperty(`customLevels`)){let e=t.level||this.level;i[o](e)}return this.onChild(i),i}function se(){let e=`{${this[c].substr(1)}}`,t=JSON.parse(e);return delete t.pid,delete t.hostname,t}function ce(e){this[c]=ee(this,e)}function R(e,t){return Object.assign(t,e)}function le(e,t,n){let r=this[p](),i=this[l],a=this[v],o=this[y],s=this[f]||R,c,d=this[D].streamWrite;e==null?c={}:e instanceof Error?(c={[a]:e},t===void 0&&(t=e.message)):(c=e,t===void 0&&e[o]===void 0&&e[a]&&(t=e[a].message)),i&&(c=s(c,i(c,n,this)));let g=this[u](c,t,n,r),_=this[h];_[x]===!0&&(_.lastLevel=n,_.lastObj=c,_.lastMsg=t,_.lastTime=r.slice(this[m]),_.lastLogger=this),_.write(d?d(g):g)}function ue(e){if(e!=null&&typeof e!=`function`)throw Error(`callback must be a function`);let t=this[h];typeof t.flush==`function`?t.flush(e||F):e&&e()}})),ht=n(((e,t)=>{let{hasOwnProperty:n}=Object.prototype,r=_();r.configure=_,r.stringify=r,r.default=r,e.stringify=r,e.configure=_,t.exports=r;let i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function a(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function o(e,t){if(e.length>200||t)return e.sort(t);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r!==0&&e[r-1]>n;)e[r]=e[r-1],r--;e[r]=n}return e}let s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(e){return s.call(e)!==void 0&&e.length!==0}function l(e,t,n){e.length<n&&(n=e.length);let r=t===`,`?``:` `,i=`"0":${r}${e[0]}`;for(let a=1;a<n;a++)i+=`${t}"${a}":${r}${e[a]}`;return i}function u(e){if(n.call(e,`circularValue`)){let t=e.circularValue;if(typeof t==`string`)return`"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return{toString(){throw TypeError(`Converting circular structure to JSON`)}};throw TypeError(`The "circularValue" argument must be of type string or the value null or undefined`)}return`"[Circular]"`}function d(e){let t;if(n.call(e,`deterministic`)&&(t=e.deterministic,typeof t!=`boolean`&&typeof t!=`function`))throw TypeError(`The "deterministic" argument must be of type boolean or comparator function`);return t===void 0?!0:t}function f(e,t){let r;if(n.call(e,t)&&(r=e[t],typeof r!=`boolean`))throw TypeError(`The "${t}" argument must be of type boolean`);return r===void 0?!0:r}function p(e,t){let r;if(n.call(e,t)){if(r=e[t],typeof r!=`number`)throw TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw TypeError(`The "${t}" argument must be an integer`);if(r<1)throw RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function m(e){return e===1?`1 item`:`${e} items`}function h(e){let t=new Set;for(let n of e)(typeof n==`string`||typeof n==`number`)&&t.add(String(n));return t}function g(e){if(n.call(e,`strict`)){let t=e.strict;if(typeof t!=`boolean`)throw TypeError(`The "strict" argument must be of type boolean`);if(t)return e=>{let t=`Object can not safely be stringified. Received type ${typeof e}`;throw typeof e!=`function`&&(t+=` (${e.toString()})`),Error(t)}}}function _(e){e={...e};let t=g(e);t&&(e.bigint===void 0&&(e.bigint=!1),`circularValue`in e||(e.circularValue=Error));let n=u(e),r=f(e,`bigint`),i=d(e),s=typeof i==`function`?i:void 0,_=p(e,`maximumDepth`),v=p(e,`maximumBreadth`);function y(e,l,u,d,f,p){let h=l[e];switch(typeof h==`object`&&h&&typeof h.toJSON==`function`&&(h=h.toJSON(e)),h=d.call(l,e,h),typeof h){case`string`:return a(h);case`object`:{if(h===null)return`null`;if(u.indexOf(h)!==-1)return n;let e=``,t=`,`,r=p;if(Array.isArray(h)){if(h.length===0)return`[]`;if(_<u.length+1)return`"[Array]"`;u.push(h),f!==``&&(p+=f,e+=`\n${p}`,t=`,\n${p}`);let n=Math.min(h.length,v),i=0;for(;i<n-1;i++){let n=y(String(i),h,u,d,f,p);e+=n===void 0?`null`:n,e+=t}let a=y(String(i),h,u,d,f,p);if(e+=a===void 0?`null`:a,h.length-1>v){let n=h.length-v-1;e+=`${t}"... ${m(n)} not stringified"`}return f!==``&&(e+=`\n${r}`),u.pop(),`[${e}]`}let l=Object.keys(h),g=l.length;if(g===0)return`{}`;if(_<u.length+1)return`"[Object]"`;let b=``,x=``;f!==``&&(p+=f,t=`,\n${p}`,b=` `);let S=Math.min(g,v);i&&!c(h)&&(l=o(l,s)),u.push(h);for(let n=0;n<S;n++){let r=l[n],i=y(r,h,u,d,f,p);i!==void 0&&(e+=`${x}${a(r)}:${b}${i}`,x=t)}if(g>v){let n=g-v;e+=`${x}"...":${b}"${m(n)} not stringified"`,x=t}return f!==``&&x.length>1&&(e=`\n${p}${e}\n${r}`),u.pop(),`{${e}}`}case`number`:return isFinite(h)?String(h):t?t(h):`null`;case`boolean`:return h===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(h);default:return t?t(h):void 0}}function b(e,i,o,s,c,l){switch(typeof i==`object`&&i&&typeof i.toJSON==`function`&&(i=i.toJSON(e)),typeof i){case`string`:return a(i);case`object`:{if(i===null)return`null`;if(o.indexOf(i)!==-1)return n;let e=l,t=``,r=`,`;if(Array.isArray(i)){if(i.length===0)return`[]`;if(_<o.length+1)return`"[Array]"`;o.push(i),c!==``&&(l+=c,t+=`\n${l}`,r=`,\n${l}`);let n=Math.min(i.length,v),a=0;for(;a<n-1;a++){let e=b(String(a),i[a],o,s,c,l);t+=e===void 0?`null`:e,t+=r}let u=b(String(a),i[a],o,s,c,l);if(t+=u===void 0?`null`:u,i.length-1>v){let e=i.length-v-1;t+=`${r}"... ${m(e)} not stringified"`}return c!==``&&(t+=`\n${e}`),o.pop(),`[${t}]`}o.push(i);let u=``;c!==``&&(l+=c,r=`,\n${l}`,u=` `);let d=``;for(let e of s){let n=b(e,i[e],o,s,c,l);n!==void 0&&(t+=`${d}${a(e)}:${u}${n}`,d=r)}return c!==``&&d.length>1&&(t=`\n${l}${t}\n${e}`),o.pop(),`{${t}}`}case`number`:return isFinite(i)?String(i):t?t(i):`null`;case`boolean`:return i===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(i);default:return t?t(i):void 0}}function x(e,u,d,f,p){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return x(e,u,d,f,p);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=p;if(Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u),p+=f;let e=`\n${p}`,n=`,\n${p}`,r=Math.min(u.length,v),i=0;for(;i<r-1;i++){let t=x(String(i),u[i],d,f,p);e+=t===void 0?`null`:t,e+=n}let a=x(String(i),u[i],d,f,p);if(e+=a===void 0?`null`:a,u.length-1>v){let t=u.length-v-1;e+=`${n}"... ${m(t)} not stringified"`}return e+=`\n${t}`,d.pop(),`[${e}]`}let r=Object.keys(u),h=r.length;if(h===0)return`{}`;if(_<d.length+1)return`"[Object]"`;p+=f;let g=`,\n${p}`,y=``,b=``,S=Math.min(h,v);c(u)&&(y+=l(u,g,v),r=r.slice(u.length),S-=u.length,b=g),i&&(r=o(r,s)),d.push(u);for(let e=0;e<S;e++){let t=r[e],n=x(t,u[t],d,f,p);n!==void 0&&(y+=`${b}${a(t)}: ${n}`,b=g)}if(h>v){let e=h-v;y+=`${b}"...": "${m(e)} not stringified"`,b=g}return b!==``&&(y=`\n${p}${y}\n${t}`),d.pop(),`{${y}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function S(e,u,d){switch(typeof u){case`string`:return a(u);case`object`:{if(u===null)return`null`;if(typeof u.toJSON==`function`){if(u=u.toJSON(e),typeof u!=`object`)return S(e,u,d);if(u===null)return`null`}if(d.indexOf(u)!==-1)return n;let t=``,r=u.length!==void 0;if(r&&Array.isArray(u)){if(u.length===0)return`[]`;if(_<d.length+1)return`"[Array]"`;d.push(u);let e=Math.min(u.length,v),n=0;for(;n<e-1;n++){let e=S(String(n),u[n],d);t+=e===void 0?`null`:e,t+=`,`}let r=S(String(n),u[n],d);if(t+=r===void 0?`null`:r,u.length-1>v){let e=u.length-v-1;t+=`,"... ${m(e)} not stringified"`}return d.pop(),`[${t}]`}let f=Object.keys(u),p=f.length;if(p===0)return`{}`;if(_<d.length+1)return`"[Object]"`;let h=``,g=Math.min(p,v);r&&c(u)&&(t+=l(u,`,`,v),f=f.slice(u.length),g-=u.length,h=`,`),i&&(f=o(f,s)),d.push(u);for(let e=0;e<g;e++){let n=f[e],r=S(n,u[n],d);r!==void 0&&(t+=`${h}${a(n)}:${r}`,h=`,`)}if(p>v){let e=p-v;t+=`${h}"...":"${m(e)} not stringified"`}return d.pop(),`{${t}}`}case`number`:return isFinite(u)?String(u):t?t(u):`null`;case`boolean`:return u===!0?`true`:`false`;case`undefined`:return;case`bigint`:if(r)return String(u);default:return t?t(u):void 0}}function C(e,t,n){if(arguments.length>1){let r=``;if(typeof n==`number`?r=` `.repeat(Math.min(n,10)):typeof n==`string`&&(r=n.slice(0,10)),t!=null){if(typeof t==`function`)return y(``,{"":e},[],t,r,``);if(Array.isArray(t))return b(``,e,[],h(t),r,``)}if(r.length!==0)return x(``,e,[],r,``)}return S(``,e,[])}return C}})),gt=n(((e,t)=>{let n=Symbol.for(`pino.metadata`),{DEFAULT_LEVELS:r}=dt(),i=r.info;function a(e,t){e||=[],t||={dedupe:!1};let a=Object.create(r);a.silent=1/0,t.levels&&typeof t.levels==`object`&&Object.keys(t.levels).forEach(e=>{a[e]=t.levels[e]});let u={write:d,add:m,remove:h,emit:f,flushSync:p,end:g,minLevel:0,lastId:0,streams:[],clone:_,[n]:!0,streamLevels:a};return Array.isArray(e)?e.forEach(m,u):m.call(u,e),e=null,u;function d(e){let r,i=this.lastLevel,{streams:a}=this,o=0,u;for(let d=s(a.length,t.dedupe);l(d,a.length,t.dedupe);d=c(d,t.dedupe))if(r=a[d],r.level<=i){if(o!==0&&o!==r.level)break;if(u=r.stream,u[n]){let{lastTime:e,lastMsg:t,lastObj:n,lastLogger:r}=this;u.lastLevel=i,u.lastTime=e,u.lastMsg=t,u.lastObj=n,u.lastLogger=r}u.write(e),t.dedupe&&(o=r.level)}else if(!t.dedupe)break}function f(...e){for(let{stream:t}of this.streams)typeof t.emit==`function`&&t.emit(...e)}function p(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync()}function m(e){if(!e)return u;let t=typeof e.write==`function`||e.stream,n=e.write?e:e.stream;if(!t)throw Error(`stream object needs to implement either StreamEntry or DestinationStream interface`);let{streams:r,streamLevels:a}=this,s;s=typeof e.levelVal==`number`?e.levelVal:typeof e.level==`string`?a[e.level]:typeof e.level==`number`?e.level:i;let c={stream:n,level:s,levelVal:void 0,id:++u.lastId};return r.unshift(c),r.sort(o),this.minLevel=r[0].level,u}function h(e){let{streams:t}=this,n=t.findIndex(t=>t.id===e);return n>=0&&(t.splice(n,1),t.sort(o),this.minLevel=t.length>0?t[0].level:-1),u}function g(){for(let{stream:e}of this.streams)typeof e.flushSync==`function`&&e.flushSync(),e.end()}function _(e){let t=Array(this.streams.length);for(let n=0;n<t.length;n++)t[n]={level:e,stream:this.streams[n].stream};return{write:d,add:m,remove:h,minLevel:e,streams:t,clone:_,emit:f,flushSync:p,[n]:!0}}}function o(e,t){return e.level-t.level}function s(e,t){return t?e-1:0}function c(e,t){return t?e-1:e+1}function l(e,t,n){return n?e>=0:e<t}t.exports=a})),_t=n(((e,n)=>{let r=t(`node:os`),i=Ye(),a=Xe(),o=$e(),s=et(),c=mt(),l=Qe(),{configure:u}=ht(),{assertDefaultLevelFound:d,mappings:f,genLsCache:p,genLevelComparison:m,assertLevelComparison:h}=ft(),{DEFAULT_LEVELS:g,SORTING_ORDER:_}=dt(),{createArgsNormalizer:v,asChindings:y,buildSafeSonicBoom:b,buildFormatters:x,stringify:S,normalizeDestFileDescriptor:C,noop:w}=ut(),{version:T}=pt(),{chindingsSym:E,redactFmtSym:D,serializersSym:O,timeSym:k,timeSliceIndexSym:A,streamSym:j,stringifySym:M,stringifySafeSym:N,stringifiersSym:P,setLevelSym:ee,endSym:te,formatOptsSym:ne,messageKeySym:re,errorKeySym:F,nestedKeySym:ie,mixinSym:ae,levelCompSym:I,useOnlyCustomLevelsSym:oe,formattersSym:L,hooksSym:se,nestedKeyStrSym:ce,mixinMergeStrategySym:R,msgPrefixSym:le}=l,{epochTime:ue,nullTime:de}=s,{pid:z}=process,fe=r.hostname(),pe=i.err,me=v({level:`info`,levelComparison:_.ASC,levels:g,messageKey:`msg`,errorKey:`err`,nestedKey:null,enabled:!0,base:{pid:z,hostname:fe},serializers:Object.assign(Object.create(null),{err:pe}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return{level:t}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:ue,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100}),he=Object.assign(Object.create(null),i);function ge(...e){let t={},{opts:n,stream:r}=me(t,a(),...e);n.level&&typeof n.level==`string`&&g[n.level.toLowerCase()]!==void 0&&(n.level=n.level.toLowerCase());let{redact:i,crlf:s,serializers:l,timestamp:_,messageKey:v,errorKey:b,nestedKey:C,base:T,name:z,level:fe,customLevels:pe,levelComparison:he,mixin:ge,mixinMergeStrategy:_e,useOnlyCustomLevels:B,formatters:ve,hooks:ye,depthLimit:be,edgeLimit:xe,onChild:Se,msgPrefix:Ce}=n,V=u({maximumDepth:be,maximumBreadth:xe}),we=x(ve.level,ve.bindings,ve.log),Te=S.bind({[N]:V}),H=i?o(i,Te):{},Ee=i?{stringify:H[D]}:{stringify:Te},De=`}`+(s?`\r
|
|
4
4
|
`:`
|
|
@@ -88,5 +88,5 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
|
|
|
88
88
|
`)){let n=t.trim();if(!n)continue;let r=e.get(n)??Te(this.contentDir,V(this.projectDir,n));r&&!r.startsWith(`..`)&&u.push(r)}}}catch{u=t.map(e=>e.contentRelPath)}let d=this.buildCommitMessage(u),f=await kh(this.projectDir),p=f===null;this.identityUnresolved!==p&&(this.identityUnresolved=p,this.cc1Broadcaster?.signal(`sync-status`));let m=f?.name??`Open Knowledge`,h=f?.email??`sync@open-knowledge.local`;e.git.env({GIT_AUTHOR_NAME:m,GIT_AUTHOR_EMAIL:h,GIT_COMMITTER_NAME:m,GIT_COMMITTER_EMAIL:h});let g=(await e.git.raw([`commit-tree`,c,`-p`,i,`-m`,d])).trim();if(!g||!Sb.test(g)){$.warn({raw:g},`[sync] commit-tree returned invalid SHA — aborting push`),this.transitionTo(`idle`);return}if(await e.git.raw([`update-ref`,`refs/heads/${this.currentBranch}`,g,i]),t.length>0){let e=L(this.projectDir,{credentialArgs:this.credentialArgs});for(let n=0;n<t.length;n+=100){let r=t.slice(n,n+100).map(e=>e.projectRelPath);try{await e.git.raw([`reset`,`HEAD`,`--`,...r])}catch{}}}let _=!1;try{await e.git.raw([`rev-parse`,`--abbrev-ref`,`${this.currentBranch}@{u}`]),_=!0}catch{}_?await e.git.raw([`push`,`origin`,this.currentBranch]):await e.git.raw([`push`,`--set-upstream`,`origin`,this.currentBranch]),r=g}),r&&(this.lastPushedSha=r,this.lastSyncUtc=new Date().toISOString(),this.ahead=0,this.state===`pushing`&&this.transitionTo(`idle`),this.pausedReason===`dirty-tree`&&(this.pausedReason=void 0,this.error=void 0,this.schedulePull(0)))}catch(t){let n=bb(t instanceof Error?t:Error(String(t)));if(n.class===`semantic`&&n.subclass===`non-fast-forward`){if(e>0){$.info({},`[sync] push rejected (non-fast-forward) — fetching, merging, retrying`);let e=L(this.projectDir,{credentialArgs:this.credentialArgs});this.setBatchInProgress?.(!0);try{if(await e.git.fetch(`origin`),await this.commitDirtyContentFilesToHead(e),!await this.pauseIfNonContentDirty(e)){this.setBatchInProgress?.(!1);return}await e.git.merge([`origin/${this.currentBranch}`])}catch(e){let t=bb(e instanceof Error?e:Error(String(e)));t.class===`semantic`&&t.subclass===`merge-conflict`?await this.handleMergeConflict():this.handleError(t),this.scheduleSaveState();return}finally{this.setBatchInProgress?.(!1)}await this.doPushCycle(0);return}$.info({},`[sync] push still rejected after retry — waiting for next pull cycle`),this.consecutiveFailures++,this.state===`pushing`&&this.transitionTo(`idle`)}else this.handleError(n)}finally{try{_e(n)}catch{}}this.scheduleSaveState()}async commitDirtyContentFilesToHead(e){if((await e.git.status()).files.length===0)return null;let t=(await e.git.revparse(`HEAD`)).trim(),n=this.gatherContentFilesSync();if(n.length===0)return null;let r=V(xe(),`ok-sync-retry-idx-${process.pid}-${Date.now()}.idx`),i=L(this.projectDir,{credentialArgs:this.credentialArgs,gitIndexFile:r});try{await i.git.raw([`read-tree`,t]);for(let e=0;e<n.length;e+=100){let t=n.slice(e,e+100).map(e=>e.projectRelPath);await i.git.raw([`add`,`--`,...t])}let r=(await i.git.raw([`write-tree`])).trim();if(r===(await i.git.raw([`rev-parse`,`${t}^{tree}`])).trim())return null;let a=await kh(this.projectDir),o=a?.name??`Open Knowledge`,s=a?.email??`sync@open-knowledge.local`;i.git.env({GIT_AUTHOR_NAME:o,GIT_AUTHOR_EMAIL:s,GIT_COMMITTER_NAME:o,GIT_COMMITTER_EMAIL:s});let c=(await i.git.raw([`commit-tree`,r,`-p`,t,`-m`,`Auto-save: interim before merge`])).trim();if(!c||!Sb.test(c))return $.warn({raw:c},`[sync] commit-tree returned invalid SHA in commitDirtyContentFilesToHead`),null;await e.git.raw([`update-ref`,`refs/heads/${this.currentBranch}`,c,t]);for(let t=0;t<n.length;t+=100){let r=n.slice(t,t+100).map(e=>e.projectRelPath);try{await e.git.raw([`reset`,`HEAD`,`--`,...r])}catch{}}return c}finally{try{_e(r)}catch{}}}async pauseIfNonContentDirty(e){let t=``;try{t=(await e.git.raw([`diff-index`,`--name-only`,`HEAD`])).trim()}catch{return!0}if(!t)return!0;let n=t.split(`
|
|
89
89
|
`).map(e=>e.trim()).filter(Boolean);return n.length===0?!0:(this.error=`External changes pending: ${n.slice(0,3).join(`, `)}${n.length>3?`, +${n.length-3} more`:``}`,this.pausedReason=`external-changes-pending`,this.consecutiveFailures=0,this.transitionTo(`idle`),this.scheduleSaveState(),$.warn({files:n},`[sync] paused — non-content tracked files dirty`),!1)}gatherContentFilesSync(){let e=[],t=n=>{let r;try{r=fe(n,{withFileTypes:!0})}catch{return}for(let i of r){let r=V(n,i.name);if(i.isDirectory()){if(i.name===`node_modules`||i.name===`.git`||i.name.startsWith(`.`)&&i.name!==`.open-knowledge`)continue;t(r)}else if(i.isFile()){let t=Te(this.contentDir,r);if(!t.startsWith(`..`)&&!this.contentFilter.isExcluded(t)){let n=Te(this.projectDir,r);e.push({contentRelPath:t,projectRelPath:n})}}}};return R(this.contentDir)&&t(this.contentDir),e}buildCommitMessage(e){return e.length===0?`Auto-save: changes saved`:e.length<=3?`Auto-save: Updated ${e.join(`, `)}`:`Auto-save: ${e.length} files changed`}async handleMergeConflict(){let e=L(this.projectDir,{credentialArgs:this.credentialArgs}),t=[];try{let n=(await e.git.raw([`diff`,`--name-only`,`--diff-filter=U`])).trim();t=n?n.split(`
|
|
90
90
|
`).map(e=>e.trim()).filter(Boolean):[]}catch(t){$.error({err:t},`[sync] failed to list conflicted files — aborting merge to avoid committing unresolved state`);try{await e.git.raw([`merge`,`--abort`])}catch(e){$.warn({err:e},`[sync] git merge --abort failed during cleanup`)}this.error=`Failed to detect conflict files — merge aborted`,this.pausedReason=void 0,this.transitionTo(`idle`);return}let n=[],r=[];for(let e of t){let t=V(this.projectDir,e),i=Te(this.contentDir,t);!i.startsWith(`..`)&&!this.contentFilter.isExcluded(i)?n.push(e):r.push(e)}for(let t of r)try{await e.git.raw([`checkout`,`--theirs`,`--`,t]),await e.git.raw([`add`,`--`,t]),$.info({file:t},`[sync] auto-resolved non-content conflict with theirs`)}catch(e){$.warn({err:e,file:t},`[sync] auto-resolve failed — escalating to content conflict`),n.push(t)}if(n.length>0){for(let e of n)this.conflictStore.addConflict({file:e,detectedAt:new Date().toISOString()});this.conflictCount=this.conflictStore.count(),this.pullTimer!==null&&(clearTimeout(this.pullTimer),this.pullTimer=null),this.pushTimer!==null&&(clearTimeout(this.pushTimer),this.pushTimer=null),this.transitionTo(`conflict`),$.warn({files:n},`[sync] content conflicts — sync paused until resolved`)}else try{await e.git.raw([`commit`,`--no-edit`]),this.lastSyncUtc=new Date().toISOString(),this.behind=0,this.transitionTo(`idle`),$.info({},`[sync] all conflicts auto-resolved — merge committed`)}catch(t){$.warn({err:t},`[sync] failed to commit after auto-resolving conflicts — aborting merge`);try{await e.git.raw([`merge`,`--abort`])}catch(e){$.warn({err:e},`[sync] git merge --abort failed during cleanup`)}this.transitionTo(`idle`)}}async abortMerge(){let e=L(this.projectDir,{credentialArgs:this.credentialArgs});try{await e.git.raw([`merge`,`--abort`]),$.info({},`[sync] merge aborted`)}catch(e){$.warn({err:e},`[sync] git merge --abort failed — conflicts.json still cleared`)}this.conflictStore.clear(),this.conflictCount=0,this.transitionTo(`idle`),this.scheduleSaveState()}handleError(e){this.error=e.message,$.warn({class:e.class,subclass:e.subclass,retryable:e.retryable,rawStderr:e.rawStderr},`[sync-error] ${e.message}`),e.class===`auth`?(this.transitionTo(`auth-error`),this.pausedReason=`auth-error`):e.class===`semantic`&&e.subclass===`protected-branch`?(this.syncEnabled=!1,this.transitionTo(`disabled`),this.pausedReason=`protected-branch`):e.class===`local`&&e.subclass===`dirty-tree`?(this.consecutiveFailures++,this.transitionTo(`idle`),this.pausedReason=`dirty-tree`,this.schedulePush(0)):e.retryable?(this.consecutiveFailures++,this.transitionTo(`offline`)):(this.consecutiveFailures++,this.transitionTo(`idle`))}transitionTo(e){if(this.state===e)return;let t=this.state;this.state=e,$.info({from:t,to:e},`[sync] state: ${t} → ${e}`),this.onStateChange?.(e),this.cc1Broadcaster?.signal(`sync-status`)}scheduleSaveState(){this.stateSaveTimer===null&&(this.stateSaveTimer=setTimeout(()=>{this.stateSaveTimer=null,this.saveStateNow()},5e3))}saveStateNow(){try{let e={version:1,lastSyncUtc:this.lastSyncUtc,lastFetchUtc:this.lastFetchUtc,lastPushedSha:this.lastPushedSha,consecutiveFailures:this.consecutiveFailures,pausedReason:this.pausedReason,pausedSinceUtc:this.pausedReason?new Date().toISOString():void 0,inflightConflicts:this.conflictStore.list().map(e=>e.file),syncEnabled:this.syncEnabled};B(this.statePath,JSON.stringify(e,null,2),`utf-8`)}catch(e){$.warn({err:e},`[sync] failed to persist sync state`)}}loadState(){if(R(this.statePath))try{let e=z(this.statePath,`utf-8`),t=JSON.parse(e);if(t.version!==1)return;this.lastSyncUtc=t.lastSyncUtc??null,this.lastFetchUtc=t.lastFetchUtc??null,this.lastPushedSha=t.lastPushedSha??null,this.consecutiveFailures=t.consecutiveFailures??0,this.pausedReason=t.pausedReason,t.syncEnabled!==void 0&&(this.syncEnabled=t.syncEnabled);let n=t.inflightConflicts??[];if(n.length>0){for(let e of n)this.conflictStore.list().some(t=>t.file===e)||this.conflictStore.addConflict({file:e,detectedAt:new Date().toISOString()});this.conflictCount=this.conflictStore.count()}}catch(e){$.warn({err:e},`[sync] failed to load sync state`)}}};const Db=(()=>{let e=Object.freeze({origin:`park-snapshot`,paired:!0});return Object.freeze({source:`local`,skipStoreHooks:!1,context:e})})();function Ob(e){let{contentDir:t,projectDir:n=t,quiet:r=!0,debounce:i=2e3,maxDebounce:a=1e4,gitEnabled:o=!0,commitDebounceMs:s=3e4,wipRef:c=`refs/wip/main`,enableTestRoutes:l=!1,shadowRepo:u,contentRoot:d,includePatterns:f=[`**/*.md`,`**/*.mdx`],excludePatterns:p=[],destroyTimeoutMs:m=1e4,localOpCliArgs:h}=e,g=ln(`server`),_=H(t,`.open-knowledge`);re(_,{port:e.port??0,worktreeRoot:n});let v,y,x,S,C,w,T=null,E=null,D=null,O=null;function k(e){T?.signal(e)}try{v=Py({projectDir:n,contentDir:t,includePatterns:f,excludePatterns:p}),y=new vm({projectDir:n,contentDir:t,contentFilter:v}),x={current:u},S=nh({contentDir:t,projectDir:n,gitEnabled:o,commitDebounceMs:s,wipRef:c,shadowRef:x,contentRoot:d,backlinkIndex:y,getCurrentBranch:()=>oe?.getLastKnownBranch()??null,getPrincipal:()=>O}),C=new gy({quiet:r,debounce:i,maxDebounce:a,extensions:[S.extension]}),T=new El(C),E=new un(C),D=new Hn(C),w=new Pl(C);let m=qy({backlinkIndex:y,signalChannel:k});C.configuration.extensions.push(m),C.configuration.extensions.push({async onAuthenticate(e){try{let t=e.token;if(!t)return;let n=JSON.parse(t),r=e.context;typeof n.principalId==`string`&&(O&&n.principalId===O.id?r.principalId=O.id:O?console.warn(JSON.stringify({event:`principal-token-mismatch`,claimed:n.principalId,loaded:O.id})):r.principalId=n.principalId),typeof n.tabSessionId==`string`&&(r.tabSessionId=n.tabSessionId),r.kind=`human`}catch{}}});let g=h_({hocuspocus:C,sessionManager:w,contentDir:t,getFileIndex:()=>I?I.getFileIndex():new Map,getAliasMap:()=>I?I.getAliasMap():new Map,enableTestRoutes:l,shadowRef:x,flushGitCommit:()=>S.flushPendingGitCommit(),getCurrentBranch:()=>oe?.getLastKnownBranch()??null,contentRoot:d,backlinkIndex:y,signalChannel:k,agentFocusBroadcaster:E,agentPresenceBroadcaster:D,onAgentWrite:e.onAgentWrite,getSyncEngine:()=>L,localOpCliArgs:h,projectDir:n,getPrincipal:()=>O});C.configuration.extensions.push(g),C.configuration.extensions.push(eb({mdManager:Dl,schema:Ol,shadowRef:x,contentRoot:d,getCurrentBranch:()=>oe?.getLastKnownBranch()??null}))}catch(e){throw te(_),e}let A=null;function j(e,t){let n=H(e,`rescue`),r=H(n,`${t}${Up(t)}`);return r.startsWith(`${n}/`)?r:null}function N(e){let t=C.documents.get(e);if(!t)return null;let n=Tl(t.getXmlFragment(`default`),Ol).toJSON(),r=Dl.serialize(n),i=t.getMap(`metadata`).get(`frontmatter`);return M(typeof i==`string`?i:``,r)}let P=(e,t)=>zy(C,e,t);function ee(e){return e.kind===`rename`?e.newDocName:e.docName}async function ne(e){try{switch(e.kind){case`create`:g.info({docName:e.docName},`[reconcile] create: ${e.docName}`),y.updateDocumentFromMarkdown(e.docName,e.content),y.saveToDisk().catch(t=>{console.warn(`[backlinks] Failed to persist create for ${e.docName}:`,t)}),k(`files`),k(`backlinks`),k(`graph`);break;case`update`:{let{docName:t,content:n}=e,r=C.documents.get(t);if(!r){y.updateDocumentFromMarkdown(t,n),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist closed-doc update for ${t}:`,e)}),k(`backlinks`),k(`graph`);return}let i=Xm(t)??``,a=N(t)??i,o=oh({docName:t,base:i,ours:a,theirs:n}),s=mh(i).slice(0,6),c=mh(a).slice(0,6),l=mh(n).slice(0,6);switch(g.info({docName:t,base:s,ours:c,theirs:l,result:o.kind},`[reconcile] ${t} base=${s} ours=${c} theirs=${l} result=${o.kind}`),o.kind){case`noop`:y.updateDocumentFromMarkdown(t,n),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist noop update for ${t}:`,e)}),k(`backlinks`),k(`graph`);break;case`clean`:try{P(t,o.newContent),Zm(t,o.newContent),hn(),y.updateDocumentFromMarkdown(t,n),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist clean update for ${t}:`,e)}),k(`backlinks`),k(`graph`)}catch(e){g.error({err:e,docName:t},`[reconcile] failed to apply clean content to Y.Doc for ${t}`),Zm(t,n)}break;case`merged`:try{P(t,o.newContent),Zm(t,o.newContent),hn(),y.updateDocumentFromMarkdown(t,n),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist merged update for ${t}:`,e)}),k(`backlinks`),k(`graph`)}catch(e){g.error({err:e,docName:t},`[reconcile] failed to apply merged content to Y.Doc for ${t}`),Zm(t,n)}break;case`conflicts`:try{P(t,o.newContent),Zm(t,o.newContent),hn(),gn(),y.updateDocumentFromMarkdown(t,n),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist conflict update for ${t}:`,e)}),k(`backlinks`),k(`graph`)}catch(e){g.error({err:e,docName:t},`[reconcile] failed to apply conflict content to Y.Doc for ${t}`),Zm(t,n)}break;case`refused`:{gn();let e=r.getMap(`lifecycle`);e.set(`status`,`conflict`),e.set(`reason`,o.reason);break}}break}case`delete`:{let{docName:t}=e,n=C.documents.get(t);if(!n){y.deleteDocument(t),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist closed-doc delete for ${t}:`,e)}),k(`files`),k(`backlinks`),k(`graph`);return}let r=Xm(t)??``,i=N(t)??``,a=i!==r;if(a&&x.current){let e=x.current,n=oe?.getLastKnownBranch()??`main`;queueMicrotask(()=>{Lm(e,d??``,{kind:`external-change-rescue`,docName:t,contents:i,label:`External change recovered @ ${new Date().toISOString()}`,branch:n,metadata:{incomingDiskSha:``}}).then(()=>{yn(),g.info({docName:t},`[reconcile] rescue checkpoint saved (delete): ${t}`)}).catch(e=>{g.error({docName:t,err:e},`[reconcile] rescue checkpoint write failed: ${t}`)})})}n.getMap(`lifecycle`).set(`status`,`deleted-upstream`),Qm(t),y.deleteDocument(t),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist delete for ${t}:`,e)}),g.info({docName:t,isDirty:a},`[reconcile] delete: ${t} (dirty=${a})`),C.closeConnections(t),await C.unloadDocument(n),k(`files`),k(`backlinks`),k(`graph`);break}case`rename`:{let{oldDocName:t,newDocName:n,content:r}=e,i=C.documents.get(t);if(Qm(t),Zm(n,r),y.renameDocument(t,n,r),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist rename for ${t} -> ${n}:`,e)}),i){let e=i.getMap(`lifecycle`);e.set(`status`,`renamed`),e.set(`newPath`,n)}g.info({oldDocName:t,newDocName:n},`[reconcile] rename: ${t} → ${n}`),k(`files`),k(`backlinks`),k(`graph`);break}case`conflict`:{let{docName:t}=e,n=C.documents.get(t);if(!n)return;let r=n.getMap(`lifecycle`);r.set(`status`,`conflict`),r.set(`reason`,`conflict-markers`),g.info({docName:t},`[reconcile] conflict markers detected: ${t}`);break}}}catch(t){g.error({err:t,kind:e.kind,docName:ee(e)},`[reconcile] failed to handle ${e.kind} for ${ee(e)}`)}}let F=[];async function ie(e){if(th()){F.push(e);return}await ne(e)}async function ae(){let e=F.splice(0,F.length);for(let t of e)await ne(t)}let I=null,oe=null,L=null,se=null;async function ce(e){if(C.documents.size===0)return;let t=!1,n=new Promise(e=>{C.configuration.extensions.push({async afterUnloadDocument({instance:n}){!t&&n.getDocumentsCount()===0&&(t=!0,e())}})}),r=Array.from(C.documents.keys());C.closeConnections(),C.flushPendingStores();let i,a=new Promise((n,a)=>{i=setTimeout(()=>{t=!0;let n=Array.from(C.documents.keys()),i=[],o=[];if(x.current){for(let e of n)if(!J(e))try{let t=N(e);if(t===null){g.warn({docName:e},`[rescue] skipping ${e} — document dropped from map mid-rescue`),o.push(e);continue}let n=j(x.current.gitDir,e);if(!n){g.warn({docName:e,gitDir:x.current.gitDir},`[rescue] path-traversal guard rejected docName: ${e}`),o.push(e);continue}ue(Se(n),{recursive:!0}),B(n,t,`utf-8`),yn(),i.push(e),g.info({docName:e},`[rescue] rescue buffer saved on flush timeout: ${e}`)}catch(t){o.push(e),g.error({err:t,docName:e},`[rescue] failed to write rescue buffer for ${e}`)}}else g.warn({stillLoadedCount:n.length},`[rescue] shadow repo unavailable at flush timeout — ${n.length} doc(s) will be lost: [${n.join(`, `)}]`),o.push(...n);let s=i.length>0||o.length>0?` — rescued [${i.join(`, `)}]${o.length>0?`, lost [${o.join(`, `)}]`:``}`:``;a(Error(`flushAllStoresAndWait timeout after ${e}ms — ${n.length}/${r.length} docs did not unload: [${n.join(`, `)}]${s}`))},e)});try{await Promise.race([n,a])}finally{i!==void 0&&clearTimeout(i)}}async function le(){return se||(se=(async()=>{let e=Date.now(),t=[],r,i=await Promise.race([pe.then(()=>`completed`,e=>(g.debug({err:e},`[server] init incomplete during shutdown`),`failed`)),new Promise(e=>{r=setTimeout(()=>e(`timeout`),5e3)})]);r!==void 0&&clearTimeout(r),i===`timeout`&&g.warn({},`[server] init did not complete within 5s during shutdown`);let a=C.documents.size;try{try{try{oe&&=(await oe.unsubscribe(),null),I&&=(await I.unsubscribe(),null)}catch(e){t.push({phase:`watcher-unsubscribe`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown phase-1 watcher unsubscribe failed`)}try{T?.destroy(),D?.destroy(),A&&=(await A.disconnect(),null)}catch(e){t.push({phase:`cc1-teardown`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown phase-1b CC1 teardown failed`)}try{await w.closeAll()}catch(e){t.push({phase:`agent-session-drain`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown phase-2 agent session drain failed`)}try{await ce(m)}catch(e){t.push({phase:`flush-all-stores`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown phase-3 flush failed`)}let e;try{await Promise.race([(async()=>{await S.flushPendingGitCommit(),await S.waitForPendingCommits()})(),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`L2 git flush timeout`)),m)})])}catch(e){t.push({phase:`git-commit-flush`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown phase-4 git commit flush failed`)}finally{e!==void 0&&clearTimeout(e)}try{L&&=(await L.destroy(),null)}catch(e){t.push({phase:`sync-engine-stop`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown sync-engine-stop failed`)}}finally{if(x.current){try{let e=(await Fe({baseDir:n,timeout:{block:5e3}}).revparse(`HEAD`)).trim();e&&B(H(x.current.gitDir,`last-known-head`),e,`utf-8`)}catch{}try{wm(x.current)}catch(e){t.push({phase:`shadow-repo-release`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown phase-5 destroyShadowRepo failed`)}}let r=Date.now()-e;t.length===0?g.info({documentCount:a,durationMs:r},`[server] shutdown flushed ${a} documents in ${r}ms`):g.warn({documentCount:a,durationMs:r,phaseErrors:t},`[server] shutdown flushed ${a} documents in ${r}ms with ${t.length} phase error(s)`)}}finally{try{te(_)}catch(e){t.push({phase:`server-lock-release`,error:e instanceof Error?e.message:String(e)}),g.error({err:e},`[server] shutdown phase-6 releaseServerLock failed`)}}})(),se)}let de=[];async function fe(){try{O=await Yy(t),g.info({principalId:O.id},`[server] principal loaded`)}catch(e){g.warn({err:e},`[server] principal load failed — browser writes will use SERVICE_WRITER`)}if(!x.current)try{x.current=await Cm(n),g.info({gitDir:x.current.gitDir},`[server] history repo initialized at ${x.current.gitDir}`)}catch(e){g.error({err:e},`[server] history repo init failed`),de.push(`shadow-repo`)}if(x.current)try{await Sm(x.current).raw(`rev-parse`,`--git-dir`)}catch(e){let t=e instanceof Error?e.message:String(e);if(t.includes(`not a git repository`)||t.includes(`invalid object`)){g.warn({},`[server] history repo appears corrupted — reinitializing`);try{x.current=await Cm(n)}catch(e){g.error({err:e},`[server] history repo reinit failed`),x.current=void 0,de.includes(`shadow-repo`)||de.push(`shadow-repo`)}}else g.error({err:e},`[server] history repo check failed (transient?)`)}if(x.current)try{let e=H(x.current.gitDir,`last-known-head`),t=null;try{t=z(e,`utf-8`).trim()||null}catch{}let r=null;try{r=(await Fe({baseDir:n,timeout:{block:1e4}}).revparse(`HEAD`)).trim()||null}catch{}if(r!==null){if(r!==t){let e=`main`;try{let t=(await Fe({baseDir:n,timeout:{block:1e4}}).raw(`rev-parse`,`--abbrev-ref`,`HEAD`)).trim();t&&t!==`HEAD`&&(e=t)}catch{}g.info({lastKnownHead:t,currentHead:r,branch:e},`[head-drift] lastKnownHead=${t??`null`}, currentHead=${r}, action=import`);try{await Pm(x.current,d??``,t,r,e),vn()}catch(e){g.warn({err:e},`[head-drift] commitUpstreamImport failed — continuing`)}}else g.info({currentHead:r},`[head-drift] lastKnownHead=${t??`null`}, currentHead=${r}, action=noop`);try{B(e,r,`utf-8`)}catch(e){g.warn({err:e},`[head-drift] failed to write last-known-head`)}}}catch(e){g.warn({err:e},`[head-drift] check failed — continuing`)}try{let e=Qh(t);e.recovered&&e.journal&&g.warn({sourceDocName:e.journal.sourceDocName,destinationDocName:e.journal.destinationDocName,restoredDocNames:e.restoredDocNames},`[managed-rename] recovered pending rename ${e.journal.sourceDocName} -> ${e.journal.destinationDocName}`)}catch(e){g.error({err:e},`[server] managed rename recovery failed`),de.push(`managed-rename-recovery`)}try{A=await C.openDirectConnection(b)}catch(e){g.error({err:e},`[server] failed to open __system__ direct connection — CC1 push disabled`),de.push(`cc1-push`)}try{I=await Dh(t,ie,v),y.rebuildFromDisk(Ym()),y.saveToDisk().catch(e=>{console.warn(`[backlinks] Failed to persist startup cache for ${Ym()}:`,e)})}catch(e){g.error({err:e},`[server] disk bridge watcher failed to start`),de.push(`file-watcher`)}try{oe=await Wy(n,async({trigger:e})=>{if(g.info({trigger:e},`[batch] begin trigger=${e}`),_n(),C.flushPendingStores(),await S.flushPendingGitCommit(),eh(!0),x.current){let e=Ym(),t=Vy(n),r=t?Uy(t)??e:e,i=[];for(let[e,t]of C.documents){if(J(e))continue;let n=null;if(t.transact(()=>{n=N(e)},Db),n===null)continue;let r=Xm(e)??n;i.push({docName:e,markdown:n,diskSnapshot:r})}if(i.length>0)try{let t=await zm(x.current,e,Mm.id,i,r);t&&(xn(),g.info({count:i.length,branch:e,sha:t.slice(0,8)},`[history] parked ${i.length} docs on ${e} → ${t.slice(0,8)}`))}catch(e){g.error({err:e},`[shadow] park failed`)}}},async e=>{let n=F.length,r=e.newBranch??`main`;if(eh(!1),g.info({kind:e.batchKind,headMoved:e.headMoved,docs:n,timeout:!!e.timeout},`[batch] end kind=${e.batchKind} headMoved=${e.headMoved} docs=${n}${e.timeout?` timeout`:``}`),e.batchKind===`within-branch`)await ae();else{bn(),F.splice(0,F.length),Jm(r),y.switchBranch(r);for(let[e,n]of C.documents)if(!J(e))try{let i=Wm(e,t);if(!R(i)){let t=Xm(e)??``,i=N(e)??``;if(i!==t&&x.current){let t=x.current;queueMicrotask(()=>{Lm(t,d??``,{kind:`external-change-rescue`,docName:e,contents:i,label:`External change recovered @ ${new Date().toISOString()}`,branch:r,metadata:{incomingDiskSha:``}}).then(()=>{yn(),g.info({docName:e},`[reconcile] rescue checkpoint saved on branch switch: ${e}`)}).catch(t=>{g.error({docName:e,err:t},`[reconcile] rescue checkpoint write failed: ${e}`)})})}n.getMap(`lifecycle`).set(`status`,`deleted-upstream`),g.info({docName:e,branch:r},`[branch-switch] tombstone: ${e} (not on ${r})`);continue}let a=z(i,`utf-8`);P(e,a),Zm(e,a),g.info({docName:e},`[branch-switch] reset: ${e}`)}catch(t){g.error({err:t,docName:e},`[branch-switch] failed to reset ${e}`)}if(g.info({branch:r,docCount:C.documents.size},`[branch-switch] loaded branch ${r} (${C.documents.size} docs)`),y.rebuildFromDisk(r),y.saveToDisk(r).catch(e=>{console.warn(`[backlinks] Failed to persist branch cache for ${r}:`,e)}),x.current&&e.batchKind===`cross-branch`){let e=0;for(let[t]of C.documents)if(!J(t))try{let n=await Bm(x.current,r,Mm.id,t);if(!n||n.markdown===n.diskSnapshot)continue;let i=Xm(t);if(!i)continue;let a=oh({docName:t,base:n.diskSnapshot,ours:n.markdown,theirs:i});switch(a.kind){case`merged`:case`clean`:P(t,a.newContent),Zm(t,a.newContent),e++;break;case`conflicts`:P(t,a.newContent),Zm(t,a.newContent),gn(),e++;break;case`noop`:case`refused`:break}}catch(e){g.error({err:e,docName:t},`[branch-switch] restore WIP failed for ${t}`)}e>0&&g.info({count:e,branch:r},`[branch-switch] restored ${e} parked docs on ${r}`)}if(e.oldBranch?.startsWith(`detached-`)&&x.current)try{let t=Sm(x.current),n=(await t.raw(`for-each-ref`,`refs/wip/${e.oldBranch}/`,`--format=%(refname)`)).trim();if(n){for(let e of n.split(`
|
|
91
|
-
`))e&&await t.raw(`update-ref`,`-d`,e);g.info({context:e.oldBranch},`[branch-switch] cleaned up detached context ${e.oldBranch}`)}}catch(e){g.error({err:e},`[branch-switch] detached cleanup failed`)}}if(e.headMoved&&e.newHead&&x.current&&n>0){let t=d??`content`;try{let n=await Pm(x.current,t,e.oldHead,e.newHead,r);vn(),g.info({oldHead:e.oldHead?.slice(0,8)??`null`,newHead:e.newHead.slice(0,8),sha:n.slice(0,8)},`[history] upstream-import from ${e.oldHead?.slice(0,8)??`null`}..${e.newHead.slice(0,8)} → ${n.slice(0,8)}`)}catch(e){g.error({err:e},`[shadow] upstream-import failed`)}}})}catch(e){g.error({err:e},`[server] HEAD watcher failed to start`),de.push(`head-watcher`)}let e=h?.[0]??`open-knowledge`,r=[`-c`,`credential.helper=!${h&&h.length>1?h.join(` `):e} auth git-credential`];try{L=new Eb({projectDir:n,contentDir:t,contentFilter:v,contentRoot:d,credentialArgs:r,cc1Broadcaster:T,setBatchInProgress:eh,onStateChange:e=>{g.info({state:e},`[sync] state → ${e}`)}}),await L.start()}catch(e){g.warn({err:e},`[server] SyncEngine failed to start — sync disabled`),L=null}}let pe=fe();return{hocuspocus:C,sessionManager:w,cc1Broadcaster:T,agentFocusBroadcaster:E,agentPresenceBroadcaster:D,contentFilter:v,destroy:le,ready:pe,degraded:de,lockDir:_,get syncEngine(){return L}}}async function kb(e){let t=e.skipAutoInit??!1,n=e.attachUiSibling??!0,r=e.idleShutdownMs,i=e.log??ln(`boot`),{createServer:a}=await import(`node:http`),{WebSocketServer:o}=await import(`./wrapper-_sZfvZ-v.mjs`),{updateServerLockPort:s}=await import(`./server-lock-
|
|
92
|
-
//# sourceMappingURL=src-
|
|
91
|
+
`))e&&await t.raw(`update-ref`,`-d`,e);g.info({context:e.oldBranch},`[branch-switch] cleaned up detached context ${e.oldBranch}`)}}catch(e){g.error({err:e},`[branch-switch] detached cleanup failed`)}}if(e.headMoved&&e.newHead&&x.current&&n>0){let t=d??`content`;try{let n=await Pm(x.current,t,e.oldHead,e.newHead,r);vn(),g.info({oldHead:e.oldHead?.slice(0,8)??`null`,newHead:e.newHead.slice(0,8),sha:n.slice(0,8)},`[history] upstream-import from ${e.oldHead?.slice(0,8)??`null`}..${e.newHead.slice(0,8)} → ${n.slice(0,8)}`)}catch(e){g.error({err:e},`[shadow] upstream-import failed`)}}})}catch(e){g.error({err:e},`[server] HEAD watcher failed to start`),de.push(`head-watcher`)}let e=h?.[0]??`open-knowledge`,r=[`-c`,`credential.helper=!${h&&h.length>1?h.join(` `):e} auth git-credential`];try{L=new Eb({projectDir:n,contentDir:t,contentFilter:v,contentRoot:d,credentialArgs:r,cc1Broadcaster:T,setBatchInProgress:eh,onStateChange:e=>{g.info({state:e},`[sync] state → ${e}`)}}),await L.start()}catch(e){g.warn({err:e},`[server] SyncEngine failed to start — sync disabled`),L=null}}let pe=fe();return{hocuspocus:C,sessionManager:w,cc1Broadcaster:T,agentFocusBroadcaster:E,agentPresenceBroadcaster:D,contentFilter:v,destroy:le,ready:pe,degraded:de,lockDir:_,get syncEngine(){return L}}}async function kb(e){let t=e.skipAutoInit??!1,n=e.attachUiSibling??!0,r=e.idleShutdownMs,i=e.log??ln(`boot`),{createServer:a}=await import(`node:http`),{WebSocketServer:o}=await import(`./wrapper-_sZfvZ-v.mjs`),{updateServerLockPort:s}=await import(`./server-lock-zOHsiWX-.mjs`),c=!1;!t&&e.ensureProjectGitFn&&(c=!!(await e.ensureProjectGitFn()).didInit);let l=!1;if(!t&&e.autoInitFn)try{l=!!await e.autoInitFn()}catch(e){i.warn({err:e},`autoInitFn failed`)}let u=Ob({contentDir:e.contentDir,projectDir:e.projectDir,contentRoot:e.contentRoot,port:e.port,host:e.host,quiet:e.quiet??!1,debounce:e.debounce,maxDebounce:e.maxDebounce,gitEnabled:e.gitEnabled,commitDebounceMs:e.commitDebounceMs,wipRef:e.wipRef,enableTestRoutes:e.enableTestRoutes,shadowRepo:e.shadowRepo,includePatterns:e.includePatterns,excludePatterns:e.excludePatterns,destroyTimeoutMs:e.destroyTimeoutMs,localOpCliArgs:e.localOpCliArgs,onAgentWrite:e.onAgentWrite}),{hocuspocus:d,destroy:f,ready:p,degraded:m,lockDir:h,agentPresenceBroadcaster:g}=u,_=a((e,t)=>{let n=e.url?.split(`?`)[0];if(n?.startsWith(`/api/`)){d.hooks(`onRequest`,{request:e,response:t}).then(()=>{t.writableEnded||t.headersSent||(t.statusCode=404,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({error:`API route not found`,path:n})))}).catch(e=>{i.error({err:e},`Unhandled onRequest error`),!t.writableEnded&&!t.headersSent?(t.writeHead(500),t.end(`Internal server error`)):t.writableEnded||t.end()});return}t.writeHead(404,{"Content-Type":`application/json`}),t.end(JSON.stringify({error:"Not found. The React UI is served by `ok ui` (default port 3000).",path:n??`/`}))}),v=new o({noServer:!0});v.on(`error`,e=>{i.error({err:e},`WebSocketServer error`)});let y=e.keepaliveGraceMs??1e4,b=new Map,x=new Set,S=!1;_.on(`upgrade`,(e,t,n)=>{if(e.url?.startsWith(`/collab/keepalive`)){t.on(`error`,e=>{zn(e)||i.error({err:e},`MCP keepalive socket error`)}),v.handleUpgrade(e,t,n,t=>{let n=Ab(e.url);if(n){let e=b.get(n);e!==void 0&&(clearTimeout(e),b.delete(n),i.info({connectionId:n},`[keepalive] reconnect during grace — timer cancelled`))}let r=setInterval(()=>{try{t.ping()}catch{}},3e4);r.unref?.();let a=n?setInterval(()=>{g?.bumpPresenceTs(mn(n))},3e3):null;a?.unref?.(),t.on(`close`,()=>{if(clearInterval(r),a!==null&&clearInterval(a),!n)return;let e=setTimeout(()=>{if(b.delete(n),S)return;let e=(async()=>{i.info({connectionId:n},`[keepalive] grace expired — cleaning up sessions`);try{await u.sessionManager.closeAllForAgent(n)}catch(e){i.error({err:e,connectionId:n},`[keepalive] closeAllForAgent failed`)}try{u.agentFocusBroadcaster?.clearFocus(n)}catch(e){i.error({err:e,connectionId:n},`[keepalive] clearFocus failed`)}try{g?.clearPresence(mn(n))}catch(e){i.error({err:e,connectionId:n},`[keepalive] clearPresence failed`)}})();x.add(e),e.finally(()=>x.delete(e))},y);e.unref?.(),b.set(n,e),i.info({connectionId:n,graceMs:y},`[keepalive] disconnected — grace timer started`)}),t.on(`error`,e=>{zn(e)||i.error({err:e},`MCP keepalive WS error`),t.terminate()})});return}e.url?.startsWith(`/collab`)&&(t.on(`error`,e=>{zn(e)||i.error({err:e},`Upgrade socket error`)}),v.handleUpgrade(e,t,n,t=>{let n=d.handleConnection(t,e);t.on(`message`,e=>{n.handleMessage((e instanceof ArrayBuffer,new Uint8Array(e)))}),t.on(`close`,(e,t)=>{n.handleClose({code:e,reason:t.toString()})}),t.on(`error`,e=>{zn(e)||i.error({err:e},`WebSocket error`),t.terminate()})}))});let C=null;r!==null&&(C=g_({httpServer:_,thresholdMs:r??18e5,log:i,onShutdown:(e.idleShutdownHandler??(e=>async()=>{await e()}))(async()=>{await f()})})),await new Promise((t,n)=>{let r=e=>n(e);_.once(`error`,r),_.listen(e.port,e.host,()=>{_.removeListener(`error`,r),t()})});let w=_.address(),T=typeof w==`object`&&w?w.port:e.port??0;if(s(h,T),n&&e.spawnUiSiblingFn)try{await e.spawnUiSiblingFn({lockDir:h,log:i})}catch(e){i.warn({err:e},`spawnUiSiblingFn failed`)}let E=!1;return{httpServer:_,destroy:async()=>{if(!E){E=!0,S=!0,C?.detach();for(let e of b.values())clearTimeout(e);b.clear(),x.size>0&&await Promise.allSettled([...x]),await new Promise(e=>{_.close(()=>e())}),await f()}},lockDir:h,contentDir:e.contentDir,port:T,ready:p,degraded:m,didAutoInit:l,didGitInit:c,serverInstance:u}}function Ab(e){if(!e)return null;try{return pn(new URL(e,`http://localhost`).searchParams.get(`connectionId`))}catch{return null}}const jb=He(Me);var Mb=class extends Error{stderr;constructor(e,t=``,n){super(e,n),this.name=`ProjectGitInitError`,this.stderr=t}};async function Nb(e){let t=H(e),n=H(t,`.git`);if(R(n))return{didInit:!1};let r=``;try{r=(await jb(`git`,[`init`,`--initial-branch=main`,t])).stderr??``}catch(e){let n=typeof e==`object`&&e&&`stderr`in e?String(e.stderr??``):``;throw new Mb(`git init failed at ${t}: ${e instanceof Error?e.message:String(e)}`,n,{cause:e})}if(!R(H(n,`HEAD`)))throw new Mb(`git init reported success but ${n}/HEAD is missing (partial init detected)`,r);return console.log(`[project-git] initialized .git/ at ${t} (branch: main)`),{didInit:!0}}export{fm as $,Dh as A,jm as B,mh as C,un as Ct,hh as D,_h as E,cn as Et,oh as F,km as G,Om as H,ah as I,Im as J,Cm as K,nh as L,uh as M,rh as N,fh as O,ih as P,vm as Q,Wm as R,bh as S,pn as St,xh as T,ln as Tt,Pm as U,Mm as V,Em as W,Vm as X,Lm as Y,Sm as Z,qg as _,zn as _t,Ob as a,rp as at,ug as b,fn as bt,Zy as c,Rl as ct,Uy as d,Pl as dt,Mp as et,Ry as f,Al as ft,Jg as g,Vn as gt,g_ as h,Hn as ht,Ab as i,Pp as it,vh as j,yh as k,Yy as l,ru as lt,Py as m,J as mt,Nb as n,Fp as nt,eb as o,$f as ot,zy as p,El as pt,Rm as q,kb as r,Ip as rt,Xy as s,Ll as st,Mb as t,Np as tt,qy as u,Jl as ut,h_ as v,Fn as vt,ph as w,sn as wt,lg as x,mn as xt,n_ as y,Dn as yt,Am as z};
|
|
92
|
+
//# sourceMappingURL=src-rqPIkHTi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./start-BufFj0pL.mjs";export{e as startCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./constants-
|
|
2
|
-
//# sourceMappingURL=start-
|
|
1
|
+
import{a as e}from"./constants-p2mrQUZK.mjs";import{O as t}from"./src-CQw-HNNM.mjs";import{Command as n}from"commander";import{closeSync as r,existsSync as i,mkdirSync as a,openSync as o}from"node:fs";import{join as s}from"node:path";import{spawn as c}from"node:child_process";function l(){let e=process.execPath,t=process.argv[1];return t?{command:e,prefixArgs:[t]}:(console.warn(`[self-spawn] process.argv[1] is empty — falling back to \`npx @inkeep/open-knowledge\`. This re-introduces the version-drift surface that re-exec was fixing. Observed argv: ${JSON.stringify(process.argv)}`),{command:`npx`,prefixArgs:[`@inkeep/open-knowledge`]})}function u(e){return e.uiLock?e.isAlive(e.uiLock.pid)?{action:`skip`,reason:`alive`,pid:e.uiLock.pid,port:e.uiLock.port}:{action:`spawn`,reason:`stale`,stalePid:e.uiLock.pid}:{action:`spawn`,reason:`absent`}}function d(e){i(e.lockDir)||a(e.lockDir,{recursive:!0});let t=o(s(e.lockDir,`last-spawn-error.log`),`w`),n=e.spawn??c,{PORT:u,...d}=process.env,f=l();try{let r=n(f.command,[...f.prefixArgs,...e.args??[`ui`]],{detached:!0,stdio:[`ignore`,`ignore`,t],cwd:e.cwd,env:d});return r.unref(),r}finally{try{r(t)}catch{}}}async function f(e){let t=e.now()+e.timeoutMs;for(;e.now()<t;){let t=e.readUiLock();if(t&&t.port>0)return t.port;await e.sleep(e.pollIntervalMs)}let n=e.readUiLock();return n&&n.port>0?n.port:null}function p(e){let t=e.sigtermGraceMs??1e4,n=e.sigtermPollIntervalMs??200,r=e.sleep??(e=>new Promise(t=>setTimeout(t,e)));return async()=>{try{let i=e.readUiLock();if(i&&e.isAlive(i.pid))try{e.killPid(i.pid,`SIGTERM`),e.log?.info({pid:i.pid,port:i.port},`idle-shutdown: SIGTERM UI sibling`);let a=Date.now()+t;for(;Date.now()<a&&e.isAlive(i.pid);)await r(n);if(e.isAlive(i.pid))try{e.killPid(i.pid,`SIGKILL`),e.log?.warn({pid:i.pid,graceMs:t},`idle-shutdown: SIGTERM grace expired — escalated to SIGKILL`)}catch(t){e.log?.error({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: SIGKILL failed`)}}catch(t){e.log?.warn({pid:i.pid,err:t instanceof Error?t.message:String(t)},`idle-shutdown: failed to SIGTERM UI sibling`)}}catch(t){e.log?.warn({err:t instanceof Error?t.message:String(t)},`idle-shutdown: UI lookup failed; proceeding with destroy`)}await e.destroy()}}async function m(e){let{config:n,cwd:r}=e,i=e.skipAutoInit??!1,a=e.skipUiAutoSpawn??!1,o=e.idleThresholdMs??18e5,{existsSync:s,mkdirSync:c}=await import(`node:fs`),{resolve:l}=await import(`node:path`),{bootServer:m,ensureProjectGit:h,getLogger:g,isProcessAlive:_,readUiLock:v}=await import(`./src-DHnGx64r.mjs`),{resolveContentDir:y}=await import(`./paths-CJMOZlvG.mjs`),b=e.log??g(`start`),x=y(n,r);s(x)||(c(x,{recursive:!0}),b.info({contentDir:x},`Created content directory`));let S=!s(l(r,t)),C=i?void 0:async()=>{try{let{initContent:e}=await import(`./init-DJzYkC45.mjs`),t=e(r);return S||t.created.length>0}catch(e){return console.warn(`Auto-init failed:`,e instanceof Error?e.message:e),!1}},w=!1,T=l(x,t),E=n.server.openOnAgentEdit?()=>{if(w)return;let e=v(T);if(!e||e.port<=0||!_(e.pid))return;w=!0;let t=`http://localhost:${e.port}`;import(`./open-browser-CfwaLBtR.mjs`).then(({openBrowser:e})=>e(t)).catch(()=>{})}:void 0,D=null,O=await m({contentDir:x,projectDir:r,contentRoot:n.content.dir,port:n.server.port,host:n.server.host,quiet:!1,debounce:n.persistence.debounceMs,maxDebounce:n.persistence.maxDebounceMs,includePatterns:n.content.include,excludePatterns:n.content.exclude,onAgentWrite:E,localOpCliArgs:[process.execPath,process.argv[1]],attachUiSibling:!0,idleShutdownMs:o,skipAutoInit:i,autoInitFn:C,ensureProjectGitFn:i?void 0:()=>h(r),spawnUiSiblingFn:async({lockDir:t})=>{if(D=u({uiLock:v(t),isAlive:_}),D.action===`spawn`&&!a)try{d({lockDir:t,cwd:r,spawn:e.spawn}),b.info({reason:D.reason},`[start] auto-spawned ok ui sibling`)}catch(e){console.warn(`[start] failed to auto-spawn ok ui: ${e instanceof Error?e.message:String(e)}`)}else D.action===`skip`&&b.info({port:D.port,pid:D.pid},`UI already running at port ${D.port}`)},idleShutdownHandler:e=>p({readUiLock:()=>v(O.lockDir),isAlive:_,killPid:(e,t)=>{process.kill(e,t)},destroy:e,log:b}),log:b});D||={action:`skip`,reason:`alive`,pid:0,port:0};let k=D,A=null;if(k.action===`skip`)A=k.port>0?k.port:null;else if(!a){let t=e.uiBindTimeoutMs??3e3;A=await f({readUiLock:()=>v(O.lockDir),now:Date.now,sleep:e=>new Promise(t=>setTimeout(t,e)),timeoutMs:t,pollIntervalMs:50}),A===null&&b.warn({timeoutMs:t},`[start] ok ui did not bind within timeout — banner falls back to API URL`)}return{httpServer:O.httpServer,destroy:O.destroy,lockDir:O.lockDir,contentDir:x,port:O.port,ready:O.ready,degraded:O.degraded,uiSpawnDecision:D,resolvedUiPort:A,didAutoInit:O.didAutoInit,didGitInit:O.didGitInit}}function h(r){return new n(`start`).description(`Start the knowledge base collab server`).option(`-p, --port <port>`,`Server port`,void 0).option(`-H, --host <host>`,`Server host`,void 0).option(`--open`,`Open browser after start`).option(`--no-init`,`Skip auto-scaffolding of ${t}/`).action(async n=>{let{renderBanner:i}=await import(`./banner-C51OKbnz.mjs`),{dim:a,error:o,info:s,warning:c}=await import(`./colors-xJqYhQcY.mjs`),l=r(),u=process.cwd();n.port!==void 0&&(l.server.port=Number(n.port)),n.host!==void 0&&(l.server.host=n.host);let d;try{d=await m({config:l,cwd:u,skipAutoInit:n.init===!1})}catch(e){let{ProjectGitInitError:t}=await import(`./src-DHnGx64r.mjs`);e instanceof t&&(console.error(o(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.`)),e.stderr&&console.error(a(e.stderr.trim())),process.exit(1)),console.error(`${o(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let f=!1,p=async e=>{if(!f){f=!0,console.log(a(`\nShutting down (${e})...`));try{await d.destroy()}catch(e){console.error(`${o(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)}};process.once(`SIGINT`,()=>{p(`SIGINT`)}),process.once(`SIGTERM`,()=>{p(`SIGTERM`)});let h=`http://${l.server.host}:${d.port}`,g=l.server.host===`0.0.0.0`||l.server.host===`::`?`http://0.0.0.0:${d.port}`:void 0,_=d.resolvedUiPort,v=_!==null&&_>0?`http://${l.server.host}:${_}`:h;console.log(i({name:`open-knowledge`,version:e,localUrl:v,apiUrl:v===h?void 0:h,networkUrl:g})),d.didAutoInit&&(console.log(` ${s(`✓`)} Scaffolded ${t}/ (first run)`),console.log(` ${a("Tip: Run `open-knowledge init` to register MCP tools for Claude Code")}\n`));let y={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};d.ready.then(async()=>{if(d.degraded.length>0){console.log();for(let e of d.degraded){let t=y[e]??`${e} (check server logs for details)`;console.warn(` ${c(`⚠`)} ${c(e)}: ${a(t)}`)}console.log()}if(d.didAutoInit||d.didGitInit)if(d.didGitInit&&console.log(`\n ${s(`✓`)} Initialized git repo at ${u}/.git/ (default branch: main)`),d.didAutoInit)try{let{previewContent:e,formatPreviewBlock:t}=await import(`./preview-CfQP5PHw.mjs`),n=e({projectDir:u,contentDir:d.contentDir,include:l.content.include,exclude:l.content.exclude});console.log(`\n${t(n,u)}\n`)}catch(e){console.warn(`Content preview unavailable: ${e instanceof Error?e.message:String(e)}`)}else console.log();if(n.open){let{openBrowser:e}=await import(`./open-browser-CfwaLBtR.mjs`);e(v)}}).catch(e=>{console.error(` ${o(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})})}export{d as a,u as i,m as n,h as o,p as r,l as s,f as t};
|
|
2
|
+
//# sourceMappingURL=start-BufFj0pL.mjs.map
|
package/package.json
CHANGED
package/dist/init-1srg7AC9.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./constants-oa8rklCf.mjs";import{O as t}from"./src-CQw-HNNM.mjs";import{n,t as r}from"./src-skP-DoiW.mjs";import{o as i,s as a}from"./init-Cr5zNjLr.mjs";import{t as o}from"./preview-B7p7jyyl.mjs";import{t as s}from"./is-object-DaHwJLOe.mjs";import{Command as c}from"commander";import{existsSync as l,mkdirSync as u,readFileSync as d,writeFileSync as f}from"node:fs";import{homedir as p}from"node:os";import{basename as m,dirname as h,isAbsolute as g,join as _,posix as v,relative as y,resolve as b,sep as x,win32 as S}from"node:path";import{parse as C,stringify as w}from"smol-toml";const T=[`claude`,`claude-desktop`,`cursor`,`vscode`,`windsurf`,`codex`],E=[`@inkeep/open-knowledge`,`mcp`],ee={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`};function D(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=b(e);if(m(t)===`cli.mjs`&&m(h(t))===`dist`)return t;let n=t.split(x),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return _(i.length===0?x:i.join(x),`packages`,`cli`,`dist`,`cli.mjs`)}function O(e={}){return e.mode===`dev`?{command:`node`,args:[D(e.cliEntryPath),`mcp`],env:{...ee}}:{command:`npx`,args:[...E]}}function k(e){return e===`win32`?S:v}function A(e={}){let t=e.platformName??process.platform,n=e.home??p(),r=e.env??process.env,i=k(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function j(e={}){let t=e.platformName??process.platform,n=e.home??p();return k(t).join(n,`.claude.json`)}function M(e={}){let t=e.platformName??process.platform,n=e.home??p(),r=e.env??process.env;if(t===`darwin`)return v.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??S.join(n,`AppData`,`Roaming`);return S.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function N(e={}){let t=e.platformName??process.platform,n=e.home??p();return k(t).join(n,`.cursor`,`mcp.json`)}function P(e={}){return k(e.platformName??process.platform).join(A(e),`Code`,`User`,`mcp.json`)}function F(e={}){let t=e.platformName??process.platform,n=e.home??p();return k(t).join(n,`.codeium`,`windsurf`,`mcp_config.json`)}function I(e={}){let t=e.platformName??process.platform,n=e.home??p();return(e.env??process.env).CODEX_HOME??k(t).join(n,`.codex`)}function L(e={}){return k(e.platformName??process.platform).join(I(e),`config.toml`)}function R(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>R(e,t[n]));if(s(e)&&s(t)){let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((e,t)=>e===r[t])&&n.every(n=>R(e[n],t[n]))}return!1}function z(e,t){return Object.entries(t).every(([t,n])=>R(e[t],n))}function B(e,t){return{...e,...t}}function V(e){return{...e,isCompatible(t,n,r){return z(t,e.buildEntry(n,r))},mergeManagedFields(t,n,r){return B(t,e.buildEntry(n,r))}}}const H={claude:V({id:`claude`,label:`Claude Code`,configPath:(e,t)=>j({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>O(t),scope:`global`,detectPath:(e,t)=>_(t??p(),`.claude`),legacyProjectConfigPath:e=>_(e,`.mcp.json`),instructionsPath:e=>_(e,`CLAUDE.md`)}),"claude-desktop":V({id:`claude-desktop`,label:`Claude Desktop`,configPath:(e,t)=>M({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>O(t),scope:`global`,detectPath:(e,t)=>h(M({home:t}))}),cursor:V({id:`cursor`,label:`Cursor`,configPath:(e,t)=>N({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>O(t),scope:`global`,detectPath:(e,t)=>h(N({home:t})),legacyProjectConfigPath:e=>_(e,`.cursor`,`mcp.json`)}),vscode:V({id:`vscode`,label:`VS Code`,configPath:(e,t)=>P({home:t}),format:`json`,topLevelKey:`servers`,serverName:()=>e,buildEntry:(e,t)=>({type:`stdio`,...O(t)}),scope:`global`,detectPath:(e,t)=>h(P({home:t})),legacyProjectConfigPath:e=>_(e,`.vscode`,`mcp.json`)}),windsurf:V({id:`windsurf`,label:`Windsurf`,configPath:(e,t)=>F({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>e,buildEntry:(e,t)=>O(t),scope:`global`,detectPath:(e,t)=>h(F({home:t}))}),codex:V({id:`codex`,label:`Codex`,configPath:(e,t)=>L({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>e,buildEntry:(e,t)=>O(t),scope:`global`,detectPath:(e,t)=>h(L({home:t})),legacyProjectConfigPath:e=>_(e,`.codex`,`config.toml`)})};function U(e){let t=e.filter(e=>!(e in H));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${T.join(`, `)}`);return e.map(e=>H[e])}function W(e){if(!l(e))return{};let t=d(e,`utf-8`).trim();if(t===``)return{};try{let n=JSON.parse(t);if(s(n))return n;throw Error(`${e} root must be a JSON object`)}catch(t){throw t instanceof SyntaxError?Error(`${e} contains invalid JSON: ${t.message}`):t}}function G(e){if(!l(e))return{};let t=d(e,`utf-8`).trim();if(t===``)return{};try{let n=C(t);if(s(n))return n;throw Error(`${e} root must be a TOML table`)}catch(t){throw Error(`${e} contains invalid TOML: ${t instanceof Error?t.message:String(t)}`)}}function K(e,t){u(h(e),{recursive:!0}),f(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function q(e,t){u(h(e),{recursive:!0});let n=w(t);f(e,n.endsWith(`
|
|
2
|
-
`)?n:`${n}\n`,`utf-8`)}const J=`0.0.1`,Y=`open-knowledge-ui`;function te(e,t={}){let n=_(e,`.claude`,`launch.json`),r=t.mode===`dev`?{name:Y,runtimeExecutable:`node`,runtimeArgs:[D(t.cliEntryPath),`ui`],port:3e3}:{name:Y,runtimeExecutable:`npx`,runtimeArgs:[`@inkeep/open-knowledge`,`ui`],port:3e3};try{if(!l(n))return u(h(n),{recursive:!0}),f(n,`${JSON.stringify({version:J,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let e=d(n,`utf-8`).trim(),t=e?JSON.parse(e):{};if(!s(t))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let i=Array.isArray(t.configurations)?t.configurations:[],a=i.findIndex(e=>s(e)&&e.name===Y);a>=0?i[a]=r:i.push(r);let o={...t,version:t.version??J,configurations:i};return f(n,`${JSON.stringify(o,null,2)}\n`,`utf-8`),{action:a>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function X(e,t,n){try{return l(e.detectPath?.(t,n)??h(e.configPath(t,n)))}catch{return!1}}function ne(e,t,n,r){let i=e.serverName(t),a;try{a=e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:i,error:t instanceof Error?t.message:String(t)}}if(!X(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:a,serverName:i};let o;try{o=e.format===`toml`?G(a):W(a)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let s=o[e.topLevelKey]??{},c=s[i],l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}let u={...o,[e.topLevelKey]:{...s,[i]:l}};try{e.format===`toml`?q(a,u):K(a,u)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:a,serverName:i,error:t instanceof Error?t.message:String(t)}}return{editorId:e.id,label:e.label,action:c===void 0?`written`:`overwritten`,configPath:a,serverName:i}}function re(e,t){let n=e.legacyProjectConfigPath?.(t);if(!(!n||!l(n)))return{editorId:e.id,label:e.label,path:n}}async function Z(e={}){let t=b(e.cwd??process.cwd()),r={mode:e.devMcp?`dev`:`published`,cliEntryPath:e.cliEntryPath},o=await n(t),s;try{s=i(t)}catch(n){let r=H.claude.configPath(t,e.home);return{contentCreated:[],contentSkipped:[],editors:[],legacyProjectConfigs:[],rootInstructions:[],didGitInit:o.didInit,mcpAction:`failed`,mcpPath:r,mcpError:`Content scaffolding failed: ${n instanceof Error?n.message:String(n)}`}}let c=U(e.editors??$(t,e.home)),l=c.filter(n=>X(n,t,e.home)),u=[];for(let n of c){if(e.mcp===!1){let r=``;try{r=n.configPath(t,e.home)}catch{}u.push({editorId:n.id,label:n.label,action:`skipped-flag`,configPath:r,serverName:n.serverName(t)});continue}u.push(ne(n,t,r,e.home))}let d=e.mcp===!1?[]:l.map(e=>re(e,t)).filter(e=>e!==void 0),f=l.some(e=>e.id===`claude`)&&e.mcp!==!1?te(t,r):void 0,p=l.map(e=>e.instructionsPath?.(t)).filter(e=>e!==void 0).map(e=>g(e)?y(t,e):e),m=e.rootInstructions===!1?[]:a(t,!0,p),h=e.mcp===!1?`skipped-flag`:`skipped-missing`,_=u.find(e=>e.editorId===`claude`)??u[0]??{action:h,configPath:H.claude.configPath(t,e.home)};return{contentCreated:s.created,contentSkipped:s.skipped,editors:u,legacyProjectConfigs:d,rootInstructions:m,launchJson:f,didGitInit:o.didInit,mcpAction:_.action,mcpPath:_.configPath,mcpError:`error`in _?_.error:void 0}}function Q(e,n){let r=[],i=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),a=e.editors.some(e=>e.action===`failed`),s=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),c=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),l=e=>{let t=e.configPath.startsWith(n)?y(n,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${t} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${t} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${t} FAILED: ${e.error}`}};e.didGitInit&&r.push(`Initialized git repo at ${n}/.git/ (default branch: main)`);let u=_(n,t);if(e.contentCreated.length>0?(r.push(`Content scaffolded at ${u}/`),r.push(` Created: ${e.contentCreated.join(`, `)}`)):r.push(`Content already present at ${u}/`),e.contentSkipped.length>0&&r.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),r.push(``),e.mcpError&&e.editors.length===0)r.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)r.push(`MCP server configuration:`),r.push(e.mcpAction===`skipped-flag`?` MCP config not written — use without --no-mcp to configure editors`:` No supported editor config directories detected; skipped MCP registration`);else if(s)r.push(`MCP config not written — use without --no-mcp to configure editors`);else if(c)r.push(`MCP server configuration:`),r.push(` No supported editor config directories detected; skipped MCP registration`);else{r.push(`MCP server configuration:`);for(let t of e.editors){let i=t.configPath.startsWith(n)?y(n,t.configPath):t.configPath.replace(/^\/Users\/[^/]+/,`~`),a=t.serverName===`open-knowledge`?``:` (${t.serverName})`,o=` `.repeat(Math.max(1,14-t.label.length)),s=t.editorId===`claude-desktop`&&(t.action===`written`||t.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(t.action){case`written`:r.push(` ${t.label}${o}${i} registered${a}${s}`);break;case`overwritten`:r.push(` ${t.label}${o}${i} updated${a}${s}`);break;case`skipped-missing`:r.push(` ${t.label}${o}${i} config root missing; skipped`);break;case`failed`:r.push(` ${t.label}${o}${i} FAILED: ${t.error}`);break;case`skipped-flag`:break}t.editorId===`claude`&&e.launchJson&&r.push(l(e.launchJson))}}if(a&&(r.push(``),r.push(`For failed editors, add the MCP server entry manually. See:`),r.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){r.push(``),r.push(`Legacy project MCP configs detected:`);for(let t of e.legacyProjectConfigs)r.push(` ${t.label} ${y(n,t.path)}`);r.push(` These project-local files may override the new global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.rootInstructions.length>0){let t=e.rootInstructions.filter(e=>e.action!==`skipped-symlink`);if(t.length>0){r.push(``),r.push(`Root instructions:`);for(let e of t){let t=e.path.startsWith(n)?y(n,e.path):e.path,i=` `.repeat(Math.max(1,14-e.file.length));switch(e.action){case`created`:r.push(` ${e.file}${i}${t} created`);break;case`appended`:r.push(` ${e.file}${i}${t} appended Open Knowledge section`);break;case`replaced`:r.push(` ${e.file}${i}${t} replaced Open Knowledge section`);break;case`skipped-existing`:r.push(` ${e.file}${i}${t} already has Open Knowledge section`);break}}}}if(e.preview?(r.push(``),r.push(o(e.preview,n))):e.previewWarning&&(r.push(``),r.push(`Content preview unavailable: ${e.previewWarning}`)),i){let t=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.label);r.push(``),r.push(`Next steps:`),r.push(` 1. Open your editor (${t.join(` / `)})`),r.push(` 2. Approve the MCP server when prompted`),r.push(` 3. The knowledge base is ready — use the three workflow tools:`),r.push(` - mcp__open-knowledge__init-content — bootstrap articles from the codebase`),r.push(` - mcp__open-knowledge__ingest — capture an external source`),r.push(` - mcp__open-knowledge__research — gather sources and write findings`)}return r.join(`
|
|
3
|
-
`)}function $(e,t){let n=[];for(let r of T)X(H[r],e,t)&&n.push(r);return n}function ie(){return new c(`init`).description(`Scaffold ${t}/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the ${t}/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).action(async e=>{let t=process.cwd(),n;try{n=await Z({cwd:t,mcp:e.mcp,devMcp:e.devMcp})}catch(e){if(e instanceof r){process.stderr.write(`open-knowledge requires git to initialize a parent repo. Install git or run 'git init' yourself, then re-run.
|
|
4
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}try{let{previewContent:e}=await import(`./preview-CFVO89Px.mjs`),{loadConfig:r}=await import(`./loader-CVOTHZaY.mjs`),{resolveContentDir:i}=await import(`./paths-5vJ24bHl.mjs`),{config:a}=r(t),o=i(a,t);n.preview=e({projectDir:t,contentDir:o,include:a.content.include,exclude:a.content.exclude})}catch(e){n.previewWarning=e instanceof Error?e.message:String(e)}process.stdout.write(`${Q(n,t)}\n`),(n.editors.some(e=>e.action===`failed`)||n.mcpAction===`failed`)&&(process.exitCode=1)})}export{Z as i,Q as n,ie as r,$ as t};
|
|
5
|
-
//# sourceMappingURL=init-1srg7AC9.mjs.map
|
package/dist/init-B7uATxQD.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./init-Cr5zNjLr.mjs";export{o as CLAUDE_MD_SECTION,n as OK_MARKER_BEGIN,i as OK_MARKER_END,t as PREVIEW_GUIDANCE,e as ensureOkGitignoredAtRoot,r as initContent,a as upsertRootInstructions};
|
package/dist/init-DSYBjbGB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,t as r}from"./init-1srg7AC9.mjs";export{r as detectInstalledEditors,t as formatInitResult,n as initCommand,e as runInit};
|
package/dist/loader-CVOTHZaY.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-BjvYg6bR.mjs";export{e as loadConfig};
|
package/dist/paths-5vJ24bHl.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./paths-Dcbxj9qp.mjs";export{t as resolveContentDir,e as resolveLockDir};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-B7p7jyyl.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-DVEMi7bH.js","assets/dist-B2YW_ZWG.js","assets/panel-DTlG8EiB.js","assets/w3c-keyname-DLDSJn4E.js","assets/dist-CQbn9Fxc.js","assets/dist-X189qk_S.js","assets/dist-Dm75HY2n.js","assets/dist-k7VFO_3K.js","assets/dist-Bx72hMUu.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{Cn as e,Kn as t,Sn as n,T as r,X as i,Y as a,Z as o,hn as s,v as c,vn as l}from"./panel-DTlG8EiB.js";import{A as u,Ct as d,F as f,G as p,I as m,J as h,K as g,L as _,P as v,Q as ee,St as y,Tt as b,_ as te,_t as x,a as S,bt as C,c as ne,d as re,et as ie,f as ae,g as oe,gt as w,h as T,ht as E,kt as D,l as se,m as ce,p as le,pt as ue,q as de,s as fe,t as pe,u as me,v as he,vt as O,wt as ge,xt as k,yt as A}from"./clipboard-CdKkyvy1.js";import{At as _e,Dt as j,Et as ve,N as M,Nt as N,Pt as P,Q as ye,Tt as F,Y as I,Z as L,a as R,bt as z,ft as B,jt as V,lt as be,q as H,wt as xe}from"./dist-B2YW_ZWG.js";var U=t(e(),1),Se=s(),Ce=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:C(this.yanchor),yhead:C(this.yhead)}}static fromJSON(t){return new e(O(t.yanchor),O(t.yhead))}},we=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new E(e)}toYPos(e,t=0){return A(this.ytext,e,t)}fromYPos(e){let t=x(O(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new Ce(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?F.cursor(n.pos,n.assoc):F.range(t.pos,n.pos)}},W=j.define({combine(e){return e[e.length-1]}}),G=z.define(),Te=class{constructor(e){this.view=e,this.conf=e.state.facet(W),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[G.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(G)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
|
|
3
|
-
`);e!==r&&t.delete(e+n,r-e),s.length>0&&t.insert(e+n,s),n+=s.length-(r-e)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},Ee=L.fromClass(Te),De=I.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:`0px 2px 0px 4px`},".cm-ySelectionCaret":{position:`relative`,borderLeft:`1px solid black`,borderRight:`1px solid black`,marginLeft:`-1px`,marginRight:`-1px`,boxSizing:`border-box`,display:`inline`},".cm-ySelectionCaretDot":{borderRadius:`50%`,position:`absolute`,width:`.4em`,height:`.4em`,top:`-.2em`,left:`-.2em`,backgroundColor:`inherit`,transition:`transform .3s ease-in-out`,boxSizing:`border-box`},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:`bottom center`,transform:`scale(0)`},".cm-ySelectionInfo":{position:`absolute`,top:`-1.05em`,left:`-1px`,fontSize:`.75em`,fontFamily:`serif`,fontStyle:`normal`,fontWeight:`normal`,lineHeight:`normal`,userSelect:`none`,color:`white`,paddingLeft:`2px`,paddingRight:`2px`,zIndex:101,transition:`opacity .3s ease-in-out`,backgroundColor:`inherit`,opacity:0,transitionDelay:`0s`,whiteSpace:`nowrap`},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:`0s`}}),Oe=z.define(),ke=class extends ye{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return k(`span`,[d(`class`,`cm-ySelectionCaret`),d(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[y(``),k(`div`,[d(`class`,`cm-ySelectionCaretDot`)]),y(``),k(`div`,[d(`class`,`cm-ySelectionInfo`)],[y(this.name)]),y(``)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},Ae=class{constructor(e){this.conf=e.state.facet(W),this._listener=({added:t,updated:n,removed:r},i,a)=>{t.concat(n).concat(r).findIndex(e=>e!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[Oe.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=_e.of([])}destroy(){this._awareness.off(`change`,this._listener)}update(e){let t=this.conf.ytext,n=t.doc,r=this.conf.awareness,i=[],a=this.conf.awareness.getLocalState();if(a!=null){let n=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),i=n?e.state.selection.main:null,o=a.cursor==null?null:O(a.cursor.anchor),s=a.cursor==null?null:O(a.cursor.head);if(i!=null){let e=A(t,i.anchor),n=A(t,i.head);(a.cursor==null||!w(o,e)||!w(s,n))&&r.setLocalStateField(`cursor`,{anchor:e,head:n})}else a.cursor!=null&&n&&r.setLocalStateField(`cursor`,null)}r.getStates().forEach((a,o)=>{if(o===r.doc.clientID)return;let s=a.cursor;if(s==null||s.anchor==null||s.head==null)return;let c=x(s.anchor,n),l=x(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:u=`#30bced`,name:d=`Anonymous`}=a.user||{},f=a.user&&a.user.colorLight||u+`33`,p=b(c.index,l.index),m=ge(c.index,l.index),h=e.view.state.doc.lineAt(p),g=e.view.state.doc.lineAt(m);if(h.number===g.number)i.push({from:p,to:m,value:H.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});else{i.push({from:p,to:h.from+h.length,value:H.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})}),i.push({from:g.from,to:m,value:H.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});for(let t=h.number+1;t<g.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:H.line({attributes:{style:`background-color: ${f}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:H.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new ke(u,d)})})}),this.decorations=H.set(i,!0)}},je=L.fromClass(Ae,{decorations:e=>e.decorations}),Me=class{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},K=j.define({combine(e){return e[e.length-1]}});z.define();var Ne=class{constructor(e){this.view=e,this.conf=e.state.facet(K),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(W),this._beforeChangeSelection=null,this._mux=ue(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{let n=t.meta.get(this);if(n){let t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[I.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on(`stack-item-added`,this._onStackItemAdded),this._undoManager.on(`stack-item-popped`,this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(G)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off(`stack-item-added`,this._onStackItemAdded),this._undoManager.off(`stack-item-popped`,this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}},Pe=L.fromClass(Ne),Fe=({state:e,dispatch:t})=>e.facet(K).undo()||!0,Ie=({state:e,dispatch:t})=>e.facet(K).redo()||!0,Le=(e,t,{undoManager:n=new E(e)}={})=>{let r=new we(e,t),i=[W.of(r),Ee];return t&&i.push(De,je),n!==!1&&i.push(K.of(new Me(n)),Pe,I.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?Fe(t):e.inputType===`historyRedo`?Ie(t):!1}})),i},Re=[R.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>ce({jsx:!0})}),R.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>ce({typescript:!0,jsx:!0})}),R.of({name:`json`,alias:[`jsonc`],extensions:[`json`,`jsonc`],load:()=>D(()=>import(`./dist-DVEMi7bH.js`).then(e=>e.json()),__vite__mapDeps([0,1,2,3,4]))}),R.of({name:`yaml`,alias:[`yml`],extensions:[`yaml`,`yml`],load:()=>D(()=>import(`./dist-X189qk_S.js`).then(e=>e.yaml()),__vite__mapDeps([5,1,2,3,4]))}),R.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>T()}),R.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>le()}),R.of({name:`python`,alias:[`py`],extensions:[`py`,`pyw`],load:()=>D(()=>import(`./dist-Dm75HY2n.js`).then(e=>e.python()),__vite__mapDeps([6,7,1,2,3,4]))}),R.of({name:`rust`,alias:[`rs`],extensions:[`rs`],load:()=>D(()=>import(`./dist-Bx72hMUu.js`).then(e=>e.rust()),__vite__mapDeps([8,1,2,3,4]))}),R.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>re()}),R.of({name:`bash`,alias:[`sh`,`shell`,`zsh`],extensions:[`sh`,`bash`,`zsh`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{shell:n}]=await Promise.all([D(()=>import(`./dist-B2YW_ZWG.js`).then(e=>e.m),__vite__mapDeps([1,2,3])),D(()=>import(`./shell-COsTRxlr.js`),[])]);return new t(e.define(n))}}),R.of({name:`go`,alias:[`golang`],extensions:[`go`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{go:n}]=await Promise.all([D(()=>import(`./dist-B2YW_ZWG.js`).then(e=>e.m),__vite__mapDeps([1,2,3])),D(()=>import(`./go-IODVg4Ok.js`),[])]);return new t(e.define(n))}})],ze=N.define(),Be=N.define(),Ve=H.line({class:`agent-flash`}),He=P.define({create(){return H.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(ze)){let{from:r,to:i}=n.value,a=[];for(let e=r;e<=i;){let n=t.state.doc.lineAt(e);a.push(Ve.range(n.from)),e=n.to+1}e=e.update({add:a,sort:!0})}else n.is(Be)&&(e=H.none);return e},provide:e=>I.decorations.from(e)});function Ue(e){let t=e.getMap(`agent-flash`);return[He,L.define(e=>{let n=0,r=Date.now(),s=null,c=null,l=!1;function u(){let t=e.state.doc.length;t!==0&&(l||(e.dispatch({effects:ze.of({from:0,to:t})}),c&&clearTimeout(c),c=setTimeout(()=>{c=null,!l&&e.dispatch({effects:Be.of(null)})},a)))}let d=e=>{if(i(t),!o(t,r))return;r=Date.now();let a=Date.now();if(a-n<500){if(!s){let e=500-(a-n);s=setTimeout(()=>{s=null,n=Date.now(),u()},e)}return}n=a,u()};t.observe(d);let f=()=>{document.visibilityState===`visible`?o(t,r)&&(r=Date.now(),n=Date.now(),u()):r=Date.now()};return document.addEventListener(`visibilitychange`,f),{update(e){},destroy(){l=!0,t.unobserve(d),document.removeEventListener(`visibilitychange`,f),s&&=(clearTimeout(s),null),c&&=(clearTimeout(c),null)}}})]}var q=/\[([^\]\n]*)\]\((<[^>\n]+>|[^)\s\n]+)(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\)/g,We=H.mark({class:`cm-md-internal-link`});function Ge(e,t){return t>0&&e[t-1]===`!`}function Ke(e){let t=e[2]??``;return t.startsWith(`<`)&&t.endsWith(`>`)?t.slice(1,-1):t}function qe(e){let t=new V;for(let{from:n,to:r}of e.visibleRanges){let i=e.state.doc.sliceString(n,r);q.lastIndex=0;let a=q.exec(i);for(;a!==null;){let e=Ge(i,a.index)?null:p(Ke(a));e&&e.kind!==`external`&&t.add(n+a.index,n+a.index+a[0].length,We),a=q.exec(i)}}return t.finish()}var Je=L.fromClass(class{decorations;constructor(e){this.decorations=qe(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=qe(e.view))}},{decorations:e=>e.decorations}),Ye=I.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);q.lastIndex=0;let i=q.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=Ge(r.text,i.index)?null:p(Ke(i));if(t&&t.kind!==`external`)return e.preventDefault(),t.kind===`doc`&&h(e)?(de(t),!0):(g(t),!0)}i=q.exec(r.text)}return!1}}),Xe=I.theme({".cm-md-internal-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-md-internal-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function Ze(){return[Je,Ye,Xe]}var Qe=5e3,J=null,$e=0,et=null,Y=new Map;async function tt(){let e=Date.now();return J&&e-$e<Qe?J:(J=await f(),$e=e,et=ot(J),J)}async function nt(e){let t=Date.now(),n=Y.get(e);if(n!==void 0&&t-n.time<Qe)return n.headings;try{let n=await v(e);return Y.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),Y.set(e,{headings:[],time:t}),[]}}var X=/\[\[[^\]]*?\]\]/g,rt=H.mark({class:`cm-wiki-link`}),it=H.mark({class:`cm-wiki-link cm-wiki-link-broken`});function at(e){let t=new Set;for(let n of e)t.add(n.docName.toLowerCase()),n.title&&t.add(n.title.toLowerCase());return t}function ot(e){let t=at(e);for(let n of e){let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function st(e){return e.split(/[#|]/)[0].trim().toLowerCase()}function ct(e){let t=new V,n=J?et:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);X.lastIndex=0;let o=X.exec(a);for(;o!==null;){let e=rt;if(n){let t=st(o[0].slice(2,-2));t&&!n.has(t)&&(e=it)}t.add(r+o.index,r+o.index+o[0].length,e),o=X.exec(a)}}return t.finish()}var lt=L.fromClass(class{decorations;cacheWarmAtBuild;constructor(e){this.cacheWarmAtBuild=J!==null,this.decorations=ct(e),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=J!==null;(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t)&&(this.cacheWarmAtBuild=t,this.decorations=ct(e.view))}warmCache(e){tt().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}},{decorations:e=>e.decorations}),Z=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,ut=I.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);Z.lastIndex=0;let i=Z.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=c(t,n);if(!r)return!1;e.preventDefault(),r.kind===`external`?window.open(r.url,`_blank`,`noopener,noreferrer`):h(e)?de(r):window.location.hash=r.anchor?`#/${r.docName}?anchor=${encodeURIComponent(r.anchor)}`:`#/${r.docName}`}return!0}i=Z.exec(r.text)}return!1}});async function dt(e){let t=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!t)return null;let n=t[1],r=e.pos-n.length,i=n.indexOf(`#`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1),a=r+i+1,o=await nt(e);if(!o.length)return null;let s=m(o,t);return s.length?{from:a,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}return{from:r,filter:!1,options:_(await tt().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),n).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.docName+a},selection:{anchor:r+e.docName.length+a.length}})}}))}}var ft=I.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function pt(){return[lt,ut,ft,ae.data.of({autocomplete:dt})]}var mt=H.mark({class:`cm-link-ref-broken`}),ht=/^\s{0,3}\[([^\]]+)\]:\s/,gt=/\[([^\]]*)\]\[([^\]]*)\]/g,_t=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Q(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function vt(e){let t=[];return M(e).iterate({enter(e){if(_t.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function $(e){let t=new Set,n=[],r=e.doc,i=vt(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Q(n.from,i))continue;let a=ht.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Q(t.from,i)&&!ht.test(t.text))for(gt.lastIndex=0;;){let e=gt.exec(t.text);if(!e)break;let r=t.from+e.index;if(Q(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(mt.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),H.set(a)}var yt=P.define({create(e){return $(e)},update(e,t){return t.docChanged?$(t.state):e},provide:e=>I.decorations.from(e)}),bt=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,xt=H.mark({class:`cm-del`}),St=H.line({class:`cm-table-header`}),Ct=H.line({class:`cm-table-row`});function wt(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Tt(e,t){let n=[],r=M(e);for(let{from:i,to:a}of t)r.iterate({from:i,to:a,enter(t){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(xt.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=bt.exec(r.text),a=i?i[1].length:2,o=H.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=wt(r.text),a=H.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(St.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Ct.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Ct.range(r.from)),!1}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),H.set(n)}var Et=class{decorations;constructor(e){this.decorations=Tt(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||M(e.startState)!==M(e.state))&&(this.decorations=Tt(e.view.state,e.view.visibleRanges))}},Dt=L.fromClass(Et,{decorations:e=>e.decorations});function Ot(){return[Dt,yt]}var kt=n(),At=me({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),jt=se({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Mt=new xe,Nt=new xe;function Pt(e,t){let n=e.state.doc,i=1;if(n.lines>=1&&n.line(1).text===`---`){for(let e=2;e<=n.lines;e++)if(n.line(e).text===`---`){i=e+1;break}}let a=r(),o=0;for(let r=i;r<=n.lines;r++){let i=n.line(r);if(!a(i.text)&&/^#{1,6}\s/.test(i.text)){if(o===t.index){e.dispatch({selection:F.cursor(i.from),effects:I.scrollIntoView(i.from,{y:`start`})}),e.focus();return}o++}}}function Ft(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:F.cursor(r),effects:I.scrollIntoView(r,{y:`center`})}),e.focus()})}function It(e){let t=(0,Se.c)(29),{docName:n,ytext:r,provider:i,placeholder:a,isSourceModeActive:o}=e,s=(0,U.useRef)(null),c=(0,U.useRef)(null),[u,d]=(0,U.useState)(null);if(u)throw u;let{resolvedTheme:f}=l(),p;t[0]!==o||t[1]!==i.awareness?(p=()=>{let e=i.awareness;if(e)return e.setLocalStateField(`mode`,o?`source`:`wysiwyg`),()=>{e.setLocalStateField(`mode`,`wysiwyg`)}},t[0]=o,t[1]=i.awareness,t[2]=p):p=t[2];let m;t[3]!==o||t[4]!==i?(m=[i,o],t[3]=o,t[4]=i,t[5]=m):m=t[5],(0,U.useEffect)(p,m);let h=(0,U.useRef)(null),g;t[6]!==a||t[7]!==i||t[8]!==f||t[9]!==r?(g=()=>{let e=s.current;if(!e)return;let t=i.configuration.name??``,n,o=Lt;try{n=ee({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let t=pe({ydoc:i.document,ytext:r}),n=new I({state:ve.create({doc:r.toString(),extensions:[fe,be.of([ne]),re({base:ae,extensions:[oe],codeLanguages:Re}),Le(r,i.awareness),Ue(i.document),pt(),Ze(),Ot(),t,Mt.of(f===`dark`?At:jt),Nt.of(B(a??``)),I.lineWrapping,I.theme({"&":{height:`100%`}})]}),parent:e}),s=n.contentDOM;return s.addEventListener(`keydown`,o),s.addEventListener(`paste`,o),s.addEventListener(`drop`,o),s.addEventListener(`cut`,o),{view:n,ydoc:i.document,ytext:r,provider:i}}}),h.current=n,c.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),h.current=null,c.current=null,d(t instanceof Error?t:Error(String(t)))}return()=>{let e=h.current;e&&ie(e),h.current=null,c.current=null}},t[6]=a,t[7]=i,t[8]=f,t[9]=r,t[10]=g):g=t[10];let _;t[11]!==i||t[12]!==r?(_=[r,i],t[11]=i,t[12]=r,t[13]=_):_=t[13],(0,U.useEffect)(g,_);let v,y;t[14]===f?(v=t[15],y=t[16]):(v=()=>{c.current&&c.current.dispatch({effects:Mt.reconfigure(f===`dark`?At:jt)})},y=[f],t[14]=f,t[15]=v,t[16]=y),(0,U.useEffect)(v,y);let b,x;t[17]===a?(b=t[18],x=t[19]):(b=()=>{c.current&&c.current.dispatch({effects:Nt.reconfigure(B(a??``))})},x=[a],t[17]=a,t[18]=b,t[19]=x),(0,U.useEffect)(b,x);let C,w;t[20]!==n||t[21]!==o?(w=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!o)return;let r=c.current;r&&(Pt(r,t),te(n))};return window.addEventListener(S,e),()=>window.removeEventListener(S,e)},C=[n,o],t[20]=n,t[21]=o,t[22]=C,t[23]=w):(C=t[22],w=t[23]),(0,U.useEffect)(w,C);let T,E;t[24]!==n||t[25]!==o?(T=()=>{if(!o)return;let e=c.current;if(!e)return;let t=he(n);if(t){if(t.kind===`outline`){Pt(e,t.detail);return}Ft(e,t.detail)}},E=[n,o],t[24]=n,t[25]=o,t[26]=T,t[27]=E):(T=t[26],E=t[27]),(0,U.useEffect)(T,E);let D;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,kt.jsx)(`div`,{ref:s,className:`source-editor h-full py-3`}),t[28]=D):D=t[28],D}function Lt(){return u()}export{It as SourceEditor};
|