@thebuoyant-tsdev/mui-ts-library 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`),l=require(`@mui/material`),u=require(`@mui/icons-material/InfoOutlined`);u=s(u,1);let d=require(`@mui/icons-material/WarningAmberOutlined`);d=s(d,1);let f=require(`@mui/icons-material/ErrorOutlined`);f=s(f,1);let p=require(`@mui/icons-material/CheckCircleOutlined`);p=s(p,1);let m=require(`react/jsx-runtime`),h=require(`@codemirror/view`),g=require(`@codemirror/state`),_=require(`@codemirror/lang-json`),v=require(`@codemirror/commands`),y=require(`@codemirror/language`),b=require(`@codemirror/lint`),x=require(`@lezer/highlight`),S=require(`@mui/icons-material/ContentCopy`);S=s(S,1);let C=require(`@mui/icons-material/Check`);C=s(C,1);let w=require(`@mui/icons-material/Delete`);w=s(w,1);let T=require(`@mui/icons-material/Undo`);T=s(T,1);let E=require(`@mui/icons-material/Redo`);E=s(E,1);let D=require(`@mui/icons-material/AutoFixHigh`);D=s(D,1);let O=require(`@mui/icons-material/Compress`);O=s(O,1);let k=require(`zustand`),A=require(`zustand/vanilla`),j=require(`@tanstack/react-virtual`),M=require(`@mui/icons-material/Add`);M=s(M,1);let N=require(`@mui/icons-material/Edit`);N=s(N,1);let P=require(`@mui/icons-material/RestartAlt`);P=s(P,1);let F=require(`@mui/icons-material/Restore`);F=s(F,1);let I=require(`@mui/icons-material/Today`);I=s(I,1);let L=require(`@mui/icons-material/UnfoldLess`);L=s(L,1);let R=require(`@mui/icons-material/UnfoldMore`);R=s(R,1);let z=require(`@mui/icons-material/Visibility`);z=s(z,1);let B=require(`@mui/icons-material/VisibilityOff`);B=s(B,1);let V=require(`@mui/icons-material/Close`);V=s(V,1);let H=require(`@tiptap/react`),U=require(`@tiptap/starter-kit`),ee=require(`@tiptap/extension-text-style`),W=require(`@tiptap/extension-color`),G=require(`@tiptap/extension-highlight`),K=require(`@tiptap/extension-placeholder`),q=require(`@tiptap/extension-character-count`),te=require(`tiptap-markdown`),J=require(`@mui/icons-material/FormatBold`);J=s(J,1);let Y=require(`@mui/icons-material/FormatItalic`);Y=s(Y,1);let ne=require(`@mui/icons-material/FormatUnderlined`);ne=s(ne,1);let re=require(`@mui/icons-material/StrikethroughS`);re=s(re,1);let ie=require(`@mui/icons-material/FormatListBulleted`);ie=s(ie,1);let X=require(`@mui/icons-material/FormatListNumbered`);X=s(X,1);let ae=require(`@mui/icons-material/FormatQuote`);ae=s(ae,1);let oe=require(`@mui/icons-material/Code`);oe=s(oe,1);let se=require(`@mui/icons-material/InsertLink`);se=s(se,1);let ce=require(`@mui/icons-material/HorizontalRule`);ce=s(ce,1);let le=require(`@mui/icons-material/FormatColorText`);le=s(le,1);let ue=require(`@mui/icons-material/BorderColor`);ue=s(ue,1);let de=require(`@mui/icons-material/FormatClear`);de=s(de,1);let fe=require(`@mui/icons-material/FormatColorReset`);fe=s(fe,1);let pe=require(`@codemirror/lang-sql`),me=require(`@codemirror/autocomplete`),he=require(`@mui/icons-material/PlayArrow`);he=s(he,1);let ge=require(`sql-formatter`),_e=require(`@mui/icons-material/WarningAmber`);_e=s(_e,1);var ve={confirmLabel:`Confirm`,cancelLabel:`Cancel`},ye={info:u.default,warning:d.default,error:f.default,success:p.default},be={info:`primary`,warning:`warning`,error:`error`,success:`success`};function xe({open:e,options:t,translation:n,onConfirm:r,onCancel:i}){let{title:a,description:o,confirmLabel:s,cancelLabel:c,severity:u=`info`,hideCancelButton:d=!1,maxWidth:f=`xs`,showIcon:p=!0}=t,h=p?ye[u]:null,g=be[u],_=s??n.confirmLabel,v=c??n.cancelLabel;return(0,m.jsxs)(l.Dialog,{open:e,onClose:i,maxWidth:f,fullWidth:!0,"aria-labelledby":a?`confirm-dialog-title`:void 0,"aria-describedby":o?`confirm-dialog-description`:void 0,children:[a&&(0,m.jsxs)(l.DialogTitle,{id:`confirm-dialog-title`,"data-testid":`confirm-dialog-title`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[h&&(0,m.jsx)(h,{color:u,"data-testid":`confirm-dialog-icon`,fontSize:`small`}),a]}),o&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.Divider,{}),(0,m.jsx)(l.DialogContent,{children:typeof o==`string`?(0,m.jsx)(l.Typography,{id:`confirm-dialog-description`,"data-testid":`confirm-dialog-description`,variant:`body2`,color:`text.secondary`,children:o}):(0,m.jsx)(`div`,{id:`confirm-dialog-description`,"data-testid":`confirm-dialog-description`,children:o})})]}),(0,m.jsx)(l.Divider,{}),(0,m.jsxs)(l.DialogActions,{sx:{px:2,py:1.5},children:[!d&&(0,m.jsx)(l.Button,{"data-testid":`confirm-dialog-cancel-btn`,onClick:i,color:`inherit`,children:v}),(0,m.jsx)(l.Button,{"data-testid":`confirm-dialog-confirm-btn`,onClick:r,color:g,variant:`contained`,autoFocus:!0,children:_})]})]})}var Se=(0,c.createContext)(()=>Promise.resolve(!1));function Ce({children:e,translation:t}){let n={...ve,...t},r=(0,c.useRef)(null),[i,a]=(0,c.useState)({open:!1,options:{}}),o=(0,c.useCallback)(e=>(r.current?.(!1),new Promise(t=>{r.current=t,a({open:!0,options:e})})),[]);return(0,m.jsxs)(Se.Provider,{value:o,children:[e,(0,m.jsx)(xe,{open:i.open,options:i.options,translation:n,onConfirm:()=>{r.current?.(!0),r.current=null,a(e=>({...e,open:!1}))},onCancel:()=>{r.current?.(!1),r.current=null,a(e=>({...e,open:!1}))}})]})}function we(){return(0,c.useContext)(Se)}var Te={showFormat:!0,showCompact:!0,showCopy:!0,showClear:!0,showUndoRedo:!0},Ee={format:`Format JSON`,compact:`Compact JSON`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,validJson:`Valid JSON`,invalidJson:`Invalid JSON`};function De({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,highlightColors:o,onViewReady:s,onCursorChange:u,onBlur:d,onFocus:f}){let p=(0,c.useRef)(null),S=(0,c.useRef)(null),C=(0,c.useRef)(t),w=(0,c.useRef)(u),T=(0,c.useRef)(d),E=(0,c.useRef)(f),D=(0,c.useRef)(s),O=(0,c.useRef)(new g.Compartment),k=(0,c.useRef)(new g.Compartment),A=(0,l.useTheme)(),j=A.palette.mode===`dark`,M=o?.propertyName??A.palette.primary.main,N=o?.string??A.palette.success.main,P=o?.number??A.palette.warning.main,F=o?.boolean??A.palette.info.main,I=o?.null??A.palette.text.secondary;return(0,c.useEffect)(()=>{C.current=t},[t]),(0,c.useEffect)(()=>{w.current=u},[u]),(0,c.useEffect)(()=>{T.current=d},[d]),(0,c.useEffect)(()=>{E.current=f},[f]),(0,c.useEffect)(()=>{D.current=s},[s]),(0,c.useEffect)(()=>{if(!p.current)return;let t=S.current?.state.doc.toString()??e??``,o=y.HighlightStyle.define([{tag:x.tags.propertyName,color:M,fontWeight:`bold`},{tag:x.tags.string,color:N},{tag:x.tags.number,color:P},{tag:x.tags.bool,color:F,fontWeight:`bold`},{tag:x.tags.null,color:I,fontStyle:`italic`},{tag:x.tags.bracket,color:A.palette.text.secondary},{tag:x.tags.punctuation,color:A.palette.text.disabled},{tag:x.tags.invalid,color:A.palette.error.main,textDecoration:`underline wavy`}]),s=[h.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:A.palette.text.primary},".cm-gutters":{backgroundColor:j?A.palette.grey[900]:A.palette.grey[50],color:A.palette.text.disabled,border:`none`,borderRight:`1px solid ${A.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{minWidth:`36px`,paddingLeft:`4px`},".cm-activeLineGutter":{backgroundColor:A.palette.action.selected},".cm-activeLine":{backgroundColor:A.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:A.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:A.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:A.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:A.palette.error.main},".cm-lint-marker-warning":{color:A.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:A.palette.background.paper,border:`1px solid ${A.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${A.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${A.palette.warning.main}`}},{dark:j}),(0,y.syntaxHighlighting)(o),(0,_.json)(),(0,b.lintGutter)(),(0,b.linter)((0,_.jsonParseLinter)()),(0,v.history)(),h.keymap.of([...v.defaultKeymap,...v.historyKeymap]),O.current.of(h.EditorView.editable.of(!r&&!i)),k.current.of(g.EditorState.readOnly.of(i)),(0,h.highlightActiveLine)(),...a?[(0,h.lineNumbers)(),(0,h.highlightActiveLineGutter)()]:[],...n?[(0,h.placeholder)(n)]:[],h.EditorView.updateListener.of(e=>{e.docChanged&&C.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);w.current(n.number,t-n.from+1)}),h.EditorView.domEventHandlers({blur:()=>{T.current?.()},focus:()=>{E.current?.()}})],c=new h.EditorView({state:g.EditorState.create({doc:t,extensions:s}),parent:p.current});return S.current=c,D.current(c),()=>{D.current(null),c.destroy(),S.current=null}},[j,M,N,P,F,I]),(0,c.useEffect)(()=>{let t=S.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{S.current?.dispatch({effects:[O.current.reconfigure(h.EditorView.editable.of(!r&&!i)),k.current.reconfigure(g.EditorState.readOnly.of(i))]})},[r,i]),(0,m.jsx)(l.Box,{ref:p,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:A.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function Oe({label:e,icon:t,onClick:n,disabled:r}){return(0,m.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:n,disabled:r,color:`default`,sx:{borderRadius:1},"aria-label":e,children:t})})})}function ke({viewRef:e,toolbarConfig:t,translation:n,indent:r,disabled:i}){let[a,o]=(0,c.useState)(!1),s=i||!e.current;function u(){let t=e.current;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n),null,r);t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function d(){let t=e.current;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n));t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function f(){let t=e.current?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})}function p(){let t=e.current;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function h(){let t=e.current;t&&((0,v.undo)(t),t.focus())}function g(){let t=e.current;t&&((0,v.redo)(t),t.focus())}let _=t.showFormat||t.showCompact,y=t.showCopy||t.showClear,b=t.showUndoRedo;return(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`JSON editor actions`,children:[_&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,m.jsx)(Oe,{label:n.format,icon:(0,m.jsx)(D.default,{fontSize:`small`}),onClick:u,disabled:s}),t.showCompact&&(0,m.jsx)(Oe,{label:n.compact,icon:(0,m.jsx)(O.default,{fontSize:`small`}),onClick:d,disabled:s})]}),_&&(y||b)&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),y&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,m.jsx)(Oe,{label:a?n.copySuccess:n.copy,icon:a?(0,m.jsx)(C.default,{fontSize:`small`,color:`success`}):(0,m.jsx)(S.default,{fontSize:`small`}),onClick:f,disabled:s}),t.showClear&&(0,m.jsx)(Oe,{label:n.clear,icon:(0,m.jsx)(w.default,{fontSize:`small`}),onClick:p,disabled:s})]}),y&&b&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),b&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,m.jsx)(Oe,{label:n.undo,icon:(0,m.jsx)(T.default,{fontSize:`small`}),onClick:h,disabled:s}),(0,m.jsx)(Oe,{label:n.redo,icon:(0,m.jsx)(E.default,{fontSize:`small`}),onClick:g,disabled:s})]}),!_&&!y&&!b&&(0,m.jsx)(l.Box,{sx:{height:32}})]})}function Ae({helperText:e,error:t,showLineColumn:n,showValidation:r,isValid:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o));return(0,m.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,m.jsxs)(l.Box,{children:[r&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,m.jsx)(p.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,m.jsx)(f.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,m.jsx)(l.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,m.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,m.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function je(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function Me(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function Ne({value:e,onChange:t,onValidChange:n,placeholder:r,height:i,width:a,disabled:o=!1,readonly:s=!1,error:u=!1,helperText:d,name:f,indent:p=2,showLineNumbers:h=!0,showLineColumn:g=!0,showValidation:_=!1,toolbarConfig:v,translation:y,highlightColors:b,onBlur:x,onFocus:S}){let C={...Ee,...y},w={...Te,...v},T=je(i),E=je(a),D=T===`auto`,O=D?void 0:T??300,k=(0,c.useRef)(null),[A,j]=(0,c.useState)({line:1,col:1}),[M,N]=(0,c.useState)(()=>Me(e??``)),P=(0,c.useCallback)(e=>{k.current=e},[]),F=(0,c.useCallback)((e,t)=>{j({line:e,col:t})},[]),I=(0,c.useCallback)(e=>{let r=Me(e);N(r),n?.(r),t?.(e)},[t,n]),L=g||_||!!d;return(0,m.jsxs)(l.Box,{sx:{width:E??`100%`,...D?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,m.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...D?{flex:1}:{height:O},borderColor:u?`error.main`:void 0,"&:focus-within":{borderColor:u?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(ke,{viewRef:k,toolbarConfig:w,translation:C,indent:p,disabled:o}),(0,m.jsx)(l.Divider,{})]}),(0,m.jsx)(De,{value:e,onChange:I,placeholder:r,disabled:o,readonly:s,showLineNumbers:h,highlightColors:b,onViewReady:P,onCursorChange:F,onBlur:x,onFocus:S})]}),L&&(0,m.jsx)(Ae,{helperText:d,error:u,showLineColumn:g,showValidation:_,isValid:M,cursorLine:A.line,cursorCol:A.col,translation:C}),f&&(0,m.jsx)(`input`,{type:`hidden`,name:f,value:e??``})]})}function Pe(e){let t=new Date,n=Ye(t),r=Xe(t);if(e.length===0)return{start:n,end:r};let i=e.map(e=>e.startDate.getTime()),a=e.map(e=>e.endDate.getTime()),o=Be(He(new Date(Math.min(...i)),-1)),s=Ve(He(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function Fe(e,t){return t===`weeks`?{start:Ge(e.start),end:e.end}:t===`quarters`?{start:Ye(e.start),end:Xe(e.end)}:e}function Ie(e,t){let n=t.end.getTime()-t.start.getTime();if(n<=0)return{left:0,width:0};let r=(e.startDate.getTime()-t.start.getTime())/n*100,i=(e.endDate.getTime()-e.startDate.getTime())/n*100;return{left:Math.max(0,r),width:Math.max(0,i)}}function Le(e){let t=new Map;for(let n of e)t.set(n.id,{...n,children:[],depth:0});let n=[];for(let e of t.values())e.parentId&&t.has(e.parentId)?t.get(e.parentId).children.push(e):n.push(e);return Re(n,0),n}function Re(e,t){for(let n of e)n.depth=t,Re(n.children,t+1)}function ze(e,t){let n=[];function r(e){for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)}return r(e),n}function Be(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function Ve(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function He(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function Z(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function Ue(e,t,n){if(n===0)return e;let r=new Map;for(let t of e)for(let e of t.dependencies??[])r.has(e)||r.set(e,[]),r.get(e).push(t.id);let i=new Map(e.map(e=>[e.id,e])),a=[...r.get(t)??[]],o=new Set;for(;a.length>0;){let e=a.shift();if(o.has(e))continue;o.add(e);let t=i.get(e);i.set(e,{...t,startDate:new Date(t.startDate.getTime()+n),endDate:new Date(t.endDate.getTime()+n)}),a.push(...r.get(e)??[])}return e.map(e=>i.get(e.id))}function We(e){let t=[],n=Be(e.start);for(;n<=e.end;)t.push(n),n=He(n,1);return t}function Ge(e){let t=new Date(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t.setHours(0,0,0,0),t}function Ke(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-n);let r=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-r.getTime())/864e5+1)/7)}function qe(e){let t=[],n=Ge(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function Je(e){let t=[],n=new Date(e.start.getFullYear(),e.start.getMonth(),e.start.getDate(),0,0,0,0),r=new Date(e.end.getFullYear(),e.end.getMonth(),e.end.getDate(),0,0,0,0).getTime();for(;n.getTime()<=r;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1,0,0,0,0);return t}function Ye(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function Xe(e){let t=Math.floor(e.getMonth()/3)*3+2;return Ve(new Date(e.getFullYear(),t,1))}function Ze(e){let t=[],n=Ye(e.start);for(;n<=e.end;){let e=Math.floor(n.getMonth()/3)+1;t.push({key:`${n.getFullYear()}-Q${e}`,label:`Q${e} ${n.getFullYear()}`,start:new Date(n)}),n=new Date(n.getFullYear(),n.getMonth()+3,1)}return t}function Qe(e){if(e.length===0)return new Set;let t=new Map;for(let n of e)for(let e of n.dependencies??[])t.has(e)||t.set(e,[]),t.get(e).push(n.id);let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=new Set;function a(e){if(r.has(e))return r.get(e);if(i.has(e))return n.get(e)?.endDate.getTime()??0;i.add(e);let o=n.get(e)?.endDate.getTime()??0;for(let n of t.get(e)??[])o=Math.max(o,a(n));return i.delete(e),r.set(e,o),o}for(let t of e)a(t.id);let o=Math.max(...r.values()),s=new Set;for(let t of e)a(t.id)===o&&s.add(t.id);return s}function $e(e,t){let n=t.startDate<e.start?Be(He(t.startDate,-1)):e.start,r=t.endDate>e.end?Ve(He(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function et(e,t=`months`,n=!1,r,i=!1){let a=Pe(e);return(0,A.createStore)((o,s)=>({tasks:e,taskTree:Le(e),expandedIds:n?new Set(e.map(e=>e.id)):new Set(e.filter(e=>!e.parentId).map(e=>e.id)),timeScale:t,timelineRange:r??a,isRangeCustomized:r!==void 0,cascadeDependencies:i,defaultTimeScale:t,initialExpandAll:n,isExpandedCustomized:!1,setTasks:e=>{o(t=>({tasks:e,taskTree:Le(e),...t.isRangeCustomized?{}:{timelineRange:Pe(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:Le(n),timelineRange:$e(t.timelineRange,e)}})},updateTask:e=>{o(t=>{let n=t.tasks.find(t=>t.id===e.id),r=t.tasks.map(t=>t.id===e.id?e:t);if(t.cascadeDependencies&&n){let t=e.endDate.getTime()-n.endDate.getTime();r=Ue(r,e.id,t)}let i=$e(t.timelineRange,e);for(let e of r)i=$e(i,e);return{tasks:r,taskTree:Le(r),timelineRange:i}})},deleteTask:e=>{o(t=>{let n=new Set,r=e=>{n.add(e),t.tasks.filter(t=>t.parentId===e).forEach(e=>r(e.id))};r(e);let i=t.tasks.filter(e=>!n.has(e.id));return{tasks:i,taskTree:Le(i)}})},toggleExpand:e=>{o(t=>{let n=new Set(t.expandedIds);return n.has(e)?n.delete(e):n.add(e),{expandedIds:n}})},expandAll:()=>{o(e=>({expandedIds:new Set(e.tasks.map(e=>e.id)),isExpandedCustomized:!0}))},collapseAll:()=>{o({expandedIds:new Set,isExpandedCustomized:!0})},setTimeScale:e=>{o({timeScale:e})},setTimelineRange:e=>{o({timelineRange:e,isRangeCustomized:!0})},resetTimelineRange:()=>{o(e=>({timelineRange:Pe(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:Pe(e.tasks),isRangeCustomized:!1,isExpandedCustomized:!1,expandedIds:e.initialExpandAll?new Set(e.tasks.map(e=>e.id)):new Set(e.tasks.filter(e=>!e.parentId).map(e=>e.id))}))},getVisibleTasks:()=>{let{taskTree:e,expandedIds:t}=s();return ze(e,t)}}))}var tt={scaleDays:`Tage`,scaleWeeks:`Wochen`,scaleMonths:`Monate`,scaleQuarters:`Quartale`,rangeFrom:`Von`,rangeTo:`Bis`,rangeResetTooltip:`Bereich zurücksetzen`,columnName:`Name`,columnStatus:`Status`,statusPlanned:`Planned`,statusInProgress:`In Progress`,statusDone:`Done`,statusBlocked:`Blocked`,weekColumnPrefix:`KW`,dateLocale:`de-DE`,dialogAddTitle:`Aufgabe hinzufügen`,dialogEditTitle:`Aufgabe bearbeiten`,dialogDeleteTitle:`Aufgabe löschen`,dialogSave:`Speichern`,dialogCancel:`Abbrechen`,dialogDelete:`Löschen`,dialogFieldName:`Name`,dialogFieldStartDate:`Startdatum`,dialogFieldEndDate:`Enddatum`,dialogFieldStatus:`Status`,dialogFieldMilestone:`Ist Meilenstein`,dialogFieldParent:`Übergeordnete Aufgabe`,dialogFieldParentNone:`— Keine —`,dialogDeleteConfirm:`Soll die Aufgabe "{name}" wirklich gelöscht werden?`,dialogFieldDependencies:`Vorgänger`,dialogFieldDependenciesNone:`— Keine —`,scrollToTodayTooltip:`Zum heutigen Tag`,expandAllTooltip:`Alle aufklappen`,collapseAllTooltip:`Alle zuklappen`,resetViewTooltip:`Ansicht zurücksetzen`,columnActions:`Aktionen`,addTaskTooltip:`Aufgabe hinzufügen`,editTaskTooltip:`Aufgabe bearbeiten`,deleteTaskTooltip:`Aufgabe löschen`};function nt(e){return e.toISOString().slice(0,10)}function rt(e,t,n){return e<t?t:e>n?n:e}function it(e){return e.flatMap(e=>[e,...it(e.children)])}function at({label:e}){let t=(0,c.useRef)(null),[n,r]=(0,c.useState)(!1);return(0,m.jsx)(l.Tooltip,{title:e,disableHoverListener:!n,children:(0,m.jsx)(l.Typography,{ref:t,component:`span`,variant:`body2`,noWrap:!0,sx:{display:`block`,overflow:`hidden`,textOverflow:`ellipsis`,minWidth:0},onMouseEnter:()=>{t.current&&r(t.current.scrollWidth>t.current.clientWidth)},children:e})})}function ot({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=Tt(),s=Q(e=>e.taskTree),u=Q(e=>e.timelineRange),d=(0,c.useMemo)(()=>it(s),[s]),f=(0,c.useMemo)(()=>{if(t===`add`||!n)return new Set;let e=t=>[t.id,...t.children.flatMap(e)],r=d.find(e=>e.id===n.id);return new Set(r?e(r):[n.id])},[t,n,d]),p=d.filter(e=>!f.has(e.id)),h=p,g=nt(rt(new Date,u.start,u.end)),[_,v]=(0,c.useState)({name:``,startDate:g,endDate:g,status:`planned`,isMilestone:!1,parentId:``,dependencies:[]});(0,c.useEffect)(()=>{if(!e)return;let i=nt(rt(new Date,u.start,u.end));v(t===`edit`&&n?{name:n.name,startDate:nt(n.startDate),endDate:nt(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,parentId:n.parentId??``,dependencies:n.dependencies??[]}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,parentId:r??``,dependencies:[]})},[e,t,n,r,u]);let y=e=>{v(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},b=e=>{v(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},x=e=>{v(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate}))},S=_.name.trim()!==``&&_.startDate!==``&&_.endDate!==``&&_.endDate>=_.startDate,C=()=>{S&&i({name:_.name.trim(),startDate:new Date(_.startDate),endDate:new Date(_.endDate),status:_.status,isMilestone:_.isMilestone||void 0,parentId:_.parentId||void 0,dependencies:_.dependencies.length>0?_.dependencies:void 0})},w=[`planned`,`in-progress`,`done`,`blocked`],T={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,m.jsxs)(l.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,m.jsx)(l.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,m.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,m.jsx)(l.TextField,{label:o.dialogFieldName,value:_.name,onChange:e=>v(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,m.jsx)(l.TextField,{label:o.dialogFieldStartDate,type:`date`,value:_.startDate,onChange:e=>y(e.target.value),required:!0,fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-start`}}}),(0,m.jsx)(l.TextField,{label:o.dialogFieldEndDate,type:`date`,value:_.endDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,disabled:_.isMilestone,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-end`,min:_.startDate}}}),(0,m.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,m.jsx)(l.InputLabel,{children:o.dialogFieldStatus}),(0,m.jsx)(l.Select,{value:_.status,label:o.dialogFieldStatus,onChange:e=>v(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:w.map(e=>(0,m.jsx)(l.MenuItem,{value:e,children:T[e]},e))})]}),(0,m.jsx)(l.FormControlLabel,{control:(0,m.jsx)(l.Checkbox,{checked:_.isMilestone,onChange:e=>x(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,m.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,m.jsx)(l.InputLabel,{children:o.dialogFieldParent}),(0,m.jsxs)(l.Select,{value:_.parentId,label:o.dialogFieldParent,onChange:e=>v(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,m.jsx)(l.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,m.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,m.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,m.jsx)(at,{label:e.name})]})},e.id))]})]}),(0,m.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,m.jsx)(l.InputLabel,{children:o.dialogFieldDependencies}),(0,m.jsx)(l.Select,{multiple:!0,value:_.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;v(e=>({...e,dependencies:typeof t==`string`?t.split(`,`):t}))},inputProps:{"data-testid":`gantt-dialog-field-dependencies`},renderValue:e=>e.length===0?o.dialogFieldDependenciesNone:e.map(e=>d.find(t=>t.id===e)?.name??e).join(`, `),MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:h.map(e=>(0,m.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,m.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,m.jsx)(at,{label:e.name})]})},e.id))})]})]}),(0,m.jsxs)(l.DialogActions,{children:[(0,m.jsx)(l.Button,{onClick:a,children:o.dialogCancel}),(0,m.jsx)(l.Button,{onClick:C,variant:`contained`,disabled:!S,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function st({open:e,task:t,onConfirm:n,onClose:r}){let i=Tt(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,m.jsxs)(l.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,m.jsx)(l.DialogTitle,{children:i.dialogDeleteTitle}),(0,m.jsx)(l.DialogContent,{children:(0,m.jsx)(l.DialogContentText,{children:a})}),(0,m.jsxs)(l.DialogActions,{children:[(0,m.jsx)(l.Button,{onClick:r,children:i.dialogCancel}),(0,m.jsx)(l.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}var ct={planned:`warning.main`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},lt={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function ut(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function dt({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,onTaskClick:i,onAddTask:a,onEditTask:o,onDeleteTask:s,onStatusChange:u,inlineEdit:d,onInlineRename:f}){let[p,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),v=Tt(),{statusColors:y}=Dt(),b=()=>{g!==null&&g.trim()&&f?.(e,g.trim()),_(null)};return(0,m.jsxs)(l.Box,{className:`gantt-task-row`,"data-testid":`gantt-task-row-${e.id}`,sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,cursor:i?`pointer`:`default`,"&:hover":i?{bgcolor:`action.hover`}:void 0},onClick:()=>i?.(e),children:[(0,m.jsxs)(l.Box,{sx:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:.75,pl:1+e.depth*2,pr:.5,height:`100%`},children:[(0,m.jsx)(l.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,m.jsx)(l.Box,{component:`span`,sx:{fontSize:9,userSelect:`none`,cursor:`pointer`},onClick:t=>{t.stopPropagation(),n(e.id)},children:t.has(e.id)?`▼`:`▶`})}),(0,m.jsx)(l.Box,{sx:{width:8,height:8,borderRadius:e.isMilestone?0:`50%`,transform:e.isMilestone?`rotate(45deg)`:void 0,flexShrink:0,bgcolor:e.color??y?.[e.status]??ct[e.status]??`grey.400`}}),g===null?(0,m.jsx)(l.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:d?`text`:`inherit`},onDoubleClick:d?t=>{t.stopPropagation(),_(e.name)}:void 0,children:e.name}):(0,m.jsx)(l.TextField,{size:`small`,variant:`standard`,value:g,autoFocus:!0,onChange:e=>_(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b()),e.key===`Escape`&&(e.stopPropagation(),_(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),r&&(0,m.jsxs)(l.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[o&&(0,m.jsx)(l.Tooltip,{title:v.editTaskTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,m.jsx)(N.default,{fontSize:`inherit`})})}),a&&(0,m.jsx)(l.Tooltip,{title:v.addTaskTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),a(e)},children:(0,m.jsx)(M.default,{fontSize:`inherit`})})}),s&&(0,m.jsx)(l.Tooltip,{title:v.deleteTaskTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,m.jsx)(w.default,{fontSize:`inherit`})})})]}),(0,m.jsxs)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,m.jsx)(l.Chip,{label:ut(e.status,v),size:`small`,variant:`outlined`,color:e.color??y?.[e.status]?`default`:lt[e.status]??`default`,sx:{height:20,fontSize:10,cursor:u?`pointer`:`default`,...(e.color??y?.[e.status])&&{borderColor:e.color??y?.[e.status],color:e.color??y?.[e.status]}},onClick:u?e=>{e.stopPropagation(),h(e.currentTarget)}:void 0}),u&&(0,m.jsx)(l.Menu,{anchorEl:p,open:!!p,onClose:()=>h(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,m.jsx)(l.MenuItem,{selected:e.status===t,onClick:()=>{u(e,t),h(null)},children:ut(t,v)},t))})]})]})}function ft({scrollRef:e,onScroll:t,panelWidth:n,onTaskClick:r,onAddTask:i,onEditTask:a,onDeleteTask:o,onStatusChange:s,onTasksChange:u,enableBuiltinDialogs:d,onTaskCreated:f,onTaskUpdated:p,onTaskDeleted:h,inlineEdit:g,virtualizeRows:_=!1}){let v=Tt(),y=Ct(),b=Q(e=>e.taskTree),x=Q(e=>e.expandedIds),S=Q(e=>e.toggleExpand),C=Q(e=>e.timeScale),w=Q(e=>e.addTask),T=Q(e=>e.updateTask),E=Q(e=>e.deleteTask),D=(0,c.useMemo)(()=>ze(b,x),[b,x]),O=(0,j.useVirtualizer)({count:D.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[k,A]=(0,c.useState)(!1),[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(!1),[I,L]=(0,c.useState)(null),R=e=>{let t={...e,id:crypto.randomUUID()};w(t),u?.(y.getState().tasks),f?.(t),A(!1)},z=e=>{if(!I)return;let t={...e,id:I.id};T(t),u?.(y.getState().tasks),p?.(t),N(!1)},B=()=>{I&&(E(I.id),u?.(y.getState().tasks),h?.(I.id),F(!1))},V=(e,t)=>{let n={...e,name:t};T(n),u?.(y.getState().tasks),p?.(n)},H=d?e=>{L(e),A(!0)}:i,U=d?e=>{L(e),N(!0)}:a,ee=d?e=>{L(e),F(!0)}:o,W=!!(H||U||ee),G=C===`days`?80:40;return(0,m.jsxs)(l.Box,{ref:e,onScroll:t,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`},children:[(0,m.jsxs)(l.Box,{sx:{height:G,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,m.jsxs)(l.Box,{sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:C===`days`?`1px solid`:void 0,borderColor:C===`days`?`divider`:void 0},children:[(0,m.jsx)(l.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:v.columnName})}),W&&(0,m.jsx)(l.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:v.columnActions})}),(0,m.jsx)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:v.columnStatus})})]}),C===`days`&&(0,m.jsx)(l.Box,{sx:{flex:1}})]}),_?(0,m.jsx)(l.Box,{sx:{position:`relative`,height:O.getTotalSize()},children:O.getVirtualItems().map(e=>(0,m.jsx)(l.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,m.jsx)(dt,{task:D[e.index],expandedIds:x,toggleExpand:S,hasActionsColumn:W,onTaskClick:r,onAddTask:H,onEditTask:U,onDeleteTask:ee,onStatusChange:s,inlineEdit:g,onInlineRename:g?V:void 0})},e.key))}):D.map(e=>(0,m.jsx)(dt,{task:e,expandedIds:x,toggleExpand:S,hasActionsColumn:W,onTaskClick:r,onAddTask:H,onEditTask:U,onDeleteTask:ee,onStatusChange:s,inlineEdit:g,onInlineRename:g?V:void 0},e.id)),d&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(ot,{open:k,mode:`add`,defaultParentId:I?.id,onSave:R,onClose:()=>A(!1)}),(0,m.jsx)(ot,{open:M,mode:`edit`,initialTask:I??void 0,onSave:z,onClose:()=>N(!1)}),(0,m.jsx)(st,{open:P,task:I,onConfirm:B,onClose:()=>F(!1)})]})]})}function pt({items:e}){return(0,m.jsx)(l.Box,{sx:{display:`flex`},children:e.map(e=>(0,m.jsx)(l.Box,{sx:{width:e.width,flexShrink:0,height:40,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRight:`1px solid`,borderColor:`divider`,bgcolor:e.isWeekend?`action.hover`:`transparent`},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function mt({columns:e,groups:t}){return(0,m.jsxs)(l.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:t?80:40,overflow:`visible`},children:[t&&(0,m.jsx)(l.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,m.jsx)(pt,{items:t})}),(0,m.jsx)(pt,{items:e})]})}var ht={planned:`warning.light`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},gt=864e5;function _t(e,t,n){if(n===0)return[];let r=[],i=new Map(e.map((e,t)=>[e.id,t]));for(let a of e){if(!a.dependencies?.length)continue;let o=i.get(a.id),s=Ie(a,t).left/100*n,c=o*40+40/2;for(let o of a.dependencies){let l=i.get(o);if(l===void 0)continue;let u=e[l],d=Ie(u,t),f=(d.left+d.width)/100*n,p=l*40+40/2,m;m=s>=f+48?(f+s)/2:f+24<=n-8?f+24:Math.max(s-24,8),r.push({key:`${o}-${a.id}`,d:`M ${f} ${p} H ${m} V ${c} H ${s}`})}}return r}function vt({scrollRef:e,onScroll:t,onTaskClick:n,onMilestoneClick:r,draggable:i=!1,resizable:a=!1,progressDraggable:o=!1,showCriticalPath:s=!1,virtualizeRows:u=!1,onTaskMoved:d,onTaskResized:f,onTasksChange:p,onStatusChange:h}){let g=(0,l.useTheme)(),_=Q(e=>e.taskTree),v=Q(e=>e.tasks),y=Q(e=>e.expandedIds),b=Q(e=>e.timelineRange),x=Q(e=>e.timeScale),S=Q(e=>e.updateTask),C=Ct(),w=Tt(),{statusColors:T,criticalPathColor:E,milestoneColor:D,todayLineColor:O,weekendColor:k,barBorderRadius:A}=Dt(),M=`gantt-arrow-${(0,c.useId)().replace(/:/g,``)}`,N=(0,c.useMemo)(()=>ze(_,y),[_,y]),P=(0,c.useMemo)(()=>Fe(b,x),[b,x]),F=(0,c.useMemo)(()=>x===`days`?Je(P).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):x===`weeks`?qe(P).map(e=>({key:e.toISOString(),label:`${w.weekColumnPrefix}${Ke(e)}`,width:40})):x===`quarters`?Ze(P).map(e=>({key:e.key,label:e.label,width:360})):We(P).map(e=>({key:e.toISOString(),label:e.toLocaleString(w.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[x,P,w.weekColumnPrefix,w.dateLocale]),I=(0,c.useMemo)(()=>F.reduce((e,t)=>e+t.width,0),[F]),L=(0,c.useMemo)(()=>{if(x!==`days`)return;let e=new Map;for(let t of F){let n=new Date(t.key),r=`${n.getFullYear()}-${n.getMonth()}`;e.has(r)||e.set(r,{label:n.toLocaleString(w.dateLocale,{month:`short`,year:`2-digit`}),width:0}),e.get(r).width+=20}return Array.from(e.entries()).map(([e,t])=>({key:e,...t}))},[x,F,w.dateLocale]),R=(0,c.useMemo)(()=>_t(N,P,I),[N,P,I]),z=(0,c.useMemo)(()=>s?Qe(v):new Set,[s,v]),B=(0,j.useVirtualizer)({count:N.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),V=(0,c.useMemo)(()=>{if(x!==`days`)return[];let e=0;return F.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[x,F]),H=(0,c.useMemo)(()=>{let e=Date.now(),t=P.start.getTime(),n=P.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*I},[P,I]);(0,c.useEffect)(()=>{if(H===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,H-t/2)},[]);let U=x===`days`?20:x===`weeks`?40:x===`quarters`?360:120,ee=L?80:40,W=(0,c.useRef)(1);W.current=I>0?I/((P.end.getTime()-P.start.getTime())/gt):1;let G=(0,c.useRef)(null),K=(0,c.useRef)(null),[q,te]=(0,c.useState)(null),J=(0,c.useRef)(!1),[Y,ne]=(0,c.useState)(null),re=(0,c.useRef)(d);re.current=d;let ie=(0,c.useRef)(f);ie.current=f;let X=(0,c.useRef)(p);X.current=p;let ae=(0,c.useRef)(h);ae.current=h;let oe=(e,t,n)=>{e.stopPropagation(),J.current=!1,G.current={type:n,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate},document.body.style.cursor=n===`resize`?`ew-resize`:`grabbing`;let r=e=>{let t=G.current;if(!t||t.type===`progress`)return;let n=e.clientX-t.startX,r=Math.round(n/W.current);Math.abs(n)>=5&&(J.current=!0);let i={taskId:t.taskId,type:t.type,deltaDays:r};K.current=i,te(i)},i=()=>{document.body.style.cursor=``;let e=G.current,t=K.current;if(e&&t&&J.current&&t.deltaDays!==0){let n=C.getState().tasks.find(t=>t.id===e.taskId);if(n){if(t.type===`move`){let r=Z(e.originalStart,t.deltaDays),i=Z(e.originalEnd,t.deltaDays);S({...n,startDate:r,endDate:i}),re.current?.(n,r,i)}else{let r=Z(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:Z(e.originalStart,1);S({...n,endDate:i}),ie.current?.(n,i)}X.current?.(C.getState().tasks)}}G.current=null,K.current=null,te(null),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},se=(e,t,n,r)=>{e.stopPropagation(),J.current=!1,G.current={type:`progress`,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate,initialProgress:n,barWidthPx:r},document.body.style.cursor=`ew-resize`;let i=e=>{let t=G.current;if(!t||t.type!==`progress`)return;let n=e.clientX-t.startX;Math.abs(n)>=5&&(J.current=!0);let r=n/(t.barWidthPx??1)*100,i=Math.round(Math.max(0,Math.min(100,(t.initialProgress??0)+r))),a={taskId:t.taskId,type:`progress`,deltaDays:0,newProgress:i};K.current=a,te(a)},a=()=>{document.body.style.cursor=``;let e=G.current,t=K.current;if(e&&t&&t.type===`progress`&&t.newProgress!==void 0&&J.current){let n=C.getState().tasks.find(t=>t.id===e.taskId);n&&(S({...n,progress:t.newProgress}),X.current?.(C.getState().tasks))}G.current=null,K.current=null,te(null),document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a)};document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)},ce=e=>e.toLocaleDateString(w.dateLocale,{day:`2-digit`,month:`short`});return(0,m.jsx)(l.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,m.jsxs)(l.Box,{sx:{minWidth:I,position:`relative`},children:[(0,m.jsx)(mt,{columns:F,groups:L}),V.length>0&&(0,m.jsx)(l.Box,{"aria-hidden":!0,"data-testid":`gantt-weekend-strips`,sx:{position:`absolute`,top:ee,left:0,width:I,height:N.length*40,pointerEvents:`none`},children:V.map(e=>(0,m.jsx)(l.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:k??`action.hover`}},e.key))}),(()=>{let e=(e,t,s)=>{let c=q?.taskId===e.id,u=e;if(c&&q)if(q.type===`move`)u={...e,startDate:Z(e.startDate,q.deltaDays),endDate:Z(e.endDate,q.deltaDays)};else if(q.type===`resize`){let t=Z(e.endDate,q.deltaDays);u={...e,endDate:t>e.startDate?t:Z(e.startDate,1)}}else q.type===`progress`&&q.newProgress!==void 0&&(u={...e,progress:q.newProgress});let{left:d,width:f}=Ie(u,P);return(0,m.jsx)(l.Box,{"data-testid":`gantt-bar-row-${e.id}`,style:s===void 0?void 0:{position:`absolute`,top:s,left:0,width:`100%`},sx:{height:40,position:`relative`,borderBottom:`1px solid`,borderColor:`divider`,backgroundImage:e=>`linear-gradient(to right, transparent calc(${U}px - 1px), ${e.palette.divider} calc(${U}px - 1px), ${e.palette.divider} ${U}px)`,backgroundSize:`${U}px 100%`,backgroundRepeat:`repeat-x`},children:e.isMilestone?d>=0&&d<=100?(0,m.jsx)(l.Box,{"data-testid":`gantt-milestone-${e.id}`,sx:{position:`absolute`,left:`${d}%`,top:`50%`,width:12,height:12,bgcolor:D??`warning.main`,transform:`translate(-50%, -50%) rotate(45deg)`,cursor:r?`pointer`:`default`,boxShadow:z.has(e.id)?`0 0 0 2.5px ${E??g.palette.error.main}`:void 0,"&:hover":r?{opacity:.8}:void 0},onClick:()=>r?.(e)}):null:(()=>{let t=Math.max(0,d),r=Math.min(100,d+Math.max(f,.5))-t;return r<=0?null:(0,m.jsxs)(m.Fragment,{children:[c&&q&&q.type!==`progress`&&q.deltaDays!==0&&(0,m.jsx)(l.Box,{sx:{position:`absolute`,left:`${t}%`,top:2,bgcolor:`grey.800`,color:`common.white`,borderRadius:.5,px:.75,lineHeight:`18px`,fontSize:`0.65rem`,whiteSpace:`nowrap`,pointerEvents:`none`,zIndex:100},children:q.type===`move`?`${ce(u.startDate)} – ${ce(u.endDate)}`:`→ ${ce(u.endDate)}`}),c&&q?.type===`progress`&&q.newProgress!==void 0&&(0,m.jsxs)(l.Box,{sx:{position:`absolute`,left:`${t}%`,top:2,bgcolor:`grey.800`,color:`common.white`,borderRadius:.5,px:.75,lineHeight:`18px`,fontSize:`0.65rem`,whiteSpace:`nowrap`,pointerEvents:`none`,zIndex:100},children:[q.newProgress,`%`]}),(0,m.jsxs)(l.Box,{"data-testid":`gantt-bar-${e.id}`,sx:{position:`absolute`,left:`${t}%`,width:`${r}%`,height:16,top:`50%`,transform:`translateY(-50%)`,bgcolor:e.color??T?.[e.status]??ht[e.status]??`grey.300`,borderRadius:A===void 0?1:`${A}px`,overflow:`hidden`,opacity:c?.75:1,boxShadow:z.has(e.id)?`inset 0 0 0 2.5px ${E??g.palette.error.main}`:void 0,cursor:c?`grabbing`:i?`grab`:n?`pointer`:`default`,userSelect:`none`,"&:hover":i||n?{opacity:c?.75:.8}:void 0},onMouseDown:i?t=>oe(t,e,`move`):void 0,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),ne({task:e,mouseX:t.clientX,mouseY:t.clientY})},onClick:()=>{if(J.current){J.current=!1;return}n?.(e)},children:[u.progress!==void 0&&u.progress>0&&(0,m.jsx)(l.Box,{"data-testid":`gantt-progress-${e.id}`,sx:{position:`absolute`,left:0,top:0,width:`${Math.min(u.progress,100)}%`,height:`100%`,bgcolor:`currentColor`,opacity:.4}}),o&&(0,m.jsx)(l.Box,{"data-testid":`gantt-progress-handle-${e.id}`,sx:{position:`absolute`,left:`${Math.min(u.progress??0,100)}%`,top:0,width:6,height:`100%`,transform:`translateX(-50%)`,cursor:`ew-resize`,bgcolor:`rgba(255,255,255,0.35)`},onMouseDown:t=>{t.stopPropagation();let n=r/100*I;se(t,e,u.progress??0,n)}}),a&&(0,m.jsx)(l.Box,{"data-testid":`gantt-resize-handle-${e.id}`,sx:{position:`absolute`,right:0,top:0,width:6,height:`100%`,cursor:`ew-resize`},onMouseDown:t=>{t.stopPropagation(),oe(t,e,`resize`)}})]})]})})()},t)};return u?(0,m.jsx)(l.Box,{sx:{position:`relative`,height:B.getTotalSize()},children:B.getVirtualItems().map(t=>e(N[t.index],t.key,t.start))}):(0,m.jsx)(m.Fragment,{children:N.map(t=>e(t,t.id))})})(),(0,m.jsx)(l.Menu,{open:Y!==null,onClose:()=>ne(null),anchorReference:`anchorPosition`,anchorPosition:Y===null?void 0:{top:Y.mouseY,left:Y.mouseX},children:[`planned`,`in-progress`,`done`,`blocked`].map(e=>{let t={planned:w.statusPlanned,"in-progress":w.statusInProgress,done:w.statusDone,blocked:w.statusBlocked};return(0,m.jsx)(l.MenuItem,{selected:Y?.task.status===e,"data-testid":`gantt-status-menu-${e}`,onClick:()=>{if(!Y)return;let t=C.getState().tasks.find(e=>e.id===Y.task.id)??Y.task;S({...t,status:e}),ae.current?.(t,e),X.current?.(C.getState().tasks),ne(null)},children:t[e]},e)})}),(R.length>0||H!==null)&&(0,m.jsxs)(`svg`,{"data-testid":`gantt-dependency-arrows`,style:{position:`absolute`,top:ee,left:0,width:I,height:N.length*40,pointerEvents:`none`,overflow:`visible`},children:[R.length>0&&(0,m.jsx)(`defs`,{children:(0,m.jsx)(`marker`,{id:M,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,m.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),R.map(e=>(0,m.jsx)(`path`,{"data-testid":`gantt-dep-${e.key}`,d:e.d,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeOpacity:.4,markerEnd:`url(#${M})`},e.key)),H!==null&&(0,m.jsx)(`line`,{"data-testid":`gantt-today-line`,x1:H,y1:0,x2:H,y2:N.length*40,stroke:O??g.palette.primary.main,strokeWidth:1.5,strokeDasharray:`4 2`})]})]})})}function yt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function bt(e){let[t,n,r]=e.split(`-`).map(Number);return!t||!n||!r?null:new Date(t,n-1,r,0,0,0,0)}function xt({onScrollToToday:e,config:t}){let n=Tt(),r=Q(e=>e.timeScale),i=Q(e=>e.defaultTimeScale),a=Q(e=>e.setTimeScale),o=Q(e=>e.timelineRange),s=Q(e=>e.isRangeCustomized),u=Q(e=>e.isExpandedCustomized),d=Q(e=>e.setTimelineRange),f=Q(e=>e.resetTimelineRange),p=Q(e=>e.resetView),h=Q(e=>e.tasks),g=Q(e=>e.expandedIds),_=Q(e=>e.expandAll),v=Q(e=>e.collapseAll),y=h.length>0&&h.every(e=>g.has(e.id)),b=r!==i||s||u,x=(0,c.useMemo)(()=>Date.now(),[]),S=x>=o.start.getTime()&&x<=o.end.getTime(),C={days:n.scaleDays,weeks:n.scaleWeeks,months:n.scaleMonths,quarters:n.scaleQuarters},w={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},T=Object.keys(C).filter(e=>w[e]);return(0,m.jsxs)(l.Box,{"data-testid":`gantt-toolbar`,sx:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:1,px:1.5,py:.75,borderBottom:`1px solid`,borderColor:`divider`,bgcolor:`background.paper`},children:[T.length>0&&(0,m.jsx)(l.ToggleButtonGroup,{value:r,exclusive:!0,onChange:(e,t)=>{t&&a(t)},size:`small`,"aria-label":n.scaleMonths,children:T.map(e=>(0,m.jsx)(l.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:C[e]},e))}),(0,m.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,m.jsx)(l.Tooltip,{title:y?n.collapseAllTooltip:n.expandAllTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:y?v:_,"data-testid":`gantt-expand-collapse-all`,children:y?(0,m.jsx)(L.default,{fontSize:`small`}):(0,m.jsx)(R.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,m.jsx)(l.Tooltip,{title:n.scrollToTodayTooltip,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:e,disabled:!S,"data-testid":`gantt-scroll-to-today`,children:(0,m.jsx)(I.default,{fontSize:`small`})})})}),t.showDateRange&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.TextField,{type:`date`,size:`small`,label:n.rangeFrom,value:yt(o.start),onChange:e=>{let t=bt(e.target.value);t&&d({start:t,end:o.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,m.jsx)(l.TextField,{type:`date`,size:`small`,label:n.rangeTo,value:yt(o.end),onChange:e=>{let t=bt(e.target.value);t&&d({start:o.start,end:t})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-end`}},sx:{width:148}})]}),t.showRangeReset&&s&&(0,m.jsx)(l.Tooltip,{title:n.rangeResetTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:f,"data-testid":`gantt-range-reset`,children:(0,m.jsx)(F.default,{fontSize:`small`})})}),t.showResetView&&(0,m.jsx)(l.Tooltip,{title:n.resetViewTooltip,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:p,disabled:!b,"data-testid":`gantt-reset-view`,children:(0,m.jsx)(P.default,{fontSize:`small`})})})})]})]})}var St=(0,c.createContext)(null);function Q(e){let t=(0,c.useContext)(St);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,k.useStore)(t,e)}function Ct(){let e=(0,c.useContext)(St);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var wt=(0,c.createContext)(tt);function Tt(){return(0,c.useContext)(wt)}var Et=(0,c.createContext)({});function Dt(){return(0,c.useContext)(Et)}function Ot(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var kt=[`days`,`weeks`,`months`,`quarters`],At={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0};function jt({tasks:e,onTaskClick:t,onMilestoneClick:n,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u=!0,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,showToolbar:h=!0,toolbarConfig:g,height:_,width:v,minPanelWidth:y=200,maxPanelWidth:b=600,zoomable:x=!1,draggable:S=!1,resizable:C=!1,inlineEdit:w=!1,progressDraggable:T=!1,showCriticalPath:E=!1,virtualizeRows:D=!1,onTaskMoved:O,onTaskResized:k}){let A=Ot(_,400),j=(0,c.useMemo)(()=>({...At,...g}),[g]),M=Ot(v,`100%`),N=Q(e=>e.setTasks),P=Q(e=>e.timeScale),F=Q(e=>e.setTimeScale),I=Q(e=>e.timelineRange),L=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(!1),[B,V]=(0,c.useState)(320);(0,c.useEffect)(()=>{N(e)},[e,N]);let H=()=>{z.current||=(z.current=!0,R.current&&L.current&&(R.current.scrollTop=L.current.scrollTop),!1)},U=()=>{z.current||=(z.current=!0,L.current&&R.current&&(L.current.scrollTop=R.current.scrollTop),!1)},ee=(0,c.useCallback)(()=>{if(!R.current)return;let e=Fe(I,P),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*R.current.scrollWidth;R.current.scrollLeft=Math.max(0,i-R.current.clientWidth/2)},[I,P]);(0,c.useEffect)(()=>{if(!x||!R.current)return;let e=R.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=kt.indexOf(P);e.deltaY<0&&t>0?F(kt[t-1]):e.deltaY>0&&t<kt.length-1&&F(kt[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,P,F]);let W=(0,c.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=B,r=e=>{let r=e.clientX-t;V(Math.max(y,Math.min(b,n+r)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[B,y,b]);return(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexDirection:`column`,height:A,width:M,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[h&&(0,m.jsx)(xt,{onScrollToToday:ee,config:j}),(0,m.jsxs)(l.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,m.jsx)(ft,{scrollRef:L,onScroll:H,panelWidth:B,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D}),(0,m.jsx)(l.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:W}),(0,m.jsx)(vt,{scrollRef:R,onScroll:U,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onTaskMoved:O,onTaskResized:k,onTasksChange:s,onStatusChange:o})]})]})}function Mt({tasks:e,timeScale:t=`months`,initialExpandAll:n=!1,showToolbar:r=!0,defaultRangeStart:i,defaultRangeEnd:a,translations:o,enableBuiltinDialogs:s=!0,toolbarConfig:l,zoomable:u=!1,draggable:d=!1,resizable:f=!1,inlineEdit:p=!1,progressDraggable:h=!1,showCriticalPath:g=!1,virtualizeRows:_=!1,cascadeDependencies:v=!1,statusColors:y,ganttTheme:b,onTaskClick:x,onMilestoneClick:S,onAddTask:C,onEditTask:w,onDeleteTask:T,onStatusChange:E,onTasksChange:D,onTaskMoved:O,onTaskResized:k,onTaskCreated:A,onTaskUpdated:j,onTaskDeleted:M,height:N,width:P,minPanelWidth:F,maxPanelWidth:I}){let L=(0,c.useMemo)(()=>({...tt,...o}),[o]),[R]=(0,c.useState)(()=>{if(!(i!==void 0||a!==void 0))return et(e,t,n,void 0,v);let r=Pe(e);return et(e,t,n,{start:i??r.start,end:a??r.end},v)}),z=(0,c.useMemo)(()=>({...b,statusColors:{...y,...b?.statusColors}}),[y,b]);return(0,m.jsx)(wt.Provider,{value:L,children:(0,m.jsx)(Et.Provider,{value:z,children:(0,m.jsx)(St.Provider,{value:R,children:(0,m.jsx)(jt,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:l,zoomable:u,draggable:d,resizable:f,inlineEdit:p,progressDraggable:h,showCriticalPath:g,virtualizeRows:_,onTaskClick:x,onMilestoneClick:S,onAddTask:C,onEditTask:w,onDeleteTask:T,onStatusChange:E,onTasksChange:D,onTaskMoved:O,onTaskResized:k,onTaskCreated:A,onTaskUpdated:j,onTaskDeleted:M,height:N,width:P,minPanelWidth:F,maxPanelWidth:I})})})})}var Nt=e=>Math.max(0,Math.min(4,Math.round(e)));function Pt(e,t){let n=e??``,r=n.length,i=/[a-z]/.test(n),a=/[A-Z]/.test(n),o=/\d/.test(n),s=/[^A-Za-z0-9]/.test(n),c=[i,a,o,s].filter(Boolean).length;if(r<t){let e=r===0?0:1;return{score:e,percent:e*25,meterStatus:`weak`,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}let l=0;l+=1,r>=t+4&&(l+=1),c>=2&&(l+=1),c>=3&&(l+=1),/^(.)\1+$/.test(n)&&(l-=2),/1234|abcd|qwer|password|passwort|admin/i.test(n)&&(l-=2);let u=Nt(l),d=u<=1?`weak`:u===2?`ok`:u===3?`good`:`very good`;return{score:u,percent:u*25,meterStatus:d,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}var Ft={label:`Password`,summaryHeaderLabel:`Requirements for your password`,summaryMinChars:`At least {n} characters`,summaryCapitalLetter:`At least 1 capital letter`,summaryLowerCaseLetter:`At least 1 lowercase letter`,summaryNumber:`At least 1 number`,summarySpecialChar:`At least 1 special character`,showPasswordLabel:`Show password`,hidePasswordLabel:`Hide password`,meterAriaLabel:`Password strength`},It={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},Lt={failure:`#cc0000`,success:`#43a047`};function Rt({label:e,fulfilled:t,checkColors:n}){return(0,m.jsxs)(l.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,children:[(0,m.jsx)(l.Typography,{variant:`caption`,children:e}),t?(0,m.jsx)(p.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,m.jsx)(f.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function zt({value:e,name:t,inputRef:n,disabled:r=!1,error:i=!1,helperText:a,autoComplete:o,showPasswordAdornment:s=!0,showMeter:u=!0,showSummary:d=!0,inputSize:f=`medium`,translation:p,meterColors:h,passwordMinLength:g=8,checkColors:_=Lt,onPasswordChange:v}){let y={...Ft,...p},b={...It,...h},x=`${(0,c.useId)()}-password`,[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(``),E=e===void 0?w:e,D=(0,c.useMemo)(()=>Pt(E,g),[E,g]);return(0,m.jsxs)(l.Stack,{children:[(0,m.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:i,children:[(0,m.jsx)(l.InputLabel,{htmlFor:x,size:f,children:y.label}),(0,m.jsx)(l.OutlinedInput,{id:x,type:S?`text`:`password`,fullWidth:!0,size:f,value:E,onChange:t=>{let n=t.target.value;e===void 0&&T(n),v&&v(n,Pt(n,g))},disabled:r,inputRef:n,inputProps:{"data-testid":`psm-input`,name:t,autoComplete:o},endAdornment:s?(0,m.jsx)(l.InputAdornment,{position:`end`,children:(0,m.jsx)(l.IconButton,{"data-testid":`psm-toggle`,disabled:r,"aria-label":S?y.hidePasswordLabel:y.showPasswordLabel,onClick:()=>{C(e=>!e)},onMouseDown:e=>{e.preventDefault()},onMouseUp:e=>{e.preventDefault()},edge:`end`,children:S?(0,m.jsx)(B.default,{}):(0,m.jsx)(z.default,{})})}):null,label:y.label}),a&&(0,m.jsx)(l.FormHelperText,{children:a})]}),u&&(0,m.jsx)(l.Box,{role:`progressbar`,"aria-label":y.meterAriaLabel,"aria-valuenow":D.percent,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,height:`8px`,border:`1px solid`,borderColor:`divider`,borderRadius:`6px`,mt:.5,display:`flex`},children:(0,m.jsx)(l.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${D.percent}%`,backgroundColor:(e=>{switch(e.meterStatus){case`weak`:return b.weak;case`ok`:return b.ok;case`good`:return b.good;case`very good`:return b.veryGood;default:return`transparent`}})(D),borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})}),d&&(0,m.jsxs)(l.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},children:[(0,m.jsx)(l.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:y.summaryHeaderLabel}),(0,m.jsxs)(l.Stack,{direction:`row`,spacing:6,children:[(0,m.jsxs)(l.Stack,{direction:`column`,children:[(0,m.jsx)(Rt,{label:y.summaryMinChars.replace(`{n}`,String(g)),fulfilled:D.length>=g,checkColors:_}),(0,m.jsx)(Rt,{label:y.summaryCapitalLetter,fulfilled:D.hasUpper,checkColors:_}),(0,m.jsx)(Rt,{label:y.summaryLowerCaseLetter,fulfilled:D.hasLower,checkColors:_})]}),(0,m.jsxs)(l.Stack,{direction:`column`,children:[(0,m.jsx)(Rt,{label:y.summaryNumber,fulfilled:D.hasDigit,checkColors:_}),(0,m.jsx)(Rt,{label:y.summarySpecialChar,fulfilled:D.hasSymbol,checkColors:_})]})]})]})]})}function Bt(e){return(0,A.createStore)(t=>({tags:e,searchValue:``,setTags:e=>{t({tags:e})},setSearchValue:e=>{t({searchValue:e})},selectTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e&&!t.disabled?{...t,selected:!0}:t),searchValue:``}))},deleteTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e?{...t,selected:!1}:t)}))},addTag:e=>{t(t=>({tags:[...t.tags,{...e,selected:!0}],searchValue:``}))}}))}var Vt=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`];function Ht({availableTags:e,searchValue:t,translation:n,onSearchChange:r,onTagSelect:i,onTagCreate:a,inputSize:o=`medium`,chipSize:s=`medium`,disabled:u=!1,loading:d=!1,isMaxReached:f=!1,allowCreate:p=!1,listboxMaxHeight:h}){let[g,_]=(0,c.useState)(`default`),[v,y]=(0,c.useState)(!1),b=u||f,x=e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),S=p&&t.trim()!==``&&x.length===0,w=v&&!S,T=()=>{a?.(t.trim(),g),_(`default`)},E=()=>{r(``),_(`default`)};return(0,m.jsxs)(l.Box,{sx:{mb:2},children:[(0,m.jsx)(l.Autocomplete,{options:e,value:null,open:w,onOpen:()=>{S||y(!0)},onClose:()=>y(!1),size:o,disabled:b,loading:d,getOptionLabel:e=>e.label,inputValue:t,onInputChange:(e,t)=>{r(t)},onChange:(e,t)=>{t&&i(t)},slotProps:{listbox:{sx:{display:`flex`,flexWrap:`wrap`,gap:1,padding:1,...h!==void 0&&{maxHeight:h,overflowY:`auto`}}}},renderInput:e=>(0,m.jsx)(l.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:f&&!u?n.maxTagsReachedText:void 0,onKeyDown:e=>{S&&e.key===`Enter`&&(e.preventDefault(),T())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,m.jsxs)(m.Fragment,{children:[S&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:e=>{e.preventDefault()},onClick:T,children:(0,m.jsx)(C.default,{fontSize:`small`})}),(0,m.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>{e.preventDefault()},onClick:E,children:(0,m.jsx)(V.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...t},n)=>{let r=!!(n.foregroundColor||n.backgroundColor);return(0,m.jsx)(`li`,{...t,style:{width:`auto`,padding:0,margin:0},children:(0,m.jsx)(l.Chip,{size:s,label:n.label,color:r?void 0:n.color??`default`,sx:r?{color:n.foregroundColor??`inherit`,backgroundColor:n.backgroundColor??`transparent`}:void 0})},e)},isOptionEqualToValue:(e,t)=>e.id===t.id,noOptionsText:n.noAvailableTagsText,loadingText:n.loadingText}),S&&(0,m.jsx)(l.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:Vt.map(e=>(0,m.jsx)(l.Chip,{size:s,color:e,label:e,variant:g===e?`filled`:`outlined`,onClick:()=>_(e),clickable:!0},e))})]})}function Ut({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,disabled:i=!1}){let a=!!(e.foregroundColor||e.backgroundColor);return(0,m.jsx)(l.Chip,{size:r,label:e.label,onDelete:t?()=>t(e):void 0,onClick:n?()=>n(e):void 0,clickable:!!n&&!e.disabled&&!i,disabled:i||e.disabled,variant:e.selected?`filled`:`outlined`,color:a?void 0:e.color??`default`,sx:{...a&&{color:e.foregroundColor??`inherit`,backgroundColor:e.backgroundColor??`transparent`,borderColor:e.backgroundColor??void 0,"& .MuiChip-deleteIcon":{color:e.foregroundColor?`${e.foregroundColor}99`:`inherit`,"&:hover":{color:e.foregroundColor??`inherit`}}},cursor:n&&!e.disabled&&!i?`pointer`:`default`}})}function Wt({selectedTags:e,translation:t,onTagDelete:n,showSelectedTagsLabel:r,chipSize:i=`medium`,disabled:a=!1,maxVisibleChips:o,popoverPlacement:s=`bottom`}){let[u,d]=(0,c.useState)(null),f=o===void 0?e:e.slice(0,o),p=o===void 0?[]:e.slice(o),h=!!u&&p.length>0,g=s===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},_=s===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,m.jsxs)(l.Box,{sx:{mb:2},children:[r&&(0,m.jsx)(l.Typography,{variant:`subtitle2`,gutterBottom:!0,children:t.selectedTagsLabel}),e.length===0?(0,m.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,m.jsxs)(l.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},children:[f.map(e=>(0,m.jsx)(Ut,{tag:e,onDelete:n,chipSize:i,disabled:a},e.id)),p.length>0&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.Chip,{size:i,label:`+${p.length}`,variant:`outlined`,clickable:!0,onClick:e=>d(e.currentTarget)}),(0,m.jsx)(l.Popover,{open:h,anchorEl:u,onClose:()=>d(null),anchorOrigin:g,transformOrigin:_,children:(0,m.jsx)(l.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},children:p.map(e=>(0,m.jsx)(Ut,{tag:e,onDelete:a?void 0:n,chipSize:i,disabled:a},e.id))})})]})]})]})}var Gt={selectedTagsLabel:`Selected tags`,autoCompleteLabel:`Search and add tags`,noSelectedTagsText:`No tags selected.`,noAvailableTagsText:`No tags available.`,placeholder:`Type to search...`,loadingText:`Loading...`,maxTagsReachedText:`Maximum number of tags reached.`},Kt=(0,c.createContext)(null);function qt(e){let t=(0,c.useContext)(Kt);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,k.useStore)(t,e)}function Jt({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,inputSize:i=`medium`,chipSize:a=`small`,disabled:o=!1,loading:s=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:h,translation:g,onTagSelect:_,onTagDelete:v,onTagsChange:y,onSearchChange:b,onTagCreate:x}){let S=qt(e=>e.tags),C=qt(e=>e.searchValue),w=qt(e=>e.setTags),T=qt(e=>e.setSearchValue),E=qt(e=>e.selectTag),D=qt(e=>e.deleteTag),O=qt(e=>e.addTag);(0,c.useEffect)(()=>{w(e)},[e,w]);let k=(0,c.useMemo)(()=>S.filter(e=>e.selected).sort((e,t)=>e.label.localeCompare(t.label)),[S]),A=(0,c.useMemo)(()=>S.filter(e=>!e.selected&&!e.disabled).sort((e,t)=>e.label.localeCompare(t.label)),[S]),j=u!==void 0&&k.length>=u,M=e=>{y&&y(e.filter(e=>e.selected),e)};return(0,m.jsx)(l.Box,{sx:{width:`100%`},children:(0,m.jsxs)(l.Stack,{children:[t&&(0,m.jsx)(Wt,{selectedTags:k,translation:g,onTagDelete:e=>{D(e.id);let t=S.map(t=>t.id===e.id?{...t,selected:!1}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&v&&v(r,n,t),M(t)},showSelectedTagsLabel:n,chipSize:a,disabled:o,maxVisibleChips:f,popoverPlacement:p}),r&&(0,m.jsx)(Ht,{availableTags:A,searchValue:C,translation:g,onSearchChange:e=>{T(e),b&&b(e)},onTagSelect:e=>{if(e.disabled||e.selected)return;E(e.id);let t=S.map(t=>t.id===e.id?{...t,selected:!0}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&_&&_(r,n,t),M(t)},onTagCreate:(e,t)=>{let n={id:e.toLowerCase().replace(/\s+/g,`-`),label:e,color:t,selected:!0};O(n);let r=[...S,n],i=r.filter(e=>e.selected);_&&_(n,i,r),M(r),x&&x(e,t)},inputSize:i,chipSize:a,disabled:o,loading:s,isMaxReached:j,allowCreate:d,listboxMaxHeight:h})]})})}function Yt({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,translation:i,inputSize:a=`medium`,chipSize:o=`small`,disabled:s=!1,loading:l=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:h,onTagSelect:g,onTagDelete:_,onTagsChange:v,onSearchChange:y,onTagCreate:b}){let x={...Gt,...i},[S]=(0,c.useState)(()=>Bt(e));return(0,m.jsx)(Kt.Provider,{value:S,children:(0,m.jsx)(Jt,{tags:e,showSelectedTags:t,showSelectedTagsLabel:n,showAutoComplete:r,translation:x,inputSize:a,chipSize:o,disabled:s,loading:l,maxTags:u,allowCreate:d,maxVisibleChips:f,popoverPlacement:p,listboxMaxHeight:h,onTagSelect:g,onTagDelete:_,onTagsChange:v,onSearchChange:y,onTagCreate:b})})}var Xt={showBold:!0,showItalic:!0,showUnderline:!0,showStrike:!0,showHeading1:!0,showHeading2:!0,showHeading3:!0,showBulletList:!0,showOrderedList:!0,showBlockquote:!0,showCodeBlock:!0,showLink:!0,showHorizontalRule:!0,showTextColor:!0,showHighlight:!0,showUndoRedo:!0,showClearFormat:!0},Zt={bold:`Bold`,italic:`Italic`,underline:`Underline`,strike:`Strikethrough`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet list`,orderedList:`Numbered list`,blockquote:`Blockquote`,codeBlock:`Code block`,link:`Insert link`,horizontalRule:`Horizontal rule`,textColor:`Text color`,removeTextColor:`Remove text color`,highlight:`Highlight`,removeHighlight:`Remove highlight`,undo:`Undo`,redo:`Redo`,clearFormat:`Clear formatting`,linkDialogTitle:`Insert link`,linkDialogUrlLabel:`URL`,linkDialogSave:`Save`,linkDialogCancel:`Cancel`,linkDialogRemove:`Remove link`,characterCount:`{count} characters`,characterCountMax:`{count} / {max} characters`};function Qt({editor:e,error:t,disabled:n,readonly:r}){return(0,m.jsx)(l.Box,{sx:{flex:1,minHeight:0,display:`flex`,flexDirection:`column`,px:1.5,py:1,cursor:n||r?`default`:`text`,opacity:n?.5:1,"& > div":{flex:1,display:`flex`,flexDirection:`column`,minHeight:0},"& .ProseMirror":{flex:1,minHeight:0,overflowY:`auto`,overflowX:`hidden`,wordBreak:`break-word`,overflowWrap:`break-word`,outline:`none`,"& p.is-editor-empty:first-of-type::before":{content:`attr(data-placeholder)`,color:`text.disabled`,pointerEvents:`none`,float:`left`,height:0},"& h1":{typography:`h4`,mb:1},"& h2":{typography:`h5`,mb:1},"& h3":{typography:`h6`,mb:1},"& p":{my:.5},"& ul, & ol":{pl:3},"& blockquote":{borderLeft:`4px solid`,borderColor:t?`error.main`:`divider`,pl:2,color:`text.secondary`,my:1},"& code":{bgcolor:`action.hover`,px:.5,borderRadius:.5,fontFamily:`monospace`,fontSize:`0.875em`},"& pre":{bgcolor:`action.hover`,p:1.5,borderRadius:1,overflowX:`auto`,"& code":{bgcolor:`transparent`,px:0}},"& a":{color:`primary.main`,cursor:`pointer`},"& mark":{borderRadius:.5,px:.25},"& hr":{borderColor:`divider`,my:2}}},children:(0,m.jsx)(H.EditorContent,{editor:e})})}function $t({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``);(0,c.useEffect)(()=>{if(e){let e=n.getAttributes(`link`).href;a(e??``)}},[e,n]);let o=n.isActive(`link`);function s(){i.trim()?n.chain().focus().extendMarkRange(`link`).setLink({href:i.trim()}).run():n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function u(){n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function d(e){e.key===`Enter`&&s()}return(0,m.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,m.jsx)(l.DialogTitle,{children:r.linkDialogTitle}),(0,m.jsx)(l.DialogContent,{children:(0,m.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,label:r.linkDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:d,variant:`outlined`,size:`small`,sx:{mt:1},placeholder:`https://`})}),(0,m.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,m.jsx)(l.Button,{onClick:u,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,m.jsx)(l.Button,{onClick:t,children:r.linkDialogCancel}),(0,m.jsx)(l.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var en=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],tn=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function nn({color:e,active:t,onClick:n}){return(0,m.jsx)(l.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,m.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>n(e),sx:{width:22,height:22,bgcolor:e,border:t?`2px solid`:`1px solid`,borderColor:t?`primary.main`:e===`#ffffff`||e===`#f5f5dc`?`divider`:`transparent`,borderRadius:.5,cursor:`pointer`,p:0,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`transform 0.1s`,"&:hover":{transform:`scale(1.2)`,zIndex:1}},children:t&&(0,m.jsx)(l.Box,{component:`span`,sx:{width:10,height:6,borderLeft:`2px solid`,borderBottom:`2px solid`,borderColor:e===`#ffffff`||e===`#f5f5dc`||e===`#ffd700`||e===`#ffff00`||e===`#adff2f`||e===`#ffa500`||e===`#b7b7b7`||e===`#d2b48c`?`#000`:`#fff`,transform:`rotate(-45deg) translateY(-1px)`,display:`block`}})})})}function rn({anchorEl:e,open:t,onClose:n,mode:r,activeColor:i,onSelectColor:a,onRemoveColor:o,removeLabel:s}){let u=(0,c.useRef)(null),d=r===`highlight`?tn:en;function f(e){a(e.target.value)}return(0,m.jsxs)(l.Popover,{open:t,anchorEl:e,onClose:n,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{p:1.5}}},children:[(0,m.jsx)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:d.map(e=>(0,m.jsx)(nn,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,m.jsx)(l.Tooltip,{title:`Custom color`,arrow:!0,children:(0,m.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>u.current?.click(),sx:{width:22,height:22,background:`conic-gradient(red, yellow, lime, cyan, blue, magenta, red)`,border:`1px solid`,borderColor:`divider`,borderRadius:.5,cursor:`pointer`,p:0,flexShrink:0,"&:hover":{transform:`scale(1.2)`},transition:`transform 0.1s`}})}),(0,m.jsx)(`input`,{ref:u,type:`color`,defaultValue:i??`#000000`,onChange:f,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,m.jsx)(l.Tooltip,{title:s,arrow:!0,children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:()=>{o(),n()},sx:{borderRadius:1,ml:`auto`},children:(0,m.jsx)(fe.default,{fontSize:`small`})})})]})]})}function $({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,m.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:i,color:r?`primary`:`default`,sx:{borderRadius:1},"aria-label":e,"aria-pressed":r,children:t})})})}function an({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,m.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,m.jsx)(`span`,{children:(0,m.jsxs)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:i,disabled:r,sx:{borderRadius:1,flexDirection:`column`,gap:0,pb:.25},"aria-label":e,children:[(0,m.jsx)(l.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,m.jsx)(l.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function on(){return(0,m.jsx)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:`H1`})}function sn(){return(0,m.jsx)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:`H2`})}function cn(){return(0,m.jsx)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:`H3`})}function ln({editor:e,toolbarConfig:t,translation:n,disabled:r}){let[i,a]=(0,c.useState)(!1),[o,s]=(0,c.useState)(null),[u,d]=(0,c.useState)(null),f=r||!e,p=e?.getAttributes(`textStyle`)?.color,h=e?.getAttributes(`highlight`)?.color,g=t.showBold||t.showItalic||t.showUnderline||t.showStrike,_=t.showHeading1||t.showHeading2||t.showHeading3,v=t.showBulletList||t.showOrderedList,y=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,b=t.showTextColor||t.showHighlight,x=t.showUndoRedo||t.showClearFormat,S=[g,_,v,y,b,x],C=S.filter(Boolean).length;function w(e,t){return!e||S.slice(t+1).findIndex(Boolean)===-1?null:(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[g&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,m.jsx)($,{label:n.bold,icon:(0,m.jsx)(J.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:f}),t.showItalic&&(0,m.jsx)($,{label:n.italic,icon:(0,m.jsx)(Y.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:f}),t.showUnderline&&(0,m.jsx)($,{label:n.underline,icon:(0,m.jsx)(ne.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:f}),t.showStrike&&(0,m.jsx)($,{label:n.strike,icon:(0,m.jsx)(re.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:f})]}),w(g,0),_&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,m.jsx)($,{label:n.heading1,icon:(0,m.jsx)(on,{}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:f}),t.showHeading2&&(0,m.jsx)($,{label:n.heading2,icon:(0,m.jsx)(sn,{}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:f}),t.showHeading3&&(0,m.jsx)($,{label:n.heading3,icon:(0,m.jsx)(cn,{}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:f})]}),w(_,1),v&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,m.jsx)($,{label:n.bulletList,icon:(0,m.jsx)(ie.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:f}),t.showOrderedList&&(0,m.jsx)($,{label:n.orderedList,icon:(0,m.jsx)(X.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:f})]}),w(v,2),y&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,m.jsx)($,{label:n.blockquote,icon:(0,m.jsx)(ae.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:f}),t.showCodeBlock&&(0,m.jsx)($,{label:n.codeBlock,icon:(0,m.jsx)(oe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:f}),t.showLink&&(0,m.jsx)($,{label:n.link,icon:(0,m.jsx)(se.default,{fontSize:`small`}),onClick:()=>a(!0),active:e?.isActive(`link`),disabled:f}),t.showHorizontalRule&&(0,m.jsx)($,{label:n.horizontalRule,icon:(0,m.jsx)(ce.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:f})]}),w(y,3),b&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,m.jsx)(an,{label:n.textColor,icon:(0,m.jsx)(le.default,{fontSize:`small`}),activeColor:p,disabled:f,onClick:e=>s(e.currentTarget)}),t.showHighlight&&(0,m.jsx)(an,{label:n.highlight,icon:(0,m.jsx)(ue.default,{fontSize:`small`}),activeColor:h,disabled:f,onClick:e=>d(e.currentTarget)})]}),w(b,4),x&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)($,{label:n.undo,icon:(0,m.jsx)(T.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:f||!e?.can().undo()}),(0,m.jsx)($,{label:n.redo,icon:(0,m.jsx)(E.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:f||!e?.can().redo()})]}),t.showClearFormat&&(0,m.jsx)($,{label:n.clearFormat,icon:(0,m.jsx)(de.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:f})]}),C===0&&(0,m.jsx)(l.Box,{sx:{height:32}})]}),t.showLink&&e&&(0,m.jsx)($t,{open:i,onClose:()=>a(!1),editor:e,translation:n}),t.showTextColor&&(0,m.jsx)(rn,{anchorEl:o,open:!!o,onClose:()=>s(null),mode:`textColor`,activeColor:p,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,m.jsx)(rn,{anchorEl:u,open:!!u,onClose:()=>d(null),mode:`highlight`,activeColor:h,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight})]})}function un({helperText:e,error:t,showCharacterCount:n,charCount:r,maxCharacters:i,translation:a}){let o=i===void 0?a.characterCount.replace(`{count}`,String(r)):a.characterCountMax.replace(`{count}`,String(r)).replace(`{max}`,String(i));return(0,m.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,m.jsx)(l.FormHelperText,{error:t,children:e??``}),n&&(0,m.jsx)(l.FormHelperText,{sx:{color:i!==void 0&&r>=i?`error`:`text.secondary`},children:o})]})}function dn(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function fn({value:e,onChange:t,placeholder:n,outputFormat:r=`html`,height:i,width:a,showCharacterCount:o=!1,maxCharacters:s,toolbarConfig:u,disabled:d=!1,readonly:f=!1,name:p,error:h=!1,helperText:g,translation:_,onBlur:v,onFocus:y}){let b={...Zt,..._},x={...Xt,...u},S=dn(i),C=dn(a),w=S===`auto`,T=w?void 0:S??200,E=(0,H.useEditor)({shouldRerenderOnTransaction:!0,extensions:[U.StarterKit.configure({link:{openOnClick:!1}}),ee.TextStyle,W.Color,G.Highlight.configure({multicolor:!0}),te.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),K.Placeholder.configure({placeholder:n??``}),...s!==void 0&&s>0?[q.CharacterCount.configure({limit:s})]:o?[q.CharacterCount]:[]],content:e??``,editable:!d&&!f,onUpdate({editor:e}){t&&t(r===`json`?JSON.stringify(e.getJSON()):e.getHTML())},onBlur(){v?.()},onFocus(){y?.()}});(0,c.useEffect)(()=>{!E||e===void 0||(r===`json`?JSON.stringify(E.getJSON()):E.getHTML())!==e&&E.commands.setContent(e,{emitUpdate:!1})},[E,e,r]),(0,c.useEffect)(()=>{E&&E.setEditable(!d&&!f)},[E,d,f]);let D=E?.storage.characterCount?.characters?.()??0,O=o||s!==void 0&&s>0||!!g;return(0,m.jsxs)(l.Box,{sx:{width:C??`100%`,...w?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,m.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...w?{flex:1}:{height:T},borderColor:h?`error.main`:void 0,"&:focus-within":{borderColor:h?`error.main`:`primary.main`,borderWidth:2}},children:[!f&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(ln,{editor:E,toolbarConfig:x,translation:b,disabled:d}),(0,m.jsx)(l.Divider,{})]}),(0,m.jsx)(Qt,{editor:E,error:h,disabled:d,readonly:f})]}),O&&(0,m.jsx)(un,{helperText:g,error:h,showCharacterCount:o||s!==void 0&&s>0,charCount:D,maxCharacters:s&&s>0?s:void 0,translation:b}),p&&(0,m.jsx)(`input`,{type:`hidden`,name:p,value:E?r===`json`?JSON.stringify(E.getJSON()):E.getHTML():``})]})}var pn={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0},mn={format:`Format SQL`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,execute:`Execute`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,errorCount:`{count} error(s)`},hn={standard:pe.StandardSQL,mysql:pe.MySQL,postgresql:pe.PostgreSQL,sqlite:pe.SQLite,mssql:pe.MSSQL};function gn({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:u,identifierColor:d,schema:f,onLint:p,onDiagnosticsChange:_,onViewReady:S,onCursorChange:C,onBlur:w,onFocus:T}){let E=(0,c.useRef)(null),D=(0,c.useRef)(null),O=(0,c.useRef)(t),k=(0,c.useRef)(C),A=(0,c.useRef)(w),j=(0,c.useRef)(T),M=(0,c.useRef)(S),N=(0,c.useRef)(p),P=(0,c.useRef)(_),F=(0,c.useRef)(new g.Compartment),I=(0,c.useRef)(new g.Compartment),L=(0,l.useTheme)(),R=L.palette.mode===`dark`,z=!!p,B=JSON.stringify(f);return(0,c.useEffect)(()=>{O.current=t},[t]),(0,c.useEffect)(()=>{k.current=C},[C]),(0,c.useEffect)(()=>{A.current=w},[w]),(0,c.useEffect)(()=>{j.current=T},[T]),(0,c.useEffect)(()=>{M.current=S},[S]),(0,c.useEffect)(()=>{N.current=p},[p]),(0,c.useEffect)(()=>{P.current=_},[_]),(0,c.useEffect)(()=>{if(!E.current)return;let t=D.current?.state.doc.toString()??e??``,c=s??L.palette.primary.main,l=u??L.palette.success.main,p=d??L.palette.info.main,m=y.HighlightStyle.define([{tag:x.tags.keyword,color:c,fontWeight:`bold`},{tag:x.tags.name,color:p},{tag:[x.tags.string,x.tags.special(x.tags.string)],color:l,fontWeight:`bold`},{tag:x.tags.number,color:L.palette.warning.main},{tag:[x.tags.lineComment,x.tags.blockComment],color:L.palette.text.disabled,fontStyle:`italic`},{tag:x.tags.operator,color:L.palette.text.secondary},{tag:[x.tags.function(x.tags.variableName),x.tags.function(x.tags.name)],color:L.palette.secondary.main},{tag:x.tags.typeName,color:L.palette.info.main},{tag:x.tags.invalid,color:L.palette.error.main,textDecoration:`underline wavy`}]),_=h.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:L.palette.text.primary},".cm-gutters":{backgroundColor:R?L.palette.grey[900]:L.palette.grey[50],color:L.palette.text.disabled,border:`none`,borderRight:`1px solid ${L.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{minWidth:`36px`,paddingLeft:`4px`},".cm-activeLineGutter":{backgroundColor:L.palette.action.selected},".cm-activeLine":{backgroundColor:L.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:L.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:L.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:L.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:L.palette.background.paper,border:`1px solid ${L.palette.divider}`,borderRadius:`4px`,boxShadow:L.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:L.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:L.palette.primary.main+`20`,color:L.palette.primary.main},".cm-completionMatchedText":{color:L.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:L.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:L.palette.error.main},".cm-lint-marker-warning":{color:L.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:L.palette.background.paper,border:`1px solid ${L.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${L.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${L.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${L.palette.info.main}`}},{dark:R}),S=f?Object.fromEntries(f.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,C=async e=>{let t=N.current;if(!t)return[];let n=e.state.doc.toString();try{let r=(await t(n)).map(t=>{let n=Math.max(1,Math.min(t.line,e.state.doc.lines)),r=e.state.doc.line(n);return{from:r.from+Math.max(0,(t.col??1)-1),to:r.to,severity:t.severity??`error`,message:t.message}});return P.current?.(r.length),r}catch{return[]}},w=[_,(0,y.syntaxHighlighting)(m),(0,pe.sql)({dialect:hn[o],schema:S}),(0,v.history)(),(0,me.autocompletion)(),h.keymap.of([...v.defaultKeymap,...v.historyKeymap,...me.completionKeymap]),F.current.of(h.EditorView.editable.of(!r&&!i)),I.current.of(g.EditorState.readOnly.of(i)),(0,h.highlightActiveLine)(),...a?[(0,h.lineNumbers)(),(0,h.highlightActiveLineGutter)()]:[],...n?[(0,h.placeholder)(n)]:[],...z?[(0,b.lintGutter)(),(0,b.linter)(C,{delay:600})]:[],h.EditorView.updateListener.of(e=>{e.docChanged&&O.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);k.current(n.number,t-n.from+1)}),h.EditorView.domEventHandlers({blur:()=>{A.current?.()},focus:()=>{j.current?.()}})],T=new h.EditorView({state:g.EditorState.create({doc:t,extensions:w}),parent:E.current});return D.current=T,M.current(T),()=>{M.current(null),T.destroy(),D.current=null}},[R,o,z,s,u,d,B]),(0,c.useEffect)(()=>{let t=D.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{D.current?.dispatch({effects:[F.current.reconfigure(h.EditorView.editable.of(!r&&!i)),I.current.reconfigure(g.EditorState.readOnly.of(i))]})},[r,i]),(0,m.jsx)(l.Box,{ref:E,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:L.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}var _n={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function vn({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,m.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:n,disabled:i,color:r?`primary`:`default`,sx:{borderRadius:1},"aria-label":e,children:t})})})}function yn({viewRef:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a}){let[o,s]=(0,c.useState)(!1),u=i||!e.current;function d(){let t=e.current?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})}function f(){let t=e.current;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function p(){let t=e.current;t&&((0,v.undo)(t),t.focus())}function h(){let t=e.current;t&&((0,v.redo)(t),t.focus())}function g(){let t=e.current;if(!t)return;let n=t.state.doc.toString();try{let e=(0,ge.format)(n,{language:_n[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function _(){let t=e.current;!t||!a||a(t.state.doc.toString())}let y=t.showFormat,b=t.showCopy||t.showClear,x=t.showUndoRedo,O=t.showExecute&&!!a;return(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[y&&(0,m.jsx)(l.Box,{sx:{display:`flex`,gap:.25},children:(0,m.jsx)(vn,{label:n.format,icon:(0,m.jsx)(D.default,{fontSize:`small`}),onClick:g,disabled:u})}),y&&(b||x)&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),b&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,m.jsx)(vn,{label:o?n.copySuccess:n.copy,icon:o?(0,m.jsx)(C.default,{fontSize:`small`,color:`success`}):(0,m.jsx)(S.default,{fontSize:`small`}),onClick:d,disabled:u}),t.showClear&&(0,m.jsx)(vn,{label:n.clear,icon:(0,m.jsx)(w.default,{fontSize:`small`}),onClick:f,disabled:u})]}),b&&x&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),x&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,m.jsx)(vn,{label:n.undo,icon:(0,m.jsx)(T.default,{fontSize:`small`}),onClick:p,disabled:u}),(0,m.jsx)(vn,{label:n.redo,icon:(0,m.jsx)(E.default,{fontSize:`small`}),onClick:h,disabled:u})]}),O&&(0,m.jsxs)(m.Fragment,{children:[(b||x)&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,m.jsx)(vn,{label:n.execute,icon:(0,m.jsx)(he.default,{fontSize:`small`}),onClick:_,disabled:u})]}),!y&&!b&&!x&&!O&&(0,m.jsx)(l.Box,{sx:{height:32}})]})}function bn({helperText:e,error:t,showLineColumn:n,showErrorCount:r,diagnosticsCount:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o)),u=s.errorCount.replace(`{count}`,String(i));return(0,m.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,m.jsxs)(l.Box,{children:[r&&i>0&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,m.jsx)(_e.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,m.jsx)(l.FormHelperText,{sx:{color:`error.main`,m:0},children:u})]}),(0,m.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,m.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function xn(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function Sn({value:e,onChange:t,placeholder:n,height:r,width:i,disabled:a=!1,readonly:o=!1,error:s=!1,helperText:u,name:d,dialect:f=`standard`,showLineNumbers:p=!0,showLineColumn:h=!0,showErrorCount:g=!1,toolbarConfig:_,translation:v,highlightColors:y,schema:b,onExecute:x,onLint:S,onBlur:C,onFocus:w}){let T={...mn,...v},E={...pn,..._},D=xn(r),O=xn(i),k=D===`auto`,A=k?void 0:D??300,j=(0,c.useRef)(null),[M,N]=(0,c.useState)({line:1,col:1}),[P,F]=(0,c.useState)(0),I=(0,c.useCallback)(e=>{j.current=e},[]),L=(0,c.useCallback)((e,t)=>{N({line:e,col:t})},[]),R=(0,c.useCallback)(e=>{F(e)},[]),z=h||g||!!u;return(0,m.jsxs)(l.Box,{sx:{width:O??`100%`,...k?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,m.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...k?{flex:1}:{height:A},borderColor:s?`error.main`:void 0,"&:focus-within":{borderColor:s?`error.main`:`primary.main`,borderWidth:2}},children:[!o&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(yn,{viewRef:j,toolbarConfig:E,translation:T,dialect:f,disabled:a,onExecute:x}),(0,m.jsx)(l.Divider,{})]}),(0,m.jsx)(gn,{value:e,onChange:t,placeholder:n,disabled:a,readonly:o,showLineNumbers:p,dialect:f,keywordColor:y?.keyword,stringColor:y?.string,identifierColor:y?.identifier,schema:b,onLint:S,onDiagnosticsChange:S?R:void 0,onViewReady:I,onCursorChange:L,onBlur:C,onFocus:w})]}),z&&(0,m.jsx)(bn,{helperText:u,error:s,showLineColumn:h,showErrorCount:g,diagnosticsCount:P,cursorLine:M.line,cursorCol:M.col,translation:T}),d&&(0,m.jsx)(`input`,{type:`hidden`,name:d,value:e??``})]})}exports.ConfirmDialogProvider=Ce,exports.DEFAULT_CHECK_COLORS=Lt,exports.DEFAULT_CONFIRM_DIALOG_TRANSLATION=ve,exports.DEFAULT_GANTT_TRANSLATIONS=tt,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=Te,exports.DEFAULT_JSON_EDITOR_TRANSLATION=Ee,exports.DEFAULT_METER_COLORS=It,exports.DEFAULT_PASSWORD_TRANSLATIONS=Ft,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=Xt,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=Zt,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=pn,exports.DEFAULT_SQL_EDITOR_TRANSLATION=mn,exports.DEFAULT_TAG_SELECTION_TRANSLATION=Gt,exports.GanttChart=Mt,exports.JsonEditor=Ne,exports.PasswordStrengthMeter=zt,exports.RichTextEditor=fn,exports.SqlEditor=Sn,exports.TagSelection=Yt,exports.useConfirm=we,exports.useGanttChartStore=Q,exports.useGanttTheme=Dt,exports.useGanttTranslations=Tt,exports.useRawGanttChartStore=Ct;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`),l=require(`@mui/material`),u=require(`@mui/icons-material/InfoOutlined`);u=s(u,1);let d=require(`@mui/icons-material/WarningAmberOutlined`);d=s(d,1);let f=require(`@mui/icons-material/ErrorOutlined`);f=s(f,1);let p=require(`@mui/icons-material/CheckCircleOutlined`);p=s(p,1);let m=require(`react/jsx-runtime`),h=require(`@codemirror/view`),g=require(`@codemirror/state`),_=require(`@codemirror/lang-json`),v=require(`@codemirror/commands`),y=require(`@codemirror/language`),b=require(`@codemirror/lint`),x=require(`@lezer/highlight`),S=require(`@mui/icons-material/ContentCopy`);S=s(S,1);let C=require(`@mui/icons-material/Check`);C=s(C,1);let w=require(`@mui/icons-material/Delete`);w=s(w,1);let T=require(`@mui/icons-material/Undo`);T=s(T,1);let E=require(`@mui/icons-material/Redo`);E=s(E,1);let D=require(`@mui/icons-material/AutoFixHigh`);D=s(D,1);let O=require(`@mui/icons-material/Compress`);O=s(O,1);let k=require(`zustand`),A=require(`zustand/vanilla`),j=require(`@tanstack/react-virtual`),M=require(`@mui/icons-material/Add`);M=s(M,1);let N=require(`@mui/icons-material/Edit`);N=s(N,1);let P=require(`@mui/icons-material/RestartAlt`);P=s(P,1);let F=require(`@mui/icons-material/Restore`);F=s(F,1);let I=require(`@mui/icons-material/Today`);I=s(I,1);let L=require(`@mui/icons-material/UnfoldLess`);L=s(L,1);let R=require(`@mui/icons-material/UnfoldMore`);R=s(R,1);let z=require(`@mui/icons-material/Visibility`);z=s(z,1);let B=require(`@mui/icons-material/VisibilityOff`);B=s(B,1);let V=require(`@mui/icons-material/Close`);V=s(V,1);let H=require(`@tiptap/react`),U=require(`@tiptap/starter-kit`),W=require(`@tiptap/extension-text-style`),G=require(`@tiptap/extension-color`),ee=require(`@tiptap/extension-highlight`),te=require(`@tiptap/extension-placeholder`),ne=require(`@tiptap/extension-character-count`),re=require(`tiptap-markdown`),ie=require(`@mui/icons-material/Fullscreen`);ie=s(ie,1);let ae=require(`@mui/icons-material/FullscreenExit`);ae=s(ae,1);let oe=require(`@mui/icons-material/FormatBold`);oe=s(oe,1);let se=require(`@mui/icons-material/FormatItalic`);se=s(se,1);let ce=require(`@mui/icons-material/FormatUnderlined`);ce=s(ce,1);let le=require(`@mui/icons-material/StrikethroughS`);le=s(le,1);let ue=require(`@mui/icons-material/FormatListBulleted`);ue=s(ue,1);let de=require(`@mui/icons-material/FormatListNumbered`);de=s(de,1);let fe=require(`@mui/icons-material/FormatQuote`);fe=s(fe,1);let pe=require(`@mui/icons-material/Code`);pe=s(pe,1);let me=require(`@mui/icons-material/InsertLink`);me=s(me,1);let he=require(`@mui/icons-material/HorizontalRule`);he=s(he,1);let ge=require(`@mui/icons-material/FormatColorText`);ge=s(ge,1);let _e=require(`@mui/icons-material/BorderColor`);_e=s(_e,1);let ve=require(`@mui/icons-material/FormatClear`);ve=s(ve,1);let ye=require(`@mui/icons-material/FormatColorReset`);ye=s(ye,1);let K=require(`@codemirror/lang-sql`),be=require(`@codemirror/autocomplete`),xe=require(`@mui/icons-material/PlayArrow`);xe=s(xe,1);let Se=require(`sql-formatter`),Ce=require(`@mui/icons-material/WarningAmber`);Ce=s(Ce,1);var we={confirmLabel:`Confirm`,cancelLabel:`Cancel`},Te={info:u.default,warning:d.default,error:f.default,success:p.default},Ee={info:`primary`,warning:`warning`,error:`error`,success:`success`};function De({open:e,options:t,translation:n,onConfirm:r,onCancel:i}){let{title:a,description:o,confirmLabel:s,cancelLabel:c,severity:u=`info`,hideCancelButton:d=!1,maxWidth:f=`xs`,showIcon:p=!0}=t,h=p?Te[u]:null,g=Ee[u],_=s??n.confirmLabel,v=c??n.cancelLabel;return(0,m.jsxs)(l.Dialog,{open:e,onClose:i,maxWidth:f,fullWidth:!0,"aria-labelledby":a?`confirm-dialog-title`:void 0,"aria-describedby":o?`confirm-dialog-description`:void 0,children:[a&&(0,m.jsxs)(l.DialogTitle,{id:`confirm-dialog-title`,"data-testid":`confirm-dialog-title`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[h&&(0,m.jsx)(h,{color:u,"data-testid":`confirm-dialog-icon`,fontSize:`small`}),a]}),o&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.Divider,{}),(0,m.jsx)(l.DialogContent,{children:typeof o==`string`?(0,m.jsx)(l.Typography,{id:`confirm-dialog-description`,"data-testid":`confirm-dialog-description`,variant:`body2`,color:`text.secondary`,children:o}):(0,m.jsx)(`div`,{id:`confirm-dialog-description`,"data-testid":`confirm-dialog-description`,children:o})})]}),(0,m.jsx)(l.Divider,{}),(0,m.jsxs)(l.DialogActions,{sx:{px:2,py:1.5},children:[!d&&(0,m.jsx)(l.Button,{"data-testid":`confirm-dialog-cancel-btn`,onClick:i,color:`inherit`,children:v}),(0,m.jsx)(l.Button,{"data-testid":`confirm-dialog-confirm-btn`,onClick:r,color:g,variant:`contained`,autoFocus:!0,children:_})]})]})}var Oe=(0,c.createContext)(()=>Promise.resolve(!1));function ke({children:e,translation:t}){let n={...we,...t},r=(0,c.useRef)(null),[i,a]=(0,c.useState)({open:!1,options:{}}),o=(0,c.useCallback)(e=>(r.current?.(!1),new Promise(t=>{r.current=t,a({open:!0,options:e})})),[]);return(0,m.jsxs)(Oe.Provider,{value:o,children:[e,(0,m.jsx)(De,{open:i.open,options:i.options,translation:n,onConfirm:()=>{r.current?.(!0),r.current=null,a(e=>({...e,open:!1}))},onCancel:()=>{r.current?.(!1),r.current=null,a(e=>({...e,open:!1}))}})]})}function Ae(){return(0,c.useContext)(Oe)}var je={showFormat:!0,showCompact:!0,showCopy:!0,showClear:!0,showUndoRedo:!0},Me={format:`Format JSON`,compact:`Compact JSON`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,validJson:`Valid JSON`,invalidJson:`Invalid JSON`};function Ne({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,highlightColors:o,onViewReady:s,onCursorChange:u,onBlur:d,onFocus:f}){let p=(0,c.useRef)(null),S=(0,c.useRef)(null),C=(0,c.useRef)(t),w=(0,c.useRef)(u),T=(0,c.useRef)(d),E=(0,c.useRef)(f),D=(0,c.useRef)(s),O=(0,c.useRef)(new g.Compartment),k=(0,c.useRef)(new g.Compartment),A=(0,l.useTheme)(),j=A.palette.mode===`dark`,M=o?.propertyName??A.palette.primary.main,N=o?.string??A.palette.success.main,P=o?.number??A.palette.warning.main,F=o?.boolean??A.palette.info.main,I=o?.null??A.palette.text.secondary;return(0,c.useEffect)(()=>{C.current=t},[t]),(0,c.useEffect)(()=>{w.current=u},[u]),(0,c.useEffect)(()=>{T.current=d},[d]),(0,c.useEffect)(()=>{E.current=f},[f]),(0,c.useEffect)(()=>{D.current=s},[s]),(0,c.useEffect)(()=>{if(!p.current)return;let t=S.current?.state.doc.toString()??e??``,o=y.HighlightStyle.define([{tag:x.tags.propertyName,color:M,fontWeight:`bold`},{tag:x.tags.string,color:N},{tag:x.tags.number,color:P},{tag:x.tags.bool,color:F,fontWeight:`bold`},{tag:x.tags.null,color:I,fontStyle:`italic`},{tag:x.tags.bracket,color:A.palette.text.secondary},{tag:x.tags.punctuation,color:A.palette.text.disabled},{tag:x.tags.invalid,color:A.palette.error.main,textDecoration:`underline wavy`}]),s=[h.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:A.palette.text.primary},".cm-gutters":{backgroundColor:j?A.palette.grey[900]:A.palette.grey[50],color:A.palette.text.disabled,border:`none`,borderRight:`1px solid ${A.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{minWidth:`36px`,paddingLeft:`4px`},".cm-activeLineGutter":{backgroundColor:A.palette.action.selected},".cm-activeLine":{backgroundColor:A.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:A.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:A.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:A.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:A.palette.error.main},".cm-lint-marker-warning":{color:A.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:A.palette.background.paper,border:`1px solid ${A.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${A.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${A.palette.warning.main}`}},{dark:j}),(0,y.syntaxHighlighting)(o),(0,_.json)(),(0,b.lintGutter)(),(0,b.linter)((0,_.jsonParseLinter)()),(0,v.history)(),h.keymap.of([...v.defaultKeymap,...v.historyKeymap]),O.current.of(h.EditorView.editable.of(!r&&!i)),k.current.of(g.EditorState.readOnly.of(i)),(0,h.highlightActiveLine)(),...a?[(0,h.lineNumbers)(),(0,h.highlightActiveLineGutter)()]:[],...n?[(0,h.placeholder)(n)]:[],h.EditorView.updateListener.of(e=>{e.docChanged&&C.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);w.current(n.number,t-n.from+1)}),h.EditorView.domEventHandlers({blur:()=>{T.current?.()},focus:()=>{E.current?.()}})],c=new h.EditorView({state:g.EditorState.create({doc:t,extensions:s}),parent:p.current});return S.current=c,D.current(c),()=>{D.current(null),c.destroy(),S.current=null}},[j,M,N,P,F,I]),(0,c.useEffect)(()=>{let t=S.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{S.current?.dispatch({effects:[O.current.reconfigure(h.EditorView.editable.of(!r&&!i)),k.current.reconfigure(g.EditorState.readOnly.of(i))]})},[r,i]),(0,m.jsx)(l.Box,{ref:p,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:A.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function q({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,m.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:i,color:r?`primary`:`default`,sx:{borderRadius:1},"aria-label":e,"aria-pressed":r,children:t})})})}function Pe({viewRef:e,toolbarConfig:t,translation:n,indent:r,disabled:i}){let[a,o]=(0,c.useState)(!1),s=i||!e.current;function u(){let t=e.current;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n),null,r);t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function d(){let t=e.current;if(!t)return;let n=t.state.doc.toString();try{let e=JSON.stringify(JSON.parse(n));t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function f(){let t=e.current?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})}function p(){let t=e.current;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function h(){let t=e.current;t&&((0,v.undo)(t),t.focus())}function g(){let t=e.current;t&&((0,v.redo)(t),t.focus())}let _=t.showFormat||t.showCompact,y=t.showCopy||t.showClear,b=t.showUndoRedo;return(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`JSON editor actions`,children:[_&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,m.jsx)(q,{label:n.format,icon:(0,m.jsx)(D.default,{fontSize:`small`}),onClick:u,disabled:s}),t.showCompact&&(0,m.jsx)(q,{label:n.compact,icon:(0,m.jsx)(O.default,{fontSize:`small`}),onClick:d,disabled:s})]}),_&&(y||b)&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),y&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,m.jsx)(q,{label:a?n.copySuccess:n.copy,icon:a?(0,m.jsx)(C.default,{fontSize:`small`,color:`success`}):(0,m.jsx)(S.default,{fontSize:`small`}),onClick:f,disabled:s}),t.showClear&&(0,m.jsx)(q,{label:n.clear,icon:(0,m.jsx)(w.default,{fontSize:`small`}),onClick:p,disabled:s})]}),y&&b&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),b&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,m.jsx)(q,{label:n.undo,icon:(0,m.jsx)(T.default,{fontSize:`small`}),onClick:h,disabled:s}),(0,m.jsx)(q,{label:n.redo,icon:(0,m.jsx)(E.default,{fontSize:`small`}),onClick:g,disabled:s})]}),!_&&!y&&!b&&(0,m.jsx)(l.Box,{sx:{height:32}})]})}function Fe({helperText:e,error:t,showLineColumn:n,showValidation:r,isValid:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o));return(0,m.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,m.jsxs)(l.Box,{children:[r&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,m.jsx)(p.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,m.jsx)(f.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,m.jsx)(l.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,m.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,m.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function J(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function Ie(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function Le({value:e,onChange:t,onValidChange:n,placeholder:r,height:i,width:a,disabled:o=!1,readonly:s=!1,error:u=!1,helperText:d,name:f,indent:p=2,showLineNumbers:h=!0,showLineColumn:g=!0,showValidation:_=!1,toolbarConfig:v,translation:y,highlightColors:b,onBlur:x,onFocus:S}){let C={...Me,...y},w={...je,...v},T=J(i),E=J(a),D=T===`auto`,O=D?void 0:T??300,k=(0,c.useRef)(null),[A,j]=(0,c.useState)({line:1,col:1}),[M,N]=(0,c.useState)(()=>Ie(e??``)),P=(0,c.useCallback)(e=>{k.current=e},[]),F=(0,c.useCallback)((e,t)=>{j({line:e,col:t})},[]),I=(0,c.useCallback)(e=>{let r=Ie(e);N(r),n?.(r),t?.(e)},[t,n]),L=g||_||!!d;return(0,m.jsxs)(l.Box,{sx:{width:E??`100%`,...D?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,m.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...D?{flex:1}:{height:O},borderColor:u?`error.main`:void 0,"&:focus-within":{borderColor:u?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Pe,{viewRef:k,toolbarConfig:w,translation:C,indent:p,disabled:o}),(0,m.jsx)(l.Divider,{})]}),(0,m.jsx)(Ne,{value:e,onChange:I,placeholder:r,disabled:o,readonly:s,showLineNumbers:h,highlightColors:b,onViewReady:P,onCursorChange:F,onBlur:x,onFocus:S})]}),L&&(0,m.jsx)(Fe,{helperText:d,error:u,showLineColumn:g,showValidation:_,isValid:M,cursorLine:A.line,cursorCol:A.col,translation:C}),f&&(0,m.jsx)(`input`,{type:`hidden`,name:f,value:e??``})]})}function Y(e){let t=new Date,n=Qe(t),r=$e(t);if(e.length===0)return{start:n,end:r};let i=e.map(e=>e.startDate.getTime()),a=e.map(e=>e.endDate.getTime()),o=Ue(Ge(new Date(Math.min(...i)),-1)),s=We(Ge(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function Re(e,t){return t===`weeks`?{start:Je(e.start),end:e.end}:t===`quarters`?{start:Qe(e.start),end:$e(e.end)}:e}function ze(e,t){let n=t.end.getTime()-t.start.getTime();if(n<=0)return{left:0,width:0};let r=(e.startDate.getTime()-t.start.getTime())/n*100,i=(e.endDate.getTime()-e.startDate.getTime())/n*100;return{left:Math.max(0,r),width:Math.max(0,i)}}function Be(e){let t=new Map;for(let n of e)t.set(n.id,{...n,children:[],depth:0});let n=[];for(let e of t.values())e.parentId&&t.has(e.parentId)?t.get(e.parentId).children.push(e):n.push(e);return Ve(n,0),n}function Ve(e,t){for(let n of e)n.depth=t,Ve(n.children,t+1)}function He(e,t){let n=[];function r(e){for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)}return r(e),n}function Ue(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function We(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function Ge(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function X(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function Ke(e,t,n){if(n===0)return e;let r=new Map;for(let t of e)for(let e of t.dependencies??[])r.has(e)||r.set(e,[]),r.get(e).push(t.id);let i=new Map(e.map(e=>[e.id,e])),a=[...r.get(t)??[]],o=new Set;for(;a.length>0;){let e=a.shift();if(o.has(e))continue;o.add(e);let t=i.get(e);i.set(e,{...t,startDate:new Date(t.startDate.getTime()+n),endDate:new Date(t.endDate.getTime()+n)}),a.push(...r.get(e)??[])}return e.map(e=>i.get(e.id))}function qe(e){let t=[],n=Ue(e.start);for(;n<=e.end;)t.push(n),n=Ge(n,1);return t}function Je(e){let t=new Date(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t.setHours(0,0,0,0),t}function Ye(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-n);let r=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-r.getTime())/864e5+1)/7)}function Xe(e){let t=[],n=Je(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function Ze(e){let t=[],n=new Date(e.start.getFullYear(),e.start.getMonth(),e.start.getDate(),0,0,0,0),r=new Date(e.end.getFullYear(),e.end.getMonth(),e.end.getDate(),0,0,0,0).getTime();for(;n.getTime()<=r;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1,0,0,0,0);return t}function Qe(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function $e(e){let t=Math.floor(e.getMonth()/3)*3+2;return We(new Date(e.getFullYear(),t,1))}function et(e){let t=[],n=Qe(e.start);for(;n<=e.end;){let e=Math.floor(n.getMonth()/3)+1;t.push({key:`${n.getFullYear()}-Q${e}`,label:`Q${e} ${n.getFullYear()}`,start:new Date(n)}),n=new Date(n.getFullYear(),n.getMonth()+3,1)}return t}function tt(e){if(e.length===0)return new Set;let t=new Map;for(let n of e)for(let e of n.dependencies??[])t.has(e)||t.set(e,[]),t.get(e).push(n.id);let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=new Set;function a(e){if(r.has(e))return r.get(e);if(i.has(e))return n.get(e)?.endDate.getTime()??0;i.add(e);let o=n.get(e)?.endDate.getTime()??0;for(let n of t.get(e)??[])o=Math.max(o,a(n));return i.delete(e),r.set(e,o),o}for(let t of e)a(t.id);let o=Math.max(...r.values()),s=new Set;for(let t of e)a(t.id)===o&&s.add(t.id);return s}function nt(e,t){let n=t.startDate<e.start?Ue(Ge(t.startDate,-1)):e.start,r=t.endDate>e.end?We(Ge(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function rt(e,t=`months`,n=!1,r,i=!1){let a=Y(e);return(0,A.createStore)((o,s)=>({tasks:e,taskTree:Be(e),expandedIds:n?new Set(e.map(e=>e.id)):new Set(e.filter(e=>!e.parentId).map(e=>e.id)),timeScale:t,timelineRange:r??a,isRangeCustomized:r!==void 0,cascadeDependencies:i,defaultTimeScale:t,initialExpandAll:n,isExpandedCustomized:!1,setTasks:e=>{o(t=>({tasks:e,taskTree:Be(e),...t.isRangeCustomized?{}:{timelineRange:Y(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:Be(n),timelineRange:nt(t.timelineRange,e)}})},updateTask:e=>{o(t=>{let n=t.tasks.find(t=>t.id===e.id),r=t.tasks.map(t=>t.id===e.id?e:t);if(t.cascadeDependencies&&n){let t=e.endDate.getTime()-n.endDate.getTime();r=Ke(r,e.id,t)}let i=nt(t.timelineRange,e);for(let e of r)i=nt(i,e);return{tasks:r,taskTree:Be(r),timelineRange:i}})},deleteTask:e=>{o(t=>{let n=new Set,r=e=>{n.add(e),t.tasks.filter(t=>t.parentId===e).forEach(e=>r(e.id))};r(e);let i=t.tasks.filter(e=>!n.has(e.id));return{tasks:i,taskTree:Be(i)}})},toggleExpand:e=>{o(t=>{let n=new Set(t.expandedIds);return n.has(e)?n.delete(e):n.add(e),{expandedIds:n}})},expandAll:()=>{o(e=>({expandedIds:new Set(e.tasks.map(e=>e.id)),isExpandedCustomized:!0}))},collapseAll:()=>{o({expandedIds:new Set,isExpandedCustomized:!0})},setTimeScale:e=>{o({timeScale:e})},setTimelineRange:e=>{o({timelineRange:e,isRangeCustomized:!0})},resetTimelineRange:()=>{o(e=>({timelineRange:Y(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:Y(e.tasks),isRangeCustomized:!1,isExpandedCustomized:!1,expandedIds:e.initialExpandAll?new Set(e.tasks.map(e=>e.id)):new Set(e.tasks.filter(e=>!e.parentId).map(e=>e.id))}))},getVisibleTasks:()=>{let{taskTree:e,expandedIds:t}=s();return He(e,t)}}))}var it={scaleDays:`Tage`,scaleWeeks:`Wochen`,scaleMonths:`Monate`,scaleQuarters:`Quartale`,rangeFrom:`Von`,rangeTo:`Bis`,rangeResetTooltip:`Bereich zurücksetzen`,columnName:`Name`,columnStatus:`Status`,statusPlanned:`Planned`,statusInProgress:`In Progress`,statusDone:`Done`,statusBlocked:`Blocked`,weekColumnPrefix:`KW`,dateLocale:`de-DE`,dialogAddTitle:`Aufgabe hinzufügen`,dialogEditTitle:`Aufgabe bearbeiten`,dialogDeleteTitle:`Aufgabe löschen`,dialogSave:`Speichern`,dialogCancel:`Abbrechen`,dialogDelete:`Löschen`,dialogFieldName:`Name`,dialogFieldStartDate:`Startdatum`,dialogFieldEndDate:`Enddatum`,dialogFieldStatus:`Status`,dialogFieldMilestone:`Ist Meilenstein`,dialogFieldParent:`Übergeordnete Aufgabe`,dialogFieldParentNone:`— Keine —`,dialogDeleteConfirm:`Soll die Aufgabe "{name}" wirklich gelöscht werden?`,dialogFieldDependencies:`Vorgänger`,dialogFieldDependenciesNone:`— Keine —`,scrollToTodayTooltip:`Zum heutigen Tag`,expandAllTooltip:`Alle aufklappen`,collapseAllTooltip:`Alle zuklappen`,resetViewTooltip:`Ansicht zurücksetzen`,columnActions:`Aktionen`,addTaskTooltip:`Aufgabe hinzufügen`,editTaskTooltip:`Aufgabe bearbeiten`,deleteTaskTooltip:`Aufgabe löschen`},at={planned:`warning.light`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},ot={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function st(e){return e.toISOString().slice(0,10)}function ct(e,t,n){return e<t?t:e>n?n:e}function lt(e){return e.flatMap(e=>[e,...lt(e.children)])}function ut({label:e}){let t=(0,c.useRef)(null),[n,r]=(0,c.useState)(!1);return(0,m.jsx)(l.Tooltip,{title:e,disableHoverListener:!n,children:(0,m.jsx)(l.Typography,{ref:t,component:`span`,variant:`body2`,noWrap:!0,sx:{display:`block`,overflow:`hidden`,textOverflow:`ellipsis`,minWidth:0},onMouseEnter:()=>{t.current&&r(t.current.scrollWidth>t.current.clientWidth)},children:e})})}function dt({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=Q(),s=Z(e=>e.taskTree),u=Z(e=>e.timelineRange),d=(0,c.useMemo)(()=>lt(s),[s]),f=(0,c.useMemo)(()=>{if(t===`add`||!n)return new Set;let e=t=>[t.id,...t.children.flatMap(e)],r=d.find(e=>e.id===n.id);return new Set(r?e(r):[n.id])},[t,n,d]),p=d.filter(e=>!f.has(e.id)),h=p,g=st(ct(new Date,u.start,u.end)),[_,v]=(0,c.useState)({name:``,startDate:g,endDate:g,status:`planned`,isMilestone:!1,parentId:``,dependencies:[]});(0,c.useEffect)(()=>{if(!e)return;let i=st(ct(new Date,u.start,u.end));v(t===`edit`&&n?{name:n.name,startDate:st(n.startDate),endDate:st(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,parentId:n.parentId??``,dependencies:n.dependencies??[]}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,parentId:r??``,dependencies:[]})},[e,t,n,r,u]);let y=e=>{v(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},b=e=>{v(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},x=e=>{v(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate}))},S=_.name.trim()!==``&&_.startDate!==``&&_.endDate!==``&&_.endDate>=_.startDate,C=()=>{S&&i({name:_.name.trim(),startDate:new Date(_.startDate),endDate:new Date(_.endDate),status:_.status,isMilestone:_.isMilestone||void 0,parentId:_.parentId||void 0,dependencies:_.dependencies.length>0?_.dependencies:void 0})},w=[`planned`,`in-progress`,`done`,`blocked`],T={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,m.jsxs)(l.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,m.jsx)(l.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,m.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,m.jsx)(l.TextField,{label:o.dialogFieldName,value:_.name,onChange:e=>v(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,m.jsx)(l.TextField,{label:o.dialogFieldStartDate,type:`date`,value:_.startDate,onChange:e=>y(e.target.value),required:!0,fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-start`}}}),(0,m.jsx)(l.TextField,{label:o.dialogFieldEndDate,type:`date`,value:_.endDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,disabled:_.isMilestone,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-end`,min:_.startDate}}}),(0,m.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,m.jsx)(l.InputLabel,{children:o.dialogFieldStatus}),(0,m.jsx)(l.Select,{value:_.status,label:o.dialogFieldStatus,onChange:e=>v(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:w.map(e=>(0,m.jsx)(l.MenuItem,{value:e,children:T[e]},e))})]}),(0,m.jsx)(l.FormControlLabel,{control:(0,m.jsx)(l.Checkbox,{checked:_.isMilestone,onChange:e=>x(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,m.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,m.jsx)(l.InputLabel,{children:o.dialogFieldParent}),(0,m.jsxs)(l.Select,{value:_.parentId,label:o.dialogFieldParent,onChange:e=>v(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,m.jsx)(l.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,m.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,m.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,m.jsx)(ut,{label:e.name})]})},e.id))]})]}),(0,m.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,m.jsx)(l.InputLabel,{children:o.dialogFieldDependencies}),(0,m.jsx)(l.Select,{multiple:!0,value:_.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;v(e=>({...e,dependencies:typeof t==`string`?t.split(`,`):t}))},inputProps:{"data-testid":`gantt-dialog-field-dependencies`},renderValue:e=>e.length===0?o.dialogFieldDependenciesNone:e.map(e=>d.find(t=>t.id===e)?.name??e).join(`, `),MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:h.map(e=>(0,m.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,pl:e.depth*2,gap:.75,minWidth:0,width:`100%`,overflow:`hidden`},children:[e.depth>0&&(0,m.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,m.jsx)(ut,{label:e.name})]})},e.id))})]})]}),(0,m.jsxs)(l.DialogActions,{children:[(0,m.jsx)(l.Button,{onClick:a,children:o.dialogCancel}),(0,m.jsx)(l.Button,{onClick:C,variant:`contained`,disabled:!S,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function ft({open:e,task:t,onConfirm:n,onClose:r}){let i=Q(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,m.jsxs)(l.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,m.jsx)(l.DialogTitle,{children:i.dialogDeleteTitle}),(0,m.jsx)(l.DialogContent,{children:(0,m.jsx)(l.DialogContentText,{children:a})}),(0,m.jsxs)(l.DialogActions,{children:[(0,m.jsx)(l.Button,{onClick:r,children:i.dialogCancel}),(0,m.jsx)(l.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}function pt(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function mt({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,onTaskClick:i,onAddTask:a,onEditTask:o,onDeleteTask:s,onStatusChange:u,inlineEdit:d,onInlineRename:f}){let[p,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),v=Q(),{statusColors:y}=It(),b=()=>{g!==null&&g.trim()&&f?.(e,g.trim()),_(null)};return(0,m.jsxs)(l.Box,{className:`gantt-task-row`,"data-testid":`gantt-task-row-${e.id}`,sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,cursor:i?`pointer`:`default`,"&:hover":i?{bgcolor:`action.hover`}:void 0},onClick:()=>i?.(e),children:[(0,m.jsxs)(l.Box,{sx:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:.75,pl:1+e.depth*2,pr:.5,height:`100%`},children:[(0,m.jsx)(l.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,m.jsx)(l.Box,{component:`span`,sx:{fontSize:9,userSelect:`none`,cursor:`pointer`},onClick:t=>{t.stopPropagation(),n(e.id)},children:t.has(e.id)?`▼`:`▶`})}),(0,m.jsx)(l.Box,{sx:{width:8,height:8,borderRadius:e.isMilestone?0:`50%`,transform:e.isMilestone?`rotate(45deg)`:void 0,flexShrink:0,bgcolor:e.color??y?.[e.status]??at[e.status]??`grey.400`}}),g===null?(0,m.jsx)(l.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:d?`text`:`inherit`},onDoubleClick:d?t=>{t.stopPropagation(),_(e.name)}:void 0,children:e.name}):(0,m.jsx)(l.TextField,{size:`small`,variant:`standard`,value:g,autoFocus:!0,onChange:e=>_(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b()),e.key===`Escape`&&(e.stopPropagation(),_(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),r&&(0,m.jsxs)(l.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[o&&(0,m.jsx)(l.Tooltip,{title:v.editTaskTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,m.jsx)(N.default,{fontSize:`inherit`})})}),a&&(0,m.jsx)(l.Tooltip,{title:v.addTaskTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),a(e)},children:(0,m.jsx)(M.default,{fontSize:`inherit`})})}),s&&(0,m.jsx)(l.Tooltip,{title:v.deleteTaskTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,m.jsx)(w.default,{fontSize:`inherit`})})})]}),(0,m.jsxs)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,m.jsx)(l.Chip,{label:pt(e.status,v),size:`small`,variant:`outlined`,color:e.color??y?.[e.status]?`default`:ot[e.status]??`default`,sx:{height:20,fontSize:10,cursor:u?`pointer`:`default`,...(e.color??y?.[e.status])&&{borderColor:e.color??y?.[e.status],color:e.color??y?.[e.status]}},onClick:u?e=>{e.stopPropagation(),h(e.currentTarget)}:void 0}),u&&(0,m.jsx)(l.Menu,{anchorEl:p,open:!!p,onClose:()=>h(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,m.jsx)(l.MenuItem,{selected:e.status===t,onClick:()=>{u(e,t),h(null)},children:pt(t,v)},t))})]})]})}function ht({scrollRef:e,onScroll:t,panelWidth:n,onTaskClick:r,onAddTask:i,onEditTask:a,onDeleteTask:o,onStatusChange:s,onTasksChange:u,enableBuiltinDialogs:d,onTaskCreated:f,onTaskUpdated:p,onTaskDeleted:h,inlineEdit:g,virtualizeRows:_=!1}){let v=Q(),y=Nt(),b=Z(e=>e.taskTree),x=Z(e=>e.expandedIds),S=Z(e=>e.toggleExpand),C=Z(e=>e.timeScale),w=Z(e=>e.addTask),T=Z(e=>e.updateTask),E=Z(e=>e.deleteTask),D=(0,c.useMemo)(()=>He(b,x),[b,x]),O=(0,j.useVirtualizer)({count:D.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[k,A]=(0,c.useState)(!1),[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(!1),[I,L]=(0,c.useState)(null),R=e=>{let t={...e,id:crypto.randomUUID()};w(t),u?.(y.getState().tasks),f?.(t),A(!1)},z=e=>{if(!I)return;let t={...e,id:I.id};T(t),u?.(y.getState().tasks),p?.(t),N(!1)},B=()=>{I&&(E(I.id),u?.(y.getState().tasks),h?.(I.id),F(!1))},V=(e,t)=>{let n={...e,name:t};T(n),u?.(y.getState().tasks),p?.(n)},H=d?e=>{L(e),A(!0)}:i,U=d?e=>{L(e),N(!0)}:a,W=d?e=>{L(e),F(!0)}:o,G=!!(H||U||W),ee=C===`days`?80:40;return(0,m.jsxs)(l.Box,{ref:e,onScroll:t,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`},children:[(0,m.jsxs)(l.Box,{sx:{height:ee,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,m.jsxs)(l.Box,{sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:C===`days`?`1px solid`:void 0,borderColor:C===`days`?`divider`:void 0},children:[(0,m.jsx)(l.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:v.columnName})}),G&&(0,m.jsx)(l.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:v.columnActions})}),(0,m.jsx)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:v.columnStatus})})]}),C===`days`&&(0,m.jsx)(l.Box,{sx:{flex:1}})]}),_?(0,m.jsx)(l.Box,{sx:{position:`relative`,height:O.getTotalSize()},children:O.getVirtualItems().map(e=>(0,m.jsx)(l.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,m.jsx)(mt,{task:D[e.index],expandedIds:x,toggleExpand:S,hasActionsColumn:G,onTaskClick:r,onAddTask:H,onEditTask:U,onDeleteTask:W,onStatusChange:s,inlineEdit:g,onInlineRename:g?V:void 0})},e.key))}):D.map(e=>(0,m.jsx)(mt,{task:e,expandedIds:x,toggleExpand:S,hasActionsColumn:G,onTaskClick:r,onAddTask:H,onEditTask:U,onDeleteTask:W,onStatusChange:s,inlineEdit:g,onInlineRename:g?V:void 0},e.id)),d&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(dt,{open:k,mode:`add`,defaultParentId:I?.id,onSave:R,onClose:()=>A(!1)}),(0,m.jsx)(dt,{open:M,mode:`edit`,initialTask:I??void 0,onSave:z,onClose:()=>N(!1)}),(0,m.jsx)(ft,{open:P,task:I,onConfirm:B,onClose:()=>F(!1)})]})]})}var gt=864e5;function _t({totalWidth:e,displayRange:t,onTaskMoved:n,onTaskResized:r,onTasksChange:i}){let a=Z(e=>e.updateTask),o=Nt(),s=Q(),l=(0,c.useRef)(1);l.current=e>0?e/((t.end.getTime()-t.start.getTime())/gt):1;let u=(0,c.useRef)(n);u.current=n;let d=(0,c.useRef)(r);d.current=r;let f=(0,c.useRef)(i);f.current=i;let p=(0,c.useRef)(null),m=(0,c.useRef)(null),[h,g]=(0,c.useState)(null),_=(0,c.useRef)(!1);return{activeDrag:h,suppressClickRef:_,handleBarMouseDown:(e,t,n)=>{e.stopPropagation(),_.current=!1,p.current={type:n,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate},document.body.style.cursor=n===`resize`?`ew-resize`:`grabbing`;let r=e=>{let t=p.current;if(!t||t.type===`progress`)return;let n=e.clientX-t.startX,r=Math.round(n/l.current);Math.abs(n)>=5&&(_.current=!0);let i={taskId:t.taskId,type:t.type,deltaDays:r};m.current=i,g(i)},i=()=>{document.body.style.cursor=``;let e=p.current,t=m.current;if(e&&t&&_.current&&t.deltaDays!==0){let n=o.getState().tasks.find(t=>t.id===e.taskId);if(n){if(t.type===`move`){let r=X(e.originalStart,t.deltaDays),i=X(e.originalEnd,t.deltaDays);a({...n,startDate:r,endDate:i}),u.current?.(n,r,i)}else{let r=X(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:X(e.originalStart,1);a({...n,endDate:i}),d.current?.(n,i)}f.current?.(o.getState().tasks)}}p.current=null,m.current=null,g(null),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},handleProgressMouseDown:(e,t,n,r)=>{e.stopPropagation(),_.current=!1,p.current={type:`progress`,taskId:t.id,startX:e.clientX,originalStart:t.startDate,originalEnd:t.endDate,initialProgress:n,barWidthPx:r},document.body.style.cursor=`ew-resize`;let i=e=>{let t=p.current;if(!t||t.type!==`progress`)return;let n=e.clientX-t.startX;Math.abs(n)>=5&&(_.current=!0);let r=n/(t.barWidthPx??1)*100,i=Math.round(Math.max(0,Math.min(100,(t.initialProgress??0)+r))),a={taskId:t.taskId,type:`progress`,deltaDays:0,newProgress:i};m.current=a,g(a)},s=()=>{document.body.style.cursor=``;let e=p.current,t=m.current;if(e&&t&&t.type===`progress`&&t.newProgress!==void 0&&_.current){let n=o.getState().tasks.find(t=>t.id===e.taskId);n&&(a({...n,progress:t.newProgress}),f.current?.(o.getState().tasks))}p.current=null,m.current=null,g(null),document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,s)};document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,s)},formatDragDate:e=>e.toLocaleDateString(s.dateLocale,{day:`2-digit`,month:`short`})}}function vt({items:e}){return(0,m.jsx)(l.Box,{sx:{display:`flex`},children:e.map(e=>(0,m.jsx)(l.Box,{sx:{width:e.width,flexShrink:0,height:40,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRight:`1px solid`,borderColor:`divider`,bgcolor:e.isWeekend?`action.hover`:`transparent`},children:(0,m.jsx)(l.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function yt({columns:e,groups:t}){return(0,m.jsxs)(l.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:t?80:40,overflow:`visible`},children:[t&&(0,m.jsx)(l.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,m.jsx)(vt,{items:t})}),(0,m.jsx)(vt,{items:e})]})}function bt({task:e,virtualTop:t,activeDrag:n,displayRange:r,totalWidth:i,gridColumnWidth:a,criticalTaskIds:o,draggable:s=!1,resizable:c=!1,progressDraggable:u=!1,onTaskClick:d,onMilestoneClick:f,onContextMenu:p,suppressClickRef:h,handleBarMouseDown:g,handleProgressMouseDown:_,formatDragDate:v}){let y=(0,l.useTheme)(),{statusColors:b,criticalPathColor:x,milestoneColor:S,barBorderRadius:C}=It(),w=n?.taskId===e.id,T=e;if(w&&n)if(n.type===`move`)T={...e,startDate:X(e.startDate,n.deltaDays),endDate:X(e.endDate,n.deltaDays)};else if(n.type===`resize`){let t=X(e.endDate,n.deltaDays);T={...e,endDate:t>e.startDate?t:X(e.startDate,1)}}else n.type===`progress`&&n.newProgress!==void 0&&(T={...e,progress:n.newProgress});let{left:E,width:D}=ze(T,r);return(0,m.jsx)(l.Box,{"data-testid":`gantt-bar-row-${e.id}`,style:t===void 0?void 0:{position:`absolute`,top:t,left:0,width:`100%`},sx:{height:40,position:`relative`,borderBottom:`1px solid`,borderColor:`divider`,backgroundImage:e=>`linear-gradient(to right, transparent calc(${a}px - 1px), ${e.palette.divider} calc(${a}px - 1px), ${e.palette.divider} ${a}px)`,backgroundSize:`${a}px 100%`,backgroundRepeat:`repeat-x`},children:e.isMilestone?(0,m.jsx)(xt,{task:e,left:E,milestoneColor:S,criticalPathColor:x,isCritical:o.has(e.id),onMilestoneClick:f,theme:y}):(0,m.jsx)(St,{task:e,effectiveTask:T,left:E,width:D,totalWidth:i,isDragging:w,activeDrag:n,draggable:s,resizable:c,progressDraggable:u,isCritical:o.has(e.id),statusColors:b,criticalPathColor:x,barBorderRadius:C,onTaskClick:d,onContextMenu:p,suppressClickRef:h,handleBarMouseDown:g,handleProgressMouseDown:_,formatDragDate:v,theme:y})})}function xt({task:e,left:t,milestoneColor:n,criticalPathColor:r,isCritical:i,onMilestoneClick:a,theme:o}){return t<0||t>100?null:(0,m.jsx)(l.Box,{"data-testid":`gantt-milestone-${e.id}`,sx:{position:`absolute`,left:`${t}%`,top:`50%`,width:12,height:12,bgcolor:n??`warning.main`,transform:`translate(-50%, -50%) rotate(45deg)`,cursor:a?`pointer`:`default`,boxShadow:i?`0 0 0 2.5px ${r??o.palette.error.main}`:void 0,"&:hover":a?{opacity:.8}:void 0},onClick:()=>a?.(e)})}function St({task:e,effectiveTask:t,left:n,width:r,totalWidth:i,isDragging:a,activeDrag:o,draggable:s,resizable:c,progressDraggable:u,isCritical:d,statusColors:f,criticalPathColor:p,barBorderRadius:h,onTaskClick:g,onContextMenu:_,suppressClickRef:v,handleBarMouseDown:y,handleProgressMouseDown:b,formatDragDate:x,theme:S}){let C=Math.max(0,n),w=Math.min(100,n+Math.max(r,.5))-C;return w<=0?null:(0,m.jsxs)(m.Fragment,{children:[a&&o&&o.type!==`progress`&&o.deltaDays!==0&&(0,m.jsx)(Ct,{left:C,children:o.type===`move`?`${x(t.startDate)} – ${x(t.endDate)}`:`→ ${x(t.endDate)}`}),a&&o?.type===`progress`&&o.newProgress!==void 0&&(0,m.jsxs)(Ct,{left:C,children:[o.newProgress,`%`]}),(0,m.jsxs)(l.Box,{"data-testid":`gantt-bar-${e.id}`,sx:{position:`absolute`,left:`${C}%`,width:`${w}%`,height:16,top:`50%`,transform:`translateY(-50%)`,bgcolor:e.color??f?.[e.status]??at[e.status]??`grey.300`,borderRadius:h===void 0?1:`${h}px`,overflow:`hidden`,opacity:a?.75:1,boxShadow:d?`inset 0 0 0 2.5px ${p??S.palette.error.main}`:void 0,cursor:a?`grabbing`:s?`grab`:g?`pointer`:`default`,userSelect:`none`,"&:hover":s||g?{opacity:a?.75:.8}:void 0},onMouseDown:s?t=>y(t,e,`move`):void 0,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),_(e,t.clientX,t.clientY)},onClick:()=>{if(v.current){v.current=!1;return}g?.(e)},children:[t.progress!==void 0&&t.progress>0&&(0,m.jsx)(l.Box,{"data-testid":`gantt-progress-${e.id}`,sx:{position:`absolute`,left:0,top:0,width:`${Math.min(t.progress,100)}%`,height:`100%`,bgcolor:`currentColor`,opacity:.4}}),u&&(0,m.jsx)(l.Box,{"data-testid":`gantt-progress-handle-${e.id}`,sx:{position:`absolute`,left:`${Math.min(t.progress??0,100)}%`,top:0,width:6,height:`100%`,transform:`translateX(-50%)`,cursor:`ew-resize`,bgcolor:`rgba(255,255,255,0.35)`},onMouseDown:n=>{n.stopPropagation();let r=w/100*i;b(n,e,t.progress??0,r)}}),c&&(0,m.jsx)(l.Box,{"data-testid":`gantt-resize-handle-${e.id}`,sx:{position:`absolute`,right:0,top:0,width:6,height:`100%`,cursor:`ew-resize`},onMouseDown:t=>{t.stopPropagation(),y(t,e,`resize`)}})]})]})}function Ct({left:e,children:t}){return(0,m.jsx)(l.Box,{sx:{position:`absolute`,left:`${e}%`,top:2,bgcolor:`grey.800`,color:`common.white`,borderRadius:.5,px:.75,lineHeight:`18px`,fontSize:`0.65rem`,whiteSpace:`nowrap`,pointerEvents:`none`,zIndex:100},children:t})}function wt({strips:e,totalWidth:t,height:n,top:r}){let{weekendColor:i}=It();return e.length===0?null:(0,m.jsx)(l.Box,{"aria-hidden":!0,"data-testid":`gantt-weekend-strips`,sx:{position:`absolute`,top:r,left:0,width:t,height:n,pointerEvents:`none`},children:e.map(e=>(0,m.jsx)(l.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:i??`action.hover`}},e.key))})}function Tt({contextMenu:e,onClose:t,onSelect:n}){let r=Q(),i={planned:r.statusPlanned,"in-progress":r.statusInProgress,done:r.statusDone,blocked:r.statusBlocked};return(0,m.jsx)(l.Menu,{open:e!==null,onClose:t,anchorReference:`anchorPosition`,anchorPosition:e===null?void 0:{top:e.mouseY,left:e.mouseX},children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,m.jsx)(l.MenuItem,{selected:e?.task.status===t,"data-testid":`gantt-status-menu-${t}`,onClick:()=>{e&&n(e.task,t)},children:i[t]},t))})}function Et({dependencyLines:e,todayX:t,totalWidth:n,height:r,top:i,arrowMarkerId:a}){let o=(0,l.useTheme)(),{todayLineColor:s}=It();return e.length===0&&t===null?null:(0,m.jsxs)(`svg`,{"data-testid":`gantt-dependency-arrows`,style:{position:`absolute`,top:i,left:0,width:n,height:r,pointerEvents:`none`,overflow:`visible`},children:[e.length>0&&(0,m.jsx)(`defs`,{children:(0,m.jsx)(`marker`,{id:a,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,m.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),e.map(e=>(0,m.jsx)(`path`,{"data-testid":`gantt-dep-${e.key}`,d:e.d,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeOpacity:.4,markerEnd:`url(#${a})`},e.key)),t!==null&&(0,m.jsx)(`line`,{"data-testid":`gantt-today-line`,x1:t,y1:0,x2:t,y2:r,stroke:s??o.palette.primary.main,strokeWidth:1.5,strokeDasharray:`4 2`})]})}function Dt(e,t,n){if(n===0)return[];let r=[],i=new Map(e.map((e,t)=>[e.id,t]));for(let a of e){if(!a.dependencies?.length)continue;let o=i.get(a.id),s=ze(a,t).left/100*n,c=o*40+40/2;for(let o of a.dependencies){let l=i.get(o);if(l===void 0)continue;let u=e[l],d=ze(u,t),f=(d.left+d.width)/100*n,p=l*40+40/2,m;m=s>=f+48?(f+s)/2:f+24<=n-8?f+24:Math.max(s-24,8),r.push({key:`${o}-${a.id}`,d:`M ${f} ${p} H ${m} V ${c} H ${s}`})}}return r}function Ot({scrollRef:e,onScroll:t,onTaskClick:n,onMilestoneClick:r,draggable:i=!1,resizable:a=!1,progressDraggable:o=!1,showCriticalPath:s=!1,virtualizeRows:u=!1,onTaskMoved:d,onTaskResized:f,onTasksChange:p,onStatusChange:h}){let g=Z(e=>e.taskTree),_=Z(e=>e.tasks),v=Z(e=>e.expandedIds),y=Z(e=>e.timelineRange),b=Z(e=>e.timeScale),x=Z(e=>e.updateTask),S=Nt(),C=Q(),w=`gantt-arrow-${(0,c.useId)().replace(/:/g,``)}`,T=(0,c.useMemo)(()=>He(g,v),[g,v]),E=(0,c.useMemo)(()=>Re(y,b),[y,b]),D=(0,c.useMemo)(()=>b===`days`?Ze(E).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):b===`weeks`?Xe(E).map(e=>({key:e.toISOString(),label:`${C.weekColumnPrefix}${Ye(e)}`,width:40})):b===`quarters`?et(E).map(e=>({key:e.key,label:e.label,width:360})):qe(E).map(e=>({key:e.toISOString(),label:e.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[b,E,C.weekColumnPrefix,C.dateLocale]),O=(0,c.useMemo)(()=>D.reduce((e,t)=>e+t.width,0),[D]),k=(0,c.useMemo)(()=>{if(b!==`days`)return;let e=new Map;for(let t of D){let n=new Date(t.key),r=`${n.getFullYear()}-${n.getMonth()}`;e.has(r)||e.set(r,{label:n.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:0}),e.get(r).width+=20}return Array.from(e.entries()).map(([e,t])=>({key:e,...t}))},[b,D,C.dateLocale]),A=(0,c.useMemo)(()=>Dt(T,E,O),[T,E,O]),M=(0,c.useMemo)(()=>s?tt(_):new Set,[s,_]),N=(0,j.useVirtualizer)({count:T.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),P=(0,c.useMemo)(()=>{if(b!==`days`)return[];let e=0;return D.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[b,D]),F=(0,c.useMemo)(()=>{let e=Date.now(),t=E.start.getTime(),n=E.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*O},[E,O]);(0,c.useEffect)(()=>{if(F===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,F-t/2)},[]);let I=b===`days`?20:b===`weeks`?40:b===`quarters`?360:120,L=k?80:40,{activeDrag:R,suppressClickRef:z,handleBarMouseDown:B,handleProgressMouseDown:V,formatDragDate:H}=_t({totalWidth:O,displayRange:E,onTaskMoved:d,onTaskResized:f,onTasksChange:p}),[U,W]=(0,c.useState)(null),G=(0,c.useRef)(h);G.current=h;let ee=(0,c.useRef)(p);return ee.current=p,(0,m.jsx)(l.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,m.jsxs)(l.Box,{sx:{minWidth:O,position:`relative`},children:[(0,m.jsx)(yt,{columns:D,groups:k}),(0,m.jsx)(wt,{strips:P,totalWidth:O,height:T.length*40,top:L}),u?(0,m.jsx)(l.Box,{sx:{position:`relative`,height:N.getTotalSize()},children:N.getVirtualItems().map(e=>(0,m.jsx)(bt,{task:T[e.index],virtualTop:e.start,activeDrag:R,displayRange:E,totalWidth:O,gridColumnWidth:I,criticalTaskIds:M,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>W({task:e,mouseX:t,mouseY:n}),suppressClickRef:z,handleBarMouseDown:B,handleProgressMouseDown:V,formatDragDate:H},e.key))}):(0,m.jsx)(m.Fragment,{children:T.map(e=>(0,m.jsx)(bt,{task:e,activeDrag:R,displayRange:E,totalWidth:O,gridColumnWidth:I,criticalTaskIds:M,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>W({task:e,mouseX:t,mouseY:n}),suppressClickRef:z,handleBarMouseDown:B,handleProgressMouseDown:V,formatDragDate:H},e.id))}),(0,m.jsx)(Tt,{contextMenu:U,onClose:()=>W(null),onSelect:(e,t)=>{let n=S.getState().tasks.find(t=>t.id===e.id)??e;x({...n,status:t}),G.current?.(n,t),ee.current?.(S.getState().tasks),W(null)}}),(0,m.jsx)(Et,{dependencyLines:A,todayX:F,totalWidth:O,height:T.length*40,top:L,arrowMarkerId:w})]})})}function kt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function At(e){let[t,n,r]=e.split(`-`).map(Number);return!t||!n||!r?null:new Date(t,n-1,r,0,0,0,0)}function jt({onScrollToToday:e,config:t}){let n=Q(),r=Z(e=>e.timeScale),i=Z(e=>e.defaultTimeScale),a=Z(e=>e.setTimeScale),o=Z(e=>e.timelineRange),s=Z(e=>e.isRangeCustomized),u=Z(e=>e.isExpandedCustomized),d=Z(e=>e.setTimelineRange),f=Z(e=>e.resetTimelineRange),p=Z(e=>e.resetView),h=Z(e=>e.tasks),g=Z(e=>e.expandedIds),_=Z(e=>e.expandAll),v=Z(e=>e.collapseAll),y=h.length>0&&h.every(e=>g.has(e.id)),b=r!==i||s||u,x=(0,c.useMemo)(()=>Date.now(),[]),S=x>=o.start.getTime()&&x<=o.end.getTime(),C={days:n.scaleDays,weeks:n.scaleWeeks,months:n.scaleMonths,quarters:n.scaleQuarters},w={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},T=Object.keys(C).filter(e=>w[e]);return(0,m.jsxs)(l.Box,{"data-testid":`gantt-toolbar`,sx:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:1,px:1.5,py:.75,borderBottom:`1px solid`,borderColor:`divider`,bgcolor:`background.paper`},children:[T.length>0&&(0,m.jsx)(l.ToggleButtonGroup,{value:r,exclusive:!0,onChange:(e,t)=>{t&&a(t)},size:`small`,"aria-label":n.scaleMonths,children:T.map(e=>(0,m.jsx)(l.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:C[e]},e))}),(0,m.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,m.jsx)(l.Tooltip,{title:y?n.collapseAllTooltip:n.expandAllTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:y?v:_,"data-testid":`gantt-expand-collapse-all`,children:y?(0,m.jsx)(L.default,{fontSize:`small`}):(0,m.jsx)(R.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,m.jsx)(l.Tooltip,{title:n.scrollToTodayTooltip,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:e,disabled:!S,"data-testid":`gantt-scroll-to-today`,children:(0,m.jsx)(I.default,{fontSize:`small`})})})}),t.showDateRange&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.TextField,{type:`date`,size:`small`,label:n.rangeFrom,value:kt(o.start),onChange:e=>{let t=At(e.target.value);t&&d({start:t,end:o.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,m.jsx)(l.TextField,{type:`date`,size:`small`,label:n.rangeTo,value:kt(o.end),onChange:e=>{let t=At(e.target.value);t&&d({start:o.start,end:t})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-end`}},sx:{width:148}})]}),t.showRangeReset&&s&&(0,m.jsx)(l.Tooltip,{title:n.rangeResetTooltip,children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:f,"data-testid":`gantt-range-reset`,children:(0,m.jsx)(F.default,{fontSize:`small`})})}),t.showResetView&&(0,m.jsx)(l.Tooltip,{title:n.resetViewTooltip,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:p,disabled:!b,"data-testid":`gantt-reset-view`,children:(0,m.jsx)(P.default,{fontSize:`small`})})})})]})]})}var Mt=(0,c.createContext)(null);function Z(e){let t=(0,c.useContext)(Mt);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,k.useStore)(t,e)}function Nt(){let e=(0,c.useContext)(Mt);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var Pt=(0,c.createContext)(it);function Q(){return(0,c.useContext)(Pt)}var Ft=(0,c.createContext)({});function It(){return(0,c.useContext)(Ft)}function Lt(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var Rt=[`days`,`weeks`,`months`,`quarters`],zt={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0};function Bt({tasks:e,onTaskClick:t,onMilestoneClick:n,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u=!0,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,showToolbar:h=!0,toolbarConfig:g,height:_,width:v,minPanelWidth:y=200,maxPanelWidth:b=600,zoomable:x=!1,draggable:S=!1,resizable:C=!1,inlineEdit:w=!1,progressDraggable:T=!1,showCriticalPath:E=!1,virtualizeRows:D=!1,onTaskMoved:O,onTaskResized:k}){let A=Lt(_,400),j=(0,c.useMemo)(()=>({...zt,...g}),[g]),M=Lt(v,`100%`),N=Z(e=>e.setTasks),P=Z(e=>e.timeScale),F=Z(e=>e.setTimeScale),I=Z(e=>e.timelineRange),L=(0,c.useRef)(null),R=(0,c.useRef)(null),z=(0,c.useRef)(!1),[B,V]=(0,c.useState)(320);(0,c.useEffect)(()=>{N(e)},[e,N]);let H=()=>{z.current||=(z.current=!0,R.current&&L.current&&(R.current.scrollTop=L.current.scrollTop),!1)},U=()=>{z.current||=(z.current=!0,L.current&&R.current&&(L.current.scrollTop=R.current.scrollTop),!1)},W=(0,c.useCallback)(()=>{if(!R.current)return;let e=Re(I,P),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*R.current.scrollWidth;R.current.scrollLeft=Math.max(0,i-R.current.clientWidth/2)},[I,P]);(0,c.useEffect)(()=>{if(!x||!R.current)return;let e=R.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=Rt.indexOf(P);e.deltaY<0&&t>0?F(Rt[t-1]):e.deltaY>0&&t<Rt.length-1&&F(Rt[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,P,F]);let G=(0,c.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=B,r=e=>{let r=e.clientX-t;V(Math.max(y,Math.min(b,n+r)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[B,y,b]);return(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexDirection:`column`,height:A,width:M,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[h&&(0,m.jsx)(jt,{onScrollToToday:W,config:j}),(0,m.jsxs)(l.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,m.jsx)(ht,{scrollRef:L,onScroll:H,panelWidth:B,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D}),(0,m.jsx)(l.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:G}),(0,m.jsx)(Ot,{scrollRef:R,onScroll:U,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onTaskMoved:O,onTaskResized:k,onTasksChange:s,onStatusChange:o})]})]})}function Vt({tasks:e,timeScale:t=`months`,initialExpandAll:n=!1,showToolbar:r=!0,defaultRangeStart:i,defaultRangeEnd:a,translations:o,enableBuiltinDialogs:s=!0,toolbarConfig:l,zoomable:u=!1,draggable:d=!1,resizable:f=!1,inlineEdit:p=!1,progressDraggable:h=!1,showCriticalPath:g=!1,virtualizeRows:_=!1,cascadeDependencies:v=!1,statusColors:y,ganttTheme:b,onTaskClick:x,onMilestoneClick:S,onAddTask:C,onEditTask:w,onDeleteTask:T,onStatusChange:E,onTasksChange:D,onTaskMoved:O,onTaskResized:k,onTaskCreated:A,onTaskUpdated:j,onTaskDeleted:M,height:N,width:P,minPanelWidth:F,maxPanelWidth:I}){let L=(0,c.useMemo)(()=>({...it,...o}),[o]),[R]=(0,c.useState)(()=>{if(!(i!==void 0||a!==void 0))return rt(e,t,n,void 0,v);let r=Y(e);return rt(e,t,n,{start:i??r.start,end:a??r.end},v)}),z=(0,c.useMemo)(()=>({...b,statusColors:{...y,...b?.statusColors}}),[y,b]);return(0,m.jsx)(Pt.Provider,{value:L,children:(0,m.jsx)(Ft.Provider,{value:z,children:(0,m.jsx)(Mt.Provider,{value:R,children:(0,m.jsx)(Bt,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:l,zoomable:u,draggable:d,resizable:f,inlineEdit:p,progressDraggable:h,showCriticalPath:g,virtualizeRows:_,onTaskClick:x,onMilestoneClick:S,onAddTask:C,onEditTask:w,onDeleteTask:T,onStatusChange:E,onTasksChange:D,onTaskMoved:O,onTaskResized:k,onTaskCreated:A,onTaskUpdated:j,onTaskDeleted:M,height:N,width:P,minPanelWidth:F,maxPanelWidth:I})})})})}var Ht=e=>Math.max(0,Math.min(4,Math.round(e)));function Ut(e,t){let n=e??``,r=n.length,i=/[a-z]/.test(n),a=/[A-Z]/.test(n),o=/\d/.test(n),s=/[^A-Za-z0-9]/.test(n),c=[i,a,o,s].filter(Boolean).length;if(r<t){let e=r===0?0:1;return{score:e,percent:e*25,meterStatus:`weak`,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}let l=0;l+=1,r>=t+4&&(l+=1),c>=2&&(l+=1),c>=3&&(l+=1),/^(.)\1+$/.test(n)&&(l-=2),/1234|abcd|qwer|password|passwort|admin/i.test(n)&&(l-=2);let u=Ht(l),d=u<=1?`weak`:u===2?`ok`:u===3?`good`:`very good`;return{score:u,percent:u*25,meterStatus:d,length:r,hasLower:i,hasUpper:a,hasDigit:o,hasSymbol:s}}function Wt({percent:e,color:t,ariaLabel:n}){return(0,m.jsx)(l.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,height:`8px`,border:`1px solid`,borderColor:`divider`,borderRadius:`6px`,mt:.5,display:`flex`},children:(0,m.jsx)(l.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${e}%`,backgroundColor:t,borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})})}var Gt={label:`Password`,summaryHeaderLabel:`Requirements for your password`,summaryMinChars:`At least {n} characters`,summaryCapitalLetter:`At least 1 capital letter`,summaryLowerCaseLetter:`At least 1 lowercase letter`,summaryNumber:`At least 1 number`,summarySpecialChar:`At least 1 special character`,showPasswordLabel:`Show password`,hidePasswordLabel:`Hide password`,meterAriaLabel:`Password strength`},Kt={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},qt={failure:`#cc0000`,success:`#43a047`};function Jt({label:e,fulfilled:t,checkColors:n}){return(0,m.jsxs)(l.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,children:[(0,m.jsx)(l.Typography,{variant:`caption`,children:e}),t?(0,m.jsx)(p.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,m.jsx)(f.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function Yt({value:e,name:t,inputRef:n,disabled:r=!1,error:i=!1,helperText:a,autoComplete:o,showPasswordAdornment:s=!0,showMeter:u=!0,showSummary:d=!0,inputSize:f=`medium`,translation:p,meterColors:h,passwordMinLength:g=8,checkColors:_=qt,onPasswordChange:v}){let y={...Gt,...p},b={...Kt,...h},x=`${(0,c.useId)()}-password`,[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(``),E=e===void 0?w:e,D=(0,c.useMemo)(()=>Ut(E,g),[E,g]);return(0,m.jsxs)(l.Stack,{children:[(0,m.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:i,children:[(0,m.jsx)(l.InputLabel,{htmlFor:x,size:f,children:y.label}),(0,m.jsx)(l.OutlinedInput,{id:x,type:S?`text`:`password`,fullWidth:!0,size:f,value:E,onChange:t=>{let n=t.target.value;e===void 0&&T(n),v&&v(n,Ut(n,g))},disabled:r,inputRef:n,inputProps:{"data-testid":`psm-input`,name:t,autoComplete:o},endAdornment:s?(0,m.jsx)(l.InputAdornment,{position:`end`,children:(0,m.jsx)(l.IconButton,{"data-testid":`psm-toggle`,disabled:r,"aria-label":S?y.hidePasswordLabel:y.showPasswordLabel,onClick:()=>{C(e=>!e)},onMouseDown:e=>{e.preventDefault()},onMouseUp:e=>{e.preventDefault()},edge:`end`,children:S?(0,m.jsx)(B.default,{}):(0,m.jsx)(z.default,{})})}):null,label:y.label}),a&&(0,m.jsx)(l.FormHelperText,{children:a})]}),u&&(0,m.jsx)(Wt,{percent:D.percent,color:(e=>{switch(e.meterStatus){case`weak`:return b.weak;case`ok`:return b.ok;case`good`:return b.good;case`very good`:return b.veryGood;default:return`transparent`}})(D),ariaLabel:y.meterAriaLabel}),d&&(0,m.jsxs)(l.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},children:[(0,m.jsx)(l.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:y.summaryHeaderLabel}),(0,m.jsxs)(l.Stack,{direction:`row`,spacing:6,children:[(0,m.jsxs)(l.Stack,{direction:`column`,children:[(0,m.jsx)(Jt,{label:y.summaryMinChars.replace(`{n}`,String(g)),fulfilled:D.length>=g,checkColors:_}),(0,m.jsx)(Jt,{label:y.summaryCapitalLetter,fulfilled:D.hasUpper,checkColors:_}),(0,m.jsx)(Jt,{label:y.summaryLowerCaseLetter,fulfilled:D.hasLower,checkColors:_})]}),(0,m.jsxs)(l.Stack,{direction:`column`,children:[(0,m.jsx)(Jt,{label:y.summaryNumber,fulfilled:D.hasDigit,checkColors:_}),(0,m.jsx)(Jt,{label:y.summarySpecialChar,fulfilled:D.hasSymbol,checkColors:_})]})]})]})]})}function Xt(e){return(0,A.createStore)(t=>({tags:e,searchValue:``,setTags:e=>{t({tags:e})},setSearchValue:e=>{t({searchValue:e})},selectTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e&&!t.disabled?{...t,selected:!0}:t),searchValue:``}))},deleteTag:e=>{t(t=>({tags:t.tags.map(t=>t.id===e?{...t,selected:!1}:t)}))},addTag:e=>{t(t=>({tags:[...t.tags,{...e,selected:!0}],searchValue:``}))}}))}var Zt=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`];function Qt({availableTags:e,searchValue:t,translation:n,onSearchChange:r,onTagSelect:i,onTagCreate:a,inputSize:o=`medium`,chipSize:s=`medium`,disabled:u=!1,loading:d=!1,isMaxReached:f=!1,allowCreate:p=!1,listboxMaxHeight:h}){let[g,_]=(0,c.useState)(`default`),[v,y]=(0,c.useState)(!1),b=u||f,x=e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),S=p&&t.trim()!==``&&x.length===0,w=v&&!S,T=()=>{a?.(t.trim(),g),_(`default`)},E=()=>{r(``),_(`default`)};return(0,m.jsxs)(l.Box,{sx:{mb:2},children:[(0,m.jsx)(l.Autocomplete,{options:e,value:null,open:w,onOpen:()=>{S||y(!0)},onClose:()=>y(!1),size:o,disabled:b,loading:d,getOptionLabel:e=>e.label,inputValue:t,onInputChange:(e,t)=>{r(t)},onChange:(e,t)=>{t&&i(t)},slotProps:{listbox:{sx:{display:`flex`,flexWrap:`wrap`,gap:1,padding:1,...h!==void 0&&{maxHeight:h,overflowY:`auto`}}}},renderInput:e=>(0,m.jsx)(l.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:f&&!u?n.maxTagsReachedText:void 0,onKeyDown:e=>{S&&e.key===`Enter`&&(e.preventDefault(),T())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,m.jsxs)(m.Fragment,{children:[S&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:e=>{e.preventDefault()},onClick:T,children:(0,m.jsx)(C.default,{fontSize:`small`})}),(0,m.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>{e.preventDefault()},onClick:E,children:(0,m.jsx)(V.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...t},n)=>{let r=!!(n.foregroundColor||n.backgroundColor);return(0,m.jsx)(`li`,{...t,style:{width:`auto`,padding:0,margin:0},children:(0,m.jsx)(l.Chip,{size:s,label:n.label,color:r?void 0:n.color??`default`,sx:r?{color:n.foregroundColor??`inherit`,backgroundColor:n.backgroundColor??`transparent`}:void 0})},e)},isOptionEqualToValue:(e,t)=>e.id===t.id,noOptionsText:n.noAvailableTagsText,loadingText:n.loadingText}),S&&(0,m.jsx)(l.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:Zt.map(e=>(0,m.jsx)(l.Chip,{size:s,color:e,label:e,variant:g===e?`filled`:`outlined`,onClick:()=>_(e),clickable:!0},e))})]})}function $t({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,disabled:i=!1}){let a=!!(e.foregroundColor||e.backgroundColor);return(0,m.jsx)(l.Chip,{size:r,label:e.label,onDelete:t?()=>t(e):void 0,onClick:n?()=>n(e):void 0,clickable:!!n&&!e.disabled&&!i,disabled:i||e.disabled,variant:e.selected?`filled`:`outlined`,color:a?void 0:e.color??`default`,sx:{...a&&{color:e.foregroundColor??`inherit`,backgroundColor:e.backgroundColor??`transparent`,borderColor:e.backgroundColor??void 0,"& .MuiChip-deleteIcon":{color:e.foregroundColor?`${e.foregroundColor}99`:`inherit`,"&:hover":{color:e.foregroundColor??`inherit`}}},cursor:n&&!e.disabled&&!i?`pointer`:`default`}})}function en({selectedTags:e,translation:t,onTagDelete:n,showSelectedTagsLabel:r,chipSize:i=`medium`,disabled:a=!1,maxVisibleChips:o,popoverPlacement:s=`bottom`}){let[u,d]=(0,c.useState)(null),f=o===void 0?e:e.slice(0,o),p=o===void 0?[]:e.slice(o),h=!!u&&p.length>0,g=s===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},_=s===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,m.jsxs)(l.Box,{sx:{mb:2},children:[r&&(0,m.jsx)(l.Typography,{variant:`subtitle2`,gutterBottom:!0,children:t.selectedTagsLabel}),e.length===0?(0,m.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,m.jsxs)(l.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},children:[f.map(e=>(0,m.jsx)($t,{tag:e,onDelete:n,chipSize:i,disabled:a},e.id)),p.length>0&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.Chip,{size:i,label:`+${p.length}`,variant:`outlined`,clickable:!0,onClick:e=>d(e.currentTarget)}),(0,m.jsx)(l.Popover,{open:h,anchorEl:u,onClose:()=>d(null),anchorOrigin:g,transformOrigin:_,children:(0,m.jsx)(l.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},children:p.map(e=>(0,m.jsx)($t,{tag:e,onDelete:a?void 0:n,chipSize:i,disabled:a},e.id))})})]})]})]})}var tn={selectedTagsLabel:`Selected tags`,autoCompleteLabel:`Search and add tags`,noSelectedTagsText:`No tags selected.`,noAvailableTagsText:`No tags available.`,placeholder:`Type to search...`,loadingText:`Loading...`,maxTagsReachedText:`Maximum number of tags reached.`},nn=(0,c.createContext)(null);function $(e){let t=(0,c.useContext)(nn);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,k.useStore)(t,e)}function rn({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,inputSize:i=`medium`,chipSize:a=`small`,disabled:o=!1,loading:s=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:h,translation:g,onTagSelect:_,onTagDelete:v,onTagsChange:y,onSearchChange:b,onTagCreate:x}){let S=$(e=>e.tags),C=$(e=>e.searchValue),w=$(e=>e.setTags),T=$(e=>e.setSearchValue),E=$(e=>e.selectTag),D=$(e=>e.deleteTag),O=$(e=>e.addTag);(0,c.useEffect)(()=>{w(e)},[e,w]);let k=(0,c.useMemo)(()=>S.filter(e=>e.selected).sort((e,t)=>e.label.localeCompare(t.label)),[S]),A=(0,c.useMemo)(()=>S.filter(e=>!e.selected&&!e.disabled).sort((e,t)=>e.label.localeCompare(t.label)),[S]),j=u!==void 0&&k.length>=u,M=e=>{y&&y(e.filter(e=>e.selected),e)};return(0,m.jsx)(l.Box,{sx:{width:`100%`},children:(0,m.jsxs)(l.Stack,{children:[t&&(0,m.jsx)(en,{selectedTags:k,translation:g,onTagDelete:e=>{D(e.id);let t=S.map(t=>t.id===e.id?{...t,selected:!1}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&v&&v(r,n,t),M(t)},showSelectedTagsLabel:n,chipSize:a,disabled:o,maxVisibleChips:f,popoverPlacement:p}),r&&(0,m.jsx)(Qt,{availableTags:A,searchValue:C,translation:g,onSearchChange:e=>{T(e),b&&b(e)},onTagSelect:e=>{if(e.disabled||e.selected)return;E(e.id);let t=S.map(t=>t.id===e.id?{...t,selected:!0}:t),n=t.filter(e=>e.selected),r=t.find(t=>t.id===e.id);r&&_&&_(r,n,t),M(t)},onTagCreate:(e,t)=>{let n={id:e.toLowerCase().replace(/\s+/g,`-`),label:e,color:t,selected:!0};O(n);let r=[...S,n],i=r.filter(e=>e.selected);_&&_(n,i,r),M(r),x&&x(e,t)},inputSize:i,chipSize:a,disabled:o,loading:s,isMaxReached:j,allowCreate:d,listboxMaxHeight:h})]})})}function an({tags:e,showSelectedTags:t=!0,showSelectedTagsLabel:n=!0,showAutoComplete:r=!0,translation:i,inputSize:a=`medium`,chipSize:o=`small`,disabled:s=!1,loading:l=!1,maxTags:u,allowCreate:d=!1,maxVisibleChips:f,popoverPlacement:p=`bottom`,listboxMaxHeight:h,onTagSelect:g,onTagDelete:_,onTagsChange:v,onSearchChange:y,onTagCreate:b}){let x={...tn,...i},[S]=(0,c.useState)(()=>Xt(e));return(0,m.jsx)(nn.Provider,{value:S,children:(0,m.jsx)(rn,{tags:e,showSelectedTags:t,showSelectedTagsLabel:n,showAutoComplete:r,translation:x,inputSize:a,chipSize:o,disabled:s,loading:l,maxTags:u,allowCreate:d,maxVisibleChips:f,popoverPlacement:p,listboxMaxHeight:h,onTagSelect:g,onTagDelete:_,onTagsChange:v,onSearchChange:y,onTagCreate:b})})}var on={showBold:!0,showItalic:!0,showUnderline:!0,showStrike:!0,showHeading1:!0,showHeading2:!0,showHeading3:!0,showBulletList:!0,showOrderedList:!0,showBlockquote:!0,showCodeBlock:!0,showLink:!0,showHorizontalRule:!0,showTextColor:!0,showHighlight:!0,showUndoRedo:!0,showClearFormat:!0,showFullscreenButton:!1},sn={bold:`Bold`,italic:`Italic`,underline:`Underline`,strike:`Strikethrough`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,bulletList:`Bullet list`,orderedList:`Numbered list`,blockquote:`Blockquote`,codeBlock:`Code block`,link:`Insert link`,horizontalRule:`Horizontal rule`,textColor:`Text color`,removeTextColor:`Remove text color`,highlight:`Highlight`,removeHighlight:`Remove highlight`,undo:`Undo`,redo:`Redo`,clearFormat:`Clear formatting`,linkDialogTitle:`Insert link`,linkDialogUrlLabel:`URL`,linkDialogSave:`Save`,linkDialogCancel:`Cancel`,linkDialogRemove:`Remove link`,characterCount:`{count} characters`,characterCountMax:`{count} / {max} characters`,wordCount:`{count} words`,fullscreen:`Full screen`,exitFullscreen:`Exit full screen`};function cn({editor:e,error:t,disabled:n,readonly:r}){return(0,m.jsx)(l.Box,{sx:{flex:1,minHeight:0,display:`flex`,flexDirection:`column`,px:1.5,py:1,cursor:n||r?`default`:`text`,opacity:n?.5:1,"& > div":{flex:1,display:`flex`,flexDirection:`column`,minHeight:0},"& .ProseMirror":{flex:1,minHeight:0,overflowY:`auto`,overflowX:`hidden`,wordBreak:`break-word`,overflowWrap:`break-word`,outline:`none`,"& p.is-editor-empty:first-of-type::before":{content:`attr(data-placeholder)`,color:`text.disabled`,pointerEvents:`none`,float:`left`,height:0},"& h1":{typography:`h4`,mb:1},"& h2":{typography:`h5`,mb:1},"& h3":{typography:`h6`,mb:1},"& p":{my:.5},"& ul, & ol":{pl:3},"& blockquote":{borderLeft:`4px solid`,borderColor:t?`error.main`:`divider`,pl:2,color:`text.secondary`,my:1},"& code":{bgcolor:`action.hover`,px:.5,borderRadius:.5,fontFamily:`monospace`,fontSize:`0.875em`},"& pre":{bgcolor:`action.hover`,p:1.5,borderRadius:1,overflowX:`auto`,"& code":{bgcolor:`transparent`,px:0}},"& a":{color:`primary.main`,cursor:`pointer`},"& mark":{borderRadius:.5,px:.25},"& hr":{borderColor:`divider`,my:2}}},children:(0,m.jsx)(H.EditorContent,{editor:e})})}function ln({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``);(0,c.useEffect)(()=>{if(e){let e=n.getAttributes(`link`).href;a(e??``)}},[e,n]);let o=n.isActive(`link`);function s(){i.trim()?n.chain().focus().extendMarkRange(`link`).setLink({href:i.trim()}).run():n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function u(){n.chain().focus().extendMarkRange(`link`).unsetLink().run(),t()}function d(e){e.key===`Enter`&&s()}return(0,m.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,m.jsx)(l.DialogTitle,{children:r.linkDialogTitle}),(0,m.jsx)(l.DialogContent,{children:(0,m.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,label:r.linkDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:d,variant:`outlined`,size:`small`,sx:{mt:1},placeholder:`https://`})}),(0,m.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,m.jsx)(l.Button,{onClick:u,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,m.jsx)(l.Button,{onClick:t,children:r.linkDialogCancel}),(0,m.jsx)(l.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var un=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],dn=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function fn({color:e,active:t,onClick:n}){return(0,m.jsx)(l.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,m.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>n(e),sx:{width:22,height:22,bgcolor:e,border:t?`2px solid`:`1px solid`,borderColor:t?`primary.main`:e===`#ffffff`||e===`#f5f5dc`?`divider`:`transparent`,borderRadius:.5,cursor:`pointer`,p:0,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`transform 0.1s`,"&:hover":{transform:`scale(1.2)`,zIndex:1}},children:t&&(0,m.jsx)(l.Box,{component:`span`,sx:{width:10,height:6,borderLeft:`2px solid`,borderBottom:`2px solid`,borderColor:e===`#ffffff`||e===`#f5f5dc`||e===`#ffd700`||e===`#ffff00`||e===`#adff2f`||e===`#ffa500`||e===`#b7b7b7`||e===`#d2b48c`?`#000`:`#fff`,transform:`rotate(-45deg) translateY(-1px)`,display:`block`}})})})}function pn({anchorEl:e,open:t,onClose:n,mode:r,activeColor:i,onSelectColor:a,onRemoveColor:o,removeLabel:s}){let u=(0,c.useRef)(null),d=r===`highlight`?dn:un;function f(e){a(e.target.value)}return(0,m.jsxs)(l.Popover,{open:t,anchorEl:e,onClose:n,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{p:1.5}}},children:[(0,m.jsx)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:d.map(e=>(0,m.jsx)(fn,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,m.jsx)(l.Tooltip,{title:`Custom color`,arrow:!0,children:(0,m.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>u.current?.click(),sx:{width:22,height:22,background:`conic-gradient(red, yellow, lime, cyan, blue, magenta, red)`,border:`1px solid`,borderColor:`divider`,borderRadius:.5,cursor:`pointer`,p:0,flexShrink:0,"&:hover":{transform:`scale(1.2)`},transition:`transform 0.1s`}})}),(0,m.jsx)(`input`,{ref:u,type:`color`,defaultValue:i??`#000000`,onChange:f,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,m.jsx)(l.Tooltip,{title:s,arrow:!0,children:(0,m.jsx)(l.IconButton,{size:`small`,onClick:()=>{o(),n()},sx:{borderRadius:1,ml:`auto`},children:(0,m.jsx)(ye.default,{fontSize:`small`})})})]})]})}function mn({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,m.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,m.jsx)(`span`,{children:(0,m.jsxs)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:i,disabled:r,sx:{borderRadius:1,flexDirection:`column`,gap:0,pb:.25},"aria-label":e,children:[(0,m.jsx)(l.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,m.jsx)(l.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function hn({level:e}){return(0,m.jsxs)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:[`H`,e]})}function gn({editor:e,toolbarConfig:t,translation:n,disabled:r,isFullscreen:i,onToggleFullscreen:a}){let[o,s]=(0,c.useState)(!1),[u,d]=(0,c.useState)(null),[f,p]=(0,c.useState)(null),h=r||!e,g=e?.getAttributes(`textStyle`)?.color,_=e?.getAttributes(`highlight`)?.color,v=t.showBold||t.showItalic||t.showUnderline||t.showStrike,y=t.showHeading1||t.showHeading2||t.showHeading3,b=t.showBulletList||t.showOrderedList,x=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,S=t.showTextColor||t.showHighlight,C=t.showUndoRedo||t.showClearFormat,w=[v,y,b,x,S,C],D=w.filter(Boolean).length;function O(e,t){return!e||w.slice(t+1).findIndex(Boolean)===-1?null:(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[v&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,m.jsx)(q,{label:n.bold,icon:(0,m.jsx)(oe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:h}),t.showItalic&&(0,m.jsx)(q,{label:n.italic,icon:(0,m.jsx)(se.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:h}),t.showUnderline&&(0,m.jsx)(q,{label:n.underline,icon:(0,m.jsx)(ce.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:h}),t.showStrike&&(0,m.jsx)(q,{label:n.strike,icon:(0,m.jsx)(le.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:h})]}),O(v,0),y&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,m.jsx)(q,{label:n.heading1,icon:(0,m.jsx)(hn,{level:1}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:h}),t.showHeading2&&(0,m.jsx)(q,{label:n.heading2,icon:(0,m.jsx)(hn,{level:2}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:h}),t.showHeading3&&(0,m.jsx)(q,{label:n.heading3,icon:(0,m.jsx)(hn,{level:3}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:h})]}),O(y,1),b&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,m.jsx)(q,{label:n.bulletList,icon:(0,m.jsx)(ue.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:h}),t.showOrderedList&&(0,m.jsx)(q,{label:n.orderedList,icon:(0,m.jsx)(de.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:h})]}),O(b,2),x&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,m.jsx)(q,{label:n.blockquote,icon:(0,m.jsx)(fe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:h}),t.showCodeBlock&&(0,m.jsx)(q,{label:n.codeBlock,icon:(0,m.jsx)(pe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:h}),t.showLink&&(0,m.jsx)(q,{label:n.link,icon:(0,m.jsx)(me.default,{fontSize:`small`}),onClick:()=>s(!0),active:e?.isActive(`link`),disabled:h}),t.showHorizontalRule&&(0,m.jsx)(q,{label:n.horizontalRule,icon:(0,m.jsx)(he.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:h})]}),O(x,3),S&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,m.jsx)(mn,{label:n.textColor,icon:(0,m.jsx)(ge.default,{fontSize:`small`}),activeColor:g,disabled:h,onClick:e=>d(e.currentTarget)}),t.showHighlight&&(0,m.jsx)(mn,{label:n.highlight,icon:(0,m.jsx)(_e.default,{fontSize:`small`}),activeColor:_,disabled:h,onClick:e=>p(e.currentTarget)})]}),O(S,4),C&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(q,{label:n.undo,icon:(0,m.jsx)(T.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:h||!e?.can().undo()}),(0,m.jsx)(q,{label:n.redo,icon:(0,m.jsx)(E.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:h||!e?.can().redo()})]}),t.showClearFormat&&(0,m.jsx)(q,{label:n.clearFormat,icon:(0,m.jsx)(ve.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:h})]}),D===0&&(0,m.jsx)(l.Box,{sx:{height:32}}),t.showFullscreenButton&&(0,m.jsx)(l.Box,{sx:{ml:`auto`},children:(0,m.jsx)(l.Tooltip,{title:i?n.exitFullscreen:n.fullscreen,arrow:!0,children:(0,m.jsx)(`span`,{children:(0,m.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:a,disabled:r||!e,sx:{borderRadius:1},"aria-label":i?n.exitFullscreen:n.fullscreen,children:i?(0,m.jsx)(ae.default,{fontSize:`small`}):(0,m.jsx)(ie.default,{fontSize:`small`})})})})})]}),t.showLink&&e&&(0,m.jsx)(ln,{open:o,onClose:()=>s(!1),editor:e,translation:n}),t.showTextColor&&(0,m.jsx)(pn,{anchorEl:u,open:!!u,onClose:()=>d(null),mode:`textColor`,activeColor:g,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,m.jsx)(pn,{anchorEl:f,open:!!f,onClose:()=>p(null),mode:`highlight`,activeColor:_,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight})]})}function _n({helperText:e,error:t,showCharacterCount:n,charCount:r,maxCharacters:i,showWordCount:a,wordCount:o,translation:s}){let c=i===void 0?s.characterCount.replace(`{count}`,String(r)):s.characterCountMax.replace(`{count}`,String(r)).replace(`{max}`,String(i)),u=i!==void 0&&r>=i?`error`:`text.secondary`,d=s.wordCount.replace(`{count}`,String(o));return(0,m.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,m.jsx)(l.FormHelperText,{error:t,children:e??``}),(n||a)&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:1.5,alignItems:`center`},children:[a&&(0,m.jsx)(l.FormHelperText,{sx:{color:`text.secondary`},children:d}),n&&(0,m.jsx)(l.FormHelperText,{sx:{color:u},children:c})]})]})}function vn({disabled:e=!1,error:t=!1,height:n,helperText:r,maxCharacters:i,name:a,placeholder:o,readonly:s=!1,showCharacterCount:u=!1,showToolbar:d=!0,showWordCount:f=!1,toolbarConfig:p,translation:h,value:g,width:_,onBlur:v,onChange:y,onFocus:b}){let x={...sn,...h},S={...on,...p},[C,w]=(0,c.useState)(!1),T=J(n),E=J(_),D=T===`auto`,O=D?void 0:T??200,k=i!==void 0&&i>0||u||f,A=(0,H.useEditor)({shouldRerenderOnTransaction:!0,extensions:[U.StarterKit.configure({link:{openOnClick:!1}}),W.TextStyle,G.Color,ee.Highlight.configure({multicolor:!0}),re.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),te.Placeholder.configure({placeholder:o??``}),...k?i!==void 0&&i>0?[ne.CharacterCount.configure({limit:i})]:[ne.CharacterCount]:[]],content:g??``,editable:!e&&!s,onUpdate({editor:e}){y?.(e.getHTML())},onBlur(){v?.()},onFocus(){b?.()}});(0,c.useEffect)(()=>{!A||g===void 0||A.getHTML()!==g&&A.commands.setContent(g,{emitUpdate:!1})},[A,g]),(0,c.useEffect)(()=>{A&&A.setEditable(!e&&!s)},[A,e,s]);let j=A?.storage.characterCount?.characters?.()??0,M=A?.storage.characterCount?.words?.()??0,N=u||i!==void 0&&i>0||f||!!r;return(0,m.jsxs)(l.Box,{sx:C?{position:`fixed`,top:0,left:0,width:`100vw`,height:`100vh`,zIndex:1300,display:`flex`,flexDirection:`column`,bgcolor:`background.default`,p:1}:{width:E??`100%`,...D?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,m.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...C||D?{flex:1}:{height:O},borderColor:t?`error.main`:void 0,"&:focus-within":{borderColor:t?`error.main`:`primary.main`,borderWidth:2}},children:[d&&!s&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(gn,{editor:A,toolbarConfig:S,translation:x,disabled:e,isFullscreen:C,onToggleFullscreen:()=>w(e=>!e)}),(0,m.jsx)(l.Divider,{})]}),(0,m.jsx)(cn,{editor:A,error:t,disabled:e,readonly:s})]}),N&&(0,m.jsx)(_n,{helperText:r,error:t,showCharacterCount:u||i!==void 0&&i>0,charCount:j,maxCharacters:i&&i>0?i:void 0,showWordCount:f,wordCount:M,translation:x}),a&&(0,m.jsx)(`input`,{type:`hidden`,name:a,value:A?A.getHTML():``})]})}var yn={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0},bn={format:`Format SQL`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,execute:`Execute`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,errorCount:`{count} error(s)`},xn={standard:K.StandardSQL,mysql:K.MySQL,postgresql:K.PostgreSQL,sqlite:K.SQLite,mssql:K.MSSQL};function Sn({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:u,identifierColor:d,schema:f,onLint:p,onDiagnosticsChange:_,onViewReady:S,onCursorChange:C,onBlur:w,onFocus:T}){let E=(0,c.useRef)(null),D=(0,c.useRef)(null),O=(0,c.useRef)(t),k=(0,c.useRef)(C),A=(0,c.useRef)(w),j=(0,c.useRef)(T),M=(0,c.useRef)(S),N=(0,c.useRef)(p),P=(0,c.useRef)(_),F=(0,c.useRef)(new g.Compartment),I=(0,c.useRef)(new g.Compartment),L=(0,l.useTheme)(),R=L.palette.mode===`dark`,z=!!p,B=JSON.stringify(f);return(0,c.useEffect)(()=>{O.current=t},[t]),(0,c.useEffect)(()=>{k.current=C},[C]),(0,c.useEffect)(()=>{A.current=w},[w]),(0,c.useEffect)(()=>{j.current=T},[T]),(0,c.useEffect)(()=>{M.current=S},[S]),(0,c.useEffect)(()=>{N.current=p},[p]),(0,c.useEffect)(()=>{P.current=_},[_]),(0,c.useEffect)(()=>{if(!E.current)return;let t=D.current?.state.doc.toString()??e??``,c=s??L.palette.primary.main,l=u??L.palette.success.main,p=d??L.palette.info.main,m=y.HighlightStyle.define([{tag:x.tags.keyword,color:c,fontWeight:`bold`},{tag:x.tags.name,color:p},{tag:[x.tags.string,x.tags.special(x.tags.string)],color:l,fontWeight:`bold`},{tag:x.tags.number,color:L.palette.warning.main},{tag:[x.tags.lineComment,x.tags.blockComment],color:L.palette.text.disabled,fontStyle:`italic`},{tag:x.tags.operator,color:L.palette.text.secondary},{tag:[x.tags.function(x.tags.variableName),x.tags.function(x.tags.name)],color:L.palette.secondary.main},{tag:x.tags.typeName,color:L.palette.info.main},{tag:x.tags.invalid,color:L.palette.error.main,textDecoration:`underline wavy`}]),_=h.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:L.palette.text.primary},".cm-gutters":{backgroundColor:R?L.palette.grey[900]:L.palette.grey[50],color:L.palette.text.disabled,border:`none`,borderRight:`1px solid ${L.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{minWidth:`36px`,paddingLeft:`4px`},".cm-activeLineGutter":{backgroundColor:L.palette.action.selected},".cm-activeLine":{backgroundColor:L.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:L.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:L.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:L.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:L.palette.background.paper,border:`1px solid ${L.palette.divider}`,borderRadius:`4px`,boxShadow:L.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:L.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:L.palette.primary.main+`20`,color:L.palette.primary.main},".cm-completionMatchedText":{color:L.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:L.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:L.palette.error.main},".cm-lint-marker-warning":{color:L.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:L.palette.background.paper,border:`1px solid ${L.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${L.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${L.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${L.palette.info.main}`}},{dark:R}),S=f?Object.fromEntries(f.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,C=async e=>{let t=N.current;if(!t)return[];let n=e.state.doc.toString();try{let r=(await t(n)).map(t=>{let n=Math.max(1,Math.min(t.line,e.state.doc.lines)),r=e.state.doc.line(n);return{from:r.from+Math.max(0,(t.col??1)-1),to:r.to,severity:t.severity??`error`,message:t.message}});return P.current?.(r.length),r}catch{return[]}},w=[_,(0,y.syntaxHighlighting)(m),(0,K.sql)({dialect:xn[o],schema:S}),(0,v.history)(),(0,be.autocompletion)(),h.keymap.of([...v.defaultKeymap,...v.historyKeymap,...be.completionKeymap]),F.current.of(h.EditorView.editable.of(!r&&!i)),I.current.of(g.EditorState.readOnly.of(i)),(0,h.highlightActiveLine)(),...a?[(0,h.lineNumbers)(),(0,h.highlightActiveLineGutter)()]:[],...n?[(0,h.placeholder)(n)]:[],...z?[(0,b.lintGutter)(),(0,b.linter)(C,{delay:600})]:[],h.EditorView.updateListener.of(e=>{e.docChanged&&O.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);k.current(n.number,t-n.from+1)}),h.EditorView.domEventHandlers({blur:()=>{A.current?.()},focus:()=>{j.current?.()}})],T=new h.EditorView({state:g.EditorState.create({doc:t,extensions:w}),parent:E.current});return D.current=T,M.current(T),()=>{M.current(null),T.destroy(),D.current=null}},[R,o,z,s,u,d,B]),(0,c.useEffect)(()=>{let t=D.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,c.useEffect)(()=>{D.current?.dispatch({effects:[F.current.reconfigure(h.EditorView.editable.of(!r&&!i)),I.current.reconfigure(g.EditorState.readOnly.of(i))]})},[r,i]),(0,m.jsx)(l.Box,{ref:E,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:L.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}var Cn={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function wn({viewRef:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a}){let[o,s]=(0,c.useState)(!1),u=i||!e.current;function d(){let t=e.current?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})}function f(){let t=e.current;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function p(){let t=e.current;t&&((0,v.undo)(t),t.focus())}function h(){let t=e.current;t&&((0,v.redo)(t),t.focus())}function g(){let t=e.current;if(!t)return;let n=t.state.doc.toString();try{let e=(0,Se.format)(n,{language:Cn[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function _(){let t=e.current;!t||!a||a(t.state.doc.toString())}let y=t.showFormat,b=t.showCopy||t.showClear,x=t.showUndoRedo,O=t.showExecute&&!!a;return(0,m.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[y&&(0,m.jsx)(l.Box,{sx:{display:`flex`,gap:.25},children:(0,m.jsx)(q,{label:n.format,icon:(0,m.jsx)(D.default,{fontSize:`small`}),onClick:g,disabled:u})}),y&&(b||x)&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),b&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,m.jsx)(q,{label:o?n.copySuccess:n.copy,icon:o?(0,m.jsx)(C.default,{fontSize:`small`,color:`success`}):(0,m.jsx)(S.default,{fontSize:`small`}),onClick:d,disabled:u}),t.showClear&&(0,m.jsx)(q,{label:n.clear,icon:(0,m.jsx)(w.default,{fontSize:`small`}),onClick:f,disabled:u})]}),b&&x&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),x&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,m.jsx)(q,{label:n.undo,icon:(0,m.jsx)(T.default,{fontSize:`small`}),onClick:p,disabled:u}),(0,m.jsx)(q,{label:n.redo,icon:(0,m.jsx)(E.default,{fontSize:`small`}),onClick:h,disabled:u})]}),O&&(0,m.jsxs)(m.Fragment,{children:[(b||x)&&(0,m.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,m.jsx)(q,{label:n.execute,icon:(0,m.jsx)(xe.default,{fontSize:`small`}),onClick:_,disabled:u})]}),!y&&!b&&!x&&!O&&(0,m.jsx)(l.Box,{sx:{height:32}})]})}function Tn({helperText:e,error:t,showLineColumn:n,showErrorCount:r,diagnosticsCount:i,cursorLine:a,cursorCol:o,translation:s}){let c=s.lineColumn.replace(`{line}`,String(a)).replace(`{col}`,String(o)),u=s.errorCount.replace(`{count}`,String(i));return(0,m.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,m.jsxs)(l.Box,{children:[r&&i>0&&(0,m.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,m.jsx)(Ce.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,m.jsx)(l.FormHelperText,{sx:{color:`error.main`,m:0},children:u})]}),(0,m.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,m.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function En({value:e,onChange:t,placeholder:n,height:r,width:i,disabled:a=!1,readonly:o=!1,error:s=!1,helperText:u,name:d,dialect:f=`standard`,showLineNumbers:p=!0,showLineColumn:h=!0,showErrorCount:g=!1,toolbarConfig:_,translation:v,highlightColors:y,schema:b,onExecute:x,onLint:S,onBlur:C,onFocus:w}){let T={...bn,...v},E={...yn,..._},D=J(r),O=J(i),k=D===`auto`,A=k?void 0:D??300,j=(0,c.useRef)(null),[M,N]=(0,c.useState)({line:1,col:1}),[P,F]=(0,c.useState)(0),I=(0,c.useCallback)(e=>{j.current=e},[]),L=(0,c.useCallback)((e,t)=>{N({line:e,col:t})},[]),R=(0,c.useCallback)(e=>{F(e)},[]),z=h||g||!!u;return(0,m.jsxs)(l.Box,{sx:{width:O??`100%`,...k?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,m.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...k?{flex:1}:{height:A},borderColor:s?`error.main`:void 0,"&:focus-within":{borderColor:s?`error.main`:`primary.main`,borderWidth:2}},children:[!o&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(wn,{viewRef:j,toolbarConfig:E,translation:T,dialect:f,disabled:a,onExecute:x}),(0,m.jsx)(l.Divider,{})]}),(0,m.jsx)(Sn,{value:e,onChange:t,placeholder:n,disabled:a,readonly:o,showLineNumbers:p,dialect:f,keywordColor:y?.keyword,stringColor:y?.string,identifierColor:y?.identifier,schema:b,onLint:S,onDiagnosticsChange:S?R:void 0,onViewReady:I,onCursorChange:L,onBlur:C,onFocus:w})]}),z&&(0,m.jsx)(Tn,{helperText:u,error:s,showLineColumn:h,showErrorCount:g,diagnosticsCount:P,cursorLine:M.line,cursorCol:M.col,translation:T}),d&&(0,m.jsx)(`input`,{type:`hidden`,name:d,value:e??``})]})}exports.ConfirmDialogProvider=ke,exports.DEFAULT_CHECK_COLORS=qt,exports.DEFAULT_CONFIRM_DIALOG_TRANSLATION=we,exports.DEFAULT_GANTT_TRANSLATIONS=it,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=je,exports.DEFAULT_JSON_EDITOR_TRANSLATION=Me,exports.DEFAULT_METER_COLORS=Kt,exports.DEFAULT_PASSWORD_TRANSLATIONS=Gt,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=on,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=sn,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=yn,exports.DEFAULT_SQL_EDITOR_TRANSLATION=bn,exports.DEFAULT_TAG_SELECTION_TRANSLATION=tn,exports.GanttChart=Vt,exports.JsonEditor=Le,exports.PasswordStrengthMeter=Yt,exports.RichTextEditor=vn,exports.SqlEditor=En,exports.TagSelection=an,exports.useConfirm=Ae,exports.useGanttChartStore=Z,exports.useGanttTheme=It,exports.useGanttTranslations=Q,exports.useRawGanttChartStore=Nt;