@deepseekcode/cli 1.0.37 → 1.0.39
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/README.md +10 -1
- package/package.json +9 -9
- package/web/dist/assets/AssistantsView-0aLB_cG6.js +1 -0
- package/web/dist/assets/AutomationView-CAMjPhJ2.js +1 -0
- package/web/dist/assets/{ChannelConfigView-JDljUn42.js → ChannelConfigView-FcioeeYb.js} +6 -6
- package/web/dist/assets/{ConnectorsView-AemNT1Ae.js → ConnectorsView-DERP7zAW.js} +1 -1
- package/web/dist/assets/FileTreeView-hBtHBbAV.js +11 -0
- package/web/dist/assets/HookConfigView-NModtSB8.js +1 -0
- package/web/dist/assets/ModelsView-BPpO50C_.js +1 -0
- package/web/dist/assets/PluginsView-D0NE7zrt.js +1 -0
- package/web/dist/assets/ProjectsView-PIv7Gx4q.js +1 -0
- package/web/dist/assets/SessionGrid-BsDL3lov.js +47 -0
- package/web/dist/assets/SettingsModal-DdebvEmv.js +10 -0
- package/web/dist/assets/SkillsView-BNoigImJ.js +1 -0
- package/web/dist/assets/TemplatesTab-D8Pa68fj.js +1 -0
- package/web/dist/assets/ToolsView-NY-yk5YX.js +1 -0
- package/web/dist/assets/WorkspaceDirPicker-C5knnArH.js +6 -0
- package/web/dist/assets/{icons-f1hlMKvD.js → icons-BxNxyk-c.js} +219 -139
- package/web/dist/assets/index-DaiVo1RY.css +1 -0
- package/web/dist/assets/index-RB5ffy32.js +620 -0
- package/web/dist/assets/{markdown-DEtuzEyz.js → markdown-B2L4Mq-x.js} +1 -1
- package/web/dist/assets/{panels-Bn-2wCur.js → panels-P_I7Q72_.js} +1 -1
- package/web/dist/assets/profileChange-C7Jg9C61.js +1 -0
- package/web/dist/assets/{react-vendor-ClBKp0t-.js → react-vendor-B2V_5iSS.js} +1 -1
- package/web/dist/assets/{state-xD58vmym.js → state-0T92JV0u.js} +1 -1
- package/web/dist/fonts/OFL-Inter.txt +93 -0
- package/web/dist/fonts/inter-latin-400-normal.woff2 +0 -0
- package/web/dist/fonts/inter-latin-600-normal.woff2 +0 -0
- package/web/dist/icons/icon-180.png +0 -0
- package/web/dist/icons/icon-192.png +0 -0
- package/web/dist/icons/icon-512.png +0 -0
- package/web/dist/icons/icon-maskable-512.png +0 -0
- package/web/dist/index.html +38 -8
- package/web/dist/manifest.webmanifest +16 -0
- package/web/dist/assets/AssistantsView-OMdgsTIj.js +0 -1
- package/web/dist/assets/AutomationView-BPwjLbkL.js +0 -1
- package/web/dist/assets/FileTreeView-DYx-0jFV.js +0 -11
- package/web/dist/assets/HookConfigView-CS1QqgPx.js +0 -1
- package/web/dist/assets/ModelsView-B3nHezvJ.js +0 -1
- package/web/dist/assets/PluginsView-C4Xc70ec.js +0 -1
- package/web/dist/assets/SessionGrid-C9-LeJH0.js +0 -47
- package/web/dist/assets/SettingsModal-CjWT1C66.js +0 -4
- package/web/dist/assets/SkillsView-DTZyXald.js +0 -1
- package/web/dist/assets/TemplatesTab-CE-CfCf2.js +0 -1
- package/web/dist/assets/ThreeScene-CMqkpyKO.js +0 -2863
- package/web/dist/assets/ThreeScene-DvOrMIoG.css +0 -1
- package/web/dist/assets/ToolsView-CrEHDTEO.js +0 -1
- package/web/dist/assets/index-BCHbHIbw.css +0 -1
- package/web/dist/assets/index-u1vYyqna.js +0 -592
- package/web/dist/assets/sttLanguages-BNRptAQA.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,R as hn}from"./icons-f1hlMKvD.js";const we=f.createContext(null);we.displayName="PanelGroupContext";const k={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},$e=10,ne=f.useLayoutEffect,Fe=hn.useId,zn=typeof Fe=="function"?Fe:()=>null;let yn=0;function Ne(e=null){const n=zn(),t=f.useRef(e||n||null);return t.current===null&&(t.current=""+yn++),e??t.current}function Je({children:e,className:n="",collapsedSize:t,collapsible:r,defaultSize:i,forwardedRef:o,id:l,maxSize:s,minSize:a,onCollapse:h,onExpand:w,onResize:p,order:u,style:v,tagName:z="div",...C}){const E=f.useContext(we);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:L,getPanelSize:M,getPanelStyle:$,groupId:O,isPanelCollapsed:R,reevaluatePanelConstraints:P,registerPanel:K,resizePanel:J,unregisterPanel:F}=E,G=Ne(l),D=f.useRef({callbacks:{onCollapse:h,onExpand:w,onResize:p},constraints:{collapsedSize:t,collapsible:r,defaultSize:i,maxSize:s,minSize:a},id:G,idIsFromProps:l!==void 0,order:u});f.useRef({didLogMissingDefaultSizeWarning:!1}),ne(()=>{const{callbacks:_,constraints:N}=D.current,B={...N};D.current.id=G,D.current.idIsFromProps=l!==void 0,D.current.order=u,_.onCollapse=h,_.onExpand=w,_.onResize=p,N.collapsedSize=t,N.collapsible=r,N.defaultSize=i,N.maxSize=s,N.minSize=a,(B.collapsedSize!==N.collapsedSize||B.collapsible!==N.collapsible||B.maxSize!==N.maxSize||B.minSize!==N.minSize)&&P(D.current,B)}),ne(()=>{const _=D.current;return K(_),()=>{F(_)}},[u,G,K,F]),f.useImperativeHandle(o,()=>({collapse:()=>{b(D.current)},expand:_=>{L(D.current,_)},getId(){return G},getSize(){return M(D.current)},isCollapsed(){return R(D.current)},isExpanded(){return!R(D.current)},resize:_=>{J(D.current,_)}}),[b,L,M,R,G,J]);const Z=$(D.current,i);return f.createElement(z,{...C,children:e,className:n,id:G,style:{...Z,...v},[k.groupId]:O,[k.panel]:"",[k.panelCollapsible]:r||void 0,[k.panelId]:G,[k.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const xn=f.forwardRef((e,n)=>f.createElement(Je,{...e,forwardedRef:n}));Je.displayName="Panel";xn.displayName="forwardRef(Panel)";let He=null,Se=-1,Y=null;function vn(e,n){if(n){const t=(n&en)!==0,r=(n&nn)!==0,i=(n&tn)!==0,o=(n&rn)!==0;if(t)return i?"se-resize":o?"ne-resize":"e-resize";if(r)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Sn(){Y!==null&&(document.head.removeChild(Y),He=null,Y=null,Se=-1)}function Le(e,n){var t,r;const i=vn(e,n);if(He!==i){if(He=i,Y===null&&(Y=document.createElement("style"),document.head.appendChild(Y)),Se>=0){var o;(o=Y.sheet)===null||o===void 0||o.removeRule(Se)}Se=(t=(r=Y.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&t!==void 0?t:-1}}function je(e){return e.type==="keydown"}function Ye(e){return e.type.startsWith("pointer")}function Ze(e){return e.type.startsWith("mouse")}function Ee(e){if(Ye(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ze(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function bn(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Pn(e,n,t){return e.x<n.x+n.width&&e.x+e.width>n.x&&e.y<n.y+n.height&&e.y+e.height>n.y}function wn(e,n){if(e===n)throw new Error("Cannot compare node with itself");const t={a:Ue(e),b:Ue(n)};let r;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),n=t.b.pop(),r=e;x(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Ke(We(t.a)),b:Ke(We(t.b))};if(i.a===i.b){const o=r.childNodes,l={a:t.a.at(-1),b:t.b.at(-1)};let s=o.length;for(;s--;){const a=o[s];if(a===l.a)return 1;if(a===l.b)return-1}}return Math.sign(i.a-i.b)}const En=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cn(e){var n;const t=getComputedStyle((n=Qe(e))!==null&&n!==void 0?n:e).display;return t==="flex"||t==="inline-flex"}function In(e){const n=getComputedStyle(e);return!!(n.position==="fixed"||n.zIndex!=="auto"&&(n.position!=="static"||Cn(e))||+n.opacity<1||"transform"in n&&n.transform!=="none"||"webkitTransform"in n&&n.webkitTransform!=="none"||"mixBlendMode"in n&&n.mixBlendMode!=="normal"||"filter"in n&&n.filter!=="none"||"webkitFilter"in n&&n.webkitFilter!=="none"||"isolation"in n&&n.isolation==="isolate"||En.test(n.willChange)||n.webkitOverflowScrolling==="touch")}function We(e){let n=e.length;for(;n--;){const t=e[n];if(x(t,"Missing node"),In(t))return t}return null}function Ke(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ue(e){const n=[];for(;e;)n.push(e),e=Qe(e);return n}function Qe(e){const{parentNode:n}=e;return n&&n instanceof ShadowRoot?n.host:n}const en=1,nn=2,tn=4,rn=8,Rn=bn()==="coarse";let V=[],se=!1,ee=new Map,Ce=new Map;const he=new Set;function Ln(e,n,t,r,i){var o;const{ownerDocument:l}=n,s={direction:t,element:n,hitAreaMargins:r,setResizeHandlerState:i},a=(o=ee.get(l))!==null&&o!==void 0?o:0;return ee.set(l,a+1),he.add(s),be(),function(){var w;Ce.delete(e),he.delete(s);const p=(w=ee.get(l))!==null&&w!==void 0?w:1;if(ee.set(l,p-1),be(),p===1&&ee.delete(l),V.includes(s)){const u=V.indexOf(s);u>=0&&V.splice(u,1),Ge(),i("up",!0,null)}}}function An(e){const{target:n}=e,{x:t,y:r}=Ee(e);se=!0,_e({target:n,x:t,y:r}),be(),V.length>0&&(Pe("down",e),e.preventDefault(),on(n)||e.stopImmediatePropagation())}function Ae(e){const{x:n,y:t}=Ee(e);if(se&&e.buttons===0&&(se=!1,Pe("up",e)),!se){const{target:r}=e;_e({target:r,x:n,y:t})}Pe("move",e),Ge(),V.length>0&&e.preventDefault()}function ke(e){const{target:n}=e,{x:t,y:r}=Ee(e);Ce.clear(),se=!1,V.length>0&&(e.preventDefault(),on(n)||e.stopImmediatePropagation()),Pe("up",e),_e({target:n,x:t,y:r}),Ge(),be()}function on(e){let n=e;for(;n;){if(n.hasAttribute(k.resizeHandle))return!0;n=n.parentElement}return!1}function _e({target:e,x:n,y:t}){V.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),he.forEach(i=>{const{element:o,hitAreaMargins:l}=i,s=o.getBoundingClientRect(),{bottom:a,left:h,right:w,top:p}=s,u=Rn?l.coarse:l.fine;if(n>=h-u&&n<=w+u&&t>=p-u&&t<=a+u){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&wn(r,o)>0){let z=r,C=!1;for(;z&&!z.contains(o);){if(Pn(z.getBoundingClientRect(),s)){C=!0;break}z=z.parentElement}if(C)return}V.push(i)}})}function De(e,n){Ce.set(e,n)}function Ge(){let e=!1,n=!1;V.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:n=!0});let t=0;Ce.forEach(r=>{t|=r}),e&&n?Le("intersection",t):e?Le("horizontal",t):n?Le("vertical",t):Sn()}let Me=new AbortController;function be(){Me.abort(),Me=new AbortController;const e={capture:!0,signal:Me.signal};he.size&&(se?(V.length>0&&ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("contextmenu",ke,e),r.addEventListener("pointerleave",Ae,e),r.addEventListener("pointermove",Ae,e))}),window.addEventListener("pointerup",ke,e),window.addEventListener("pointercancel",ke,e)):ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("pointerdown",An,e),r.addEventListener("pointermove",Ae,e))}))}function Pe(e,n){he.forEach(t=>{const{setResizeHandlerState:r}=t,i=V.includes(t);r(e,i,n)})}function kn(){const[e,n]=f.useState(0);return f.useCallback(()=>n(t=>t+1),[])}function x(e,n){if(!e)throw console.error(n),Error(n)}function te(e,n,t=$e){return e.toFixed(t)===n.toFixed(t)?0:e>n?1:-1}function j(e,n,t=$e){return te(e,n,t)===0}function W(e,n,t){return te(e,n,t)===0}function Dn(e,n,t){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(!W(i,o,t))return!1}return!0}function le({panelConstraints:e,panelIndex:n,size:t}){const r=e[n];x(r!=null,`Panel constraints not found for index ${n}`);let{collapsedSize:i=0,collapsible:o,maxSize:l=100,minSize:s=0}=r;if(te(t,s)<0)if(o){const a=(i+s)/2;te(t,a)<0?t=i:t=s}else t=s;return t=Math.min(l,t),t=parseFloat(t.toFixed($e)),t}function ge({delta:e,initialLayout:n,panelConstraints:t,pivotIndices:r,prevLayout:i,trigger:o}){if(W(e,0))return n;const l=[...n],[s,a]=r;x(s!=null,"Invalid first pivot index"),x(a!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const p=e<0?a:s,u=t[p];x(u,`Panel constraints not found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,v)){const b=C-E;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?s:a,u=t[p];x(u,`No panel constraints found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,C)){const b=E-v;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let u=e<0?a:s,v=0;for(;;){const C=n[u];x(C!=null,`Previous layout not found for panel index ${u}`);const b=le({panelConstraints:t,panelIndex:u,size:100})-C;if(v+=b,u+=p,u<0||u>=t.length)break}const z=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-z:z}{let u=e<0?s:a;for(;u>=0&&u<t.length;){const v=Math.abs(e)-Math.abs(h),z=n[u];x(z!=null,`Previous layout not found for panel index ${u}`);const C=z-v,E=le({panelConstraints:t,panelIndex:u,size:C});if(!W(z,E)&&(h+=z-E,l[u]=E,h.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(Dn(i,l))return i;{const p=e<0?a:s,u=n[p];x(u!=null,`Previous layout not found for panel index ${p}`);const v=u+h,z=le({panelConstraints:t,panelIndex:p,size:v});if(l[p]=z,!W(z,v)){let C=v-z,b=e<0?a:s;for(;b>=0&&b<t.length;){const L=l[b];x(L!=null,`Previous layout not found for panel index ${b}`);const M=L+C,$=le({panelConstraints:t,panelIndex:b,size:M});if(W(L,$)||(C-=$-L,l[b]=$),W(C,0))break;e>0?b--:b++}}}const w=l.reduce((p,u)=>u+p,0);return W(w,100)?l:i}function Mn({layout:e,panelsArray:n,pivotIndices:t}){let r=0,i=100,o=0,l=0;const s=t[0];x(s!=null,"No pivot index found"),n.forEach((p,u)=>{const{constraints:v}=p,{maxSize:z=100,minSize:C=0}=v;u===s?(r=C,i=z):(o+=C,l+=z)});const a=Math.min(i,100-o),h=Math.max(r,100-l),w=e[s];return{valueMax:a,valueMin:h,valueNow:w}}function ze(e,n=document){return Array.from(n.querySelectorAll(`[${k.resizeHandleId}][data-panel-group-id="${e}"]`))}function ln(e,n,t=document){const i=ze(e,t).findIndex(o=>o.getAttribute(k.resizeHandleId)===n);return i??null}function sn(e,n,t){const r=ln(e,n,t);return r!=null?[r,r+1]:[-1,-1]}function an(e,n=document){var t;if(n instanceof HTMLElement&&(n==null||(t=n.dataset)===null||t===void 0?void 0:t.panelGroupId)==e)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function Ie(e,n=document){const t=n.querySelector(`[${k.resizeHandleId}="${e}"]`);return t||null}function Hn(e,n,t,r=document){var i,o,l,s;const a=Ie(n,r),h=ze(e,r),w=a?h.indexOf(a):-1,p=(i=(o=t[w])===null||o===void 0?void 0:o.id)!==null&&i!==void 0?i:null,u=(l=(s=t[w+1])===null||s===void 0?void 0:s.id)!==null&&l!==void 0?l:null;return[p,u]}function $n({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:r,panelDataArray:i,panelGroupElement:o,setLayout:l}){f.useRef({didWarnAboutMissingResizeHandle:!1}),ne(()=>{if(!o)return;const s=ze(t,o);for(let a=0;a<i.length-1;a++){const{valueMax:h,valueMin:w,valueNow:p}=Mn({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),u=s[a];if(u!=null){const v=i[a];x(v,`No panel data found for index "${a}"`),u.setAttribute("aria-controls",v.id),u.setAttribute("aria-valuemax",""+Math.round(h)),u.setAttribute("aria-valuemin",""+Math.round(w)),u.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{s.forEach((a,h)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[t,r,i,o]),f.useEffect(()=>{if(!o)return;const s=n.current;x(s,"Eager values not found");const{panelDataArray:a}=s,h=an(t,o);x(h!=null,`No group found for id "${t}"`);const w=ze(t,o);x(w,`No resize handles found for group id "${t}"`);const p=w.map(u=>{const v=u.getAttribute(k.resizeHandleId);x(v,"Resize handle element has no handle id attribute");const[z,C]=Hn(t,v,a,o);if(z==null||C==null)return()=>{};const E=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const L=a.findIndex(M=>M.id===z);if(L>=0){const M=a[L];x(M,`No panel data found for index ${L}`);const $=r[L],{collapsedSize:O=0,collapsible:R,minSize:P=0}=M.constraints;if($!=null&&R){const K=ge({delta:W($,O)?P-O:O-$,initialLayout:r,panelConstraints:a.map(J=>J.constraints),pivotIndices:sn(t,v,o),prevLayout:r,trigger:"keyboard"});r!==K&&l(K)}}break}}};return u.addEventListener("keydown",E),()=>{u.removeEventListener("keydown",E)}});return()=>{p.forEach(u=>u())}},[o,e,n,t,r,i,l])}function Ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function un(e,n){const t=e==="horizontal",{x:r,y:i}=Ee(n);return t?r:i}function Nn(e,n,t,r,i){const o=t==="horizontal",l=Ie(n,i);x(l,`No resize handle element found for id "${n}"`);const s=l.getAttribute(k.groupId);x(s,"Resize handle element has no group id attribute");let{initialCursorPosition:a}=r;const h=un(t,e),w=an(s,i);x(w,`No group element found for id "${s}"`);const p=w.getBoundingClientRect(),u=o?p.width:p.height;return(h-a)/u*100}function _n(e,n,t,r,i,o){if(je(e)){const l=t==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=l?0:s;break;case"ArrowLeft":a=l?-s:0;break;case"ArrowRight":a=l?s:0;break;case"ArrowUp":a=l?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:Nn(e,n,t,r,o)}function Gn({panelDataArray:e}){const n=Array(e.length),t=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;s!=null&&(r++,n[o]=s,i-=s)}for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;if(s!=null)continue;const a=e.length-r,h=i/a;r++,n[o]=h,i-=h}return n}function oe(e,n,t){n.forEach((r,i)=>{const o=e[i];x(o,`Panel data not found for index ${i}`);const{callbacks:l,constraints:s,id:a}=o,{collapsedSize:h=0,collapsible:w}=s,p=t[a];if(p==null||r!==p){t[a]=r;const{onCollapse:u,onExpand:v,onResize:z}=l;z&&z(r,p),w&&(u||v)&&(v&&(p==null||j(p,h))&&!j(r,h)&&v(),u&&(p==null||!j(p,h))&&j(r,h)&&u())}})}function ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=n[t])return!1;return!0}function Bn({defaultSize:e,dragState:n,layout:t,panelData:r,panelIndex:i,precision:o=3}){const l=t[i];let s;return l==null?s=e!=null?e.toPrecision(o):"1":r.length===1?s="1":s=l.toPrecision(o),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:n!==null?"none":void 0}}function Tn(e,n=10){let t=null;return(...i)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{e(...i)},n)}}function Oe(e){try{if(typeof localStorage<"u")e.getItem=n=>localStorage.getItem(n),e.setItem=(n,t)=>{localStorage.setItem(n,t)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),e.getItem=()=>null,e.setItem=()=>{}}}function cn(e){return`react-resizable-panels:${e}`}function fn(e){return e.map(n=>{const{constraints:t,id:r,idIsFromProps:i,order:o}=n;return i?r:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((n,t)=>n.localeCompare(t)).join(",")}function dn(e,n){try{const t=cn(e),r=n.getItem(t);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Fn(e,n,t){var r,i;const o=(r=dn(e,t))!==null&&r!==void 0?r:{},l=fn(n);return(i=o[l])!==null&&i!==void 0?i:null}function Wn(e,n,t,r,i){var o;const l=cn(e),s=fn(n),a=(o=dn(e,i))!==null&&o!==void 0?o:{};a[s]={expandToSizes:Object.fromEntries(t.entries()),layout:r};try{i.setItem(l,JSON.stringify(a))}catch(h){console.error(h)}}function qe({layout:e,panelConstraints:n}){const t=[...e],r=t.reduce((o,l)=>o+l,0);if(t.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${t.map(o=>`${o}%`).join(", ")}`);if(!W(r,100)&&t.length>0)for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=100/r*l;t[o]=s}let i=0;for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=le({panelConstraints:n,panelIndex:o,size:l});l!=s&&(i+=l-s,t[o]=s)}if(!W(i,0))for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=l+i,a=le({panelConstraints:n,panelIndex:o,size:s});if(l!==a&&(i-=a-l,t[o]=a,W(i,0)))break}return t}const Kn=100,me={getItem:e=>(Oe(me),me.getItem(e)),setItem:(e,n)=>{Oe(me),me.setItem(e,n)}},Xe={};function pn({autoSaveId:e=null,children:n,className:t="",direction:r,forwardedRef:i,id:o=null,onLayout:l=null,keyboardResizeBy:s=null,storage:a=me,style:h,tagName:w="div",...p}){const u=Ne(o),v=f.useRef(null),[z,C]=f.useState(null),[E,b]=f.useState([]),L=kn(),M=f.useRef({}),$=f.useRef(new Map),O=f.useRef(0),R=f.useRef({autoSaveId:e,direction:r,dragState:z,id:u,keyboardResizeBy:s,onLayout:l,storage:a}),P=f.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});f.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),f.useImperativeHandle(i,()=>({getId:()=>R.current.id,getLayout:()=>{const{layout:c}=P.current;return c},setLayout:c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current,d=qe({layout:c,panelConstraints:g.map(y=>y.constraints)});Ve(S,d)||(b(d),P.current.layout=d,m&&m(d),oe(g,d,M.current))}}),[]),ne(()=>{R.current.autoSaveId=e,R.current.direction=r,R.current.dragState=z,R.current.id=u,R.current.onLayout=l,R.current.storage=a}),$n({committedValuesRef:R,eagerValuesRef:P,groupId:u,layout:E,panelDataArray:P.current.panelDataArray,setLayout:b,panelGroupElement:v.current}),f.useEffect(()=>{const{panelDataArray:c}=P.current;if(e){if(E.length===0||E.length!==c.length)return;let m=Xe[e];m==null&&(m=Tn(Wn,Kn),Xe[e]=m);const S=[...c],g=new Map($.current);m(e,S,g,E,a)}},[e,E,a]),f.useEffect(()=>{});const K=f.useCallback(c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current;if(c.constraints.collapsible){const d=g.map(q=>q.constraints),{collapsedSize:y=0,panelSize:I,pivotIndices:H}=Q(g,c,S);if(x(I!=null,`Panel size not found for panel "${c.id}"`),!j(I,y)){$.current.set(c.id,I);const X=ie(g,c)===g.length-1?I-y:y-I,A=ge({delta:X,initialLayout:S,panelConstraints:d,pivotIndices:H,prevLayout:S,trigger:"imperative-api"});ve(S,A)||(b(A),P.current.layout=A,m&&m(A),oe(g,A,M.current))}}},[]),J=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current;if(c.constraints.collapsible){const y=d.map(U=>U.constraints),{collapsedSize:I=0,panelSize:H=0,minSize:q=0,pivotIndices:X}=Q(d,c,g),A=m??q;if(j(H,I)){const U=$.current.get(c.id),de=U!=null&&U>=A?U:A,Re=ie(d,c)===d.length-1?H-de:de-H,T=ge({delta:Re,initialLayout:g,panelConstraints:y,pivotIndices:X,prevLayout:g,trigger:"imperative-api"});ve(g,T)||(b(T),P.current.layout=T,S&&S(T),oe(d,T,M.current))}}},[]),F=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{panelSize:g}=Q(S,c,m);return x(g!=null,`Panel size not found for panel "${c.id}"`),g},[]),G=f.useCallback((c,m)=>{const{panelDataArray:S}=P.current,g=ie(S,c);return Bn({defaultSize:m,dragState:z,layout:E,panelData:S,panelIndex:g})},[z,E]),D=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),d===!0&&j(y,g)},[]),Z=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),!d||te(y,g)>0},[]),_=f.useCallback(c=>{const{panelDataArray:m}=P.current;m.push(c),m.sort((S,g)=>{const d=S.order,y=g.order;return d==null&&y==null?0:d==null?-1:y==null?1:d-y}),P.current.panelDataArrayChanged=!0,L()},[L]);ne(()=>{if(P.current.panelDataArrayChanged){P.current.panelDataArrayChanged=!1;const{autoSaveId:c,onLayout:m,storage:S}=R.current,{layout:g,panelDataArray:d}=P.current;let y=null;if(c){const H=Fn(c,d,S);H&&($.current=new Map(Object.entries(H.expandToSizes)),y=H.layout)}y==null&&(y=Gn({panelDataArray:d}));const I=qe({layout:y,panelConstraints:d.map(H=>H.constraints)});Ve(g,I)||(b(I),P.current.layout=I,m&&m(I),oe(d,I,M.current))}}),ne(()=>{const c=P.current;return()=>{c.layout=[]}},[]);const N=f.useCallback(c=>{let m=!1;const S=v.current;return S&&window.getComputedStyle(S,null).getPropertyValue("direction")==="rtl"&&(m=!0),function(d){d.preventDefault();const y=v.current;if(!y)return()=>null;const{direction:I,dragState:H,id:q,keyboardResizeBy:X,onLayout:A}=R.current,{layout:U,panelDataArray:de}=P.current,{initialLayout:xe}=H??{},Re=sn(q,c,y);let T=_n(d,c,I,H,X,y);const Be=I==="horizontal";Be&&m&&(T=-T);const gn=de.map(mn=>mn.constraints),pe=ge({delta:T,initialLayout:xe??U,panelConstraints:gn,pivotIndices:Re,prevLayout:U,trigger:je(d)?"keyboard":"mouse-or-touch"}),Te=!ve(U,pe);(Ye(d)||Ze(d))&&O.current!=T&&(O.current=T,!Te&&T!==0?Be?De(c,T<0?en:nn):De(c,T<0?tn:rn):De(c,0)),Te&&(b(pe),P.current.layout=pe,A&&A(pe),oe(de,pe,M.current))}},[]),B=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current,y=d.map(U=>U.constraints),{panelSize:I,pivotIndices:H}=Q(d,c,g);x(I!=null,`Panel size not found for panel "${c.id}"`);const X=ie(d,c)===d.length-1?I-m:m-I,A=ge({delta:X,initialLayout:g,panelConstraints:y,pivotIndices:H,prevLayout:g,trigger:"imperative-api"});ve(g,A)||(b(A),P.current.layout=A,S&&S(A),oe(d,A,M.current))},[]),ae=f.useCallback((c,m)=>{const{layout:S,panelDataArray:g}=P.current,{collapsedSize:d=0,collapsible:y}=m,{collapsedSize:I=0,collapsible:H,maxSize:q=100,minSize:X=0}=c.constraints,{panelSize:A}=Q(g,c,S);A!=null&&(y&&H&&j(A,d)?j(d,I)||B(c,I):A<X?B(c,X):A>q&&B(c,q))},[B]),ue=f.useCallback((c,m)=>{const{direction:S}=R.current,{layout:g}=P.current;if(!v.current)return;const d=Ie(c,v.current);x(d,`Drag handle element not found for id "${c}"`);const y=un(S,m);C({dragHandleId:c,dragHandleRect:d.getBoundingClientRect(),initialCursorPosition:y,initialLayout:g})},[]),ce=f.useCallback(()=>{C(null)},[]),ye=f.useCallback(c=>{const{panelDataArray:m}=P.current,S=ie(m,c);S>=0&&(m.splice(S,1),delete M.current[c.id],P.current.panelDataArrayChanged=!0,L())},[L]),re=f.useMemo(()=>({collapsePanel:K,direction:r,dragState:z,expandPanel:J,getPanelSize:F,getPanelStyle:G,groupId:u,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:ae,registerPanel:_,registerResizeHandle:N,resizePanel:B,startDragging:ue,stopDragging:ce,unregisterPanel:ye,panelGroupElement:v.current}),[K,z,r,J,F,G,u,D,Z,ae,_,N,B,ue,ce,ye]),fe={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return f.createElement(we.Provider,{value:re},f.createElement(w,{...p,children:n,className:t,id:o,ref:v,style:{...fe,...h},[k.group]:"",[k.groupDirection]:r,[k.groupId]:u}))}const Un=f.forwardRef((e,n)=>f.createElement(pn,{...e,forwardedRef:n}));pn.displayName="PanelGroup";Un.displayName="forwardRef(PanelGroup)";function ie(e,n){return e.findIndex(t=>t===n||t.id===n.id)}function Q(e,n,t){const r=ie(e,n),o=r===e.length-1?[r-1,r]:[r,r+1],l=t[r];return{...n.constraints,panelSize:l,pivotIndices:o}}function Vn({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:r}){f.useEffect(()=>{if(e||t==null||r==null)return;const i=Ie(n,r);if(i==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),t(l);break}case"F6":{l.preventDefault();const s=i.getAttribute(k.groupId);x(s,`No group element found for id "${s}"`);const a=ze(s,r),h=ln(s,n,r);x(h!==null,`No resize element found for id "${n}"`);const w=l.shiftKey?h>0?h-1:a.length-1:h+1<a.length?h+1:0;a[w].focus();break}}};return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}},[r,e,n,t])}function On({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:r,id:i,onBlur:o,onClick:l,onDragging:s,onFocus:a,onPointerDown:h,onPointerUp:w,style:p={},tabIndex:u=0,tagName:v="div",...z}){var C,E;const b=f.useRef(null),L=f.useRef({onClick:l,onDragging:s,onPointerDown:h,onPointerUp:w});f.useEffect(()=>{L.current.onClick=l,L.current.onDragging=s,L.current.onPointerDown=h,L.current.onPointerUp=w});const M=f.useContext(we);if(M===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:$,groupId:O,registerResizeHandle:R,startDragging:P,stopDragging:K,panelGroupElement:J}=M,F=Ne(i),[G,D]=f.useState("inactive"),[Z,_]=f.useState(!1),[N,B]=f.useState(null),ae=f.useRef({state:G});ne(()=>{ae.current.state=G}),f.useEffect(()=>{if(t)B(null);else{const re=R(F);B(()=>re)}},[t,F,R]);const ue=(C=r==null?void 0:r.coarse)!==null&&C!==void 0?C:15,ce=(E=r==null?void 0:r.fine)!==null&&E!==void 0?E:5;f.useEffect(()=>{if(t||N==null)return;const re=b.current;x(re,"Element ref not attached");let fe=!1;return Ln(F,re,$,{coarse:ue,fine:ce},(m,S,g)=>{if(!S){D("inactive");return}switch(m){case"down":{D("drag"),fe=!1,x(g,'Expected event to be defined for "down" action'),P(F,g);const{onDragging:d,onPointerDown:y}=L.current;d==null||d(!0),y==null||y();break}case"move":{const{state:d}=ae.current;fe=!0,d!=="drag"&&D("hover"),x(g,'Expected event to be defined for "move" action'),N(g);break}case"up":{D("hover"),K();const{onClick:d,onDragging:y,onPointerUp:I}=L.current;y==null||y(!1),I==null||I(),fe||d==null||d();break}}})},[ue,$,t,ce,R,F,N,P,K]),Vn({disabled:t,handleId:F,resizeHandler:N,panelGroupElement:J});const ye={touchAction:"none",userSelect:"none"};return f.createElement(v,{...z,children:e,className:n,id:i,onBlur:()=>{_(!1),o==null||o()},onFocus:()=>{_(!0),a==null||a()},ref:b,role:"separator",style:{...ye,...p},tabIndex:u,[k.groupDirection]:$,[k.groupId]:O,[k.resizeHandle]:"",[k.resizeHandleActive]:G==="drag"?"pointer":Z?"keyboard":void 0,[k.resizeHandleEnabled]:!t,[k.resizeHandleId]:F,[k.resizeHandleState]:G})}On.displayName="PanelResizeHandle";export{Un as P,xn as a,On as b};
|
|
1
|
+
import{a as f,R as hn}from"./icons-BxNxyk-c.js";const we=f.createContext(null);we.displayName="PanelGroupContext";const k={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},$e=10,ne=f.useLayoutEffect,Fe=hn.useId,zn=typeof Fe=="function"?Fe:()=>null;let yn=0;function Ne(e=null){const n=zn(),t=f.useRef(e||n||null);return t.current===null&&(t.current=""+yn++),e??t.current}function Je({children:e,className:n="",collapsedSize:t,collapsible:r,defaultSize:i,forwardedRef:o,id:l,maxSize:s,minSize:a,onCollapse:h,onExpand:w,onResize:p,order:u,style:v,tagName:z="div",...C}){const E=f.useContext(we);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:L,getPanelSize:M,getPanelStyle:$,groupId:O,isPanelCollapsed:R,reevaluatePanelConstraints:P,registerPanel:K,resizePanel:J,unregisterPanel:F}=E,G=Ne(l),D=f.useRef({callbacks:{onCollapse:h,onExpand:w,onResize:p},constraints:{collapsedSize:t,collapsible:r,defaultSize:i,maxSize:s,minSize:a},id:G,idIsFromProps:l!==void 0,order:u});f.useRef({didLogMissingDefaultSizeWarning:!1}),ne(()=>{const{callbacks:_,constraints:N}=D.current,B={...N};D.current.id=G,D.current.idIsFromProps=l!==void 0,D.current.order=u,_.onCollapse=h,_.onExpand=w,_.onResize=p,N.collapsedSize=t,N.collapsible=r,N.defaultSize=i,N.maxSize=s,N.minSize=a,(B.collapsedSize!==N.collapsedSize||B.collapsible!==N.collapsible||B.maxSize!==N.maxSize||B.minSize!==N.minSize)&&P(D.current,B)}),ne(()=>{const _=D.current;return K(_),()=>{F(_)}},[u,G,K,F]),f.useImperativeHandle(o,()=>({collapse:()=>{b(D.current)},expand:_=>{L(D.current,_)},getId(){return G},getSize(){return M(D.current)},isCollapsed(){return R(D.current)},isExpanded(){return!R(D.current)},resize:_=>{J(D.current,_)}}),[b,L,M,R,G,J]);const Z=$(D.current,i);return f.createElement(z,{...C,children:e,className:n,id:G,style:{...Z,...v},[k.groupId]:O,[k.panel]:"",[k.panelCollapsible]:r||void 0,[k.panelId]:G,[k.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const xn=f.forwardRef((e,n)=>f.createElement(Je,{...e,forwardedRef:n}));Je.displayName="Panel";xn.displayName="forwardRef(Panel)";let He=null,Se=-1,Y=null;function vn(e,n){if(n){const t=(n&en)!==0,r=(n&nn)!==0,i=(n&tn)!==0,o=(n&rn)!==0;if(t)return i?"se-resize":o?"ne-resize":"e-resize";if(r)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Sn(){Y!==null&&(document.head.removeChild(Y),He=null,Y=null,Se=-1)}function Le(e,n){var t,r;const i=vn(e,n);if(He!==i){if(He=i,Y===null&&(Y=document.createElement("style"),document.head.appendChild(Y)),Se>=0){var o;(o=Y.sheet)===null||o===void 0||o.removeRule(Se)}Se=(t=(r=Y.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&t!==void 0?t:-1}}function je(e){return e.type==="keydown"}function Ye(e){return e.type.startsWith("pointer")}function Ze(e){return e.type.startsWith("mouse")}function Ee(e){if(Ye(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ze(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function bn(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Pn(e,n,t){return e.x<n.x+n.width&&e.x+e.width>n.x&&e.y<n.y+n.height&&e.y+e.height>n.y}function wn(e,n){if(e===n)throw new Error("Cannot compare node with itself");const t={a:Ue(e),b:Ue(n)};let r;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),n=t.b.pop(),r=e;x(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Ke(We(t.a)),b:Ke(We(t.b))};if(i.a===i.b){const o=r.childNodes,l={a:t.a.at(-1),b:t.b.at(-1)};let s=o.length;for(;s--;){const a=o[s];if(a===l.a)return 1;if(a===l.b)return-1}}return Math.sign(i.a-i.b)}const En=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cn(e){var n;const t=getComputedStyle((n=Qe(e))!==null&&n!==void 0?n:e).display;return t==="flex"||t==="inline-flex"}function In(e){const n=getComputedStyle(e);return!!(n.position==="fixed"||n.zIndex!=="auto"&&(n.position!=="static"||Cn(e))||+n.opacity<1||"transform"in n&&n.transform!=="none"||"webkitTransform"in n&&n.webkitTransform!=="none"||"mixBlendMode"in n&&n.mixBlendMode!=="normal"||"filter"in n&&n.filter!=="none"||"webkitFilter"in n&&n.webkitFilter!=="none"||"isolation"in n&&n.isolation==="isolate"||En.test(n.willChange)||n.webkitOverflowScrolling==="touch")}function We(e){let n=e.length;for(;n--;){const t=e[n];if(x(t,"Missing node"),In(t))return t}return null}function Ke(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ue(e){const n=[];for(;e;)n.push(e),e=Qe(e);return n}function Qe(e){const{parentNode:n}=e;return n&&n instanceof ShadowRoot?n.host:n}const en=1,nn=2,tn=4,rn=8,Rn=bn()==="coarse";let V=[],se=!1,ee=new Map,Ce=new Map;const he=new Set;function Ln(e,n,t,r,i){var o;const{ownerDocument:l}=n,s={direction:t,element:n,hitAreaMargins:r,setResizeHandlerState:i},a=(o=ee.get(l))!==null&&o!==void 0?o:0;return ee.set(l,a+1),he.add(s),be(),function(){var w;Ce.delete(e),he.delete(s);const p=(w=ee.get(l))!==null&&w!==void 0?w:1;if(ee.set(l,p-1),be(),p===1&&ee.delete(l),V.includes(s)){const u=V.indexOf(s);u>=0&&V.splice(u,1),Ge(),i("up",!0,null)}}}function An(e){const{target:n}=e,{x:t,y:r}=Ee(e);se=!0,_e({target:n,x:t,y:r}),be(),V.length>0&&(Pe("down",e),e.preventDefault(),on(n)||e.stopImmediatePropagation())}function Ae(e){const{x:n,y:t}=Ee(e);if(se&&e.buttons===0&&(se=!1,Pe("up",e)),!se){const{target:r}=e;_e({target:r,x:n,y:t})}Pe("move",e),Ge(),V.length>0&&e.preventDefault()}function ke(e){const{target:n}=e,{x:t,y:r}=Ee(e);Ce.clear(),se=!1,V.length>0&&(e.preventDefault(),on(n)||e.stopImmediatePropagation()),Pe("up",e),_e({target:n,x:t,y:r}),Ge(),be()}function on(e){let n=e;for(;n;){if(n.hasAttribute(k.resizeHandle))return!0;n=n.parentElement}return!1}function _e({target:e,x:n,y:t}){V.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),he.forEach(i=>{const{element:o,hitAreaMargins:l}=i,s=o.getBoundingClientRect(),{bottom:a,left:h,right:w,top:p}=s,u=Rn?l.coarse:l.fine;if(n>=h-u&&n<=w+u&&t>=p-u&&t<=a+u){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&wn(r,o)>0){let z=r,C=!1;for(;z&&!z.contains(o);){if(Pn(z.getBoundingClientRect(),s)){C=!0;break}z=z.parentElement}if(C)return}V.push(i)}})}function De(e,n){Ce.set(e,n)}function Ge(){let e=!1,n=!1;V.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:n=!0});let t=0;Ce.forEach(r=>{t|=r}),e&&n?Le("intersection",t):e?Le("horizontal",t):n?Le("vertical",t):Sn()}let Me=new AbortController;function be(){Me.abort(),Me=new AbortController;const e={capture:!0,signal:Me.signal};he.size&&(se?(V.length>0&&ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("contextmenu",ke,e),r.addEventListener("pointerleave",Ae,e),r.addEventListener("pointermove",Ae,e))}),window.addEventListener("pointerup",ke,e),window.addEventListener("pointercancel",ke,e)):ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("pointerdown",An,e),r.addEventListener("pointermove",Ae,e))}))}function Pe(e,n){he.forEach(t=>{const{setResizeHandlerState:r}=t,i=V.includes(t);r(e,i,n)})}function kn(){const[e,n]=f.useState(0);return f.useCallback(()=>n(t=>t+1),[])}function x(e,n){if(!e)throw console.error(n),Error(n)}function te(e,n,t=$e){return e.toFixed(t)===n.toFixed(t)?0:e>n?1:-1}function j(e,n,t=$e){return te(e,n,t)===0}function W(e,n,t){return te(e,n,t)===0}function Dn(e,n,t){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(!W(i,o,t))return!1}return!0}function le({panelConstraints:e,panelIndex:n,size:t}){const r=e[n];x(r!=null,`Panel constraints not found for index ${n}`);let{collapsedSize:i=0,collapsible:o,maxSize:l=100,minSize:s=0}=r;if(te(t,s)<0)if(o){const a=(i+s)/2;te(t,a)<0?t=i:t=s}else t=s;return t=Math.min(l,t),t=parseFloat(t.toFixed($e)),t}function ge({delta:e,initialLayout:n,panelConstraints:t,pivotIndices:r,prevLayout:i,trigger:o}){if(W(e,0))return n;const l=[...n],[s,a]=r;x(s!=null,"Invalid first pivot index"),x(a!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const p=e<0?a:s,u=t[p];x(u,`Panel constraints not found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,v)){const b=C-E;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?s:a,u=t[p];x(u,`No panel constraints found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,C)){const b=E-v;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let u=e<0?a:s,v=0;for(;;){const C=n[u];x(C!=null,`Previous layout not found for panel index ${u}`);const b=le({panelConstraints:t,panelIndex:u,size:100})-C;if(v+=b,u+=p,u<0||u>=t.length)break}const z=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-z:z}{let u=e<0?s:a;for(;u>=0&&u<t.length;){const v=Math.abs(e)-Math.abs(h),z=n[u];x(z!=null,`Previous layout not found for panel index ${u}`);const C=z-v,E=le({panelConstraints:t,panelIndex:u,size:C});if(!W(z,E)&&(h+=z-E,l[u]=E,h.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(Dn(i,l))return i;{const p=e<0?a:s,u=n[p];x(u!=null,`Previous layout not found for panel index ${p}`);const v=u+h,z=le({panelConstraints:t,panelIndex:p,size:v});if(l[p]=z,!W(z,v)){let C=v-z,b=e<0?a:s;for(;b>=0&&b<t.length;){const L=l[b];x(L!=null,`Previous layout not found for panel index ${b}`);const M=L+C,$=le({panelConstraints:t,panelIndex:b,size:M});if(W(L,$)||(C-=$-L,l[b]=$),W(C,0))break;e>0?b--:b++}}}const w=l.reduce((p,u)=>u+p,0);return W(w,100)?l:i}function Mn({layout:e,panelsArray:n,pivotIndices:t}){let r=0,i=100,o=0,l=0;const s=t[0];x(s!=null,"No pivot index found"),n.forEach((p,u)=>{const{constraints:v}=p,{maxSize:z=100,minSize:C=0}=v;u===s?(r=C,i=z):(o+=C,l+=z)});const a=Math.min(i,100-o),h=Math.max(r,100-l),w=e[s];return{valueMax:a,valueMin:h,valueNow:w}}function ze(e,n=document){return Array.from(n.querySelectorAll(`[${k.resizeHandleId}][data-panel-group-id="${e}"]`))}function ln(e,n,t=document){const i=ze(e,t).findIndex(o=>o.getAttribute(k.resizeHandleId)===n);return i??null}function sn(e,n,t){const r=ln(e,n,t);return r!=null?[r,r+1]:[-1,-1]}function an(e,n=document){var t;if(n instanceof HTMLElement&&(n==null||(t=n.dataset)===null||t===void 0?void 0:t.panelGroupId)==e)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function Ie(e,n=document){const t=n.querySelector(`[${k.resizeHandleId}="${e}"]`);return t||null}function Hn(e,n,t,r=document){var i,o,l,s;const a=Ie(n,r),h=ze(e,r),w=a?h.indexOf(a):-1,p=(i=(o=t[w])===null||o===void 0?void 0:o.id)!==null&&i!==void 0?i:null,u=(l=(s=t[w+1])===null||s===void 0?void 0:s.id)!==null&&l!==void 0?l:null;return[p,u]}function $n({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:r,panelDataArray:i,panelGroupElement:o,setLayout:l}){f.useRef({didWarnAboutMissingResizeHandle:!1}),ne(()=>{if(!o)return;const s=ze(t,o);for(let a=0;a<i.length-1;a++){const{valueMax:h,valueMin:w,valueNow:p}=Mn({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),u=s[a];if(u!=null){const v=i[a];x(v,`No panel data found for index "${a}"`),u.setAttribute("aria-controls",v.id),u.setAttribute("aria-valuemax",""+Math.round(h)),u.setAttribute("aria-valuemin",""+Math.round(w)),u.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{s.forEach((a,h)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[t,r,i,o]),f.useEffect(()=>{if(!o)return;const s=n.current;x(s,"Eager values not found");const{panelDataArray:a}=s,h=an(t,o);x(h!=null,`No group found for id "${t}"`);const w=ze(t,o);x(w,`No resize handles found for group id "${t}"`);const p=w.map(u=>{const v=u.getAttribute(k.resizeHandleId);x(v,"Resize handle element has no handle id attribute");const[z,C]=Hn(t,v,a,o);if(z==null||C==null)return()=>{};const E=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const L=a.findIndex(M=>M.id===z);if(L>=0){const M=a[L];x(M,`No panel data found for index ${L}`);const $=r[L],{collapsedSize:O=0,collapsible:R,minSize:P=0}=M.constraints;if($!=null&&R){const K=ge({delta:W($,O)?P-O:O-$,initialLayout:r,panelConstraints:a.map(J=>J.constraints),pivotIndices:sn(t,v,o),prevLayout:r,trigger:"keyboard"});r!==K&&l(K)}}break}}};return u.addEventListener("keydown",E),()=>{u.removeEventListener("keydown",E)}});return()=>{p.forEach(u=>u())}},[o,e,n,t,r,i,l])}function Ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function un(e,n){const t=e==="horizontal",{x:r,y:i}=Ee(n);return t?r:i}function Nn(e,n,t,r,i){const o=t==="horizontal",l=Ie(n,i);x(l,`No resize handle element found for id "${n}"`);const s=l.getAttribute(k.groupId);x(s,"Resize handle element has no group id attribute");let{initialCursorPosition:a}=r;const h=un(t,e),w=an(s,i);x(w,`No group element found for id "${s}"`);const p=w.getBoundingClientRect(),u=o?p.width:p.height;return(h-a)/u*100}function _n(e,n,t,r,i,o){if(je(e)){const l=t==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=l?0:s;break;case"ArrowLeft":a=l?-s:0;break;case"ArrowRight":a=l?s:0;break;case"ArrowUp":a=l?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:Nn(e,n,t,r,o)}function Gn({panelDataArray:e}){const n=Array(e.length),t=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;s!=null&&(r++,n[o]=s,i-=s)}for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;if(s!=null)continue;const a=e.length-r,h=i/a;r++,n[o]=h,i-=h}return n}function oe(e,n,t){n.forEach((r,i)=>{const o=e[i];x(o,`Panel data not found for index ${i}`);const{callbacks:l,constraints:s,id:a}=o,{collapsedSize:h=0,collapsible:w}=s,p=t[a];if(p==null||r!==p){t[a]=r;const{onCollapse:u,onExpand:v,onResize:z}=l;z&&z(r,p),w&&(u||v)&&(v&&(p==null||j(p,h))&&!j(r,h)&&v(),u&&(p==null||!j(p,h))&&j(r,h)&&u())}})}function ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=n[t])return!1;return!0}function Bn({defaultSize:e,dragState:n,layout:t,panelData:r,panelIndex:i,precision:o=3}){const l=t[i];let s;return l==null?s=e!=null?e.toPrecision(o):"1":r.length===1?s="1":s=l.toPrecision(o),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:n!==null?"none":void 0}}function Tn(e,n=10){let t=null;return(...i)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{e(...i)},n)}}function Oe(e){try{if(typeof localStorage<"u")e.getItem=n=>localStorage.getItem(n),e.setItem=(n,t)=>{localStorage.setItem(n,t)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),e.getItem=()=>null,e.setItem=()=>{}}}function cn(e){return`react-resizable-panels:${e}`}function fn(e){return e.map(n=>{const{constraints:t,id:r,idIsFromProps:i,order:o}=n;return i?r:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((n,t)=>n.localeCompare(t)).join(",")}function dn(e,n){try{const t=cn(e),r=n.getItem(t);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Fn(e,n,t){var r,i;const o=(r=dn(e,t))!==null&&r!==void 0?r:{},l=fn(n);return(i=o[l])!==null&&i!==void 0?i:null}function Wn(e,n,t,r,i){var o;const l=cn(e),s=fn(n),a=(o=dn(e,i))!==null&&o!==void 0?o:{};a[s]={expandToSizes:Object.fromEntries(t.entries()),layout:r};try{i.setItem(l,JSON.stringify(a))}catch(h){console.error(h)}}function qe({layout:e,panelConstraints:n}){const t=[...e],r=t.reduce((o,l)=>o+l,0);if(t.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${t.map(o=>`${o}%`).join(", ")}`);if(!W(r,100)&&t.length>0)for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=100/r*l;t[o]=s}let i=0;for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=le({panelConstraints:n,panelIndex:o,size:l});l!=s&&(i+=l-s,t[o]=s)}if(!W(i,0))for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=l+i,a=le({panelConstraints:n,panelIndex:o,size:s});if(l!==a&&(i-=a-l,t[o]=a,W(i,0)))break}return t}const Kn=100,me={getItem:e=>(Oe(me),me.getItem(e)),setItem:(e,n)=>{Oe(me),me.setItem(e,n)}},Xe={};function pn({autoSaveId:e=null,children:n,className:t="",direction:r,forwardedRef:i,id:o=null,onLayout:l=null,keyboardResizeBy:s=null,storage:a=me,style:h,tagName:w="div",...p}){const u=Ne(o),v=f.useRef(null),[z,C]=f.useState(null),[E,b]=f.useState([]),L=kn(),M=f.useRef({}),$=f.useRef(new Map),O=f.useRef(0),R=f.useRef({autoSaveId:e,direction:r,dragState:z,id:u,keyboardResizeBy:s,onLayout:l,storage:a}),P=f.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});f.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),f.useImperativeHandle(i,()=>({getId:()=>R.current.id,getLayout:()=>{const{layout:c}=P.current;return c},setLayout:c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current,d=qe({layout:c,panelConstraints:g.map(y=>y.constraints)});Ve(S,d)||(b(d),P.current.layout=d,m&&m(d),oe(g,d,M.current))}}),[]),ne(()=>{R.current.autoSaveId=e,R.current.direction=r,R.current.dragState=z,R.current.id=u,R.current.onLayout=l,R.current.storage=a}),$n({committedValuesRef:R,eagerValuesRef:P,groupId:u,layout:E,panelDataArray:P.current.panelDataArray,setLayout:b,panelGroupElement:v.current}),f.useEffect(()=>{const{panelDataArray:c}=P.current;if(e){if(E.length===0||E.length!==c.length)return;let m=Xe[e];m==null&&(m=Tn(Wn,Kn),Xe[e]=m);const S=[...c],g=new Map($.current);m(e,S,g,E,a)}},[e,E,a]),f.useEffect(()=>{});const K=f.useCallback(c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current;if(c.constraints.collapsible){const d=g.map(q=>q.constraints),{collapsedSize:y=0,panelSize:I,pivotIndices:H}=Q(g,c,S);if(x(I!=null,`Panel size not found for panel "${c.id}"`),!j(I,y)){$.current.set(c.id,I);const X=ie(g,c)===g.length-1?I-y:y-I,A=ge({delta:X,initialLayout:S,panelConstraints:d,pivotIndices:H,prevLayout:S,trigger:"imperative-api"});ve(S,A)||(b(A),P.current.layout=A,m&&m(A),oe(g,A,M.current))}}},[]),J=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current;if(c.constraints.collapsible){const y=d.map(U=>U.constraints),{collapsedSize:I=0,panelSize:H=0,minSize:q=0,pivotIndices:X}=Q(d,c,g),A=m??q;if(j(H,I)){const U=$.current.get(c.id),de=U!=null&&U>=A?U:A,Re=ie(d,c)===d.length-1?H-de:de-H,T=ge({delta:Re,initialLayout:g,panelConstraints:y,pivotIndices:X,prevLayout:g,trigger:"imperative-api"});ve(g,T)||(b(T),P.current.layout=T,S&&S(T),oe(d,T,M.current))}}},[]),F=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{panelSize:g}=Q(S,c,m);return x(g!=null,`Panel size not found for panel "${c.id}"`),g},[]),G=f.useCallback((c,m)=>{const{panelDataArray:S}=P.current,g=ie(S,c);return Bn({defaultSize:m,dragState:z,layout:E,panelData:S,panelIndex:g})},[z,E]),D=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),d===!0&&j(y,g)},[]),Z=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),!d||te(y,g)>0},[]),_=f.useCallback(c=>{const{panelDataArray:m}=P.current;m.push(c),m.sort((S,g)=>{const d=S.order,y=g.order;return d==null&&y==null?0:d==null?-1:y==null?1:d-y}),P.current.panelDataArrayChanged=!0,L()},[L]);ne(()=>{if(P.current.panelDataArrayChanged){P.current.panelDataArrayChanged=!1;const{autoSaveId:c,onLayout:m,storage:S}=R.current,{layout:g,panelDataArray:d}=P.current;let y=null;if(c){const H=Fn(c,d,S);H&&($.current=new Map(Object.entries(H.expandToSizes)),y=H.layout)}y==null&&(y=Gn({panelDataArray:d}));const I=qe({layout:y,panelConstraints:d.map(H=>H.constraints)});Ve(g,I)||(b(I),P.current.layout=I,m&&m(I),oe(d,I,M.current))}}),ne(()=>{const c=P.current;return()=>{c.layout=[]}},[]);const N=f.useCallback(c=>{let m=!1;const S=v.current;return S&&window.getComputedStyle(S,null).getPropertyValue("direction")==="rtl"&&(m=!0),function(d){d.preventDefault();const y=v.current;if(!y)return()=>null;const{direction:I,dragState:H,id:q,keyboardResizeBy:X,onLayout:A}=R.current,{layout:U,panelDataArray:de}=P.current,{initialLayout:xe}=H??{},Re=sn(q,c,y);let T=_n(d,c,I,H,X,y);const Be=I==="horizontal";Be&&m&&(T=-T);const gn=de.map(mn=>mn.constraints),pe=ge({delta:T,initialLayout:xe??U,panelConstraints:gn,pivotIndices:Re,prevLayout:U,trigger:je(d)?"keyboard":"mouse-or-touch"}),Te=!ve(U,pe);(Ye(d)||Ze(d))&&O.current!=T&&(O.current=T,!Te&&T!==0?Be?De(c,T<0?en:nn):De(c,T<0?tn:rn):De(c,0)),Te&&(b(pe),P.current.layout=pe,A&&A(pe),oe(de,pe,M.current))}},[]),B=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current,y=d.map(U=>U.constraints),{panelSize:I,pivotIndices:H}=Q(d,c,g);x(I!=null,`Panel size not found for panel "${c.id}"`);const X=ie(d,c)===d.length-1?I-m:m-I,A=ge({delta:X,initialLayout:g,panelConstraints:y,pivotIndices:H,prevLayout:g,trigger:"imperative-api"});ve(g,A)||(b(A),P.current.layout=A,S&&S(A),oe(d,A,M.current))},[]),ae=f.useCallback((c,m)=>{const{layout:S,panelDataArray:g}=P.current,{collapsedSize:d=0,collapsible:y}=m,{collapsedSize:I=0,collapsible:H,maxSize:q=100,minSize:X=0}=c.constraints,{panelSize:A}=Q(g,c,S);A!=null&&(y&&H&&j(A,d)?j(d,I)||B(c,I):A<X?B(c,X):A>q&&B(c,q))},[B]),ue=f.useCallback((c,m)=>{const{direction:S}=R.current,{layout:g}=P.current;if(!v.current)return;const d=Ie(c,v.current);x(d,`Drag handle element not found for id "${c}"`);const y=un(S,m);C({dragHandleId:c,dragHandleRect:d.getBoundingClientRect(),initialCursorPosition:y,initialLayout:g})},[]),ce=f.useCallback(()=>{C(null)},[]),ye=f.useCallback(c=>{const{panelDataArray:m}=P.current,S=ie(m,c);S>=0&&(m.splice(S,1),delete M.current[c.id],P.current.panelDataArrayChanged=!0,L())},[L]),re=f.useMemo(()=>({collapsePanel:K,direction:r,dragState:z,expandPanel:J,getPanelSize:F,getPanelStyle:G,groupId:u,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:ae,registerPanel:_,registerResizeHandle:N,resizePanel:B,startDragging:ue,stopDragging:ce,unregisterPanel:ye,panelGroupElement:v.current}),[K,z,r,J,F,G,u,D,Z,ae,_,N,B,ue,ce,ye]),fe={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return f.createElement(we.Provider,{value:re},f.createElement(w,{...p,children:n,className:t,id:o,ref:v,style:{...fe,...h},[k.group]:"",[k.groupDirection]:r,[k.groupId]:u}))}const Un=f.forwardRef((e,n)=>f.createElement(pn,{...e,forwardedRef:n}));pn.displayName="PanelGroup";Un.displayName="forwardRef(PanelGroup)";function ie(e,n){return e.findIndex(t=>t===n||t.id===n.id)}function Q(e,n,t){const r=ie(e,n),o=r===e.length-1?[r-1,r]:[r,r+1],l=t[r];return{...n.constraints,panelSize:l,pivotIndices:o}}function Vn({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:r}){f.useEffect(()=>{if(e||t==null||r==null)return;const i=Ie(n,r);if(i==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),t(l);break}case"F6":{l.preventDefault();const s=i.getAttribute(k.groupId);x(s,`No group element found for id "${s}"`);const a=ze(s,r),h=ln(s,n,r);x(h!==null,`No resize element found for id "${n}"`);const w=l.shiftKey?h>0?h-1:a.length-1:h+1<a.length?h+1:0;a[w].focus();break}}};return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}},[r,e,n,t])}function On({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:r,id:i,onBlur:o,onClick:l,onDragging:s,onFocus:a,onPointerDown:h,onPointerUp:w,style:p={},tabIndex:u=0,tagName:v="div",...z}){var C,E;const b=f.useRef(null),L=f.useRef({onClick:l,onDragging:s,onPointerDown:h,onPointerUp:w});f.useEffect(()=>{L.current.onClick=l,L.current.onDragging=s,L.current.onPointerDown=h,L.current.onPointerUp=w});const M=f.useContext(we);if(M===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:$,groupId:O,registerResizeHandle:R,startDragging:P,stopDragging:K,panelGroupElement:J}=M,F=Ne(i),[G,D]=f.useState("inactive"),[Z,_]=f.useState(!1),[N,B]=f.useState(null),ae=f.useRef({state:G});ne(()=>{ae.current.state=G}),f.useEffect(()=>{if(t)B(null);else{const re=R(F);B(()=>re)}},[t,F,R]);const ue=(C=r==null?void 0:r.coarse)!==null&&C!==void 0?C:15,ce=(E=r==null?void 0:r.fine)!==null&&E!==void 0?E:5;f.useEffect(()=>{if(t||N==null)return;const re=b.current;x(re,"Element ref not attached");let fe=!1;return Ln(F,re,$,{coarse:ue,fine:ce},(m,S,g)=>{if(!S){D("inactive");return}switch(m){case"down":{D("drag"),fe=!1,x(g,'Expected event to be defined for "down" action'),P(F,g);const{onDragging:d,onPointerDown:y}=L.current;d==null||d(!0),y==null||y();break}case"move":{const{state:d}=ae.current;fe=!0,d!=="drag"&&D("hover"),x(g,'Expected event to be defined for "move" action'),N(g);break}case"up":{D("hover"),K();const{onClick:d,onDragging:y,onPointerUp:I}=L.current;y==null||y(!1),I==null||I(),fe||d==null||d();break}}})},[ue,$,t,ce,R,F,N,P,K]),Vn({disabled:t,handleId:F,resizeHandler:N,panelGroupElement:J});const ye={touchAction:"none",userSelect:"none"};return f.createElement(v,{...z,children:e,className:n,id:i,onBlur:()=>{_(!1),o==null||o()},onFocus:()=>{_(!0),a==null||a()},ref:b,role:"separator",style:{...ye,...p},tabIndex:u,[k.groupDirection]:$,[k.groupId]:O,[k.resizeHandle]:"",[k.resizeHandleActive]:G==="drag"?"pointer":Z?"keyboard":void 0,[k.resizeHandleEnabled]:!t,[k.resizeHandleId]:F,[k.resizeHandleState]:G})}On.displayName="PanelResizeHandle";export{Un as P,xn as a,On as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{am as s,ai as r,F as l}from"./index-RB5ffy32.js";const o=[{code:"en",label:"English",short:"EN"},{code:"zh",label:"中文",short:"中"},{code:"ja",label:"日本語",short:"JA"},{code:"ko",label:"한국어",short:"KO"},{code:"fr",label:"Français",short:"FR"},{code:"de",label:"Deutsch",short:"DE"},{code:"es",label:"Español",short:"ES"},{code:"ru",label:"Русский",short:"RU"},{code:"pt",label:"Português",short:"PT"},{code:"it",label:"Italiano",short:"IT"}],n="dsc.stt.lang",c=new Set(o.map(t=>t.code));function a(t){const e=(t??"").trim().toLowerCase();return c.has(e)?e:null}function u(t){return a(t)??"en"}function g(t){return o.find(e=>e.code===t)??{code:"en",label:"English",short:"EN"}}function i(t){return(t??"").toLowerCase().startsWith("zh")?"zh":"en"}function E(){try{const e=a(localStorage.getItem(n));if(e)return e}catch{}let t=s;try{t=r(l.getState().language)}catch{}return i(t)}function f(t){try{localStorage.setItem(n,t)}catch{}}const d="profile-changed";function S(){typeof window>"u"||window.dispatchEvent(new CustomEvent(d))}export{d as P,o as S,S as a,u as n,f as p,E as r,g as s};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/web/dist/index.html
CHANGED
|
@@ -3,7 +3,16 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
-
|
|
6
|
+
<!-- Inter Latin 子集预载(spec §4.1/§9):font-display: swap 的补位,正文首帧即得字形 -->
|
|
7
|
+
<link rel="preload" href="/fonts/inter-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin />
|
|
8
|
+
<link rel="preload" href="/fonts/inter-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin />
|
|
9
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
10
|
+
<link rel="apple-touch-icon" href="/icons/icon-180.png" />
|
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content" />
|
|
12
|
+
<meta name="mobile-web-app-capable" content="yes" />
|
|
13
|
+
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
14
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
15
|
+
<meta name="apple-mobile-web-app-title" content="DeepSeekCode" />
|
|
7
16
|
<meta name="description" content="DeepSeekCode - AI coding assistant for code generation, debugging, refactoring, and automation" />
|
|
8
17
|
<meta name="keywords" content="AI, coding, code generation, assistant, DeepSeekCode" />
|
|
9
18
|
<meta property="og:title" content="DeepSeekCode Web" />
|
|
@@ -12,13 +21,34 @@
|
|
|
12
21
|
<meta name="theme-color" content="#0d1117" />
|
|
13
22
|
<meta name="color-scheme" content="dark light" />
|
|
14
23
|
<title>DeepSeekCode Web</title>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
<!-- 首屏主题引导:在 JS bundle 执行前,按已持久化的偏好设置 html.dark/.light,消除暗/亮首帧闪烁(FOUC)。
|
|
25
|
+
存储键 'deepseekcode-settings-storage' 与 stores/settingsStore.ts、hooks/useThemeVars.ts 保持一致。 -->
|
|
26
|
+
<script>
|
|
27
|
+
(function () {
|
|
28
|
+
try {
|
|
29
|
+
var mode = 'light';
|
|
30
|
+
var raw = localStorage.getItem('deepseekcode-settings-storage');
|
|
31
|
+
if (raw) {
|
|
32
|
+
var state = (JSON.parse(raw) || {}).state;
|
|
33
|
+
var t = state && state.theme;
|
|
34
|
+
if (t === 'dark' || t === 'light' || t === 'auto') mode = t;
|
|
35
|
+
}
|
|
36
|
+
if (mode === 'auto') {
|
|
37
|
+
mode = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
38
|
+
}
|
|
39
|
+
var root = document.documentElement;
|
|
40
|
+
root.classList.toggle('dark', mode === 'dark');
|
|
41
|
+
root.classList.toggle('light', mode === 'light');
|
|
42
|
+
} catch (e) {}
|
|
43
|
+
})();
|
|
44
|
+
</script>
|
|
45
|
+
<script type="module" crossorigin src="/assets/index-RB5ffy32.js"></script>
|
|
46
|
+
<link rel="modulepreload" crossorigin href="/assets/icons-BxNxyk-c.js">
|
|
47
|
+
<link rel="modulepreload" crossorigin href="/assets/markdown-B2L4Mq-x.js">
|
|
48
|
+
<link rel="modulepreload" crossorigin href="/assets/react-vendor-B2V_5iSS.js">
|
|
49
|
+
<link rel="modulepreload" crossorigin href="/assets/state-0T92JV0u.js">
|
|
50
|
+
<link rel="modulepreload" crossorigin href="/assets/panels-P_I7Q72_.js">
|
|
51
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DaiVo1RY.css">
|
|
22
52
|
</head>
|
|
23
53
|
<body>
|
|
24
54
|
<div id="root"></div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "/",
|
|
3
|
+
"name": "DeepSeekCode",
|
|
4
|
+
"short_name": "DeepSeekCode",
|
|
5
|
+
"description": "AI coding workspace for local agent workflows",
|
|
6
|
+
"start_url": "/",
|
|
7
|
+
"scope": "/",
|
|
8
|
+
"display": "standalone",
|
|
9
|
+
"background_color": "#0d1117",
|
|
10
|
+
"theme_color": "#0d1117",
|
|
11
|
+
"icons": [
|
|
12
|
+
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
|
|
13
|
+
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" },
|
|
14
|
+
{ "src": "/icons/icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./markdown-DEtuzEyz.js";import{a as r,au as j,h as N,L as v,be as w,b7 as S,b3 as k,aU as C,a9 as I,l as z}from"./icons-f1hlMKvD.js";import{u as g,a as y,a9 as A,aa as E}from"./index-u1vYyqna.js";import"./react-vendor-ClBKp0t-.js";import"./state-xD58vmym.js";import"./panels-Bn-2wCur.js";const R={idle:"bg-green-500",running:"bg-yellow-500 animate-pulse",paused:"bg-gray-500",error:"bg-red-500"};function q(d){return R[d]??"bg-gray-500"}const O=r.memo(function({onOpenSession:s,onNavigate:m}){const{t:a}=g(),[l,u]=r.useState([]),[n,c]=r.useState(!0),[p,h]=r.useState(null),[x,f]=r.useState(null),o=r.useCallback(async()=>{try{const t=await y.assistants.list();t.success&&Array.isArray(t.data)?(u(t.data),h(null)):h(t.error||a("assistants.loadFailed"))}catch(t){h(t instanceof Error?t.message:String(t))}finally{c(!1)}},[a]);r.useEffect(()=>{o();const t=window.setInterval(()=>{o()},8e3);return()=>window.clearInterval(t)},[o]);const b=r.useCallback(async(t,i)=>{(await y.assistants.update(t,i)).success&&o()},[o]);return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-dark-border px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{size:16,className:"text-accent-blue","aria-hidden":"true"}),e.jsx("h2",{className:"text-sm font-semibold text-dark-text",children:a("assistants.title")}),!n&&e.jsx("span",{className:"rounded-full bg-dark-hover px-1.5 py-0.5 text-[10px] text-dark-muted",children:l.length})]}),e.jsxs("button",{type:"button",onClick:()=>void o(),className:"flex items-center gap-1 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-hover hover:text-dark-text",title:a("common.refresh"),children:[e.jsx(N,{size:12,className:n?"animate-spin":"","aria-hidden":"true"}),a("common.refresh")]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:n&&l.length===0?e.jsxs("div",{className:"flex items-center justify-center py-12 text-xs text-dark-muted",children:[e.jsx(v,{size:14,className:"mr-1.5 animate-spin","aria-hidden":"true"}),a("assistants.loading")]}):p&&l.length===0?e.jsx("div",{className:"py-8 text-center text-xs text-red-400",children:p}):l.length===0?e.jsxs("div",{className:"py-10 text-center text-xs text-dark-muted",children:[e.jsx(j,{size:24,className:"mx-auto mb-2 text-dark-muted","aria-hidden":"true"}),e.jsx("p",{children:a("assistants.empty")}),e.jsx("p",{className:"mt-1 text-[11px]",children:a("assistants.emptyHint")}),e.jsx("button",{type:"button",onClick:()=>m("channels"),className:"mt-3 rounded border border-dark-border px-2.5 py-1 text-[11px] text-dark-text hover:bg-dark-hover",children:a("assistants.goChannels")})]}):e.jsx("div",{className:"flex flex-col gap-2",children:l.map(t=>e.jsx(T,{assistant:t,expanded:x===t.sessionId,onToggleExpand:()=>f(x===t.sessionId?null:t.sessionId),onOpen:()=>s(t.sessionId,t.title),onUpdate:i=>void b(t.sessionId,i)},t.sessionId))})})]})}),T=r.memo(function({assistant:s,expanded:m,onToggleExpand:a,onOpen:l,onUpdate:u}){const{t:n}=g(),c=s.channel.peerKind==="group";return e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("span",{className:"text-base leading-none","aria-hidden":"true",children:A(s.channel.type)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-dark-text",title:s.title,children:s.title}),e.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${q(s.status)}`,title:n(`assistants.status.${s.status}`,{defaultValue:s.status})}),c?e.jsx(w,{size:11,className:"shrink-0 text-dark-muted","aria-label":n("assistants.group")}):e.jsx(S,{size:11,className:"shrink-0 text-dark-muted","aria-label":n("assistants.dm")})]}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-dark-muted",children:[e.jsx("span",{className:"shrink-0",children:E(s.channel.type)}),e.jsx("span",{className:"min-w-0 flex-1 truncate",title:s.channel.peerId,children:s.channel.peerId}),s.stats.unread>0&&e.jsx("span",{className:"shrink-0 rounded-full bg-red-500/80 px-1.5 text-[9px] font-medium text-white",children:s.stats.unread})]}),s.preview&&e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-snug text-dark-muted",title:s.preview,children:s.preview})]}),e.jsx(U,{mode:s.mode}),s.trust.level==="owner"?e.jsx(k,{size:12,className:"shrink-0 text-green-500","aria-label":n("assistants.trust.owner")}):s.trust.level==="public"?e.jsx(C,{size:12,className:"shrink-0 text-yellow-600","aria-label":n("assistants.trust.public")}):e.jsx(k,{size:12,className:"shrink-0 text-accent-blue","aria-label":n("assistants.trust.team")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-t border-dark-border px-3 py-1.5",children:[e.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-accent-blue hover:bg-dark-hover",children:[e.jsx(I,{size:11,"aria-hidden":"true"}),n("assistants.openSession")]}),e.jsx("button",{type:"button",onClick:a,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-dark-muted hover:bg-dark-hover hover:text-dark-text",children:n("assistants.policy")}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-[10px] text-dark-muted",children:n("assistants.groupPolicy",{mention:String(c?s.policy.mentionRequired:!1)})})]}),m&&e.jsx(M,{assistant:s,isGroup:c,onUpdate:u})]})});function U({mode:d}){const{t:s}=g();return e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[9px] font-medium ${d==="delegate"?"bg-accent-blue/15 text-accent-blue":"bg-dark-hover text-dark-muted"}`,children:s(`assistants.mode.${d}`)})}function M({assistant:d,isGroup:s,onUpdate:m}){const{t:a}=g(),[l,u]=r.useState(d.mode),[n,c]=r.useState(d.policy.mentionRequired),[p,h]=r.useState(String(d.policy.cooldownSeconds)),[x,f]=r.useState((d.policy.keywords??[]).join(", ")),[o,b]=r.useState(!1),t=()=>{b(!0),m({mode:l,policy:{mentionRequired:s?n:!1,cooldownSeconds:Math.max(0,Number(p)||0),...x.trim()?{keywords:x.split(/[,,]/).map(i=>i.trim()).filter(Boolean)}:{}}}),window.setTimeout(()=>b(!1),600)};return e.jsxs("div",{className:"border-t border-dark-border px-3 py-2.5 text-[11px]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-dark-muted",children:[a("assistants.mode.label"),e.jsxs("select",{value:l,onChange:i=>u(i.target.value),className:"rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text",children:[e.jsx("option",{value:"delegate",children:a("assistants.mode.delegate")}),e.jsx("option",{value:"direct",children:a("assistants.mode.direct")})]})]}),s&&e.jsxs("label",{className:"flex items-center gap-1.5 text-dark-muted",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:i=>c(i.target.checked)}),a("assistants.mentionRequired")]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-dark-muted",children:[a("assistants.cooldown"),e.jsx("input",{type:"number",min:0,value:p,onChange:i=>h(i.target.value),className:"w-14 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text"}),"s"]})]}),e.jsxs("label",{className:"mt-2 flex items-center gap-1.5 text-dark-muted",children:[a("assistants.keywords"),e.jsx("input",{type:"text",value:x,placeholder:a("assistants.keywordsPlaceholder")??"",onChange:i=>f(i.target.value),className:"min-w-0 flex-1 rounded border border-dark-border bg-dark-surface px-1.5 py-0.5 text-dark-text"})]}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs("button",{type:"button",onClick:t,disabled:o,className:"flex items-center gap-1 rounded bg-accent-blue px-2.5 py-1 text-[11px] font-medium text-white disabled:opacity-60",children:[o?e.jsx(v,{size:11,className:"animate-spin","aria-hidden":"true"}):e.jsx(z,{size:11,"aria-hidden":"true"}),a("common.save")]})})]})}export{O as AssistantsView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./markdown-DEtuzEyz.js";import{a as n,ay as v,h as $,aa as D,A as I,bp as L,f as O,aE as J,b2 as U,X as B}from"./icons-f1hlMKvD.js";import{u as M,ab as V}from"./index-u1vYyqna.js";import"./react-vendor-ClBKp0t-.js";import"./state-xD58vmym.js";import"./panels-Bn-2wCur.js";function Q(){const{t:a}=M(),{automations:r,runsByAutomation:d,fetchAutomations:o,createAutomation:N,deleteAutomation:y,toggleAutomation:w,runAutomation:C,fetchRuns:A,error:l}=V(),[S,x]=n.useState(!1),[m,P]=n.useState(null),[u,p]=n.useState(""),[h,b]=n.useState(""),[i,g]=n.useState("0 9 * * *"),[f,j]=n.useState("");n.useEffect(()=>{o()},[o]);const z=async t=>{const s=f.trim();if(!s)return;const[c,...T]=s.split(/\s+/),k=T.join(" ");c&&k&&(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tool:c,target:k})})).ok&&(j(""),await o())},E=async(t,s)=>{(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({entry:s})})).ok&&await o()},R=async t=>{const s=m===t?null:t;P(s),s&&await A(t)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(v,{size:20,className:"text-accent-blue"}),a("automation.title"),e.jsxs("span",{className:"text-xs text-dark-muted font-normal",children:["(",r.length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void o(),className:"p-2 rounded-lg hover:bg-dark-hover text-dark-muted",title:a("automation.refresh"),children:e.jsx($,{size:16})}),e.jsxs("button",{onClick:()=>x(t=>!t),className:"flex items-center gap-1 px-3 py-1.5 rounded-lg bg-accent-blue/20 text-accent-blue hover:bg-accent-blue/30 text-sm font-medium",children:[e.jsx(D,{size:16})," ",a("automation.new")]})]})]}),l&&e.jsxs("div",{className:"mb-3 p-3 rounded-lg bg-accent-red/10 text-accent-red text-sm flex items-center gap-2",children:[e.jsx(I,{size:16})," ",l]}),S&&e.jsxs("div",{className:"mb-4 rounded-lg border border-dark-border bg-dark-surface p-4 space-y-3",children:[e.jsx("input",{value:u,onChange:t=>p(t.target.value),placeholder:a("automation.namePlaceholder"),className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),e.jsx("textarea",{value:h,onChange:t=>b(t.target.value),placeholder:a("automation.instructionsPlaceholder"),rows:3,className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:i,onChange:t=>g(t.target.value),placeholder:a("automation.cronPlaceholder"),className:"flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),e.jsx("button",{onClick:async()=>{await N({name:u,instructions:h,schedule:{kind:"cron",cron:i}})&&(p(""),b(""),x(!1))},className:"px-4 py-2 rounded-lg bg-accent-blue text-white text-sm font-medium hover:bg-accent-blue/80",children:a("automation.create")})]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:[["0 9 * * *",a("automation.cronDaily9")],["0 9 * * 1-5",a("automation.cronWeekday9")],["*/30 * * * *",a("automation.cronEvery30Min")]].map(([t,s])=>e.jsxs("button",{onClick:()=>g(t),className:`px-2 py-1 rounded text-xs ${i===t?"bg-accent-blue/20 text-accent-blue":"bg-dark-hover text-dark-muted hover:text-dark-text"}`,children:[s," (",t,")"]},t))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2",children:[r.length===0&&e.jsx("p",{className:"text-dark-muted text-center py-8",children:a("automation.empty")}),r.map(t=>e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface",children:[e.jsxs("div",{className:"flex items-center justify-between p-3",children:[e.jsxs("button",{onClick:()=>void R(t.id),className:"flex items-center gap-2 min-w-0 text-left",children:[e.jsx(v,{size:16,className:"text-accent-blue shrink-0"}),e.jsx("span",{className:"font-medium text-sm truncate",children:t.name}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded shrink-0 ${t.status==="enabled"?"bg-accent-green/20 text-accent-green":"bg-dark-hover text-dark-muted"}`,children:t.status})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("span",{className:"text-xs text-dark-muted hidden lg:inline mr-1",children:[t.schedule.kind==="cron"?t.schedule.cron:t.schedule.fireAt,t.nextRunAt?` · ${new Date(t.nextRunAt).toLocaleString()}`:""]}),e.jsx("button",{onClick:()=>void w(t.id,t.status!=="enabled"),className:"p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted",title:t.status==="enabled"?a("automation.disable"):a("automation.enable"),children:e.jsx(L,{size:15})}),e.jsx("button",{onClick:()=>void C(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-green",title:a("automation.runNow"),children:e.jsx(O,{size:15})}),e.jsx("button",{onClick:()=>void y(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-red",title:a("automation.delete"),children:e.jsx(J,{size:15})})]})]}),m===t.id&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-dark-border pt-3",children:[e.jsx("p",{className:"text-xs text-dark-muted whitespace-pre-wrap",children:t.instructions}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-dark-muted mb-1 flex items-center gap-1",children:[e.jsx(U,{size:12})," ",a("automation.historyTitle")]}),(d[t.id]||[]).length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:a("automation.noRuns")}),(d[t.id]||[]).slice(0,10).map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-xs py-1",children:[e.jsx("span",{className:`px-1.5 py-0.5 rounded ${s.status==="ok"?"bg-accent-green/20 text-accent-green":s.status==="error"?"bg-accent-red/20 text-accent-red":"bg-accent-yellow/20 text-accent-yellow"}`,children:s.status}),e.jsx("span",{className:"text-dark-muted",children:new Date(s.startedAt).toLocaleString()}),e.jsxs("span",{className:"text-dark-muted truncate flex-1",children:["#",s.id.slice(0,8)," · ",s.trigger]})]},s.id))]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-muted mb-1",children:a("automation.permissionsTitle")}),t.permissions.length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:a("automation.permissionsEmpty")}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-1",children:t.permissions.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-accent-blue/10 text-accent-blue text-xs",children:[s,e.jsx("button",{onClick:()=>void E(t.id,s),className:"hover:text-accent-red",children:e.jsx(B,{size:12})})]},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:f,onChange:s=>j(s.target.value),placeholder:a("automation.permissionPlaceholder"),className:"flex-1 px-2 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-xs focus:outline-none focus:border-accent-blue"}),e.jsx("button",{onClick:()=>void z(t.id),className:"px-3 py-1.5 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-xs",children:a("automation.add")})]})]})]})]},t.id))]})]})}export{Q as AutomationView};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{j as l}from"./markdown-DEtuzEyz.js";import{a as s,W as K,ar as Ce,aQ as Me,h as Ne,a_ as Te,af as ke,Z as le,l as Pe,a2 as ue,X as Ee,d as Re,ad as Fe,a$ as Le}from"./icons-f1hlMKvD.js";import{u as ze,a as B,t as F}from"./index-u1vYyqna.js";import"./react-vendor-ClBKp0t-.js";import"./state-xD58vmym.js";import"./panels-Bn-2wCur.js";function de(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Ae(e){if(Array.isArray(e))return e}function $e(e,t,r){return(t=We(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function De(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,u,p,v=[],g=!0,j=!1;try{if(u=(r=r.call(e)).next,t!==0)for(;!(g=(n=u.call(r)).done)&&(v.push(n.value),v.length!==t);g=!0);}catch(N){j=!0,o=N}finally{try{if(!g&&r.return!=null&&(p=r.return(),Object(p)!==p))return}finally{if(j)throw o}}return v}}function Ie(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function pe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?fe(Object(r),!0).forEach(function(n){$e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ve(e,t){if(e==null)return{};var r,n,o=Ue(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n<u.length;n++)r=u[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function Ue(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function He(e,t){return Ae(e)||De(e,t)||Be(e,t)||Ie()}function qe(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function We(e){var t=qe(e,"string");return typeof t=="symbol"?t:t+""}function Be(e,t){if(e){if(typeof e=="string")return de(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?de(e,t):void 0}}function Qe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function he(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function me(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?he(Object(r),!0).forEach(function(n){Qe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):he(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ke(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,u){return u(o)},n)}}function G(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),u=0;u<n;u++)o[u]=arguments[u];return o.length>=e.length?e.apply(this,o):function(){for(var p=arguments.length,v=new Array(p),g=0;g<p;g++)v[g]=arguments[g];return t.apply(r,[].concat(o,v))}}}function ne(e){return{}.toString.call(e).includes("Object")}function _e(e){return!Object.keys(e).length}function X(e){return typeof e=="function"}function Ge(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Je(e,t){return ne(t)||A("changeType"),Object.keys(t).some(function(r){return!Ge(e,r)})&&A("changeField"),t}function Xe(e){X(e)||A("selectorType")}function Ye(e){X(e)||ne(e)||A("handlerType"),ne(e)&&Object.values(e).some(function(t){return!X(t)})&&A("handlersType")}function Ze(e){e||A("initialIsRequired"),ne(e)||A("initialType"),_e(e)&&A("initialContent")}function et(e,t){throw new Error(e[t]||e.default)}var tt={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},A=G(et)(tt),te={changes:Je,selector:Xe,handler:Ye,initial:Ze};function rt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};te.initial(e),te.handler(t);var r={current:e},n=G(it)(r,t),o=G(at)(r),u=G(te.changes)(e),p=G(nt)(r);function v(){var j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(N){return N};return te.selector(j),j(r.current)}function g(j){Ke(n,o,u,p)(j)}return[v,g]}function nt(e,t){return X(t)?t(e.current):t}function at(e,t){return e.current=me(me({},e.current),t),t}function it(e,t,r){return X(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var ot={create:rt},st={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function ct(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),u=0;u<n;u++)o[u]=arguments[u];return o.length>=e.length?e.apply(this,o):function(){for(var p=arguments.length,v=new Array(p),g=0;g<p;g++)v[g]=arguments[g];return t.apply(r,[].concat(o,v))}}}function lt(e){return{}.toString.call(e).includes("Object")}function ut(e){return e||ge("configIsRequired"),lt(e)||ge("configType"),e.urls?(dt(),{paths:{vs:e.urls.monacoBase}}):e}function dt(){console.warn(ve.deprecation)}function ft(e,t){throw new Error(e[t]||e.default)}var ve={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
3
|
-
You are using deprecated way of configuration.
|
|
4
|
-
|
|
5
|
-
Instead of using
|
|
6
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
7
|
-
use
|
|
8
|
-
monaco.config({ paths: { vs: '...' } })
|
|
9
|
-
|
|
10
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
11
|
-
`},ge=ct(ft)(ve),pt={config:ut},ht=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(u,p){return p(u)},o)}};function be(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],be(e[r],t[r]))}),pe(pe({},e),t)}var mt={type:"cancelation",msg:"operation is manually canceled"};function oe(e){var t=!1,r=new Promise(function(n,o){e.then(function(u){return t?o(mt):n(u)}),e.catch(o)});return r.cancel=function(){return t=!0},r}var gt=["monaco"],vt=ot.create({config:st,isInitialized:!1,resolve:null,reject:null,monaco:null}),ye=He(vt,2),Y=ye[0],ae=ye[1];function bt(e){var t=pt.config(e),r=t.monaco,n=Ve(t,gt);ae(function(o){return{config:be(o.config,n),monaco:r}})}function yt(){var e=Y(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(ae({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),oe(se);if(window.monaco&&window.monaco.editor)return xe(window.monaco),e.resolve(window.monaco),oe(se);ht(xt,wt)(Ot)}return oe(se)}function xt(e){return document.body.appendChild(e)}function jt(e){var t=document.createElement("script");return e&&(t.src=e),t}function wt(e){var t=Y(function(n){var o=n.config,u=n.reject;return{config:o,reject:u}}),r=jt("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function Ot(){var e=Y(function(r){var n=r.config,o=r.resolve,u=r.reject;return{config:n,resolve:o,reject:u}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var n=r.m||r;xe(n),e.resolve(n)},function(r){e.reject(r)})}function xe(e){Y().monaco||ae({monaco:e})}function St(){return Y(function(e){var t=e.monaco;return t})}var se=new Promise(function(e,t){return ae({resolve:e,reject:t})}),je={config:bt,init:yt,__getMonacoInstance:St},Ct={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ce=Ct,Mt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Nt=Mt;function Tt({children:e}){return K.createElement("div",{style:Nt.container},e)}var kt=Tt,Pt=kt;function Et({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:u,wrapperProps:p}){return K.createElement("section",{style:{...ce.wrapper,width:e,height:t},...p},!r&&K.createElement(Pt,null,n),K.createElement("div",{ref:o,style:{...ce.fullWidth,...!r&&ce.hide},className:u}))}var Rt=Et,we=s.memo(Rt);function Ft(e){s.useEffect(e,[])}var Oe=Ft;function Lt(e,t,r=!0){let n=s.useRef(!0);s.useEffect(n.current||!r?()=>{n.current=!1}:e,t)}var M=Lt;function J(){}function Q(e,t,r,n){return zt(e,n)||At(e,t,r,n)}function zt(e,t){return e.editor.getModel(Se(e,t))}function At(e,t,r,n){return e.editor.createModel(t,r,n?Se(e,n):void 0)}function Se(e,t){return e.Uri.parse(t)}function $t({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:u,modifiedModelPath:p,keepCurrentOriginalModel:v=!1,keepCurrentModifiedModel:g=!1,theme:j="light",loading:N="Loading...",options:C={},height:_="100%",width:I="100%",className:V,wrapperProps:U={},beforeMount:H=J,onMount:q=J}){let[w,T]=s.useState(!1),[E,y]=s.useState(!0),x=s.useRef(null),b=s.useRef(null),L=s.useRef(null),O=s.useRef(q),h=s.useRef(H),R=s.useRef(!1);Oe(()=>{let d=je.init();return d.then(m=>(b.current=m)&&y(!1)).catch(m=>(m==null?void 0:m.type)!=="cancelation"&&console.error("Monaco initialization: error:",m)),()=>x.current?D():d.cancel()}),M(()=>{if(x.current&&b.current){let d=x.current.getOriginalEditor(),m=Q(b.current,e||"",n||r||"text",u||"");m!==d.getModel()&&d.setModel(m)}},[u],w),M(()=>{if(x.current&&b.current){let d=x.current.getModifiedEditor(),m=Q(b.current,t||"",o||r||"text",p||"");m!==d.getModel()&&d.setModel(m)}},[p],w),M(()=>{let d=x.current.getModifiedEditor();d.getOption(b.current.editor.EditorOption.readOnly)?d.setValue(t||""):t!==d.getValue()&&(d.executeEdits("",[{range:d.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),d.pushUndoStop())},[t],w),M(()=>{var d,m;(m=(d=x.current)==null?void 0:d.getModel())==null||m.original.setValue(e||"")},[e],w),M(()=>{let{original:d,modified:m}=x.current.getModel();b.current.editor.setModelLanguage(d,n||r||"text"),b.current.editor.setModelLanguage(m,o||r||"text")},[r,n,o],w),M(()=>{var d;(d=b.current)==null||d.editor.setTheme(j)},[j],w),M(()=>{var d;(d=x.current)==null||d.updateOptions(C)},[C],w);let $=s.useCallback(()=>{var k;if(!b.current)return;h.current(b.current);let d=Q(b.current,e||"",n||r||"text",u||""),m=Q(b.current,t||"",o||r||"text",p||"");(k=x.current)==null||k.setModel({original:d,modified:m})},[r,t,o,e,n,u,p]),W=s.useCallback(()=>{var d;!R.current&&L.current&&(x.current=b.current.editor.createDiffEditor(L.current,{automaticLayout:!0,...C}),$(),(d=b.current)==null||d.editor.setTheme(j),T(!0),R.current=!0)},[C,j,$]);s.useEffect(()=>{w&&O.current(x.current,b.current)},[w]),s.useEffect(()=>{!E&&!w&&W()},[E,w,W]);function D(){var m,k,P,z;let d=(m=x.current)==null?void 0:m.getModel();v||((k=d==null?void 0:d.original)==null||k.dispose()),g||((P=d==null?void 0:d.modified)==null||P.dispose()),(z=x.current)==null||z.dispose()}return K.createElement(we,{width:I,height:_,isEditorReady:w,loading:N,_ref:L,className:V,wrapperProps:U})}var Dt=$t;s.memo(Dt);function It(e){let t=s.useRef();return s.useEffect(()=>{t.current=e},[e]),t.current}var Vt=It,re=new Map;function Ut({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:u,theme:p="light",line:v,loading:g="Loading...",options:j={},overrideServices:N={},saveViewState:C=!0,keepCurrentModel:_=!1,width:I="100%",height:V="100%",className:U,wrapperProps:H={},beforeMount:q=J,onMount:w=J,onChange:T,onValidate:E=J}){let[y,x]=s.useState(!1),[b,L]=s.useState(!0),O=s.useRef(null),h=s.useRef(null),R=s.useRef(null),$=s.useRef(w),W=s.useRef(q),D=s.useRef(),d=s.useRef(n),m=Vt(u),k=s.useRef(!1),P=s.useRef(!1);Oe(()=>{let a=je.init();return a.then(i=>(O.current=i)&&L(!1)).catch(i=>(i==null?void 0:i.type)!=="cancelation"&&console.error("Monaco initialization: error:",i)),()=>h.current?ie():a.cancel()}),M(()=>{var i,c,f,S;let a=Q(O.current,e||n||"",t||o||"",u||r||"");a!==((i=h.current)==null?void 0:i.getModel())&&(C&&re.set(m,(c=h.current)==null?void 0:c.saveViewState()),(f=h.current)==null||f.setModel(a),C&&((S=h.current)==null||S.restoreViewState(re.get(u))))},[u],y),M(()=>{var a;(a=h.current)==null||a.updateOptions(j)},[j],y),M(()=>{!h.current||n===void 0||(h.current.getOption(O.current.editor.EditorOption.readOnly)?h.current.setValue(n):n!==h.current.getValue()&&(P.current=!0,h.current.executeEdits("",[{range:h.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),h.current.pushUndoStop(),P.current=!1))},[n],y),M(()=>{var i,c;let a=(i=h.current)==null?void 0:i.getModel();a&&o&&((c=O.current)==null||c.editor.setModelLanguage(a,o))},[o],y),M(()=>{var a;v!==void 0&&((a=h.current)==null||a.revealLine(v))},[v],y),M(()=>{var a;(a=O.current)==null||a.editor.setTheme(p)},[p],y);let z=s.useCallback(()=>{var a;if(!(!R.current||!O.current)&&!k.current){W.current(O.current);let i=u||r,c=Q(O.current,n||e||"",t||o||"",i||"");h.current=(a=O.current)==null?void 0:a.editor.create(R.current,{model:c,automaticLayout:!0,...j},N),C&&h.current.restoreViewState(re.get(i)),O.current.editor.setTheme(p),v!==void 0&&h.current.revealLine(v),x(!0),k.current=!0}},[e,t,r,n,o,u,j,N,C,p,v]);s.useEffect(()=>{y&&$.current(h.current,O.current)},[y]),s.useEffect(()=>{!b&&!y&&z()},[b,y,z]),d.current=n,s.useEffect(()=>{var a,i;y&&T&&((a=D.current)==null||a.dispose(),D.current=(i=h.current)==null?void 0:i.onDidChangeModelContent(c=>{P.current||T(h.current.getValue(),c)}))},[y,T]),s.useEffect(()=>{if(y){let a=O.current.editor.onDidChangeMarkers(i=>{var f;let c=(f=h.current.getModel())==null?void 0:f.uri;if(c&&i.find(S=>S.path===c.path)){let S=O.current.editor.getModelMarkers({resource:c});E==null||E(S)}});return()=>{a==null||a.dispose()}}return()=>{}},[y,E]);function ie(){var a,i;(a=D.current)==null||a.dispose(),_?C&&re.set(u,h.current.saveViewState()):(i=h.current.getModel())==null||i.dispose(),h.current.dispose()}return K.createElement(we,{width:I,height:V,isEditorReady:y,loading:g,_ref:R,className:U,wrapperProps:H})}var Ht=Ut,qt=s.memo(Ht),Wt=qt;function Bt(e){var n;const t=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",json:"json",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",yaml:"yaml",yml:"yaml",toml:"toml",sql:"sql",sh:"shell",bat:"bat",ps1:"powershell",dockerfile:"dockerfile",properties:"properties",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",vue:"html",svelte:"html",svg:"xml"}[t||""]||"plaintext"}function Yt(){const{t:e}=ze(),[t,r]=s.useState([]),[n,o]=s.useState(null),[u,p]=s.useState(""),[v,g]=s.useState(""),[j,N]=s.useState(!1),[C,_]=s.useState(""),[I,V]=s.useState(!1),[U,H]=s.useState(!1),[q,w]=s.useState(!1),[T,E]=s.useState(""),y=s.useRef(null);s.useEffect(()=>{if(!n){p(""),g("");return}N(!0),B.files.read(n).then(a=>{if(a.success&&a.data){const i=typeof a.data=="string"?a.data:JSON.stringify(a.data);p(i),g(i)}else F.error(a.error||e("fileTree.readFail"))}).catch(()=>F.error(e("fileTree.readFail"))).finally(()=>N(!1))},[n]);const x=async a=>{V(!0);try{const i=await B.files.list(a);i.success&&Array.isArray(i.data)&&r(i.data.map(c=>({...c,expanded:!1})))}finally{V(!1)}},b=async a=>{if(a.type==="directory")try{const i=await B.files.list(a.path);if(i.success&&Array.isArray(i.data)){const c=i.data.map(f=>({...f,expanded:!1}));r(f=>L(f,a.id,c))}}catch{}},L=(a,i,c)=>a.map(f=>f.id===i?{...f,children:c,expanded:!0}:f.children?{...f,children:L(f.children,i,c)}:f);s.useEffect(()=>{x()},[]);const O=a=>{const i=R(t,a);if(i&&i.type==="directory"&&!i.children){b(i);return}r(c=>h(c,a))},h=(a,i)=>a.map(c=>c.id===i&&c.type==="directory"?{...c,expanded:!c.expanded}:c.children?{...c,children:h(c.children,i)}:c),R=(a,i)=>{for(const c of a){if(c.id===i)return c;if(c.children){const f=R(c.children,i);if(f)return f}}return null},$=(a,i)=>i?a.reduce((c,f)=>{if(f.name.toLowerCase().includes(i.toLowerCase()))c.push(f);else if(f.children){const S=$(f.children,i);S.length>0&&c.push({...f,children:S,expanded:!0})}return c},[]):a,W=s.useCallback(async()=>{if(n){H(!0);try{const a=await B.files.update(n,u);a.success?(g(u),F.success(e("fileTree.saved"))):F.error(a.error||e("fileTree.saveFail"))}catch{F.error(e("fileTree.saveFail"))}finally{H(!1)}}},[n,u,e]),D=()=>{o(null),p(""),g("")},d=s.useCallback(async a=>{const i=await B.files.download(a);i.success?F.success(e("fileTree.downloadStarted")):F.error(i.error||e("fileTree.downloadFail"))},[e]),m=()=>{var a;return(a=y.current)==null?void 0:a.click()},k=s.useCallback(async a=>{if(!a||a.length===0)return;const i=T||(n?n.replace(/[\\/][^\\/]+$/,""):"");w(!0);let c=0,f=0;for(const S of Array.from(a)){const Z=i?`${i}/${S.name}`:S.name;(await B.files.upload(S,Z)).success?c++:f++}w(!1),c>0&&F.success(e("fileTree.uploadedCount",{count:c})),f>0&&F.error(e("fileTree.uploadFailedCount",{count:f})),await x()},[T,n,e]),P=u!==v,z=(a,i=0)=>{var Z;const c=a.type==="directory",f=n===a.path,S=T===a.path;return l.jsxs("div",{children:[l.jsxs("div",{className:`group flex items-center gap-1 px-2 py-0.5 cursor-pointer rounded text-xs transition-colors ${f?"bg-accent-blue/20 text-accent-blue":S?"bg-accent-blue/10":"hover:bg-dark-hover"}`,style:{paddingLeft:`${i*14+6}px`},onClick:()=>c?(E(a.path),O(a.id)):o(a.path),title:c?e("fileTree.setUploadDirHint"):a.path,children:[c&&l.jsx("span",{className:"text-dark-muted shrink-0",children:a.expanded?l.jsx(Re,{size:12}):l.jsx(Fe,{size:12})}),c?l.jsx(Le,{size:12,className:"text-accent-yellow shrink-0"}):l.jsx("span",{className:"w-3"}),l.jsx("span",{className:"truncate flex-1",children:a.name}),!c&&l.jsx("button",{onClick:ee=>{ee.stopPropagation(),d(a.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-dark-border text-dark-muted hover:text-dark-text shrink-0",title:e("fileTree.download"),children:l.jsx(ue,{size:11})})]}),c&&a.expanded&&((Z=a.children)==null?void 0:Z.map(ee=>z(ee,i+1)))]},a.id)},ie=C?$(t,C):t;return l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsxs("div",{className:"w-64 shrink-0 flex flex-col overflow-hidden border-r border-dark-border",children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-dark-border",children:[l.jsxs("h2",{className:"text-xs font-semibold flex items-center gap-1.5",children:[l.jsx(Ce,{size:14}),e("fileTree.title")]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("button",{onClick:m,disabled:q,className:"p-1 rounded hover:bg-dark-hover disabled:opacity-50",title:T?e("fileTree.uploadTo",{dir:T}):e("fileTree.uploadToRoot"),children:l.jsx(Me,{size:12,className:q?"animate-pulse":""})}),l.jsx("button",{onClick:()=>x(),disabled:I,className:"p-1 rounded hover:bg-dark-hover",title:e("fileTree.refresh"),children:l.jsx(Ne,{size:12,className:I?"animate-spin":""})}),l.jsx("button",{onClick:()=>{r(t.map(a=>({...a,expanded:!1}))),o(null)},className:"p-1 rounded hover:bg-dark-hover",title:e("fileTree.collapse"),children:l.jsx(Te,{size:12})})]})]}),l.jsx("div",{className:"p-1.5 border-b border-dark-border",children:l.jsxs("div",{className:"relative",children:[l.jsx(ke,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-dark-muted"}),l.jsx("input",{type:"text",value:C,onChange:a=>_(a.target.value),placeholder:e("fileTree.searchPlaceholder"),className:"w-full pl-6 pr-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:border-accent-blue focus:outline-none"})]})}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar py-1",children:ie.map(a=>z(a))}),l.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:a=>{k(a.target.files),a.currentTarget.value=""}})]}),l.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-dark-bg",children:n?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-dark-border bg-dark-surface",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[l.jsx(le,{size:12,className:"text-dark-muted shrink-0"}),l.jsx("span",{className:"truncate",children:n}),P&&l.jsxs("span",{className:"text-accent-yellow text-[10px] shrink-0",children:["● ",e("fileTree.modified")]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:W,disabled:!P||U,className:`px-2 py-0.5 text-[10px] rounded flex items-center gap-1 transition-colors ${P?"bg-accent-green text-white hover:opacity-90":"bg-dark-border text-dark-muted cursor-not-allowed"}`,children:[l.jsx(Pe,{size:10}),e(U?"fileTree.saving":"fileTree.save")]}),l.jsx("button",{onClick:()=>void d(n),className:"p-1 rounded hover:bg-dark-hover",title:e("fileTree.download"),children:l.jsx(ue,{size:12})}),l.jsx("button",{onClick:D,className:"p-1 rounded hover:bg-dark-hover",title:e("fileTree.close"),children:l.jsx(Ee,{size:12})})]})]}),l.jsx("div",{className:"flex-1 min-h-0",children:j?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("div",{className:"w-4 h-4 border-2 border-accent-blue border-t-transparent rounded-full animate-spin"})}):l.jsx(Wt,{language:Bt(n),value:u,onChange:a=>p(a||""),theme:"vs-dark",options:{fontSize:13,fontFamily:'"Cascadia Code", "Fira Code", Consolas, monospace',minimap:{enabled:!0,renderCharacters:!1,maxColumn:80,showSlider:"mouseover"},lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,tabSize:2}})})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx(le,{size:32,className:"text-dark-muted mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-dark-muted",children:e("fileTree.selectFileHint")})]})})})]})}export{Yt as FileTreeView,Yt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./markdown-DEtuzEyz.js";import{a as y,aX as L,p as D,aY as Y,aE as B,X as z,f as G,a4 as J,ad as W,aZ as _,aL as q,aM as X,h as Q,aQ as V,a2 as Z,aa as K}from"./icons-f1hlMKvD.js";import{c as ee}from"./state-xD58vmym.js";import{a as j,u as E}from"./index-u1vYyqna.js";import"./react-vendor-ClBKp0t-.js";import"./panels-Bn-2wCur.js";const P=ee((l,d)=>({rules:[],stats:null,events:[],agents:[],loading:!1,error:null,fieldErrors:null,formOpen:!1,editingRule:null,dryRunResult:null,loadRules:async()=>{const t=await j.hooks.list();t.success&&Array.isArray(t.data)?l({rules:t.data}):t.success&&t.data&&!Array.isArray(t.data)?l({error:"服务端返回的规则数据格式异常"}):l({error:t.error||"Failed to load rules"})},loadStats:async()=>{const t=await j.hooks.stats();t.success&&t.data&&l({stats:t.data})},loadEvents:async()=>{const t=await j.hooks.events();t.success&&Array.isArray(t.data)?l({events:t.data}):t.success&&t.data&&!Array.isArray(t.data)&&l({error:"服务端返回的事件数据格式异常"})},loadAgents:async()=>{const t=await j.hooks.agents();t.success&&Array.isArray(t.data)?l({agents:t.data}):t.success&&t.data&&!Array.isArray(t.data)&&l({error:"服务端返回的Agent数据格式异常"})},loadAll:async()=>{l({loading:!0,error:null});try{await Promise.all([d().loadRules(),d().loadStats(),d().loadEvents(),d().loadAgents()])}catch(t){l({error:String(t)})}finally{l({loading:!1})}},createRule:async t=>{l({fieldErrors:null});const r=await j.hooks.create(t);if(r.success)return await d().loadRules(),await d().loadStats(),l({formOpen:!1,editingRule:null}),!0;if(r.error){l({error:r.error});try{const c=JSON.parse(r.error);c.fieldErrors&&l({fieldErrors:c.fieldErrors})}catch{}}return!1},updateRule:async(t,r)=>{l({fieldErrors:null});const c=await j.hooks.update(t,r);return c.success?(await d().loadRules(),l({formOpen:!1,editingRule:null}),!0):(l({error:c.error||"Update failed"}),!1)},deleteRule:async t=>{const r=await j.hooks.delete(t);return r.success?(await d().loadRules(),await d().loadStats(),!0):(l({error:r.error||"Delete failed"}),!1)},batchDelete:async t=>{const r=await j.hooks.batchDelete(t);return r.success?(await d().loadRules(),await d().loadStats(),!0):(l({error:r.error||"Batch delete failed"}),!1)},toggleRule:async(t,r)=>(await j.hooks.toggle(t,r)).success?(l(x=>({rules:x.rules.map(p=>p.name===t?{...p,enabled:r}:p)})),!0):(await d().loadRules(),!1),batchToggle:async(t,r)=>(await j.hooks.batchToggle(t,r)).success?(l(x=>({rules:x.rules.map(p=>t.includes(p.name)?{...p,enabled:r}:p)})),!0):(await d().loadRules(),!1),dryRun:async t=>{const r=await j.hooks.dryRun(t);return r.success&&r.data?(l({dryRunResult:r.data}),r.data):(l({error:r.error||"Dry-run failed"}),null)},openForm:t=>l({formOpen:!0,editingRule:t||null,dryRunResult:null,fieldErrors:null}),closeForm:()=>l({formOpen:!1,editingRule:null,dryRunResult:null,fieldErrors:null}),setDryRunResult:t=>l({dryRunResult:t}),clearError:()=>l({error:null}),clearFieldErrors:()=>l({fieldErrors:null})})),te={SYSTEM:"bg-accent-red/15 text-accent-red",SECURITY:"bg-accent-orange/15 text-accent-orange",PROJECT:"bg-accent-blue/15 text-accent-blue",USER:"bg-accent-green/15 text-accent-green",PLUGIN:"bg-accent-purple/15 text-accent-purple"},ae={SHELL:"bg-accent-yellow/15 text-accent-yellow",HTTP:"bg-accent-cyan/15 text-accent-cyan",PROMPT:"bg-accent-purple/15 text-accent-purple",AGENT:"bg-accent-blue/15 text-accent-blue"};function se({rules:l,onEdit:d}){const{t}=E(),{toggleRule:r,deleteRule:c,batchDelete:x,batchToggle:p}=P(),[k,b]=y.useState(new Set),[R,v]=y.useState(!1),T=Array.isArray(l)?l:[];if(T.length===0)return e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 py-16 text-dark-muted",children:[e.jsx("div",{className:"text-4xl opacity-60",children:"🪝"}),e.jsx("p",{className:"text-sm",children:t("hook.noRules")}),e.jsx("p",{className:"text-xs text-dark-muted/70",children:t("hook.noRulesHint")})]});const C=n=>{const s=new Set(k);s.has(n)?s.delete(n):s.add(n),b(s),v(s.size===T.length)},h=()=>{R?(b(new Set),v(!1)):(b(new Set(T.map(n=>n.name))),v(!0))},w=()=>{k.size!==0&&confirm(t("hook.batchDeleteConfirm",{n:k.size}))&&(x(Array.from(k)),b(new Set),v(!1))},m=n=>{k.size!==0&&(p(Array.from(k),n),b(new Set),v(!1))};return e.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[k.size>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2 rounded-lg border border-accent-blue/30 bg-accent-blue/5 px-3 py-1.5 text-sm",children:[e.jsx("span",{className:"text-dark-muted",children:t("hook.selectedItems",{n:k.size})}),e.jsx("button",{onClick:()=>m(!0),className:"rounded bg-accent-green/15 px-2 py-0.5 text-accent-green transition-colors hover:bg-accent-green/25",children:t("hook.enableAll")}),e.jsx("button",{onClick:()=>m(!1),className:"rounded bg-dark-hover px-2 py-0.5 text-dark-text transition-colors hover:bg-dark-border",children:t("hook.disableAll")}),e.jsx("button",{onClick:w,className:"rounded bg-accent-red/15 px-2 py-0.5 text-accent-red transition-colors hover:bg-accent-red/25",children:t("common.delete")})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto custom-scrollbar rounded-xl border border-dark-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-dark-hover text-dark-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-8 p-2.5",children:e.jsx("button",{onClick:h,children:R?e.jsx(L,{size:14}):e.jsx(D,{size:14})})}),e.jsx("th",{className:"p-2.5 text-left font-medium",children:t("hook.colName")}),e.jsx("th",{className:"p-2.5 text-left font-medium",children:t("hook.colEvents")}),e.jsx("th",{className:"p-2.5 text-left font-medium",children:t("hook.colType")}),e.jsx("th",{className:"p-2.5 text-left font-medium",children:t("hook.fieldPriority")}),e.jsx("th",{className:"p-2.5 text-left font-medium",children:t("hook.colStatus")}),e.jsx("th",{className:"p-2.5 text-right font-medium",children:t("hook.colActions")})]})}),e.jsx("tbody",{className:"divide-y divide-dark-border",children:T.map(n=>e.jsxs("tr",{className:"transition-colors hover:bg-dark-hover/50",children:[e.jsx("td",{className:"p-2.5",children:e.jsx("button",{onClick:()=>C(n.name),children:k.has(n.name)?e.jsx(L,{size:14,className:"text-accent-blue"}):e.jsx(D,{size:14,className:"text-dark-muted"})})}),e.jsxs("td",{className:"p-2.5",children:[e.jsx("div",{className:"font-medium text-dark-text",children:n.name}),n.description&&e.jsx("div",{className:"mt-0.5 max-w-[220px] truncate text-xs text-dark-muted",children:n.description})]}),e.jsx("td",{className:"p-2.5",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[Array.isArray(n.events)&&n.events.slice(0,3).map(s=>e.jsx("span",{className:"rounded bg-dark-hover px-1.5 py-0.5 text-xs text-dark-text",children:s},s)),Array.isArray(n.events)&&n.events.length>3&&e.jsxs("span",{className:"px-1 py-0.5 text-xs text-dark-muted",children:["+",n.events.length-3]})]})}),e.jsx("td",{className:"p-2.5",children:e.jsx("span",{className:`rounded px-1.5 py-0.5 text-xs font-medium ${ae[n.implementationType]||"bg-dark-hover text-dark-muted"}`,children:n.implementationType})}),e.jsx("td",{className:"p-2.5",children:e.jsx("span",{className:`rounded px-1.5 py-0.5 text-xs font-medium ${te[n.priority]||"bg-dark-hover text-dark-muted"}`,children:n.priority})}),e.jsx("td",{className:"p-2.5",children:e.jsx("button",{onClick:()=>r(n.name,!n.enabled),className:`relative h-5 w-9 rounded-full transition-colors ${n.enabled?"bg-accent-green":"bg-dark-border"}`,title:n.enabled?t("hook.clickToDisable"):t("hook.clickToEnable"),children:e.jsx("span",{className:`absolute top-0.5 block h-3.5 w-3.5 rounded-full bg-white transition-all ${n.enabled?"left-[18px]":"left-[2px]"}`})})}),e.jsx("td",{className:"p-2.5",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>d(n),className:"rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-accent-blue",title:t("hook.actionEdit"),children:e.jsx(Y,{size:14})}),e.jsx("button",{onClick:()=>{confirm(t("hook.deleteRuleConfirm",{name:n.name}))&&c(n.name)},className:"rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-accent-red",title:t("common.delete"),children:e.jsx(B,{size:14})})]})})]},n.name))})]})})]})}const re={name:"",description:"",events:[],implementationType:"SHELL",command:"",url:"",promptTemplate:"",agentName:"",priority:"USER",tools:[],matcherToolNamePattern:"",matcherFromState:"",matcherToState:"",timeoutMs:3e4,enabled:!0,failOpen:!0,scope:"project"},le=[{value:"SYSTEM",label:"SYSTEM (100)"},{value:"SECURITY",label:"SECURITY (80)"},{value:"PROJECT",label:"PROJECT (60)"},{value:"USER",label:"USER (40)"},{value:"PLUGIN",label:"PLUGIN (20)"}],g=l=>`w-full rounded-lg border bg-dark-bg px-3 py-2 text-sm text-dark-text placeholder-dark-muted/60 transition-colors focus:outline-none focus:ring-2 ${l?"border-accent-red focus:border-accent-red focus:ring-accent-red/20":"border-dark-border focus:border-accent-blue focus:ring-accent-blue/20"}`,f="mb-1 block text-xs font-medium text-dark-muted";function ne({events:l,agents:d}){const{t}=E(),{editingRule:r,fieldErrors:c,dryRunResult:x,createRule:p,updateRule:k,closeForm:b,dryRun:R,setDryRunResult:v,clearFieldErrors:T}=P(),C=[{value:"SHELL",label:t("hook.implShell"),desc:t("hook.implShellDesc")},{value:"HTTP",label:t("hook.implHttp"),desc:t("hook.implHttpDesc")},{value:"PROMPT",label:"LLM Prompt",desc:t("hook.implPromptDesc")},{value:"AGENT",label:"AI Agent",desc:t("hook.implAgentDesc")}],h=Array.isArray(l)?l:[],w=Array.isArray(d)?d:[],[m,n]=y.useState(0),[s,N]=y.useState(re),[S,O]=y.useState("");y.useEffect(()=>{var a,o,i;r&&N({name:r.name,description:r.description||"",events:r.events,implementationType:r.implementationType,command:r.command||"",url:r.url||"",promptTemplate:r.promptTemplate||"",agentName:r.agentName||"",priority:r.priority,tools:r.tools||[],matcherToolNamePattern:((a=r.matchers)==null?void 0:a.toolNamePattern)||"",matcherFromState:((o=r.matchers)==null?void 0:o.fromState)||"",matcherToState:((i=r.matchers)==null?void 0:i.toState)||"",timeoutMs:r.timeoutMs,enabled:r.enabled,failOpen:r.failOpen,scope:r.scope||"project"})},[r]);const u=(a,o)=>{N(i=>({...i,[a]:o})),T()},I=a=>{N(o=>({...o,events:o.events.includes(a)?o.events.filter(i=>i!==a):[...o.events,a]}))},F=a=>{const o=a.every(i=>s.events.includes(i));N(o?i=>({...i,events:i.events.filter(A=>!a.includes(A))}):i=>({...i,events:[...new Set([...i.events,...a])]}))},M=async()=>{const a={};s.matcherToolNamePattern&&(a.toolNamePattern=s.matcherToolNamePattern),s.matcherFromState&&(a.fromState=s.matcherFromState),s.matcherToState&&(a.toState=s.matcherToState);const i={...{...s,tools:s.tools.length>0?s.tools:[]}};i.matchers=a,delete i.matcherToolNamePattern,delete i.matcherFromState,delete i.matcherToState,r?await k(r.name,i):await p(i)},U=async()=>{v(null);const a={};s.matcherToolNamePattern&&(a.toolNamePattern=s.matcherToolNamePattern),await R({hook:{name:s.name||"dry-run",description:s.description,events:s.events,implementationType:s.implementationType,command:s.command,url:s.url,promptTemplate:s.promptTemplate,agentName:s.agentName,priority:s.priority,tools:s.tools,matchers:a,timeoutMs:s.timeoutMs,enabled:!0,failOpen:s.failOpen,scope:s.scope},eventType:s.events[0]||"PRE_TOOL_USE",toolName:"",toolInput:""})},H=S?h.map(a=>({...a,events:Array.isArray(a.events)?a.events.filter(o=>o.name.toLowerCase().includes(S.toLowerCase())||o.summary.includes(S)):[]})).filter(a=>a.events.length>0):h,$=[{title:t("hook.stepBasicTitle"),desc:t("hook.stepBasicDesc")},{title:t("hook.stepImplTitle"),desc:t("hook.stepImplDesc")},{title:t("hook.stepAdvancedTitle"),desc:t("hook.stepAdvancedDesc")}];return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:b}),e.jsxs("div",{className:"relative flex h-full w-[560px] flex-col border-l border-dark-border bg-dark-bg shadow-2xl animate-slide-in-right",children:[e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-b border-dark-border px-4 py-3.5",children:[e.jsx("h3",{className:"text-base font-semibold text-dark-text",children:r?t("hook.editRule",{name:r.name}):t("hook.addRule")}),e.jsx("button",{onClick:b,className:"rounded-lg p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text",children:e.jsx(z,{size:18})})]}),e.jsx("div",{className:"flex flex-shrink-0 border-b border-dark-border",children:$.map((a,o)=>{const i=o===m,A=o<m;return e.jsxs("button",{onClick:()=>n(o),className:`relative flex-1 border-b-2 px-2 py-2.5 text-center text-xs transition-colors ${i?"border-accent-blue bg-accent-blue/5 text-accent-blue":A?"border-transparent text-dark-text":"border-transparent text-dark-muted hover:text-dark-text"}`,children:[e.jsx("span",{className:`mr-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-[10px] ${i?"bg-accent-blue text-white":A?"bg-accent-green text-white":"bg-dark-hover text-dark-muted"}`,children:A?"✓":o+1}),e.jsx("span",{className:"font-medium",children:a.title})]},a.title)})}),e.jsxs("div",{className:"flex-1 min-h-0 space-y-4 overflow-auto custom-scrollbar p-4",children:[c&&Object.keys(c).length>0&&e.jsx("div",{className:"rounded-lg border border-accent-red/40 bg-accent-red/10 p-2.5 text-xs text-accent-red",children:Object.entries(c).map(([a,o])=>e.jsxs("div",{children:[e.jsxs("strong",{children:[a,":"]})," ",o]},a))}),m===0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldName")}),e.jsx("input",{value:s.name,onChange:a=>u("name",a.target.value),placeholder:"my-custom-hook",className:g(c==null?void 0:c.name)})]}),e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldDescription")}),e.jsx("textarea",{value:s.description,onChange:a=>u("description",a.target.value),placeholder:t("hook.descriptionPlaceholder"),rows:2,className:g()})]}),e.jsxs("div",{children:[e.jsx("label",{className:f,children:"Scope"}),e.jsxs("select",{value:s.scope,onChange:a=>u("scope",a.target.value),className:g(),children:[e.jsx("option",{value:"project",children:"project (.agent/hooks.json)"}),e.jsx("option",{value:"user",children:"user (~/.agent/hooks.json)"}),e.jsx("option",{value:"local",children:"local (.agent/hooks.local.json)"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-medium text-dark-muted",children:t("hook.fieldEvents")}),e.jsx("span",{className:"text-xs text-accent-blue",children:t("hook.eventsSelected",{n:s.events.length})})]}),e.jsx("input",{value:S,onChange:a=>O(a.target.value),placeholder:t("hook.searchEventsPlaceholder"),className:g()+" mb-2"}),e.jsx("div",{className:"max-h-[280px] space-y-2 overflow-auto custom-scrollbar rounded-lg border border-dark-border bg-dark-surface p-2",children:H.map(a=>e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>F(a.events.map(o=>o.name)),className:"mb-1 text-xs font-medium text-dark-muted transition-colors hover:text-dark-text",children:[a.category," — ",t("hook.toggleAllEvents")]}),a.events.map(o=>{const i=s.events.includes(o.name);return e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 transition-colors hover:bg-dark-hover",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:()=>I(o.name),className:"h-3.5 w-3.5 accent-accent-blue"}),e.jsx("span",{className:"text-xs text-dark-text",children:o.name}),e.jsxs("span",{className:"truncate text-xs text-dark-muted",children:["— ",o.summary]})]},o.name)})]},a.category))})]})]}),m===1&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldImplType")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:C.map(a=>{const o=s.implementationType===a.value;return e.jsxs("button",{onClick:()=>u("implementationType",a.value),className:`rounded-lg border p-3 text-left transition-colors ${o?"border-accent-blue bg-accent-blue/10 ring-1 ring-accent-blue/30":"border-dark-border bg-dark-surface hover:bg-dark-hover"}`,children:[e.jsx("div",{className:`text-sm font-medium ${o?"text-accent-blue":"text-dark-text"}`,children:a.label}),e.jsx("div",{className:"mt-1 text-xs text-dark-muted",children:a.desc})]},a.value)})})]}),s.implementationType==="SHELL"&&e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldCommand")}),e.jsx("input",{value:s.command,onChange:a=>u("command",a.target.value),placeholder:"python3 .agent/hooks/audit.py",className:`font-mono ${g(c==null?void 0:c.command)}`})]}),s.implementationType==="HTTP"&&e.jsxs("div",{children:[e.jsx("label",{className:f,children:"URL *"}),e.jsx("input",{value:s.url,onChange:a=>u("url",a.target.value),placeholder:"https://example.com/hooks/audit",className:g(c==null?void 0:c.url)})]}),s.implementationType==="PROMPT"&&e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldPromptTemplate")}),e.jsx("textarea",{value:s.promptTemplate,onChange:a=>u("promptTemplate",a.target.value),placeholder:t("hook.promptTemplatePlaceholder"),rows:5,className:`font-mono ${g(c==null?void 0:c.promptTemplate)}`})]}),s.implementationType==="AGENT"&&e.jsxs("div",{children:[e.jsx("label",{className:f,children:"Agent *"}),e.jsxs("select",{value:s.agentName,onChange:a=>u("agentName",a.target.value),className:g(c==null?void 0:c.agentName),children:[e.jsx("option",{value:"",children:t("hook.selectAgentPlaceholder")}),w.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.description,")"]},a.id))]}),e.jsx("p",{className:"mt-1 text-xs text-dark-muted",children:t("hook.agentReadOnlyHint")})]})]}),m===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldPriority")}),e.jsx("select",{value:s.priority,onChange:a=>u("priority",a.target.value),className:g(),children:le.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldTimeout")}),e.jsx("input",{type:"number",value:s.timeoutMs,onChange:a=>u("timeoutMs",parseInt(a.target.value)||3e4),min:100,max:3e5,step:1e3,className:g()})]}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-dark-text",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:a=>u("enabled",a.target.checked),className:"h-3.5 w-3.5 accent-accent-blue"}),t("hook.labelEnabled")]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-dark-text",children:[e.jsx("input",{type:"checkbox",checked:s.failOpen,onChange:a=>u("failOpen",a.target.checked),className:"h-3.5 w-3.5 accent-accent-blue"}),t("hook.failOpenLabel")]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:f,children:t("hook.fieldToolFilter")}),e.jsx("input",{value:s.matcherToolNamePattern,onChange:a=>u("matcherToolNamePattern",a.target.value),placeholder:"Bash.*|FileWrite.*",className:`font-mono ${g()}`})]}),s.events.some(a=>a.includes("STATE"))&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:f,children:"From State"}),e.jsx("input",{value:s.matcherFromState,onChange:a=>u("matcherFromState",a.target.value),className:g()})]}),e.jsxs("div",{children:[e.jsx("label",{className:f,children:"To State"}),e.jsx("input",{value:s.matcherToState,onChange:a=>u("matcherToState",a.target.value),className:g()})]})]}),x&&e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface p-3",children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-dark-text",children:t("hook.dryRunResultTitle")}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-dark-muted",children:t("hook.dryRunDecision")}),e.jsx("span",{className:x.decision==="ALLOW"?"text-accent-green":x.decision==="DENY"?"text-accent-red":"text-accent-yellow",children:x.decision})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-dark-muted",children:t("hook.dryRunReason")}),e.jsx("span",{className:"text-dark-text",children:x.reason})]}),x.contextOutput&&e.jsxs("div",{children:[e.jsx("span",{className:"text-dark-muted",children:t("hook.dryRunOutput")}),e.jsx("span",{className:"text-dark-text",children:x.contextOutput})]})]})]}),e.jsxs("button",{onClick:U,className:"inline-flex items-center gap-1.5 rounded-lg border border-dark-border bg-dark-surface px-3 py-1.5 text-xs text-dark-text transition-colors hover:bg-dark-hover",children:[e.jsx(G,{size:12})," ",t("hook.dryRunButton")]})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-t border-dark-border px-4 py-3",children:[e.jsx("div",{className:"flex gap-2",children:m>0&&e.jsxs("button",{onClick:()=>n(m-1),className:"inline-flex items-center gap-1 rounded-lg border border-dark-border bg-dark-surface px-3 py-1.5 text-sm text-dark-text transition-colors hover:bg-dark-hover",children:[e.jsx(J,{size:14})," ",t("hook.prevStep")]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:b,className:"rounded-lg border border-dark-border bg-dark-surface px-4 py-1.5 text-sm text-dark-text transition-colors hover:bg-dark-hover",children:t("common.cancel")}),m<2?e.jsxs("button",{onClick:()=>n(m+1),className:"inline-flex items-center gap-1 rounded-lg bg-accent-blue px-4 py-1.5 text-sm text-white transition-colors hover:bg-accent-blue/90",children:[t("hook.nextStep")," ",e.jsx(W,{size:14})]}):e.jsx("button",{onClick:M,className:"rounded-lg bg-accent-blue px-4 py-1.5 text-sm text-white transition-colors hover:bg-accent-blue/90",children:t(r?"hook.saveChanges":"hook.createRule")})]})]})]})]})}function oe({stats:l}){const{t:d}=E();if(!l)return null;const t=[{id:"total",label:d("hook.statTotal"),value:l.totalHooks,icon:_,iconWrap:"bg-accent-blue/15 text-accent-blue"},{id:"enabled",label:d("common.enabled"),value:l.enabledCount,icon:q,iconWrap:"bg-accent-green/15 text-accent-green"},{id:"disabled",label:d("common.disabled"),value:l.disabledCount,icon:X,iconWrap:"bg-dark-hover text-dark-muted"}];return e.jsx("div",{className:"grid grid-cols-3 gap-3",children:t.map(r=>{const c=r.icon;return e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-dark-border bg-dark-surface px-4 py-3",children:[e.jsx("span",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${r.iconWrap}`,children:e.jsx(c,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xl font-bold text-dark-text",children:r.value}),e.jsx("div",{className:"text-xs text-dark-muted",children:r.label})]})]},r.id)})})}function ue(){const{t:l}=E(),{rules:d,stats:t,events:r,agents:c,loading:x,error:p,formOpen:k,loadAll:b,openForm:R,clearError:v}=P();y.useEffect(()=>{b()},[]);const T=y.useCallback(async()=>{const h=await j.hooks.export();if(h.success&&h.data){const w=new Blob([JSON.stringify(h.data,null,2)],{type:"application/json"}),m=URL.createObjectURL(w),n=document.createElement("a");n.href=m,n.download="hooks-export.json",n.click(),URL.revokeObjectURL(m)}},[]),C=y.useCallback(()=>{const h=document.createElement("input");h.type="file",h.accept=".json",h.onchange=async w=>{var s;const m=(s=w.target.files)==null?void 0:s[0];if(!m)return;const n=await m.text();try{const N=JSON.parse(n),S=confirm(l("hook.importMergeConfirm"))?"merge":"replace";(await j.hooks.import({...N,mergeMode:S})).success&&b()}catch(N){console.error("Import failed:",N)}},h.click()},[b,l]);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-dark-bg text-dark-text",children:[e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-3 border-b border-dark-border px-6 py-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-dark-text",children:l("hook.configTitle")}),e.jsx("p",{className:"mt-0.5 text-xs text-dark-muted",children:l("hook.configDesc")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:b,title:l("common.refresh"),className:"rounded-lg p-2 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text",children:e.jsx(Q,{size:16,className:x?"animate-spin":""})}),e.jsxs("button",{onClick:C,className:"inline-flex items-center gap-1.5 rounded-lg border border-dark-border bg-dark-surface px-3 py-2 text-sm text-dark-text transition-colors hover:bg-dark-hover",children:[e.jsx(V,{size:14}),l("hook.import")]}),e.jsxs("button",{onClick:T,className:"inline-flex items-center gap-1.5 rounded-lg border border-dark-border bg-dark-surface px-3 py-2 text-sm text-dark-text transition-colors hover:bg-dark-hover",children:[e.jsx(Z,{size:14}),l("hook.export")]}),e.jsxs("button",{onClick:()=>R(),className:"inline-flex items-center gap-1.5 rounded-lg bg-accent-blue px-3 py-2 text-sm text-white transition-colors hover:bg-accent-blue/90",children:[e.jsx(K,{size:14}),l("hook.newRule")]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto custom-scrollbar px-6 py-4",children:[p&&e.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-lg border border-accent-red/40 bg-accent-red/10 px-4 py-2 text-sm text-accent-red",children:[e.jsx("span",{children:p}),e.jsx("button",{onClick:v,className:"text-accent-red/70 transition-colors hover:text-accent-red",children:e.jsx(z,{size:16})})]}),e.jsx(oe,{stats:t}),e.jsxs("section",{className:"mt-4 min-w-0 rounded-xl border border-dark-border bg-dark-surface p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-dark-text",children:l("hook.ruleList")}),e.jsx("span",{className:"text-xs text-dark-muted",children:l("hook.ruleCount",{n:d.length})})]}),x&&d.length===0?e.jsx("div",{className:"flex h-[520px] items-center justify-center text-dark-muted",children:l("common.loading")}):e.jsx("div",{className:"min-h-[520px]",children:e.jsx(se,{rules:d,onEdit:h=>R(h)})})]})]}),k&&e.jsx(ne,{events:r,agents:c})]})}export{ue as HookConfigView};
|