@thebuoyant-tsdev/mui-ts-library 3.11.0 → 3.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +21 -0
- package/README.md +21 -0
- package/dist/components/chord-chart/ChordChart.d.ts +1 -1
- package/dist/components/chord-chart/ChordChart.js +155 -137
- package/dist/components/chord-chart/ChordChart.types.d.ts +1 -1
- package/dist/components/circle-packing-chart/CirclePackingChart.d.ts +1 -1
- package/dist/components/circle-packing-chart/CirclePackingChart.js +134 -121
- package/dist/components/gantt-chart/GanttTaskDialog.js +131 -126
- package/dist/components/gantt-chart/hooks/useGanttDrag.js +44 -38
- package/dist/components/gantt-chart/util/gantt-chart.util.d.ts +7 -0
- package/dist/components/gantt-chart/util/gantt-chart.util.js +31 -20
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.js +222 -206
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.types.d.ts +1 -1
- package/dist/components/json-editor/JsonEditorContent.js +134 -119
- package/dist/components/json-editor/JsonEditorToolbar.js +3 -3
- package/dist/components/password-strength-meter/PasswordStrengthMeter.js +131 -130
- package/dist/components/radial-tree-chart/RadialTreeChart.js +197 -186
- package/dist/components/rich-text-editor/RichTextEditor.js +1 -1
- package/dist/components/rich-text-editor/RichTextEditorMarkdownDialog.js +40 -39
- package/dist/components/shared/useTimedFlag.d.ts +6 -0
- package/dist/components/shared/useTimedFlag.js +14 -0
- package/dist/components/sql-editor/SqlEditorHistoryMenu.js +1 -1
- package/dist/components/sql-editor/useSqlQueryHistory.js +14 -12
- package/dist/components/sql-editor/util/sqlQueryHistory.util.d.ts +1 -0
- package/dist/components/sql-editor/util/sqlQueryHistory.util.js +21 -13
- package/dist/components/sunburst-chart/SunburstChart.d.ts +1 -1
- package/dist/components/sunburst-chart/SunburstChart.js +126 -115
- package/dist/components/tag-selection/TagSelectionAutocomplete.js +7 -5
- package/dist/index.cjs +2 -2
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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(`@codemirror/view`),d=require(`@codemirror/state`),f=require(`@codemirror/lang-json`),p=require(`@codemirror/commands`),m=require(`@codemirror/language`),h=require(`@codemirror/lint`),g=require(`@lezer/highlight`),_=require(`@replit/codemirror-minimap`),v=require(`react/jsx-runtime`),y=require(`@mui/icons-material/ContentCopy`);y=s(y,1);let b=require(`@mui/icons-material/Check`);b=s(b,1);let x=require(`@mui/icons-material/Delete`);x=s(x,1);let S=require(`@mui/icons-material/Undo`);S=s(S,1);let C=require(`@mui/icons-material/Redo`);C=s(C,1);let w=require(`@mui/icons-material/AutoFixHigh`);w=s(w,1);let T=require(`@mui/icons-material/Compress`);T=s(T,1);let E=require(`@mui/icons-material/CheckCircleOutlined`);E=s(E,1);let D=require(`@mui/icons-material/ErrorOutlined`);D=s(D,1);let O=require(`zustand`),k=require(`zustand/vanilla`),A=require(`@tanstack/react-virtual`),j=require(`@mui/icons-material/Add`);j=s(j,1);let M=require(`@mui/icons-material/Edit`);M=s(M,1);let N=require(`@mui/icons-material/Download`);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/CheckCircle`);z=s(z,1);let B=require(`@mui/icons-material/Cancel`);B=s(B,1);let V=require(`@mui/icons-material/Visibility`);V=s(V,1);let H=require(`@mui/icons-material/VisibilityOff`);H=s(H,1);let U=require(`@mui/icons-material/Close`);U=s(U,1);let W=require(`@tiptap/react`),G=require(`@tiptap/starter-kit`),K=require(`@tiptap/extension-text-style`),q=require(`@tiptap/extension-color`),J=require(`@tiptap/extension-highlight`),Y=require(`@tiptap/extension-placeholder`),X=require(`@tiptap/extension-character-count`),ee=require(`@tiptap/extension-table`),te=require(`@tiptap/extension-image`),ne=require(`tiptap-markdown`),re=require(`@mui/icons-material/Fullscreen`);re=s(re,1);let ie=require(`@mui/icons-material/FullscreenExit`);ie=s(ie,1);let ae=require(`@mui/icons-material/Image`);ae=s(ae,1);let oe=require(`@mui/icons-material/EmojiEmotions`);oe=s(oe,1);let se=require(`@mui/icons-material/FormatBold`);se=s(se,1);let ce=require(`@mui/icons-material/FormatItalic`);ce=s(ce,1);let le=require(`@mui/icons-material/FormatUnderlined`);le=s(le,1);let ue=require(`@mui/icons-material/StrikethroughS`);ue=s(ue,1);let de=require(`@mui/icons-material/FormatListBulleted`);de=s(de,1);let fe=require(`@mui/icons-material/FormatListNumbered`);fe=s(fe,1);let pe=require(`@mui/icons-material/FormatQuote`);pe=s(pe,1);let me=require(`@mui/icons-material/Code`);me=s(me,1);let he=require(`@mui/icons-material/InsertLink`);he=s(he,1);let ge=require(`@mui/icons-material/HorizontalRule`);ge=s(ge,1);let _e=require(`@mui/icons-material/FormatColorText`);_e=s(_e,1);let ve=require(`@mui/icons-material/BorderColor`);ve=s(ve,1);let ye=require(`@mui/icons-material/FormatClear`);ye=s(ye,1);let be=require(`@mui/icons-material/ContentPaste`);be=s(be,1);let xe=require(`@mui/icons-material/ContentPasteOff`);xe=s(xe,1);let Se=require(`@mui/icons-material/FormatColorReset`);Se=s(Se,1);let Ce=require(`@mui/icons-material/TableChart`);Ce=s(Ce,1);let we=require(`@mui/icons-material/Search`);we=s(we,1);let Te=require(`@codemirror/lang-sql`),Ee=require(`@codemirror/autocomplete`),De=require(`@mui/icons-material/PlayArrow`);De=s(De,1);let Oe=require(`sql-formatter`),ke=require(`@mui/icons-material/History`);ke=s(ke,1);let Ae=require(`@mui/icons-material/DeleteSweep`);Ae=s(Ae,1);let je=require(`@mui/icons-material/WarningAmber`);je=s(je,1);let Z=require(`d3`);Z=s(Z,1);var Me={showFormat:!0,showCompact:!0,showCopy:!0,showClear:!0,showUndoRedo:!0},Ne={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`},Pe=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Fe=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]);function Ie(e){return Pe.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Le(e,t){if(e.doc.length===0)return null;let n=(0,m.syntaxTree)(e).resolveInner(t,1);if(!n)return null;let r=[];for(;n;){let t=n.parent;if(!t)break;if(t.name===`Property`){let i=t.getChild(`PropertyName`);if(i){let t=e.sliceDoc(i.from,i.to);try{r.unshift(Ie(JSON.parse(t)))}catch{}}n=t.parent??t;continue}if(t.name===`Array`){let e=0,i=t.firstChild;for(;i&&i.from<n.from;)Fe.has(i.name)&&e++,i=i.nextSibling;r.unshift(`[${e}]`),n=t;continue}n=t}return r.length>0?`$${r.join(``)}`:`$`}var Re=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]),ze=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Be(e){return ze.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Ve(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:`object`}function He(e,t){let n=Ve(e);return n===t||t===`number`&&n===`integer`}function Ue(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>Ue(e,t[n]));if(e&&t&&typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>Ue(e[n],t[n])):!1}return!1}function We(e,t,n=`$`){let r=[];if(t.type){let i=Array.isArray(t.type)?t.type:[t.type];if(!i.some(t=>He(e,t)))return r.push({path:n,message:`Expected type ${i.join(` | `)}, got ${Ve(e)}.`}),r}if(t.enum&&!t.enum.some(t=>Ue(t,e))&&r.push({path:n,message:`Value must be one of: ${t.enum.map(e=>JSON.stringify(e)).join(`, `)}.`}),Ve(e)===`object`&&e!==null){let i=e;for(let e of t.required??[])e in i||r.push({path:n,message:`Missing required property "${e}".`});if(t.properties)for(let[e,a]of Object.entries(t.properties))e in i&&r.push(...We(i[e],a,`${n}${Be(e)}`))}return t.items&&Array.isArray(e)&&e.forEach((e,i)=>{r.push(...We(e,t.items,`${n}[${i}]`))}),r}var Ge=/\.([A-Za-z_$][A-Za-z0-9_$]*)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]/g;function Ke(e){let t=[];for(let n of e.matchAll(Ge))n[1]===void 0?n[2]===void 0?n[3]!==void 0&&t.push({type:`key`,value:JSON.parse(`"${n[3]}"`)}):t.push({type:`index`,value:Number(n[2])}):t.push({type:`key`,value:n[1]});return t}function qe(e){let t=e.topNode;for(;t&&!Re.has(t.name);){let e=t.firstChild;if(!e)return null;t=e}return t}function Je(e,t){let n=qe((0,m.syntaxTree)(e));if(!n)return null;for(let r of Ke(t))if(r.type===`key`){if(n.name!==`Object`)return null;let t=null;for(let i=n.firstChild;i;i=i.nextSibling){if(i.name!==`Property`)continue;let n=i.getChild(`PropertyName`);if(n)try{if(JSON.parse(e.sliceDoc(n.from,n.to))===r.value){t=i.lastChild;break}}catch{}}if(!t)return null;n=t}else{if(n.name!==`Array`)return null;let e=0,t=null;for(let i=n.firstChild;i;i=i.nextSibling)if(Re.has(i.name)){if(e===r.value){t=i;break}e++}if(!t)return null;n=t}return{from:n.from,to:n.to}}function Ye({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,schema:a,showLineNumbers:o=!0,showMinimap:s=!1,showFolding:y=!0,enablePathFinder:b=!0,highlightColors:x,onViewReady:S,onCursorChange:C,onBlur:w,onFocus:T,onPathCopy:E}){let D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(null),A=(0,c.useRef)(t),j=(0,c.useRef)(C),M=(0,c.useRef)(w),N=(0,c.useRef)(T),P=(0,c.useRef)(S),F=(0,c.useRef)(E),I=(0,c.useRef)(b),L=(0,c.useRef)(a),[R,z]=(0,c.useState)(null),B=(0,c.useRef)(new d.Compartment),V=(0,c.useRef)(new d.Compartment),H=(0,l.useTheme)(),U=H.palette.mode===`dark`,W=x?.propertyName??H.palette.primary.main,G=x?.string??H.palette.success.main,K=x?.number??H.palette.warning.main,q=x?.boolean??H.palette.info.main,J=x?.null??H.palette.text.secondary;return(0,c.useEffect)(()=>{A.current=t},[t]),(0,c.useEffect)(()=>{j.current=C},[C]),(0,c.useEffect)(()=>{M.current=w},[w]),(0,c.useEffect)(()=>{N.current=T},[T]),(0,c.useEffect)(()=>{P.current=S},[S]),(0,c.useEffect)(()=>{F.current=E},[E]),(0,c.useEffect)(()=>{I.current=b},[b]),(0,c.useEffect)(()=>{L.current=a,k.current&&(0,h.forceLinting)(k.current)},[a]),(0,c.useEffect)(()=>{if(!O.current)return;let t=k.current?.state.doc.toString()??e??``,a=m.HighlightStyle.define([{tag:g.tags.propertyName,color:W,fontWeight:`bold`},{tag:g.tags.string,color:G},{tag:g.tags.number,color:K},{tag:g.tags.bool,color:q,fontWeight:`bold`},{tag:g.tags.null,color:J,fontStyle:`italic`},{tag:g.tags.bracket,color:H.palette.text.secondary},{tag:g.tags.punctuation,color:H.palette.text.disabled},{tag:g.tags.invalid,color:H.palette.error.main,textDecoration:`underline wavy`}]),c=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:H.palette.text.primary},".cm-gutters":{backgroundColor:U?H.palette.grey[900]:H.palette.grey[50],color:H.palette.text.disabled,border:`none`,borderRight:`1px solid ${H.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:H.palette.action.selected},".cm-activeLine":{backgroundColor:H.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:H.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:H.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:H.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:H.palette.error.main},".cm-lint-marker-warning":{color:H.palette.warning.main},".cm-foldGutter .cm-gutterElement":{cursor:`pointer`,color:H.palette.text.disabled},".cm-foldPlaceholder":{backgroundColor:H.palette.action.selected,border:`1px solid ${H.palette.divider}`,borderRadius:`3px`,color:H.palette.text.secondary,padding:`0 4px`},".cm-tooltip.cm-tooltip-lint":{backgroundColor:H.palette.background.paper,border:`1px solid ${H.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${H.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${H.palette.warning.main}`}},{dark:U}),l=s?[_.showMinimap.of({create:()=>{let e=document.createElement(`div`);return e.style.width=`80px`,e.style.overflow=`hidden`,e.style.borderLeft=`1px solid ${H.palette.divider}`,e.style.backgroundColor=U?H.palette.grey[900]:H.palette.grey[50],{dom:e}},displayText:`blocks`,showOverlay:`always`})]:[],v=[c,(0,m.syntaxHighlighting)(a),(0,f.json)(),(0,h.lintGutter)(),(0,h.linter)((0,f.jsonParseLinter)()),(0,h.linter)(e=>{let t=L.current;if(!t)return[];let n;try{n=JSON.parse(e.state.doc.toString())}catch{return[]}let r=[];for(let i of We(n,t)){let t=Je(e.state,i.path);t&&r.push({from:t.from,to:t.to,severity:`error`,message:i.message})}return r}),(0,p.history)(),u.keymap.of([...p.defaultKeymap,...p.historyKeymap,...m.foldKeymap]),B.current.of(u.EditorView.editable.of(!r&&!i)),V.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),...o?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[],...y?[(0,m.foldGutter)()]:[],...n?[(0,u.placeholder)(n)]:[],...l,u.EditorView.updateListener.of(e=>{e.docChanged&&A.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);j.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{M.current?.()},focus:()=>{N.current?.()},click:(e,t)=>{if(!I.current||!(e.ctrlKey||e.metaKey))return!1;let n;try{n=t.posAtCoords({x:e.clientX,y:e.clientY})}catch{return!1}if(n===null)return!1;let r=Le(t.state,n);return r?(navigator.clipboard.writeText(r).then(()=>{let t=D.current?.getBoundingClientRect();z({x:e.clientX-(t?.left??0),y:e.clientY-(t?.top??0),path:r}),F.current?.(r)}),!0):!1}})],b=new u.EditorView({state:d.EditorState.create({doc:t,extensions:v}),parent:O.current});return k.current=b,P.current(b),()=>{P.current(null),b.destroy(),k.current=null}},[U,W,G,K,q,J,s]),(0,c.useEffect)(()=>{let t=k.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)(()=>{k.current?.dispatch({effects:[B.current.reconfigure(u.EditorView.editable.of(!r&&!i)),V.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,c.useEffect)(()=>{if(!R)return;let e=setTimeout(()=>z(null),1500);return()=>clearTimeout(e)},[R]),(0,v.jsxs)(l.Box,{ref:D,sx:{position:`relative`,flex:1,overflow:`hidden`,display:`flex`},children:[(0,v.jsx)(l.Box,{ref:O,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:H.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}}),R&&(0,v.jsx)(l.Fade,{in:!0,children:(0,v.jsx)(l.Paper,{elevation:3,sx:{position:`absolute`,left:R.x,top:R.y,transform:`translate(-50%, -130%)`,px:1,py:.5,pointerEvents:`none`,zIndex:10,bgcolor:`grey.900`,color:`common.white`},children:(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{fontFamily:`monospace`},children:[`Copied: `,R.path]})})})]})}function Q({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.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 Xe({editorView:e,toolbarConfig:t,translation:n,indent:r,disabled:i}){let[a,o]=(0,c.useState)(!1),s=i||!e;function u(){let t=e;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;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?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})}function m(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function h(){let t=e;t&&((0,p.undo)(t),t.focus())}function g(){let t=e;t&&((0,p.redo)(t),t.focus())}let _=t.showFormat||t.showCompact,E=t.showCopy||t.showClear,D=t.showUndoRedo;return(0,v.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,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:u,disabled:s}),t.showCompact&&(0,v.jsx)(Q,{label:n.compact,icon:(0,v.jsx)(T.default,{fontSize:`small`}),onClick:d,disabled:s})]}),_&&(E||D)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),E&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:a?n.copySuccess:n.copy,icon:a?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:f,disabled:s}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:m,disabled:s})]}),E&&D&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),D&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:h,disabled:s}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:g,disabled:s})]}),!_&&!E&&!D&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function Ze({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,v.jsx)(E.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,v.jsx)(D.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,v.jsx)(l.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function Qe(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function $e(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function et({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,schema:m,showLineNumbers:h=!0,showLineColumn:g=!0,showMinimap:_=!1,showFolding:y=!0,showValidation:b=!1,enablePathFinder:x=!0,toolbarConfig:S,translation:C,highlightColors:w,onBlur:T,onFocus:E,onPathCopy:D}){let O={...Ne,...C},k={...Me,...S},A=Qe(i),j=Qe(a),M=A===`auto`,N=M?void 0:A??300,P=(0,c.useRef)(null),[F,I]=(0,c.useState)(null),[L,R]=(0,c.useState)({line:1,col:1}),[z,B]=(0,c.useState)(()=>$e(e??``)),V=(0,c.useCallback)(e=>{P.current=e,I(e)},[]),H=(0,c.useCallback)((e,t)=>{R({line:e,col:t})},[]),U=(0,c.useCallback)(e=>{let r=$e(e);B(r),n?.(r),t?.(e)},[t,n]),W=g||b||!!d;return(0,v.jsxs)(l.Box,{sx:{width:j??`100%`,...M?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...M?{flex:1}:{height:N},borderColor:u?`error.main`:void 0,"&:focus-within":{borderColor:u?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Xe,{editorView:F,toolbarConfig:k,translation:O,indent:p,disabled:o}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(Ye,{value:e,onChange:U,placeholder:r,disabled:o,readonly:s,schema:m,showLineNumbers:h,showMinimap:_,showFolding:y,enablePathFinder:x,highlightColors:w,onViewReady:V,onCursorChange:H,onBlur:T,onFocus:E,onPathCopy:D})]}),W&&(0,v.jsx)(Ze,{helperText:d,error:u,showLineColumn:g,showValidation:b,isValid:z,cursorLine:L.line,cursorCol:L.col,translation:O}),f&&(0,v.jsx)(`input`,{type:`hidden`,name:f,value:e??``})]})}function tt(e){let t=new Date,n=_t(t),r=vt(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=st(lt(new Date(Math.min(...i)),-1)),s=ct(lt(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function nt(e,t){return t===`weeks`?{start:pt(e.start),end:e.end}:t===`quarters`?{start:_t(e.start),end:vt(e.end)}:e}function rt(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 it(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 at(n,0),n}function at(e,t){for(let n of e)n.depth=t,at(n.children,t+1)}function ot(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 st(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function ct(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function lt(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function ut(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function dt(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 ft(e){let t=[],n=st(e.start);for(;n<=e.end;)t.push(n),n=lt(n,1);return t}function pt(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 mt(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 ht(e){let t=[],n=pt(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function gt(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 _t(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function vt(e){let t=Math.floor(e.getMonth()/3)*3+2;return ct(new Date(e.getFullYear(),t,1))}function yt(e){let t=[],n=_t(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 bt(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 xt(e,t){let n=t.startDate<e.start?st(lt(t.startDate,-1)):e.start,r=t.endDate>e.end?ct(lt(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function St(e,t=`months`,n=!1,r,i=!1){let a=tt(e);return(0,k.createStore)((o,s)=>({tasks:e,taskTree:it(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:it(e),...t.isRangeCustomized?{}:{timelineRange:tt(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:it(n),timelineRange:xt(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=dt(r,e.id,t)}let i=xt(t.timelineRange,e);for(let e of r)i=xt(i,e);return{tasks:r,taskTree:it(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:it(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:tt(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:tt(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 ot(e,t)}}))}var Ct={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`,todayLabel:`Heute`,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`,columnAssignee:`Assignee`,exportCsvTooltip:`Als CSV exportieren`,addTaskTooltip:`Aufgabe hinzufügen`,editTaskTooltip:`Aufgabe bearbeiten`,deleteTaskTooltip:`Aufgabe löschen`},wt={planned:`warning.light`,"in-progress":`info.main`,done:`success.main`,blocked:`error.main`},Tt={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function Et(e){return e.toISOString().slice(0,10)}function Dt(e,t,n){return e<t?t:e>n?n:e}function Ot(e){return e.flatMap(e=>[e,...Ot(e.children)])}function kt({label:e}){let t=(0,c.useRef)(null),[n,r]=(0,c.useState)(!1);return(0,v.jsx)(l.Tooltip,{title:e,disableHoverListener:!n,children:(0,v.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 At({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=en(),s=$(e=>e.taskTree),u=$(e=>e.timelineRange),d=(0,c.useMemo)(()=>Ot(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)),m=p,h=Et(Dt(new Date,u.start,u.end)),[g,_]=(0,c.useState)({name:``,startDate:h,endDate:h,status:`planned`,isMilestone:!1,parentId:``,dependencies:[],assignee:``});(0,c.useEffect)(()=>{if(!e)return;let i=Et(Dt(new Date,u.start,u.end));_(t===`edit`&&n?{name:n.name,startDate:Et(n.startDate),endDate:Et(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,parentId:n.parentId??``,dependencies:n.dependencies??[],assignee:n.assignee??``}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,parentId:r??``,dependencies:[],assignee:``})},[e,t,n,r,u]);let y=e=>{_(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},b=e=>{_(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},x=e=>{_(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate}))},S=g.name.trim()!==``&&g.startDate!==``&&g.endDate!==``&&g.endDate>=g.startDate,C=()=>{S&&i({name:g.name.trim(),startDate:new Date(g.startDate),endDate:new Date(g.endDate),status:g.status,isMilestone:g.isMilestone||void 0,parentId:g.parentId||void 0,dependencies:g.dependencies.length>0?g.dependencies:void 0,assignee:g.assignee.trim()||void 0})},w=[`planned`,`in-progress`,`done`,`blocked`],T={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,v.jsxs)(l.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.TextField,{label:o.dialogFieldName,value:g.name,onChange:e=>_(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,v.jsx)(l.TextField,{label:o.columnAssignee,value:g.assignee,onChange:e=>_(t=>({...t,assignee:e.target.value})),fullWidth:!0,size:`small`,placeholder:`e.g. Jane Smith`,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-assignee`}}}),(0,v.jsx)(l.TextField,{label:o.dialogFieldStartDate,type:`date`,value:g.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,v.jsx)(l.TextField,{label:o.dialogFieldEndDate,type:`date`,value:g.endDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,disabled:g.isMilestone,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-end`,min:g.startDate}}}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldStatus}),(0,v.jsx)(l.Select,{value:g.status,label:o.dialogFieldStatus,onChange:e=>_(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:w.map(e=>(0,v.jsx)(l.MenuItem,{value:e,children:T[e]},e))})]}),(0,v.jsx)(l.FormControlLabel,{control:(0,v.jsx)(l.Checkbox,{checked:g.isMilestone,onChange:e=>x(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldParent}),(0,v.jsxs)(l.Select,{value:g.parentId,label:o.dialogFieldParent,onChange:e=>_(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,v.jsx)(l.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.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,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(kt,{label:e.name})]})},e.id))]})]}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldDependencies}),(0,v.jsx)(l.Select,{multiple:!0,value:g.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;_(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:m.map(e=>(0,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.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,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(kt,{label:e.name})]})},e.id))})]})]}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:a,children:o.dialogCancel}),(0,v.jsx)(l.Button,{onClick:C,variant:`contained`,disabled:!S,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function jt({open:e,task:t,onConfirm:n,onClose:r}){let i=en(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,v.jsxs)(l.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:i.dialogDeleteTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.jsx)(l.DialogContentText,{children:a})}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:r,children:i.dialogCancel}),(0,v.jsx)(l.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}function Mt(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function Nt({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,showAssigneeColumn:i,onTaskClick:a,onAddTask:o,onEditTask:s,onDeleteTask:u,onStatusChange:d,inlineEdit:f,onInlineRename:p}){let[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),y=en(),{statusColors:b}=nn(),S=()=>{g!==null&&g.trim()&&p?.(e,g.trim()),_(null)};return(0,v.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:a?`pointer`:`default`,"&:hover":a?{bgcolor:`action.hover`}:void 0},onClick:()=>a?.(e),children:[(0,v.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,v.jsx)(l.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,v.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,v.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??b?.[e.status]??wt[e.status]??`grey.400`}}),g===null?(0,v.jsx)(l.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:f?`text`:`inherit`},onDoubleClick:f?t=>{t.stopPropagation(),_(e.name)}:void 0,children:e.name}):(0,v.jsx)(l.TextField,{size:`small`,variant:`standard`,value:g,autoFocus:!0,onChange:e=>_(e.target.value),onBlur:S,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S()),e.key===`Escape`&&(e.stopPropagation(),_(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),i&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1,overflow:`hidden`},children:(0,v.jsx)(l.Typography,{variant:`caption`,noWrap:!0,color:e.assignee?`text.primary`:`text.disabled`,children:e.assignee??`—`})}),r&&(0,v.jsxs)(l.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[s&&(0,v.jsx)(l.Tooltip,{title:y.editTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.editTaskTooltip,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,v.jsx)(M.default,{fontSize:`inherit`})})}),o&&(0,v.jsx)(l.Tooltip,{title:y.addTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.addTaskTooltip,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,v.jsx)(j.default,{fontSize:`inherit`})})}),u&&(0,v.jsx)(l.Tooltip,{title:y.deleteTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.deleteTaskTooltip,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),u(e)},children:(0,v.jsx)(x.default,{fontSize:`inherit`})})})]}),(0,v.jsxs)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,v.jsx)(l.Chip,{label:Mt(e.status,y),size:`small`,variant:`outlined`,color:e.color??b?.[e.status]?`default`:Tt[e.status]??`default`,sx:{height:20,fontSize:10,cursor:d?`pointer`:`default`,...(e.color??b?.[e.status])&&{borderColor:e.color??b?.[e.status],color:e.color??b?.[e.status]}},onClick:d?e=>{e.stopPropagation(),h(e.currentTarget)}:void 0}),d&&(0,v.jsx)(l.Menu,{anchorEl:m,open:!!m,onClose:()=>h(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,v.jsx)(l.MenuItem,{selected:e.status===t,onClick:()=>{d(e,t),h(null)},children:Mt(t,y)},t))})]})]})}function Pt({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:m,inlineEdit:h,virtualizeRows:g=!1,showAssigneeColumn:_=!1}){let y=en(),b=Qt(),x=$(e=>e.taskTree),S=$(e=>e.expandedIds),C=$(e=>e.toggleExpand),w=$(e=>e.timeScale),T=$(e=>e.addTask),E=$(e=>e.updateTask),D=$(e=>e.deleteTask),O=(0,c.useMemo)(()=>ot(x,S),[x,S]),k=(0,A.useVirtualizer)({count:O.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(!1),[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(null),z=e=>{let t={...e,id:crypto.randomUUID()};T(t),u?.(b.getState().tasks),f?.(t),M(!1)},B=e=>{if(!L)return;let t={...e,id:L.id};E(t),u?.(b.getState().tasks),p?.(t),P(!1)},V=()=>{L&&(D(L.id),u?.(b.getState().tasks),m?.(L.id),I(!1))},H=(e,t)=>{let n={...e,name:t};E(n),u?.(b.getState().tasks),p?.(n)},U=d?e=>{R(e),M(!0)}:i,W=d?e=>{R(e),P(!0)}:a,G=d?e=>{R(e),I(!0)}:o,K=!!(U||W||G),q=w===`days`?80:40;return(0,v.jsxs)(l.Box,{ref:e,onScroll:t,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`},children:[(0,v.jsxs)(l.Box,{sx:{height:q,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,v.jsxs)(l.Box,{sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:w===`days`?`1px solid`:void 0,borderColor:w===`days`?`divider`:void 0},children:[(0,v.jsx)(l.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnName})}),_&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnAssignee})}),K&&(0,v.jsx)(l.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnActions})}),(0,v.jsx)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnStatus})})]}),w===`days`&&(0,v.jsx)(l.Box,{sx:{flex:1}})]}),g?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:k.getTotalSize()},children:k.getVirtualItems().map(e=>(0,v.jsx)(l.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,v.jsx)(Nt,{task:O[e.index],expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0})},e.key))}):O.map(e=>(0,v.jsx)(Nt,{task:e,expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0},e.id)),d&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(At,{open:j,mode:`add`,defaultParentId:L?.id,onSave:z,onClose:()=>M(!1)}),(0,v.jsx)(At,{open:N,mode:`edit`,initialTask:L??void 0,onSave:B,onClose:()=>P(!1)}),(0,v.jsx)(jt,{open:F,task:L,onConfirm:V,onClose:()=>I(!1)})]})]})}var Ft=864e5;function It({totalWidth:e,displayRange:t,onTaskMoved:n,onTaskResized:r,onTasksChange:i}){let a=$(e=>e.updateTask),o=Qt(),s=en(),l=(0,c.useRef)(1),u=(0,c.useRef)(n),d=(0,c.useRef)(r),f=(0,c.useRef)(i);(0,c.useLayoutEffect)(()=>{l.current=e>0?e/((t.end.getTime()-t.start.getTime())/Ft):1,u.current=n,d.current=r,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=ut(e.originalStart,t.deltaDays),i=ut(e.originalEnd,t.deltaDays);a({...n,startDate:r,endDate:i}),u.current?.(n,r,i)}else{let r=ut(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:ut(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 Lt({items:e}){return(0,v.jsx)(l.Box,{sx:{display:`flex`},children:e.map(e=>(0,v.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,v.jsx)(l.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function Rt({columns:e,groups:t,todayX:n,todayLabel:r,todayTooltip:i,todayColor:a}){let o=(0,l.useTheme)(),s=t?80:40,c=a||o.palette.primary.main,u=o.palette.getContrastText(c);return(0,v.jsxs)(l.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:s,overflow:`visible`},children:[t&&(0,v.jsx)(l.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,v.jsx)(Lt,{items:t})}),(0,v.jsx)(Lt,{items:e}),n!=null&&r&&(0,v.jsx)(l.Tooltip,{title:i??``,placement:`top`,arrow:!0,children:(0,v.jsx)(l.Chip,{"data-testid":`gantt-today-chip`,size:`small`,label:r,sx:{position:`absolute`,bottom:0,left:n,transform:`translateX(-50%) translateY(50%)`,zIndex:3,height:20,fontSize:`0.65rem`,fontWeight:700,letterSpacing:`0.03em`,backgroundColor:c,color:u,border:`1.5px solid ${c}`,boxShadow:o.shadows[2],cursor:`default`,userSelect:`none`,"& .MuiChip-label":{px:`6px`,py:0},"&:hover":{backgroundColor:c,opacity:.9}}})})]})}function zt({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:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_}){let y=(0,l.useTheme)(),{statusColors:b,criticalPathColor:x,milestoneColor:S,barBorderRadius:C}=nn(),w=n?.taskId===e.id,T=e;if(w&&n)if(n.type===`move`)T={...e,startDate:ut(e.startDate,n.deltaDays),endDate:ut(e.endDate,n.deltaDays)};else if(n.type===`resize`){let t=ut(e.endDate,n.deltaDays);T={...e,endDate:t>e.startDate?t:ut(e.startDate,1)}}else n.type===`progress`&&n.newProgress!==void 0&&(T={...e,progress:n.newProgress});let{left:E,width:D}=rt(T,r);return(0,v.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,v.jsx)(Bt,{task:e,left:E,milestoneColor:S,criticalPathColor:x,isCritical:o.has(e.id),onMilestoneClick:f,theme:y}):(0,v.jsx)(Vt,{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:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_,theme:y})})}function Bt({task:e,left:t,milestoneColor:n,criticalPathColor:r,isCritical:i,onMilestoneClick:a,theme:o}){return t<0||t>100?null:(0,v.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 Vt({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:m,onTaskClick:h,onContextMenu:g,suppressClickRef:_,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,v.jsxs)(v.Fragment,{children:[a&&o&&o.type!==`progress`&&o.deltaDays!==0&&(0,v.jsx)(Ht,{left:C,children:o.type===`move`?`${x(t.startDate)} – ${x(t.endDate)}`:`→ ${x(t.endDate)}`}),a&&o?.type===`progress`&&o.newProgress!==void 0&&(0,v.jsxs)(Ht,{left:C,children:[o.newProgress,`%`]}),(0,v.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]??wt[e.status]??`grey.300`,borderRadius:m===void 0?1:`${m}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`:h?`pointer`:`default`,userSelect:`none`,"&:hover":s||h?{opacity:a?.75:.8}:void 0},onMouseDown:s?t=>y(t,e,`move`):void 0,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),g(e,t.clientX,t.clientY)},onClick:()=>{if(_.current){_.current=!1;return}h?.(e)},children:[t.progress!==void 0&&t.progress>0&&(0,v.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,v.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,v.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 Ht({left:e,children:t}){return(0,v.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 Ut({strips:e,totalWidth:t,height:n,top:r}){let{weekendColor:i}=nn();return e.length===0?null:(0,v.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,v.jsx)(l.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:i||`action.hover`}},e.key))})}function Wt({contextMenu:e,onClose:t,onSelect:n}){let r=en(),i={planned:r.statusPlanned,"in-progress":r.statusInProgress,done:r.statusDone,blocked:r.statusBlocked};return(0,v.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,v.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 Gt({dependencyLines:e,todayX:t,totalWidth:n,height:r,top:i,arrowMarkerId:a}){let o=(0,l.useTheme)(),{todayLineColor:s}=nn();return e.length===0&&t===null?null:(0,v.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,v.jsx)(`defs`,{children:(0,v.jsx)(`marker`,{id:a,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,v.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),e.map(e=>(0,v.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,v.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 Kt(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=rt(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=rt(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 qt({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:m}){let h=$(e=>e.taskTree),g=$(e=>e.tasks),_=$(e=>e.expandedIds),y=$(e=>e.timelineRange),b=$(e=>e.timeScale),x=$(e=>e.updateTask),S=Qt(),C=en(),w=(0,l.useTheme)(),{todayLineColor:T}=nn(),E=`gantt-arrow-${(0,c.useId)().replace(/:/g,``)}`,D=(0,c.useMemo)(()=>ot(h,_),[h,_]),O=(0,c.useMemo)(()=>nt(y,b),[y,b]),k=(0,c.useMemo)(()=>b===`days`?gt(O).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):b===`weeks`?ht(O).map(e=>({key:e.toISOString(),label:`${C.weekColumnPrefix}${mt(e)}`,width:40})):b===`quarters`?yt(O).map(e=>({key:e.key,label:e.label,width:360})):ft(O).map(e=>({key:e.toISOString(),label:e.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[b,O,C.weekColumnPrefix,C.dateLocale]),j=(0,c.useMemo)(()=>k.reduce((e,t)=>e+t.width,0),[k]),M=(0,c.useMemo)(()=>{if(b!==`days`)return;let e=new Map;for(let t of k){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,k,C.dateLocale]),N=(0,c.useMemo)(()=>Kt(D,O,j),[D,O,j]),P=(0,c.useMemo)(()=>s?bt(g):new Set,[s,g]),F=(0,A.useVirtualizer)({count:D.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),I=(0,c.useMemo)(()=>{if(b!==`days`)return[];let e=0;return k.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[b,k]),L=(0,c.useMemo)(()=>{let e=Date.now(),t=O.start.getTime(),n=O.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*j},[O,j]),R=(0,c.useMemo)(()=>new Date().toLocaleDateString(C.dateLocale,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),[C.dateLocale]),z=T||w.palette.primary.main;(0,c.useEffect)(()=>{if(L===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,L-t/2)},[]);let B=b===`days`?20:b===`weeks`?40:b===`quarters`?360:120,V=M?80:40,{activeDrag:H,suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K}=It({totalWidth:j,displayRange:O,onTaskMoved:d,onTaskResized:f,onTasksChange:p}),[q,J]=(0,c.useState)(null),Y=(0,c.useRef)(m);Y.current=m;let X=(0,c.useRef)(p);return X.current=p,(0,v.jsx)(l.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,v.jsxs)(l.Box,{sx:{minWidth:j,position:`relative`},children:[(0,v.jsx)(Rt,{columns:k,groups:M,todayX:L,todayLabel:C.todayLabel,todayTooltip:R,todayColor:z}),(0,v.jsx)(Ut,{strips:I,totalWidth:j,height:D.length*40,top:V}),u?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:F.getTotalSize()},children:F.getVirtualItems().map(e=>(0,v.jsx)(zt,{task:D[e.index],virtualTop:e.start,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.key))}):(0,v.jsx)(v.Fragment,{children:D.map(e=>(0,v.jsx)(zt,{task:e,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.id))}),(0,v.jsx)(Wt,{contextMenu:q,onClose:()=>J(null),onSelect:(e,t)=>{let n=S.getState().tasks.find(t=>t.id===e.id)??e;x({...n,status:t}),Y.current?.(n,t),X.current?.(S.getState().tasks),J(null)}}),(0,v.jsx)(Gt,{dependencyLines:N,todayX:L,totalWidth:j,height:D.length*40,top:V,arrowMarkerId:E})]})})}function Jt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Yt(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,onExportCSV:n}){let r=en(),i=$(e=>e.timeScale),a=$(e=>e.defaultTimeScale),o=$(e=>e.setTimeScale),s=$(e=>e.timelineRange),u=$(e=>e.isRangeCustomized),d=$(e=>e.isExpandedCustomized),f=$(e=>e.setTimelineRange),p=$(e=>e.resetTimelineRange),m=$(e=>e.resetView),h=$(e=>e.tasks),g=$(e=>e.expandedIds),_=$(e=>e.expandAll),y=$(e=>e.collapseAll),b=h.length>0&&h.every(e=>g.has(e.id)),x=i!==a||u||d,S=(0,c.useMemo)(()=>Date.now(),[]),C=S>=s.start.getTime()&&S<=s.end.getTime(),w={days:r.scaleDays,weeks:r.scaleWeeks,months:r.scaleMonths,quarters:r.scaleQuarters},T={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},E=Object.keys(w).filter(e=>T[e]);return(0,v.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:[E.length>0&&(0,v.jsx)(l.ToggleButtonGroup,{value:i,exclusive:!0,onChange:(e,t)=>{t&&o(t)},size:`small`,"aria-label":r.scaleMonths,children:E.map(e=>(0,v.jsx)(l.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:w[e]},e))}),(0,v.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,v.jsx)(l.Tooltip,{title:b?r.collapseAllTooltip:r.expandAllTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:b?y:_,"aria-label":b?r.collapseAllTooltip:r.expandAllTooltip,"data-testid":`gantt-expand-collapse-all`,children:b?(0,v.jsx)(L.default,{fontSize:`small`}):(0,v.jsx)(R.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,v.jsx)(l.Tooltip,{title:r.scrollToTodayTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:e,disabled:!C,"aria-label":r.scrollToTodayTooltip,"data-testid":`gantt-scroll-to-today`,children:(0,v.jsx)(I.default,{fontSize:`small`})})})}),t.showDateRange&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeFrom,value:Jt(s.start),onChange:e=>{let t=Yt(e.target.value);t&&f({start:t,end:s.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeTo,value:Jt(s.end),onChange:e=>{let t=Yt(e.target.value);t&&f({start:s.start,end:t})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-end`}},sx:{width:148}})]}),t.showRangeReset&&u&&(0,v.jsx)(l.Tooltip,{title:r.rangeResetTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:p,"aria-label":r.rangeResetTooltip,"data-testid":`gantt-range-reset`,children:(0,v.jsx)(F.default,{fontSize:`small`})})}),t.showExportCSV&&n&&(0,v.jsx)(l.Tooltip,{title:r.exportCsvTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:n,"aria-label":r.exportCsvTooltip,"data-testid":`gantt-export-csv`,children:(0,v.jsx)(N.default,{fontSize:`small`})})}),t.showResetView&&(0,v.jsx)(l.Tooltip,{title:r.resetViewTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:m,disabled:!x,"aria-label":r.resetViewTooltip,"data-testid":`gantt-reset-view`,children:(0,v.jsx)(P.default,{fontSize:`small`})})})})]})]})}var Zt=(0,c.createContext)(null);function $(e){let t=(0,c.useContext)(Zt);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,O.useStore)(t,e)}function Qt(){let e=(0,c.useContext)(Zt);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var $t=(0,c.createContext)(Ct);function en(){return(0,c.useContext)($t)}var tn=(0,c.createContext)({});function nn(){return(0,c.useContext)(tn)}function rn(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var an=[`days`,`weeks`,`months`,`quarters`],on={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0,showExportCSV:!1};function sn({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:m=!0,toolbarConfig:h,height:g,width:_,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,showAssigneeColumn:O=!1,onExportCSV:k,onTaskMoved:A,onTaskResized:j}){let M=rn(g,400),N=(0,c.useMemo)(()=>({...on,...h}),[h]),P=rn(_,`100%`),F=$(e=>e.setTasks),I=$(e=>e.timeScale),L=$(e=>e.setTimeScale),R=$(e=>e.timelineRange),z=(0,c.useRef)(null),B=(0,c.useRef)(null),V=(0,c.useRef)(!1),[H,U]=(0,c.useState)(320),W=Qt(),G=(0,c.useCallback)(()=>{let e=W.getState().tasks,t=[[`id`,`name`,`status`,`startDate`,`endDate`,`progress`,`assignee`,`parentId`,`isMilestone`,`dependencies`,`color`].join(`,`),...e.map(e=>[e.id,`"${e.name.replace(/"/g,`""`)}"`,e.status,e.startDate.toISOString().split(`T`)[0],e.endDate.toISOString().split(`T`)[0],e.progress??``,e.assignee?`"${e.assignee.replace(/"/g,`""`)}"`:``,e.parentId??``,e.isMilestone?`true`:`false`,(e.dependencies??[]).join(`;`),e.color??``].join(`,`))].join(`
|
|
2
|
-
`);if(k)k(t,e);else{let e=new Blob([t],{type:`text/csv;charset=utf-8;`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`gantt-tasks.csv`,r.click(),URL.revokeObjectURL(n)}},[W,k]);(0,c.useEffect)(()=>{F(e)},[e,F]);let K=()=>{V.current||=(V.current=!0,B.current&&z.current&&(B.current.scrollTop=z.current.scrollTop),!1)},q=()=>{V.current||=(V.current=!0,z.current&&B.current&&(z.current.scrollTop=B.current.scrollTop),!1)},J=(0,c.useCallback)(()=>{if(!B.current)return;let e=nt(R,I),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*B.current.scrollWidth;B.current.scrollLeft=Math.max(0,i-B.current.clientWidth/2)},[R,I]);(0,c.useEffect)(()=>{if(!x||!B.current)return;let e=B.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=an.indexOf(I);e.deltaY<0&&t>0?L(an[t-1]):e.deltaY>0&&t<an.length-1&&L(an[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,I,L]);let Y=(0,c.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=H,r=e=>{let r=e.clientX-t;U(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)},[H,y,b]);return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexDirection:`column`,height:M,width:P,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[m&&(0,v.jsx)(Xt,{onScrollToToday:J,config:N,onExportCSV:N.showExportCSV?G:void 0}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,v.jsx)(Pt,{scrollRef:z,onScroll:K,panelWidth:H,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D,showAssigneeColumn:O}),(0,v.jsx)(l.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:Y}),(0,v.jsx)(qt,{scrollRef:B,onScroll:q,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onTaskMoved:A,onTaskResized:j,onTasksChange:s,onStatusChange:o})]})]})}function cn({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:m=!1,showCriticalPath:h=!1,virtualizeRows:g=!1,showAssigneeColumn:_=!1,cascadeDependencies:y=!1,statusColors:b,ganttTheme:x,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R}){let z=(0,c.useMemo)(()=>({...Ct,...o}),[o]),[B]=(0,c.useState)(()=>{if(!(i!==void 0||a!==void 0))return St(e,t,n,void 0,y);let r=tt(e);return St(e,t,n,{start:i??r.start,end:a??r.end},y)}),V=(0,c.useMemo)(()=>({...x,statusColors:{...b,...x?.statusColors}}),[b,x]);return(0,v.jsx)($t.Provider,{value:z,children:(0,v.jsx)(tn.Provider,{value:V,children:(0,v.jsx)(Zt.Provider,{value:B,children:(0,v.jsx)(sn,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:l,zoomable:u,draggable:d,resizable:f,inlineEdit:p,progressDraggable:m,showCriticalPath:h,virtualizeRows:g,showAssigneeColumn:_,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R})})})})}var ln=e=>Math.max(0,Math.min(4,Math.round(e)));function un(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=ln(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 dn({percent:e,color:t,ariaLabel:n,segments:r=!1}){if(r){let r=Math.round(e/25);return(0,v.jsx)(l.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,display:`flex`,gap:`3px`,mt:.5},children:[0,1,2,3].map(e=>(0,v.jsx)(l.Box,{"data-testid":e<r?`psm-meter-segment-active`:`psm-meter-segment`,sx:{flex:1,height:`8px`,borderRadius:`3px`,border:`1px solid`,borderColor:`divider`,backgroundColor:e<r?t:`transparent`,transition:`background-color 0.3s ease-in-out`}},e))})}return(0,v.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,v.jsx)(l.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${e}%`,backgroundColor:t,borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})})}var fn={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`,generatePasswordLabel:`Generate secure password`,confirmLabel:`Confirm password`,confirmMatchLabel:`Passwords match`,confirmMismatchLabel:`Passwords do not match`,copyPasswordLabel:`Copy password`,copiedLabel:`Copied!`},pn={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},mn={failure:`#cc0000`,success:`#43a047`};function hn(e){let t=[];e.upper&&t.push(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`),e.lower&&t.push(`abcdefghijklmnopqrstuvwxyz`),e.numbers&&t.push(`0123456789`),e.symbols&&t.push(`!@#$%^&*()-_=+[]{}|;:,.<>?`),t.length===0&&t.push(`abcdefghijklmnopqrstuvwxyz`);let n=t.join(``),r=new Uint32Array(e.length);crypto.getRandomValues(r);let i=t.map(e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length]),a=Array.from(r.slice(i.length)).map(e=>n[e%n.length]),o=[...i,...a];for(let e=o.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1);[o[e],o[t]]=[o[t],o[e]]}return o.join(``)}function gn({label:e,fulfilled:t,checkColors:n}){return(0,v.jsxs)(l.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,children:[(0,v.jsx)(l.Typography,{variant:`caption`,children:e}),t?(0,v.jsx)(E.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,v.jsx)(D.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function _n({value:e,confirmValue:t,name:n,inputRef:r,disabled:i=!1,error:a=!1,helperText:o,autoComplete:s,customRequirements:u,generatorOptions:d,showConfirmField:f=!1,showPasswordAdornment:p=!0,showMeter:m=!0,showPasswordGenerator:h=!1,showSegmentedBar:g=!1,showSummary:_=!0,showCopyButton:x=!1,inputSize:S=`medium`,translation:C,meterColors:T,passwordMinLength:E=8,checkColors:D=mn,onPasswordChange:O,onConfirmChange:k,onPasswordGenerated:A}){let j={...fn,...C},M={...pn,...T},N=(0,c.useId)(),P=`${N}-password`,[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(!1),[U,W]=(0,c.useState)(``),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),Y=e===void 0?U:e,X=t===void 0?G:t,ee=f&&X.length>0,te=ee&&Y===X,ne=(0,c.useMemo)(()=>un(Y,E),[Y,E]),re=()=>{I(e=>!e)},ie=e=>{e.preventDefault()},ae=e=>{e.preventDefault()};return(0,v.jsxs)(l.Stack,{children:[(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:a,children:[(0,v.jsx)(l.InputLabel,{htmlFor:P,size:S,children:j.label}),(0,v.jsx)(l.OutlinedInput,{id:P,type:F?`text`:`password`,fullWidth:!0,size:S,value:Y,onChange:t=>{let n=t.target.value;e===void 0&&W(n),O&&O(n,un(n,E))},disabled:i,inputRef:r,inputProps:{"data-testid":`psm-input`,name:n,autoComplete:s},endAdornment:p||x&&Y.length>0?(0,v.jsxs)(l.InputAdornment,{position:`end`,children:[x&&Y.length>0&&(0,v.jsx)(l.Tooltip,{title:q?j.copiedLabel:j.copyPasswordLabel,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{"data-testid":`psm-copy`,disabled:i,"aria-label":q?j.copiedLabel:j.copyPasswordLabel,onClick:()=>{navigator.clipboard.writeText(Y).then(()=>{J(!0),setTimeout(()=>J(!1),2e3)})},onMouseDown:ie,onMouseUp:ae,edge:p?!1:`end`,children:q?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`})})})}),p&&(0,v.jsx)(l.IconButton,{"data-testid":`psm-toggle`,disabled:i,"aria-label":F?j.hidePasswordLabel:j.showPasswordLabel,onClick:re,onMouseDown:ie,onMouseUp:ae,edge:`end`,children:F?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})]}):null,label:j.label}),o&&(0,v.jsx)(l.FormHelperText,{children:o})]}),h&&(0,v.jsx)(l.Tooltip,{title:j.generatePasswordLabel,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.Button,{"data-testid":`psm-generate`,size:`small`,variant:`text`,startIcon:(0,v.jsx)(w.default,{fontSize:`small`}),disabled:i,onClick:()=>{let n=hn({length:d?.length??Math.max(16,E),upper:d?.upper??!0,lower:d?.lower??!0,numbers:d?.numbers??!0,symbols:d?.symbols??!0});e===void 0&&W(n),t===void 0&&K(``),O?.(n,un(n,E)),A?.(n),I(!0)},sx:{mt:.5,alignSelf:`flex-start`,textTransform:`none`},children:j.generatePasswordLabel})})}),f&&(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:ee&&!te,sx:{mt:1},children:[(0,v.jsx)(l.InputLabel,{htmlFor:`${N}-confirm`,size:S,children:j.confirmLabel}),(0,v.jsx)(l.OutlinedInput,{id:`${N}-confirm`,type:L?`text`:`password`,fullWidth:!0,size:S,value:X,onChange:e=>{let n=e.target.value;t===void 0&&K(n),k?.(n,n===Y)},disabled:i,inputProps:{"data-testid":`psm-confirm-input`},endAdornment:(0,v.jsxs)(l.InputAdornment,{position:`end`,children:[ee&&(te?(0,v.jsx)(z.default,{"data-testid":`psm-confirm-match`,sx:{color:D.success,mr:.5},fontSize:`small`}):(0,v.jsx)(B.default,{"data-testid":`psm-confirm-mismatch`,sx:{color:D.failure,mr:.5},fontSize:`small`})),(0,v.jsx)(l.IconButton,{size:`small`,disabled:i,onClick:()=>R(e=>!e),onMouseDown:e=>e.preventDefault(),edge:`end`,"aria-label":L?j.hidePasswordLabel:j.showPasswordLabel,children:L?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})]}),label:j.confirmLabel}),ee&&(0,v.jsx)(l.FormHelperText,{sx:{color:te?D.success:D.failure},children:te?j.confirmMatchLabel:j.confirmMismatchLabel})]}),m&&(0,v.jsx)(dn,{percent:ne.percent,color:(e=>{switch(e.meterStatus){case`weak`:return M.weak;case`ok`:return M.ok;case`good`:return M.good;case`very good`:return M.veryGood;default:return`transparent`}})(ne),ariaLabel:j.meterAriaLabel,segments:g}),_&&(0,v.jsxs)(l.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:j.summaryHeaderLabel}),(0,v.jsxs)(l.Stack,{direction:`row`,spacing:6,children:[(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(gn,{label:j.summaryMinChars.replace(`{n}`,String(E)),fulfilled:ne.length>=E,checkColors:D}),(0,v.jsx)(gn,{label:j.summaryCapitalLetter,fulfilled:ne.hasUpper,checkColors:D}),(0,v.jsx)(gn,{label:j.summaryLowerCaseLetter,fulfilled:ne.hasLower,checkColors:D})]}),(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(gn,{label:j.summaryNumber,fulfilled:ne.hasDigit,checkColors:D}),(0,v.jsx)(gn,{label:j.summarySpecialChar,fulfilled:ne.hasSymbol,checkColors:D}),u?.map((e,t)=>(0,v.jsx)(gn,{label:e.label,fulfilled:typeof e.fulfilled==`function`?e.fulfilled(Y):e.fulfilled,checkColors:D},t))]})]})]})]})}function vn(e){return(0,k.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 yn=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`],bn=[`#f44336`,`#e91e63`,`#9c27b0`,`#673ab7`,`#3f51b5`,`#2196f3`,`#03a9f4`,`#00bcd4`,`#009688`,`#4caf50`,`#8bc34a`,`#cddc39`,`#ffeb3b`,`#ffc107`,`#ff9800`,`#ff5722`,`#795548`,`#9e9e9e`,`#607d8b`,`#000000`];function xn(e){return/^#[0-9A-Fa-f]{6}$/.test(e)}function Sn(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return(.299*t+.587*n+.114*r)/255>.5?`#000000`:`#ffffff`}function Cn(e,t){let n=t.trim();if(!n)return e;let r=e.toLowerCase().indexOf(n.toLowerCase());return r===-1?e:(0,v.jsxs)(v.Fragment,{children:[e.slice(0,r),(0,v.jsx)(`strong`,{children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function wn({color:e,selected:t,onClick:n}){return(0,v.jsx)(l.Box,{onClick:n,sx:{width:24,height:24,borderRadius:.5,backgroundColor:e,cursor:`pointer`,border:`2px solid`,borderColor:t?`primary.main`:`transparent`,outline:t?`1px solid`:`none`,outlineColor:`primary.main`,outlineOffset:1,flexShrink:0,"&:hover":{transform:`scale(1.2)`,borderColor:`primary.main`},transition:`transform 0.1s`}})}function Tn({value:e,onChange:t,disabled:n=!1}){return(0,v.jsx)(l.TextField,{size:`small`,fullWidth:!0,value:e,onChange:e=>t(e.target.value),placeholder:`#rrggbb`,disabled:n,error:!n&&e.length>1&&!xn(e),sx:{"& .MuiInputBase-root":{height:28},"& .MuiInputBase-input":{py:0,px:.5,fontSize:`0.72rem`,fontFamily:`monospace`}},slotProps:{input:{startAdornment:(0,v.jsx)(l.Box,{sx:{width:12,height:12,borderRadius:.25,flexShrink:0,mr:.5,backgroundColor:xn(e)?e:`action.disabledBackground`,border:`1px solid`,borderColor:`divider`}})}}})}function En({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:m}){let[h,g]=(0,c.useState)(`default`),[_,y]=(0,c.useState)(null),[x,S]=(0,c.useState)(null),[C,w]=(0,c.useState)(!0),[T,E]=(0,c.useState)(!1),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(`#1976d2`),[j,M]=(0,c.useState)(`#ffffff`),N=u||f,P=_!==null,F=e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),I=p&&t.trim()!==``&&F.length===0,L=D&&!I,R=P?C?Sn(_):x??`#000000`:void 0,z=()=>{let e=t.trim(),n=e.toLowerCase().replace(/\s+/g,`-`);a?.(P&&_?{id:n,label:e,selected:!0,color:`default`,backgroundColor:_,foregroundColor:R}:{id:n,label:e,selected:!0,color:h}),g(`default`),y(null),S(null),w(!0),E(!1),r(``)},B=()=>{r(``),g(`default`),y(null),S(null),w(!0),E(!1)},V=e=>{y(e),A(e),g(`default`)},H=e=>{A(e),xn(e)&&(y(e),g(`default`))},W=e=>{S(e),M(e)},G=e=>{M(e),xn(e)&&S(e)},K=e=>{if(w(e),e)S(null);else if(_){let e=Sn(_);S(e),M(e)}},q=e=>e.preventDefault();return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[(0,v.jsx)(l.Autocomplete,{options:e,value:null,open:L,onOpen:()=>{I||O(!0)},onClose:()=>O(!1),size:o,disabled:N,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,...m!==void 0&&{maxHeight:m,overflowY:`auto`}}}},renderInput:e=>(0,v.jsx)(l.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:f&&!u?n.maxTagsReachedText:void 0,onKeyDown:e=>{I&&e.key===`Enter`&&(e.preventDefault(),z())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,v.jsxs)(v.Fragment,{children:[I&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:q,onClick:z,"aria-label":n.confirmCreateLabel,children:(0,v.jsx)(b.default,{fontSize:`small`})}),(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:q,onClick:B,"aria-label":n.cancelCreateLabel,children:(0,v.jsx)(U.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...n},r)=>{let i=!!(r.foregroundColor||r.backgroundColor);return(0,v.jsx)(`li`,{...n,style:{width:`auto`,padding:0,margin:0},children:(0,v.jsx)(l.Chip,{size:s,label:Cn(r.label,t),color:i?void 0:r.color??`default`,sx:i?{color:r.foregroundColor??`inherit`,backgroundColor:r.backgroundColor??`transparent`}:void 0})},e)},isOptionEqualToValue:(e,t)=>e.id===t.id,noOptionsText:n.noAvailableTagsText,loadingText:n.loadingText}),I&&(0,v.jsxs)(l.Box,{sx:{position:`relative`},onMouseDown:q,children:[(0,v.jsxs)(l.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:[yn.map(e=>(0,v.jsx)(l.Chip,{size:s,color:e,label:e,variant:!P&&h===e?`filled`:`outlined`,onClick:()=>{g(e),y(null),S(null),E(!1)},clickable:!0},e)),(0,v.jsx)(l.Tooltip,{title:n.colorPickerLabel,children:(0,v.jsx)(l.Chip,{size:s,label:P?_:`···`,variant:`outlined`,onClick:()=>{E(e=>!e),_&&A(_),x&&M(x)},sx:e=>({cursor:`pointer`,fontFamily:`monospace`,fontSize:`0.7rem`,...P?{backgroundColor:_,color:R,border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${_}, ${_}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}:{border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${e.palette.background.paper}, ${e.palette.background.paper}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}}),clickable:!0})})]}),T&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:1400,backgroundColor:`background.paper`,border:`1px solid`,borderColor:`divider`,borderRadius:1,boxShadow:8,p:1.25,width:`max-content`},children:(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`auto auto`,gap:2},children:[(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.backgroundColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5},children:[bn.map(e=>(0,v.jsx)(wn,{color:e,selected:_===e,onClick:()=>V(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(Tn,{value:k,onChange:H})})]})]}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.textColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5,opacity:C?.3:1,pointerEvents:C?`none`:`auto`,transition:`opacity 0.15s`},children:[bn.map(e=>(0,v.jsx)(wn,{color:e,selected:x===e,onClick:()=>W(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(Tn,{value:C?R??`#000000`:j,onChange:G,disabled:C})})]}),(0,v.jsxs)(l.Stack,{direction:`row`,sx:{width:`100%`,alignItems:`center`,justifyContent:`flex-end`,gap:.5,mt:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n.autoTextColorLabel}),(0,v.jsx)(l.Switch,{size:`small`,checked:C,onChange:e=>K(e.target.checked)})]})]})]})})]})]})}function Dn({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,disabled:i=!1}){let a=!!(e.foregroundColor||e.backgroundColor);return(0,v.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 On({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),m=!!u&&p.length>0,h=s===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},g=s===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[r&&(0,v.jsx)(l.Typography,{variant:`subtitle2`,gutterBottom:!0,children:t.selectedTagsLabel}),e.length===0?(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,v.jsxs)(l.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},children:[f.map(e=>(0,v.jsx)(Dn,{tag:e,onDelete:n,chipSize:i,disabled:a},e.id)),p.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Chip,{size:i,label:`+${p.length}`,variant:`outlined`,clickable:!0,onClick:e=>d(e.currentTarget)}),(0,v.jsx)(l.Popover,{open:m,anchorEl:u,onClose:()=>d(null),anchorOrigin:h,transformOrigin:g,children:(0,v.jsx)(l.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},children:p.map(e=>(0,v.jsx)(Dn,{tag:e,onDelete:a?void 0:n,chipSize:i,disabled:a},e.id))})})]})]})]})}var kn={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.`,colorPickerLabel:`Custom color`,backgroundColorLabel:`Background color`,textColorLabel:`Text color`,autoTextColorLabel:`Auto`,confirmCreateLabel:`Confirm new tag`,cancelCreateLabel:`Cancel new tag`},An=(0,c.createContext)(null);function jn(e){let t=(0,c.useContext)(An);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,O.useStore)(t,e)}function Mn({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:m,translation:h,onTagSelect:g,onTagDelete:_,onTagsChange:y,onSearchChange:b,onTagCreate:x}){let S=jn(e=>e.tags),C=jn(e=>e.searchValue),w=jn(e=>e.setTags),T=jn(e=>e.setSearchValue),E=jn(e=>e.selectTag),D=jn(e=>e.deleteTag),O=jn(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,v.jsx)(l.Box,{sx:{width:`100%`},children:(0,v.jsxs)(l.Stack,{children:[t&&(0,v.jsx)(On,{selectedTags:k,translation:h,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&&_&&_(r,n,t),M(t)},showSelectedTagsLabel:n,chipSize:a,disabled:o,maxVisibleChips:f,popoverPlacement:p}),r&&(0,v.jsx)(En,{availableTags:A,searchValue:C,translation:h,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&&g&&g(r,n,t),M(t)},onTagCreate:e=>{O(e),M([...S,e]),x&&x(e)},inputSize:i,chipSize:a,disabled:o,loading:s,isMaxReached:j,allowCreate:d,listboxMaxHeight:m})]})})}function Nn({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:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b}){let x={...kn,...i},[S]=(0,c.useState)(()=>vn(e));return(0,v.jsx)(An.Provider,{value:S,children:(0,v.jsx)(Mn,{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:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b})})}var Pn={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,showTableButton:!1,showImageButton:!1,showEmojiButton:!1,showPasteAsPlainTextButton:!1,showMarkdownButton:!1},Fn={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`,table:`Table`,insertTable:`Insert 3×3 table`,addRowBefore:`Add row before`,addRowAfter:`Add row after`,deleteRow:`Delete row`,addColumnBefore:`Add column before`,addColumnAfter:`Add column after`,deleteColumn:`Delete column`,deleteTable:`Delete table`,image:`Insert image`,imageDialogTitle:`Insert image`,imageDialogUrlLabel:`Image URL`,imageDialogAltLabel:`Alt text (optional)`,imageDialogSave:`Insert`,imageDialogCancel:`Cancel`,emoji:`Emoji`,emojiSearchPlaceholder:`Search emoji…`,pasteAsPlainText:`Paste as plain text`,pasteAsHtml:`Paste with formatting`,markdown:`Markdown`,markdownDialogTitle:`Markdown`,markdownDialogDescription:`Edit as Markdown, then apply to replace the editor content. Copy to export.`,markdownDialogApply:`Apply`,markdownDialogCancel:`Cancel`,markdownDialogCopy:`Copy`,markdownDialogCopied:`Copied!`};function In({editor:e,error:t,disabled:n,readonly:r}){return(0,v.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},"& table":{borderCollapse:`collapse`,tableLayout:`fixed`,width:`100%`,margin:`8px 0`,overflowX:`auto`},"& table td, & table th":{border:`1px solid`,borderColor:`divider`,padding:`6px 8px`,verticalAlign:`top`,boxSizing:`border-box`,minWidth:`2em`,position:`relative`},"& table th":{fontWeight:`bold`,bgcolor:`action.hover`},"& table .selectedCell::after":{content:`""`,position:`absolute`,inset:0,bgcolor:`primary.main`,opacity:.12,pointerEvents:`none`,zIndex:2},"& img":{maxWidth:`100%`,height:`auto`,borderRadius:`4px`,display:`block`,my:1}}},children:(0,v.jsx)(W.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,v.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.linkDialogTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.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,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,v.jsx)(l.Button,{onClick:u,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,v.jsx)(l.Button,{onClick:t,children:r.linkDialogCancel}),(0,v.jsx)(l.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var Rn=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],zn=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function Bn({color:e,active:t,onClick:n}){return(0,v.jsx)(l.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,v.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>n(e),"aria-label":e,"aria-pressed":t,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,v.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 Vn({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`?zn:Rn;function f(e){a(e.target.value)}return(0,v.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,v.jsx)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:d.map(e=>(0,v.jsx)(Bn,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(l.Tooltip,{title:`Custom color`,arrow:!0,children:(0,v.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>u.current?.click(),"aria-label":`Custom color`,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,v.jsx)(`input`,{ref:u,type:`color`,defaultValue:i??`#000000`,onChange:f,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,v.jsx)(l.Tooltip,{title:s,arrow:!0,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:()=>{o(),n()},"aria-label":s,sx:{borderRadius:1,ml:`auto`},children:(0,v.jsx)(Se.default,{fontSize:`small`})})})]})]})}function Hn({editor:e,translation:t,disabled:n}){let[r,i]=(0,c.useState)(null),a=n||!e,o=e?.isActive(`table`)??!1;function s(){i(null)}function u(e){e(),s()}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Tooltip,{title:t.table,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>i(e.currentTarget),disabled:a,color:o?`primary`:`default`,sx:{borderRadius:1},"aria-label":t.table,"aria-pressed":o,children:(0,v.jsx)(Ce.default,{fontSize:`small`})})})}),(0,v.jsxs)(l.Menu,{anchorEl:r,open:!!r,onClose:s,slotProps:{paper:{sx:{minWidth:220}}},children:[(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(Ce.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.insertTable})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteRow().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteRow})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteColumn().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteColumn})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteTable().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteTable})]})]})]})}function Un({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(``);function u(){let e=i.trim();e&&(n.chain().focus().setImage({src:e,alt:o.trim()||void 0}).run(),a(``),s(``),t())}function d(){a(``),s(``),t()}function f(e){e.key===`Enter`&&u()}return(0,v.jsxs)(l.Dialog,{open:e,onClose:d,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.imageDialogTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,label:r.imageDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`,placeholder:`https://example.com/image.png`}),(0,v.jsx)(l.TextField,{fullWidth:!0,label:r.imageDialogAltLabel,value:o,onChange:e=>s(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`})]}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,v.jsx)(l.Button,{onClick:d,children:r.imageDialogCancel}),(0,v.jsx)(l.Button,{onClick:u,variant:`contained`,disabled:!i.trim(),children:r.imageDialogSave})]})]})}var Wn=[{label:`Smileys`,emojis:[{emoji:`😀`,name:`grinning face`},{emoji:`😃`,name:`grinning face with big eyes`},{emoji:`😄`,name:`grinning face with smiling eyes`},{emoji:`😁`,name:`beaming face with smiling eyes`},{emoji:`😆`,name:`grinning squinting face`},{emoji:`😅`,name:`grinning face with sweat`},{emoji:`😂`,name:`face with tears of joy`},{emoji:`🤣`,name:`rolling on the floor laughing`},{emoji:`😊`,name:`smiling face with smiling eyes`},{emoji:`😇`,name:`smiling face with halo`},{emoji:`🙂`,name:`slightly smiling face`},{emoji:`😉`,name:`winking face`},{emoji:`😍`,name:`smiling face with heart eyes`},{emoji:`🥰`,name:`smiling face with hearts`},{emoji:`😘`,name:`face blowing a kiss`},{emoji:`😋`,name:`face savoring food`},{emoji:`😎`,name:`smiling face with sunglasses`},{emoji:`🤩`,name:`star struck`},{emoji:`🥳`,name:`partying face`},{emoji:`😏`,name:`smirking face`},{emoji:`😒`,name:`unamused face`},{emoji:`😔`,name:`pensive face`},{emoji:`😢`,name:`crying face`},{emoji:`😭`,name:`loudly crying face`},{emoji:`😤`,name:`face with steam from nose`},{emoji:`😠`,name:`angry face`},{emoji:`🤬`,name:`face with symbols on mouth`},{emoji:`😱`,name:`face screaming in fear`},{emoji:`😳`,name:`flushed face`},{emoji:`🤔`,name:`thinking face`},{emoji:`🙄`,name:`face with rolling eyes`},{emoji:`😴`,name:`sleeping face`},{emoji:`🤢`,name:`nauseated face`},{emoji:`🤧`,name:`sneezing face`},{emoji:`😷`,name:`face with medical mask`}]},{label:`Gestures`,emojis:[{emoji:`👋`,name:`waving hand`},{emoji:`🤚`,name:`raised back of hand`},{emoji:`✋`,name:`raised hand`},{emoji:`🖐️`,name:`hand with fingers splayed`},{emoji:`👌`,name:`ok hand`},{emoji:`✌️`,name:`victory hand`},{emoji:`🤞`,name:`crossed fingers`},{emoji:`🤙`,name:`call me hand`},{emoji:`👈`,name:`backhand index pointing left`},{emoji:`👉`,name:`backhand index pointing right`},{emoji:`👆`,name:`backhand index pointing up`},{emoji:`👇`,name:`backhand index pointing down`},{emoji:`☝️`,name:`index pointing up`},{emoji:`👍`,name:`thumbs up`},{emoji:`👎`,name:`thumbs down`},{emoji:`✊`,name:`raised fist`},{emoji:`👊`,name:`oncoming fist`},{emoji:`👏`,name:`clapping hands`},{emoji:`🙌`,name:`raising hands`},{emoji:`🤝`,name:`handshake`},{emoji:`🙏`,name:`folded hands`},{emoji:`💪`,name:`flexed biceps`},{emoji:`🦾`,name:`mechanical arm`},{emoji:`👀`,name:`eyes`},{emoji:`👁️`,name:`eye`},{emoji:`👅`,name:`tongue`},{emoji:`💋`,name:`kiss mark`}]},{label:`Hearts & Symbols`,emojis:[{emoji:`❤️`,name:`red heart`},{emoji:`🧡`,name:`orange heart`},{emoji:`💛`,name:`yellow heart`},{emoji:`💚`,name:`green heart`},{emoji:`💙`,name:`blue heart`},{emoji:`💜`,name:`purple heart`},{emoji:`🖤`,name:`black heart`},{emoji:`🤍`,name:`white heart`},{emoji:`💔`,name:`broken heart`},{emoji:`💕`,name:`two hearts`},{emoji:`💞`,name:`revolving hearts`},{emoji:`💖`,name:`sparkling heart`},{emoji:`💘`,name:`heart with arrow`},{emoji:`💝`,name:`heart with ribbon`},{emoji:`✨`,name:`sparkles`},{emoji:`⭐`,name:`star`},{emoji:`🌟`,name:`glowing star`},{emoji:`💫`,name:`dizzy`},{emoji:`🔥`,name:`fire`},{emoji:`💧`,name:`droplet`},{emoji:`💯`,name:`hundred points`},{emoji:`✅`,name:`check mark button`},{emoji:`❌`,name:`cross mark`},{emoji:`⚠️`,name:`warning`},{emoji:`🎉`,name:`party popper`},{emoji:`🎊`,name:`confetti ball`},{emoji:`🏆`,name:`trophy`},{emoji:`🥇`,name:`first place medal`}]},{label:`Nature`,emojis:[{emoji:`🐶`,name:`dog face`},{emoji:`🐱`,name:`cat face`},{emoji:`🐭`,name:`mouse face`},{emoji:`🐹`,name:`hamster`},{emoji:`🐰`,name:`rabbit face`},{emoji:`🦊`,name:`fox`},{emoji:`🐻`,name:`bear`},{emoji:`🐼`,name:`panda`},{emoji:`🐨`,name:`koala`},{emoji:`🐯`,name:`tiger face`},{emoji:`🦁`,name:`lion`},{emoji:`🐸`,name:`frog`},{emoji:`🐧`,name:`penguin`},{emoji:`🐦`,name:`bird`},{emoji:`🦋`,name:`butterfly`},{emoji:`🌸`,name:`cherry blossom`},{emoji:`🌺`,name:`hibiscus`},{emoji:`🌻`,name:`sunflower`},{emoji:`🌹`,name:`rose`},{emoji:`🌿`,name:`herb`},{emoji:`🍀`,name:`four leaf clover`},{emoji:`🌲`,name:`evergreen tree`},{emoji:`🌴`,name:`palm tree`},{emoji:`🌊`,name:`water wave`},{emoji:`🌈`,name:`rainbow`},{emoji:`☀️`,name:`sun`},{emoji:`🌙`,name:`crescent moon`},{emoji:`❄️`,name:`snowflake`},{emoji:`⚡`,name:`lightning`},{emoji:`🌪️`,name:`tornado`}]},{label:`Food`,emojis:[{emoji:`🍎`,name:`red apple`},{emoji:`🍊`,name:`tangerine`},{emoji:`🍋`,name:`lemon`},{emoji:`🍇`,name:`grapes`},{emoji:`🍓`,name:`strawberry`},{emoji:`🍒`,name:`cherries`},{emoji:`🍑`,name:`peach`},{emoji:`🥭`,name:`mango`},{emoji:`🍍`,name:`pineapple`},{emoji:`🥥`,name:`coconut`},{emoji:`🥝`,name:`kiwi fruit`},{emoji:`🍅`,name:`tomato`},{emoji:`🥑`,name:`avocado`},{emoji:`🌽`,name:`ear of corn`},{emoji:`🍕`,name:`pizza`},{emoji:`🍔`,name:`hamburger`},{emoji:`🌮`,name:`taco`},{emoji:`🍜`,name:`steaming bowl`},{emoji:`🍣`,name:`sushi`},{emoji:`🍩`,name:`doughnut`},{emoji:`🎂`,name:`birthday cake`},{emoji:`🍰`,name:`shortcake`},{emoji:`🍦`,name:`soft ice cream`},{emoji:`🍫`,name:`chocolate bar`},{emoji:`☕`,name:`hot beverage`},{emoji:`🧃`,name:`beverage box`},{emoji:`🍺`,name:`beer mug`},{emoji:`🥂`,name:`clinking glasses`}]},{label:`Objects & Travel`,emojis:[{emoji:`📱`,name:`mobile phone`},{emoji:`💻`,name:`laptop`},{emoji:`🖥️`,name:`desktop computer`},{emoji:`⌨️`,name:`keyboard`},{emoji:`📷`,name:`camera`},{emoji:`📺`,name:`television`},{emoji:`🎮`,name:`video game`},{emoji:`🎸`,name:`guitar`},{emoji:`🎹`,name:`musical keyboard`},{emoji:`📚`,name:`books`},{emoji:`📝`,name:`memo`},{emoji:`✏️`,name:`pencil`},{emoji:`🔍`,name:`magnifying glass tilted left`},{emoji:`💡`,name:`light bulb`},{emoji:`🔑`,name:`key`},{emoji:`🔒`,name:`locked`},{emoji:`⚙️`,name:`gear`},{emoji:`🔧`,name:`wrench`},{emoji:`🏠`,name:`house`},{emoji:`🏢`,name:`office building`},{emoji:`✈️`,name:`airplane`},{emoji:`🚀`,name:`rocket`},{emoji:`🚗`,name:`automobile`},{emoji:`🚲`,name:`bicycle`},{emoji:`⛵`,name:`sailboat`},{emoji:`🗺️`,name:`world map`},{emoji:`🏔️`,name:`snow capped mountain`},{emoji:`🏖️`,name:`beach with umbrella`}]}];function Gn({anchorEl:e,open:t,onClose:n,onSelect:r,translation:i}){let[a,o]=(0,c.useState)(``),s=(0,c.useMemo)(()=>{let e=a.trim().toLowerCase();return e?Wn.map(t=>({...t,emojis:t.emojis.filter(t=>t.name.includes(e)||t.emoji===e)})).filter(e=>e.emojis.length>0):Wn},[a]);function u(e){r(e),n(),o(``)}function d(){n(),o(``)}return(0,v.jsxs)(l.Popover,{open:t,anchorEl:e,onClose:d,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{width:320,maxHeight:380,display:`flex`,flexDirection:`column`}}},children:[(0,v.jsx)(l.Box,{sx:{p:1,borderBottom:1,borderColor:`divider`},children:(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,size:`small`,placeholder:i.emojiSearchPlaceholder,value:a,onChange:e=>o(e.target.value),slotProps:{input:{startAdornment:(0,v.jsx)(l.InputAdornment,{position:`start`,children:(0,v.jsx)(we.default,{fontSize:`small`})})}}})}),(0,v.jsxs)(l.Box,{sx:{overflowY:`auto`,flex:1,px:1,pb:1},children:[s.map(e=>(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,color:`text.secondary`,mt:1,mb:.5,px:.5},children:e.label}),(0,v.jsx)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.25},children:e.emojis.map(e=>(0,v.jsx)(l.Box,{component:`button`,title:e.name,"aria-label":e.name,onClick:()=>u(e.emoji),sx:{border:`none`,background:`none`,cursor:`pointer`,fontSize:`1.375rem`,lineHeight:1,p:.5,borderRadius:1,"&:hover":{bgcolor:`action.hover`}},children:e.emoji},e.emoji))})]},e.label)),s.length===0&&(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,sx:{p:2,textAlign:`center`},children:`No emoji found`})]})]})}function Kn({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(!1);(0,c.useEffect)(()=>{e&&a(n.storage.markdown.getMarkdown())},[e,n]);function u(){n.commands.setContent(i),t()}function d(){navigator.clipboard.writeText(i).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})}return(0,v.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.markdownDialogTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:1.5,pt:`16px !important`},children:[(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:r.markdownDialogDescription}),(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:8,maxRows:16,value:i,onChange:e=>a(e.target.value),variant:`outlined`,size:`small`,sx:{fontFamily:`monospace`},slotProps:{htmlInput:{style:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})]}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,v.jsx)(l.Box,{sx:{flex:1},children:(0,v.jsx)(l.Button,{onClick:d,startIcon:o?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),children:o?r.markdownDialogCopied:r.markdownDialogCopy})}),(0,v.jsx)(l.Button,{onClick:t,children:r.markdownDialogCancel}),(0,v.jsx)(l.Button,{onClick:u,variant:`contained`,children:r.markdownDialogApply})]})]})}function qn({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.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,v.jsx)(l.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,v.jsx)(l.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function Jn({level:e}){return(0,v.jsxs)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:[`H`,e]})}function Yn({editor:e,toolbarConfig:t,translation:n,disabled:r,isFullscreen:i,onToggleFullscreen:a,pasteAsPlainText:o,onTogglePasteAsPlainText:s}){let[u,d]=(0,c.useState)(!1),[f,p]=(0,c.useState)(!1),[m,h]=(0,c.useState)(!1),[g,_]=(0,c.useState)(null),[y,b]=(0,c.useState)(null),[x,w]=(0,c.useState)(null),T=r||!e,E=e?.getAttributes(`textStyle`)?.color,D=e?.getAttributes(`highlight`)?.color,O=t.showBold||t.showItalic||t.showUnderline||t.showStrike,k=t.showHeading1||t.showHeading2||t.showHeading3,A=t.showBulletList||t.showOrderedList,j=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,M=t.showTextColor||t.showHighlight,N=t.showUndoRedo||t.showClearFormat,P=t.showTableButton||t.showImageButton||t.showEmojiButton,F=[O,k,A,j,M,N,P],I=F.filter(Boolean).length;function L(e,t){return!e||F.slice(t+1).findIndex(Boolean)===-1?null:(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[O&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,v.jsx)(Q,{label:n.bold,icon:(0,v.jsx)(se.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:T}),t.showItalic&&(0,v.jsx)(Q,{label:n.italic,icon:(0,v.jsx)(ce.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:T}),t.showUnderline&&(0,v.jsx)(Q,{label:n.underline,icon:(0,v.jsx)(le.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:T}),t.showStrike&&(0,v.jsx)(Q,{label:n.strike,icon:(0,v.jsx)(ue.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:T})]}),L(O,0),k&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,v.jsx)(Q,{label:n.heading1,icon:(0,v.jsx)(Jn,{level:1}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:T}),t.showHeading2&&(0,v.jsx)(Q,{label:n.heading2,icon:(0,v.jsx)(Jn,{level:2}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:T}),t.showHeading3&&(0,v.jsx)(Q,{label:n.heading3,icon:(0,v.jsx)(Jn,{level:3}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:T})]}),L(k,1),A&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,v.jsx)(Q,{label:n.bulletList,icon:(0,v.jsx)(de.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:T}),t.showOrderedList&&(0,v.jsx)(Q,{label:n.orderedList,icon:(0,v.jsx)(fe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:T})]}),L(A,2),j&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,v.jsx)(Q,{label:n.blockquote,icon:(0,v.jsx)(pe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:T}),t.showCodeBlock&&(0,v.jsx)(Q,{label:n.codeBlock,icon:(0,v.jsx)(me.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:T}),t.showLink&&(0,v.jsx)(Q,{label:n.link,icon:(0,v.jsx)(he.default,{fontSize:`small`}),onClick:()=>d(!0),active:e?.isActive(`link`),disabled:T}),t.showHorizontalRule&&(0,v.jsx)(Q,{label:n.horizontalRule,icon:(0,v.jsx)(ge.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:T})]}),L(j,3),M&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,v.jsx)(qn,{label:n.textColor,icon:(0,v.jsx)(_e.default,{fontSize:`small`}),activeColor:E,disabled:T,onClick:e=>b(e.currentTarget)}),t.showHighlight&&(0,v.jsx)(qn,{label:n.highlight,icon:(0,v.jsx)(ve.default,{fontSize:`small`}),activeColor:D,disabled:T,onClick:e=>w(e.currentTarget)})]}),L(M,4),N&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:T||!e?.can().undo()}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:T||!e?.can().redo()})]}),t.showClearFormat&&(0,v.jsx)(Q,{label:n.clearFormat,icon:(0,v.jsx)(ye.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:T})]}),L(N,5),P&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTableButton&&(0,v.jsx)(Hn,{editor:e,translation:n,disabled:T}),t.showImageButton&&(0,v.jsx)(Q,{label:n.image,icon:(0,v.jsx)(ae.default,{fontSize:`small`}),onClick:()=>p(!0),disabled:T}),t.showEmojiButton&&(0,v.jsx)(l.Tooltip,{title:n.emoji,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>_(e.currentTarget),disabled:T,sx:{borderRadius:1},"aria-label":n.emoji,children:(0,v.jsx)(oe.default,{fontSize:`small`})})})})]}),I===0&&(0,v.jsx)(l.Box,{sx:{height:32}}),(t.showPasteAsPlainTextButton||t.showMarkdownButton||t.showFullscreenButton)&&(0,v.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,gap:.25},children:[t.showPasteAsPlainTextButton&&(0,v.jsx)(Q,{label:o?n.pasteAsHtml:n.pasteAsPlainText,icon:o?(0,v.jsx)(xe.default,{fontSize:`small`}):(0,v.jsx)(be.default,{fontSize:`small`}),onClick:s,active:o,disabled:r||!e}),t.showMarkdownButton&&(0,v.jsx)(Q,{label:n.markdown,icon:(0,v.jsx)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.7rem`,lineHeight:1},children:`MD`}),onClick:()=>h(!0),disabled:r||!e}),t.showFullscreenButton&&(0,v.jsx)(l.Tooltip,{title:i?n.exitFullscreen:n.fullscreen,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.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,v.jsx)(ie.default,{fontSize:`small`}):(0,v.jsx)(re.default,{fontSize:`small`})})})})]})]}),t.showLink&&e&&(0,v.jsx)(Ln,{open:u,onClose:()=>d(!1),editor:e,translation:n}),t.showTextColor&&(0,v.jsx)(Vn,{anchorEl:y,open:!!y,onClose:()=>b(null),mode:`textColor`,activeColor:E,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,v.jsx)(Vn,{anchorEl:x,open:!!x,onClose:()=>w(null),mode:`highlight`,activeColor:D,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight}),t.showImageButton&&e&&(0,v.jsx)(Un,{open:f,onClose:()=>p(!1),editor:e,translation:n}),t.showMarkdownButton&&e&&(0,v.jsx)(Kn,{open:m,onClose:()=>h(!1),editor:e,translation:n}),t.showEmojiButton&&(0,v.jsx)(Gn,{anchorEl:g,open:!!g,onClose:()=>_(null),onSelect:t=>e?.chain().focus().insertContent(t).run(),translation:n})]})}function Xn({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,v.jsx)(l.FormHelperText,{error:t,children:e??``}),(n||a)&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:1.5,alignItems:`center`},children:[a&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.secondary`},children:d}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:u},children:c})]})]})}function Zn({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:m,value:h,width:g,onBlur:_,onChange:y,onFocus:b,onMarkdownChange:x}){let S={...Fn,...m},C={...Pn,...p},[w,T]=(0,c.useState)(!1),[E,D]=(0,c.useState)(!1),O=(0,c.useRef)(E);(0,c.useEffect)(()=>{O.current=E},[E]);let k=Qe(n),A=Qe(g),j=k===`auto`,M=j?void 0:k??200,N=i!==void 0&&i>0||u||f,P=(0,W.useEditor)({shouldRerenderOnTransaction:!0,extensions:[G.StarterKit.configure({link:{openOnClick:!1}}),K.TextStyle,q.Color,J.Highlight.configure({multicolor:!0}),ne.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),Y.Placeholder.configure({placeholder:o??``}),...C.showTableButton?[ee.TableKit]:[],...C.showImageButton?[te.Image.configure({inline:!1,allowBase64:!0})]:[],...N?i!==void 0&&i>0?[X.CharacterCount.configure({limit:i})]:[X.CharacterCount]:[]],content:h??``,editable:!e&&!s,editorProps:{handlePaste(e,t){if(!O.current)return!1;let n=t.clipboardData?.getData(`text/plain`);if(n==null)return!1;t.preventDefault();let{state:r}=e;return e.dispatch(r.tr.insertText(n,r.selection.from,r.selection.to)),!0}},onUpdate({editor:e}){y?.(e.getHTML()),x?.(e.storage.markdown.getMarkdown())},onBlur(){_?.()},onFocus(){b?.()}});(0,c.useEffect)(()=>{!P||h===void 0||P.getHTML()!==h&&P.commands.setContent(h,{emitUpdate:!1})},[P,h]),(0,c.useEffect)(()=>{P&&P.setEditable(!e&&!s)},[P,e,s]);let F=P?.storage.characterCount?.characters?.()??0,I=P?.storage.characterCount?.words?.()??0,L=u||i!==void 0&&i>0||f||!!r;return(0,v.jsxs)(l.Box,{sx:w?{position:`fixed`,top:0,left:0,width:`100vw`,height:`100vh`,zIndex:1300,display:`flex`,flexDirection:`column`,bgcolor:`background.default`,p:1}:{width:A??`100%`,...j?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...w||j?{flex:1}:{height:M},borderColor:t?`error.main`:void 0,"&:focus-within":{borderColor:t?`error.main`:`primary.main`,borderWidth:2}},children:[d&&!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Yn,{editor:P,toolbarConfig:C,translation:S,disabled:e,isFullscreen:w,onToggleFullscreen:()=>T(e=>!e),pasteAsPlainText:E,onTogglePasteAsPlainText:()=>D(e=>!e)}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(In,{editor:P,error:t,disabled:e,readonly:s})]}),L&&(0,v.jsx)(Xn,{helperText:r,error:t,showCharacterCount:u||i!==void 0&&i>0,charCount:F,maxCharacters:i&&i>0?i:void 0,showWordCount:f,wordCount:I,translation:S}),a&&(0,v.jsx)(`input`,{type:`hidden`,name:a,value:P?P.getHTML():``})]})}var Qn={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0,showHistory:!1},$n={format:`Format SQL`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,execute:`Execute`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,errorCount:`{count} error(s)`,history:`Query history`,historyEmpty:`No queries yet`,clearHistory:`Clear history`},er={standard:Te.StandardSQL,mysql:Te.MySQL,postgresql:Te.PostgreSQL,sqlite:Te.SQLite,mssql:Te.MSSQL};function tr({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:f,identifierColor:_,schema:y,onExecute:b,onLint:x,onDiagnosticsChange:S,onViewReady:C,onCursorChange:w,onBlur:T,onFocus:E}){let D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(t),A=(0,c.useRef)(w),j=(0,c.useRef)(T),M=(0,c.useRef)(E),N=(0,c.useRef)(C),P=(0,c.useRef)(b),F=(0,c.useRef)(x),I=(0,c.useRef)(S),L=(0,c.useRef)(new d.Compartment),R=(0,c.useRef)(new d.Compartment),z=(0,l.useTheme)(),B=z.palette.mode===`dark`,V=!!x,H=JSON.stringify(y);return(0,c.useEffect)(()=>{k.current=t},[t]),(0,c.useEffect)(()=>{A.current=w},[w]),(0,c.useEffect)(()=>{j.current=T},[T]),(0,c.useEffect)(()=>{M.current=E},[E]),(0,c.useEffect)(()=>{N.current=C},[C]),(0,c.useEffect)(()=>{P.current=b},[b]),(0,c.useEffect)(()=>{F.current=x},[x]),(0,c.useEffect)(()=>{I.current=S},[S]),(0,c.useEffect)(()=>{if(!D.current)return;let t=O.current?.state.doc.toString()??e??``,c=s??z.palette.primary.main,l=f??z.palette.success.main,v=_??z.palette.info.main,b=m.HighlightStyle.define([{tag:g.tags.keyword,color:c,fontWeight:`bold`},{tag:g.tags.name,color:v},{tag:[g.tags.string,g.tags.special(g.tags.string)],color:l,fontWeight:`bold`},{tag:g.tags.number,color:z.palette.warning.main},{tag:[g.tags.lineComment,g.tags.blockComment],color:z.palette.text.disabled,fontStyle:`italic`},{tag:g.tags.operator,color:z.palette.text.secondary},{tag:[g.tags.function(g.tags.variableName),g.tags.function(g.tags.name)],color:z.palette.secondary.main},{tag:g.tags.typeName,color:z.palette.info.main},{tag:g.tags.invalid,color:z.palette.error.main,textDecoration:`underline wavy`}]),x=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:z.palette.text.primary},".cm-gutters":{backgroundColor:B?z.palette.grey[900]:z.palette.grey[50],color:z.palette.text.disabled,border:`none`,borderRight:`1px solid ${z.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:z.palette.action.selected},".cm-activeLine":{backgroundColor:z.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:z.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:z.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:z.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`,boxShadow:z.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:z.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:z.palette.primary.main+`20`,color:z.palette.primary.main},".cm-completionMatchedText":{color:z.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:z.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:z.palette.error.main},".cm-lint-marker-warning":{color:z.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${z.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${z.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${z.palette.info.main}`}},{dark:B}),S=y?Object.fromEntries(y.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,C=async e=>{let t=F.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 I.current?.(r.length),r}catch{return[]}},w=u.keymap.of([{key:`Mod-Enter`,run:e=>(P.current?.(e.state.doc.toString()),!0)}]),T=[x,(0,m.syntaxHighlighting)(b),(0,Te.sql)({dialect:er[o],schema:S}),(0,p.history)(),(0,Ee.autocompletion)(),w,u.keymap.of([...p.defaultKeymap,...p.historyKeymap,...Ee.completionKeymap]),L.current.of(u.EditorView.editable.of(!r&&!i)),R.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),...a?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[],...n?[(0,u.placeholder)(n)]:[],...V?[(0,h.lintGutter)(),(0,h.linter)(C,{delay:600})]:[],u.EditorView.updateListener.of(e=>{e.docChanged&&k.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);A.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{j.current?.()},focus:()=>{M.current?.()}})],E=new u.EditorView({state:d.EditorState.create({doc:t,extensions:T}),parent:D.current});return O.current=E,N.current(E),()=>{N.current(null),E.destroy(),O.current=null}},[B,o,V,s,f,_,H]),(0,c.useEffect)(()=>{let t=O.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)(()=>{O.current?.dispatch({effects:[L.current.reconfigure(u.EditorView.editable.of(!r&&!i)),R.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,v.jsx)(l.Box,{ref:D,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:z.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function nr(e,t=60){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}function rr({history:e,onSelect:t,onClear:n,translation:r,disabled:i}){let[a,o]=(0,c.useState)(null);function s(){o(null)}function u(e){t(e),s()}function d(){n(),s()}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Tooltip,{title:r.history,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:e=>o(e.currentTarget),disabled:i,"aria-label":r.history,children:(0,v.jsx)(ke.default,{fontSize:`small`})})})}),(0,v.jsxs)(l.Menu,{anchorEl:a,open:!!a,onClose:s,slotProps:{paper:{sx:{minWidth:280,maxWidth:400}}},children:[e.length===0&&(0,v.jsx)(l.MenuItem,{disabled:!0,children:(0,v.jsx)(l.ListItemText,{children:r.historyEmpty})}),e.map(e=>(0,v.jsx)(l.MenuItem,{onClick:()=>u(e.sql),children:(0,v.jsx)(l.ListItemText,{primary:nr(e.sql),secondary:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:new Date(e.timestamp).toLocaleString()}),slotProps:{primary:{sx:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})},e.timestamp)),e.length>0&&(0,v.jsx)(l.Divider,{}),e.length>0&&(0,v.jsxs)(l.MenuItem,{onClick:d,children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(Ae.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:r.clearHistory})]})]})]})}var ir={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function ar({editorView:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a,queryHistory:o=[],onSelectHistoryEntry:s,onClearHistory:u}){let[d,f]=(0,c.useState)(!1),m=i||!e;function h(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)})}function g(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function _(){let t=e;t&&((0,p.undo)(t),t.focus())}function T(){let t=e;t&&((0,p.redo)(t),t.focus())}function E(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=(0,Oe.format)(n,{language:ir[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function D(){let t=e;!t||!a||a(t.state.doc.toString())}let O=t.showFormat,k=t.showCopy||t.showClear,A=t.showUndoRedo,j=t.showExecute&&!!a,M=t.showHistory&&!!a&&!!s&&!!u;return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[O&&(0,v.jsx)(l.Box,{sx:{display:`flex`,gap:.25},children:(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:E,disabled:m})}),O&&(k||A)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),k&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:d?n.copySuccess:n.copy,icon:d?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:h,disabled:m}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:g,disabled:m})]}),k&&A&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),A&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:_,disabled:m}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:T,disabled:m})]}),M&&(0,v.jsxs)(v.Fragment,{children:[(k||A)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,v.jsx)(rr,{history:o,onSelect:s,onClear:u,translation:n,disabled:i})]}),j&&(0,v.jsxs)(v.Fragment,{children:[(k||A||M)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,v.jsx)(Q,{label:n.execute,icon:(0,v.jsx)(De.default,{fontSize:`small`}),onClick:D,disabled:m})]}),!O&&!k&&!A&&!M&&!j&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function or({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&i>0&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(je.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,v.jsx)(l.FormHelperText,{sx:{color:`error.main`,m:0},children:u})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function sr(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e?.sql==`string`&&typeof e?.timestamp==`number`):[]}catch{return[]}}function cr(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function lr(e,t,n){let r=t.trim();if(!r)return e;let i=e.filter(e=>e.sql!==r);return[{sql:r,timestamp:Date.now()},...i].slice(0,Math.max(0,n))}function ur(e,t){let[n,r]=(0,c.useState)(()=>sr(e));return{history:n,addEntry:(0,c.useCallback)(n=>{r(r=>{let i=lr(r,n,t);return cr(e,i),i})},[e,t]),clearHistory:(0,c.useCallback)(()=>{r([]),cr(e,[])},[e])}}function dr({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:m=!0,showErrorCount:h=!1,toolbarConfig:g,translation:_,highlightColors:y,schema:b,queryHistoryKey:x=`sql-editor-query-history`,queryHistoryMaxEntries:S=20,onExecute:C,onLint:w,onBlur:T,onFocus:E}){let D={...$n,..._},O={...Qn,...g},{history:k,addEntry:A,clearHistory:j}=ur(x,S),M=Qe(r),N=Qe(i),P=M===`auto`,F=P?void 0:M??300,I=(0,c.useRef)(null),[L,R]=(0,c.useState)(null),[z,B]=(0,c.useState)({line:1,col:1}),[V,H]=(0,c.useState)(0),U=(0,c.useCallback)(e=>{I.current=e,R(e)},[]),W=(0,c.useCallback)((e,t)=>{B({line:e,col:t})},[]),G=(0,c.useCallback)(e=>{H(e)},[]),K=C?e=>{A(e),C(e)}:void 0,q=(0,c.useCallback)(e=>{let n=I.current;n&&(n.dispatch({changes:{from:0,to:n.state.doc.length,insert:e}}),n.focus()),t?.(e)},[t]),J=m||h||!!u;return(0,v.jsxs)(l.Box,{sx:{width:N??`100%`,...P?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...P?{flex:1}:{height:F},borderColor:s?`error.main`:void 0,"&:focus-within":{borderColor:s?`error.main`:`primary.main`,borderWidth:2}},children:[!o&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ar,{editorView:L,toolbarConfig:O,translation:D,dialect:f,disabled:a,onExecute:K,queryHistory:k,onSelectHistoryEntry:q,onClearHistory:j}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(tr,{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,onExecute:K,onLint:w,onDiagnosticsChange:w?G:void 0,onViewReady:U,onCursorChange:W,onBlur:T,onFocus:E})]}),J&&(0,v.jsx)(or,{helperText:u,error:s,showLineColumn:m,showErrorCount:h,diagnosticsCount:V,cursorLine:z.line,cursorCol:z.col,translation:D}),d&&(0,v.jsx)(`input`,{type:`hidden`,name:d,value:e??``})]})}var fr=2*Math.PI,pr=11,mr=pr*.5,hr=5;function gr(e,t=0,n=`.`,r=`,`){if(e==null||!isFinite(e))return`0`;let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function _r(e,t){let n=Math.floor(t/mr);return n<=0?``:e.length<=n?e:n<hr?``:e.slice(0,n-1)+`…`}function vr({node:e,valueDecimalCount:t,valueDecimalSep:n,valueThousandsSep:r}){let i=(e.value??0)>0,a=e.ancestors().map(e=>e.data.name).reverse().join(` › `);return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.data.name}),i&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:gr(e.value??0,t,n,r)}),e.depth>0&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:a})]})}function yr({data:e,size:t=500,showSegmentLabels:n=!0,innerRadius:r=0,sortBy:i=`value`,chartColors:a,showRootLabel:o=!0,onSegmentClick:s,onZoomChange:u,valueDecimalCount:d=0,valueDecimalSeparator:f=`.`,valueThousandsSeparator:p=`,`,zoomable:m=!1,duration:h=750,disabled:g=!1}){let _=(0,l.useTheme)(),y=(0,c.useRef)(null),[b,x]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[S,C]=(0,c.useState)(1),w=(0,c.useMemo)(()=>{if(S===1)return b;let[e,t,n,r]=b.split(` `).map(Number),i=n/S,a=r/S;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[b,S]),T=t/2,E=Math.max(0,Math.min(r,Math.max(0,T-1))),D=Math.max(1,T-E),O=[_.palette.primary.main,_.palette.secondary.main,_.palette.error.main,_.palette.warning.main,_.palette.success.main,_.palette.info.main],k=a&&a.length>0?a:O,{root:A,ringThickness:j}=(0,c.useMemo)(()=>{let t=Z.hierarchy(e).sum(e=>e.value??0);i===`value`?t.sort((e,t)=>(t.value??0)-(e.value??0)):t.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`}));let n=Z.partition().size([fr,D])(t),r=Z.max(n.descendants(),e=>e.depth)??0,a=r>0?D/r:D;return r>0&&n.descendants().forEach(e=>{e.depth===0?(e.y0=0,e.y1=0):(e.y0=(e.depth-1)*a,e.y1=e.depth*a)}),{root:n,ringThickness:a}},[e,D,i]),[M,N]=(0,c.useState)(A),[P,F]=(0,c.useState)(A),I=e=>({x0:e.x0,x1:e.x1,yShift:e.depth===0?0:(e.depth-1)*j}),[L,R]=(0,c.useState)(()=>I(A)),z=(0,c.useRef)(L);if(P!==A){F(A),N(A);let e=I(A);z.current=e,R(e)}let B=(0,c.useMemo)(()=>A.children?.map(e=>e.data.name)??[A.data.name],[A]),V=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(B).range(k),[k,B]),H=e=>{if(e.data.colorConfig?.fill)return e.data.colorConfig.fill;let t=e;for(;t.depth>1;)t=t.parent;return V(t.data.name)},U=(0,c.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).padAngle(e=>Math.min((e.x1-e.x0)/2,.005)).padRadius(T/2).innerRadius(e=>E+e.y0).outerRadius(e=>E+e.y1-1),[T,E]),W=(0,c.useCallback)(e=>{let t=fr/(L.x1-L.x0);return{x0:Math.max(0,Math.min(fr,(e.x0-L.x0)*t)),x1:Math.max(0,Math.min(fr,(e.x1-L.x0)*t)),y0:Math.max(0,e.y0-L.yShift),y1:Math.max(0,e.y1-L.yShift)}},[L]);(0,c.useEffect)(()=>{let e=I(M),t=z.current;if(t.x0===e.x0&&t.x1===e.x1&&t.yShift===e.yShift)return;if(h<=0){z.current=e,R(e);return}let n=null,r=Z.interpolateNumber(t.x0,e.x0),i=Z.interpolateNumber(t.x1,e.x1),a=Z.interpolateNumber(t.yShift,e.yShift),o=performance.now(),s=e=>{let t=Math.min(1,(e-o)/h),c=Z.easeCubic(t),l={x0:r(c),x1:i(c),yShift:a(c)};z.current=l,R(l),n=t<1?requestAnimationFrame(s):null};return n=requestAnimationFrame(s),()=>{n!=null&&cancelAnimationFrame(n)}},[M,j,h]);let G=e=>e.x1>e.x0&&e.y1>e.y0,K=e=>(E+(e.y0+e.y1)/2)*(e.x1-e.x0)>12,q=e=>{let t=(e.x0+e.x1)/2*180/Math.PI,n=E+(e.y0+e.y1)/2,r=t<180?0:180;return`rotate(${t-90}) translate(${n},0) rotate(${r})`},J=(0,c.useCallback)(e=>e.ancestors().includes(M),[M]),Y=(0,c.useCallback)(e=>{let t=e.ancestors().reverse(),n=e.value??0,r=A.value??0;return{id:e.data.id,name:e.data.name,value:n||null,percentage:r>0?Math.round(n/r*1e4)/100:0,depth:e.depth,path:t.map(e=>e.data.name),pathIds:t.map(e=>e.data.id),childrenCount:e.children?.length??0,data:e.data}},[A]),X=(0,c.useCallback)(e=>{N(e),u&&u({focusNode:Y(e),isRoot:e===A})},[A,Y,u]);(0,c.useLayoutEffect)(()=>{let e=y.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();x(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{x(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,A,M,E,j,o]);let ee=(0,c.useRef)(null),te=e=>{ee.current&&=(clearTimeout(ee.current),null),ee.current=setTimeout(()=>{e(),ee.current=null},250)},ne=()=>{ee.current&&=(clearTimeout(ee.current),null)};(0,c.useLayoutEffect)(()=>{if(g)return;let e=e=>{e.key===`Escape`&&(ne(),X(A),C(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,A,X]);let re=(0,c.useCallback)(e=>{if(!m||g||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;C(e=>Math.max(.25,Math.min(8,e*t)))},[m,g]),ie=A.descendants().filter(e=>e.depth>0),ae=e=>{if(g)return;let t=ie[Number(e.currentTarget.getAttribute(`data-idx`))];if(t){if(e.ctrlKey||e.metaKey){t.children&&te(()=>X(t));return}s?.(Y(t),e)}},oe=e=>{g||(e.ctrlKey||e.metaKey)&&(ne(),X(M.parent??A))},se=e=>{if(!g){if(e.ctrlKey||e.metaKey){ne(),X(M.parent??A);return}s?.(Y(M.parent??A),e)}},ce={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:g,slotProps:{tooltip:{sx:{maxWidth:260}}}},le=_.palette.text.primary,ue=_.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:g?.5:1,cursor:g?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:w,onWheel:re,style:{fontFamily:ue??`sans-serif`,overflow:m&&S>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:y,children:[E>0&&(0,v.jsx)(l.Tooltip,{...ce,title:M.data.name,placement:`top`,children:(0,v.jsx)(`circle`,{cx:0,cy:0,r:E,fill:`transparent`,pointerEvents:g?`none`:`auto`,onClick:se,style:{cursor:g?`not-allowed`:`pointer`}})}),(0,v.jsx)(`g`,{children:ie.map((e,t)=>{let n=W(e),r=G(n),i=!!e.children;return(0,v.jsx)(l.Tooltip,{...ce,placement:`top`,title:r?(0,v.jsx)(vr,{node:e,valueDecimalCount:d,valueDecimalSep:f,valueThousandsSep:p}):``,children:(0,v.jsx)(`path`,{"data-idx":t,d:U(n)||``,fill:H(e),fillOpacity:r?i?.75:.5:0,style:{pointerEvents:r&&!g?`auto`:`none`,cursor:i&&!g?`pointer`:`default`,transition:`fill-opacity 0.15s`},onClick:ae,onDoubleClick:oe})},`tt-${e.data.id}-${t}`)})}),n&&(0,v.jsx)(`g`,{pointerEvents:`none`,textAnchor:`middle`,fill:le,children:ie.map((e,t)=>{if(!J(e))return null;let n=W(e);if(!K(n))return null;let r=(E+(n.y0+n.y1)/2)*(n.x1-n.x0)*.88,i=_r(e.data.name,r);return i?(0,v.jsx)(`text`,{transform:q(n),dy:`0.35em`,fontSize:pr,children:i},`lbl-${e.data.id}-${t}`):null})}),o&&(0,v.jsx)(l.Tooltip,{...ce,placement:`top`,title:``,children:(0,v.jsx)(`g`,{textAnchor:`middle`,fill:le,pointerEvents:g?`none`:`auto`,onClick:se,style:{cursor:M!==A&&!g?`pointer`:`default`},children:(0,v.jsx)(`text`,{fontSize:13,dy:`0.35em`,fontWeight:`bold`,children:M.data.name})})})]})})})}yr.displayName=`SunburstChart`;var br={noData:`No data`};function xr(e,t=0,n=`.`,r=`,`){if(!isFinite(e))return String(e);let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Sr({name:e,valueOut:t,valueIn:n,fmt:r}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(t),` outgoing →`]}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(n),` incoming ←`]})]})}function Cr({sourceName:e,targetName:t,sourceValue:n,targetValue:r,directed:i,fmt:a}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:[e,` → `,t]}),(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:a(n)}),i&&r>0&&r!==n&&(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.7,mt:.25},children:[t,` → `,e,`: `,a(r)]})]})}function wr({data:e,size:t=500,innerRadius:n,ringThickness:r=20,padAngle:i,ribbonPadAngle:a,sortSubgroups:o=`descending`,sortChords:s=`descending`,chartColors:u,groupColorConfigs:d,showGroupLabels:f=!0,labelOffset:p=8,ribbonOpacity:m=.75,ribbonBlendMode:h,directed:g=!0,valueDecimalCount:_=0,valueDecimalSeparator:y=`.`,valueThousandsSeparator:b=`,`,onGroupClick:x,onChordClick:S,zoomable:C=!1,disabled:w=!1}){let T=(0,l.useTheme)(),E=h??(T.palette.mode===`dark`?`normal`:`multiply`),D=[T.palette.primary.main,T.palette.secondary.main,T.palette.error.main,T.palette.warning.main,T.palette.success.main,T.palette.info.main],O=u&&u.length>0?u:D,k=n??Math.min(t,t)*.5-90,A=Math.max(10,k),j=A+Math.max(1,r),M=i??10/A,N=a??1/A,P=(0,c.useCallback)(e=>xr(e,_,y,b),[_,y,b]),{names:F,matrix:I}=(0,c.useMemo)(()=>{let t=Z.sort(Z.union(e.map(e=>e.source),e.map(e=>e.target))),n=new Map(t.map((e,t)=>[e,t])),r=Array.from({length:t.length},()=>Array(t.length).fill(0));for(let{source:t,target:i,value:a}of e){let e=n.get(t),o=n.get(i);e==null||o==null||(r[e][o]+=a)}return{names:t,matrix:r}},[e]),L=(0,c.useMemo)(()=>{let e=(g?Z.chordDirected():Z.chord()).padAngle(M);return o===`ascending`&&(e=e.sortSubgroups(Z.ascending)),o===`descending`&&(e=e.sortSubgroups(Z.descending)),s===`ascending`&&(e=e.sortChords(Z.ascending)),s===`descending`&&(e=e.sortChords(Z.descending)),e(I)},[I,M,g,o,s]),R=(0,c.useMemo)(()=>Z.arc().innerRadius(A).outerRadius(j),[A,j]),z=(0,c.useMemo)(()=>(g?Z.ribbonArrow():Z.ribbon()).radius(A-1).padAngle(N),[A,N,g]),B=(0,c.useCallback)(e=>z({source:{startAngle:e.source.startAngle,endAngle:e.source.endAngle,radius:A-1},target:{startAngle:e.target.startAngle,endAngle:e.target.endAngle,radius:A-1}})??``,[z,A]),V=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(Z.range(F.length)).range(O.length>=F.length?O:[...Array(Math.ceil(F.length/O.length))].flatMap(()=>O).slice(0,F.length)),[O,F.length]),H=(0,c.useCallback)(e=>d?.[F[e]]?.fill??V(e),[d,F,V]),U=(0,c.useRef)(null),[W,G]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[K,q]=(0,c.useState)(1),J=(0,c.useMemo)(()=>{if(K===1)return W;let[e,t,n,r]=W.split(` `).map(Number),i=n/K,a=r/K;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[W,K]);(0,c.useLayoutEffect)(()=>{let e=U.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();G(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{G(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,A,j,F.length,L]);let[Y,X]=(0,c.useState)(null),ee=(0,c.useCallback)(e=>({name:F[e.index],index:e.index,valueOut:Z.sum(L,t=>t.source.index===e.index?t.source.value:0),valueIn:Z.sum(L,t=>t.target.index===e.index?t.source.value:0)}),[F,L]),te=(0,c.useCallback)(e=>({source:{name:F[e.source.index],index:e.source.index,value:e.source.value},target:{name:F[e.target.index],index:e.target.index,value:e.target.value}}),[F]),ne=e=>{let t=(e.startAngle+e.endAngle)/2,n=t*180/Math.PI-90,r=t>Math.PI?` rotate(180)`:``;return`rotate(${n}) translate(${j+p})${r}`},re=e=>(e.startAngle+e.endAngle)/2>Math.PI?`end`:`start`,ie=(0,c.useCallback)(e=>{if(!C||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;q(e=>Math.max(.25,Math.min(8,e*t)))},[C,w]);(0,c.useLayoutEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&q(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]);let ae={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},oe=T.palette.text.primary,se=T.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:w?.5:1,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:J,onWheel:ie,style:{fontFamily:se??`sans-serif`,overflow:C&&K>1?`hidden`:`visible`},role:`img`,"aria-label":`Chord chart`,children:(0,v.jsxs)(`g`,{ref:U,children:[(0,v.jsx)(`g`,{children:L.groups.map(e=>{let t=ee(e),n=Y===e.index,r=Y!==null&&!n;return(0,v.jsx)(l.Tooltip,{...ae,title:(0,v.jsx)(Sr,{name:t.name,valueOut:t.valueOut,valueIn:t.valueIn,fmt:P}),children:(0,v.jsxs)(`g`,{style:{cursor:w?`not-allowed`:`pointer`},onMouseEnter:()=>!w&&X(e.index),onMouseLeave:()=>X(null),onClick:e=>!w&&x?.(t,e),children:[(0,v.jsx)(`path`,{d:R(e)||``,fill:H(e.index),stroke:T.palette.divider,opacity:r?.35:1,style:{transition:`opacity 0.15s`}}),f&&(0,v.jsx)(`text`,{dy:`0.35em`,fontSize:11,fill:oe,transform:ne(e),textAnchor:re(e),pointerEvents:`none`,children:F[e.index]})]})},`grp-tt-${e.index}`)})}),(0,v.jsx)(`g`,{fillOpacity:m,style:{mixBlendMode:E},children:L.map((e,t)=>{let n=te(e),r=Y===null||e.source.index===Y||e.target.index===Y;return(0,v.jsx)(l.Tooltip,{...ae,title:(0,v.jsx)(Cr,{sourceName:n.source.name,targetName:n.target.name,sourceValue:n.source.value,targetValue:n.target.value,directed:g,fmt:P}),children:(0,v.jsx)(`path`,{d:B(e),fill:H(e.target.index),stroke:`none`,opacity:r?1:.12,style:{cursor:w?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onClick:e=>!w&&S?.(n,e)})},`chord-tt-${t}`)})})]})})})}wr.displayName=`ChordChart`;var Tr={noData:`No data`},Er={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Dr={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function Or({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function kr({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function Ar({data:e,size:t=600,autoFit:n=!0,sortBy:r=`name`,showLabels:i=!0,showIcons:a=!0,chartColors:o,rootNodeRadius:s=22,branchNodeRadius:u=16,leafNodeRadius:d=11,linkColor:f,linkStrokeOpacity:p=1,linkStrokeWidth:m=1.5,labelFontSize:h=12,labelColor:g,separationSibling:_=1,separationCousin:y=2,zoomable:b=!1,drillable:x=!1,onFocusChange:S,duration:C=750,showNodePopover:w=!1,renderNodePopoverContent:T,onNodeClick:E,disabled:D=!1,translation:O}){let k=(0,l.useTheme)(),A={...Er,...O},j=[k.palette.primary.main,k.palette.secondary.main,k.palette.info.main,k.palette.success.main,k.palette.warning.main,k.palette.error.main],M=o&&o.length>0?o:j,N=(0,c.useCallback)(e=>e.depth===0?s:e.children?u:d,[s,u,d]),P=(0,c.useCallback)(e=>e.data.colorConfig?.fill??M[e.depth%M.length],[M]),[F,I]=(0,c.useState)([e]),L=F[F.length-1],[R,z]=(0,c.useState)(e),[B,V]=(0,c.useState)(!1);R!==e&&(z(e),I([e]),V(!0));let H=Math.max(1,t/2-70),U=(0,c.useMemo)(()=>{let e=Z.hierarchy(L);return r===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(e.data.name,t.data.name)),Z.tree().size([2*Math.PI,H]).separation((e,t)=>(e.parent===t.parent?_:y)*1.4/Math.max(1,e.depth))(e)},[L,r,H,_,y]),W=U.links(),G=U.descendants(),K=(0,c.useRef)(U),q=(0,c.useRef)(null),[J,Y]=(0,c.useState)(null),[X,ee]=(0,c.useState)(0);(0,c.useEffect)(()=>{let e=K.current;if(K.current=U,e===U)return;if(q.current!=null&&(cancelAnimationFrame(q.current),q.current=null),B||C<=0){V(!1),Y(null);return}Y(e),ee(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/C);ee(1-Z.easeCubic(r)),r<1?q.current=requestAnimationFrame(n):(q.current=null,Y(null))};return q.current=requestAnimationFrame(n),()=>{q.current!=null&&cancelAnimationFrame(q.current)}},[U,C,B]);let te=(0,c.useMemo)(()=>Z.linkRadial().angle(e=>e.x).radius(e=>e.y),[]),ne=(0,c.useCallback)(e=>({id:e.data.id,name:e.data.name,subname:e.data.subname??null,value:(typeof e.value==`number`?e.value:null)??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),re=(0,c.useRef)(null),[ie,ae]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[oe,se]=(0,c.useState)(1);(0,c.useLayoutEffect)(()=>{let e=re.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();ae(`${t.x-20} ${t.y-20} ${t.width+40} ${t.height+40}`)}catch{ae(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,U,i,n]);let ce=(0,c.useMemo)(()=>{if(oe===1)return ie;let[e,t,n,r]=ie.split(` `).map(Number),i=n/oe,a=r/oe;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[ie,oe]),le=(0,c.useCallback)(e=>{if(!b||D||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;se(e=>Math.max(.25,Math.min(8,e*t)))},[b,D]);(0,c.useLayoutEffect)(()=>{if(!b&&!x)return;let t=t=>{t.key===`Escape`&&(b&&se(1),x&&(I([e]),S?.(null)))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[b,x,e,S]);let ue=(0,c.useRef)(null),de=e=>{ue.current&&=(clearTimeout(ue.current),null),ue.current=setTimeout(()=>{e(),ue.current=null},250)},fe=()=>{ue.current&&=(clearTimeout(ue.current),null)},[pe,me]=(0,c.useState)(null),he=(0,c.useRef)(null),ge=(0,c.useRef)(null),[_e,ve]=(0,c.useState)(!1),[ye,be]=(0,c.useState)(null),[xe,Se]=(0,c.useState)({left:0,top:0}),[Ce,we]=(0,c.useState)(null),Te=(0,c.useCallback)(()=>{I(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return S?.(t.length<=1?null:{id:t[t.length-1].id,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]}),t})},[S]),Ee=e=>{D||!x||(e.ctrlKey||e.metaKey)&&(fe(),Te())},De=e=>{if(D)return;let t=G[Number(e.currentTarget.getAttribute(`data-idx`))];if(!t)return;let n=ne(t);if((e.ctrlKey||e.metaKey)&&x&&t.children){de(()=>{I(e=>[...e,t.data]),S?.(n)});return}if(w){let t=he.current?.getBoundingClientRect();Se({left:t?e.clientX-t.left:e.clientX,top:t?e.clientY-t.top:e.clientY}),be(ge.current),we(n),ve(!0)}E?.(n,e)},Oe=g||k.palette.text.primary,ke=f||k.palette.text.secondary,Ae=k.palette.background.paper,je=k.typography.fontFamily;return(0,v.jsxs)(l.Box,{ref:he,sx:{display:`inline-flex`,position:`relative`,opacity:D?.5:1,cursor:D?`not-allowed`:`default`,userSelect:`none`},children:[x&&F.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,gap:.5,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:F.map(e=>e.name).join(` › `)})}),(0,v.jsx)(l.Box,{ref:ge,sx:{position:`absolute`,left:xe.left,top:xe.top,width:0,height:0}}),(0,v.jsx)(`svg`,{width:t,height:t,viewBox:ce,onWheel:le,style:{fontFamily:je??`sans-serif`,overflow:b&&oe>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:re,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:ke,strokeOpacity:p,strokeWidth:m,children:W.map((e,t)=>(0,v.jsx)(`path`,{d:te(e)},`link-${t}`))}),(0,v.jsx)(`g`,{children:G.map((e,t)=>{let n=N(e),r=P(e),i=ne(e),o=pe===t,s=e.children?Dr.folder:Dr.person,c=Math.round(n*1.3);return(0,v.jsx)(l.Tooltip,{title:(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(i.specialValueA!=null||i.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[i.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:A.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueA)})]}),i.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:A.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]}),followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:D,slotProps:{tooltip:{sx:{maxWidth:260}}},children:(0,v.jsxs)(`g`,{"data-idx":t,transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,onClick:De,onDoubleClick:Ee,onMouseEnter:()=>!D&&me(t),onMouseLeave:()=>me(null),style:{cursor:D?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:Math.max(n+8,24),fill:`transparent`}),(0,v.jsx)(`circle`,{r:n+2,fill:r,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:n,fill:r,fillOpacity:o?.85:1,style:{transition:`fill-opacity 0.15s`}}),a&&(0,v.jsx)(Or,{path:s,size:c})]})},`node-${e.data.id}-${t}`)})}),J&&((e,t)=>(0,v.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:ke,strokeOpacity:p,strokeWidth:m,children:e.links().map((e,t)=>(0,v.jsx)(`path`,{d:te(e)},`ghost-link-${t}`))}),(0,v.jsx)(`g`,{children:e.descendants().map((e,t)=>(0,v.jsxs)(`g`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,children:[(0,v.jsx)(`circle`,{r:N(e)+2,fill:P(e),fillOpacity:.15}),(0,v.jsx)(`circle`,{r:N(e),fill:P(e)}),a&&(0,v.jsx)(Or,{path:e.children?Dr.folder:Dr.person,size:Math.round(N(e)*1.3)})]},`ghost-node-${t}`))})]}))(J,X),i&&(0,v.jsx)(`g`,{children:G.map((e,t)=>{let n=N(e),r=e.x<Math.PI==!e.children,i=n+6,a=r?i:-i,o=r?`start`:`end`;return(0,v.jsx)(`text`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0) rotate(${e.x>=Math.PI?180:0})`,dy:`0.35em`,x:a,textAnchor:o,paintOrder:`stroke`,stroke:Ae,strokeWidth:3,fill:Oe,fontSize:h,fontWeight:e.depth===0?`bold`:`normal`,pointerEvents:`none`,children:e.data.name},`lbl-${e.data.id}-${t}`)})})]})}),w&&(0,v.jsx)(l.Popover,{open:_e,anchorEl:ye,onClose:()=>ve(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:Ce&&(T?T(Ce):(0,v.jsx)(kr,{info:Ce,labelA:A.specialValueA??`Value A`,labelB:A.specialValueB??`Value B`}))})]})}Ar.displayName=`RadialTreeChart`;var jr=.56;function Mr(e,t,n){return e.length*n*jr<=t?e:t>=3*n*jr+n*2?`…`:``}function Nr({data:e,size:t=600,padding:n=3,sortBy:r=`value`,showLabels:i=!0,showAllLabels:a=!1,labelFontSize:o=13,innerLabelFontSize:s=9,labelColor:u,chartColors:d,depthColorStart:f,depthColorEnd:p,background:m,duration:h=750,zoomable:g=!1,disabled:_=!1,onCircleClick:y,onZoomChange:b}){let x=(0,l.useTheme)(),S=[x.palette.primary.main,x.palette.secondary.main,x.palette.error.main,x.palette.warning.main,x.palette.success.main,x.palette.info.main],C=u||x.palette.text.primary,w=m||x.palette.background.default,T=x.typography.fontFamily,E=(0,c.useMemo)(()=>{let i=Z.hierarchy(e).sum(e=>e.value??0);return r===`value`?i.sort((e,t)=>(t.value??0)-(e.value??0)):i.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`})),Z.pack().size([t,t]).padding(n)(i)},[e,t,n,r]),D=E.descendants(),O=(0,c.useMemo)(()=>Z.max(D,e=>e.depth)??0,[D]),k=!!(f&&p),A=(0,c.useMemo)(()=>k?Z.scaleSequential(Z.interpolateHcl(f,p)).domain([0,Math.max(1,O)]):null,[k,f,p,O]),j=d&&d.length>0?d:S,M=(0,c.useCallback)(e=>e.data.colorConfig?.fill?e.data.colorConfig.fill:k&&A?e.children?A(e.depth):x.palette.background.paper:j[e.depth%j.length],[k,A,j,x]),[N,P]=(0,c.useState)(1),F=(0,c.useCallback)(e=>{if(!g||_||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;P(e=>Math.max(.25,Math.min(8,e*t)))},[g,_]);(0,c.useLayoutEffect)(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&P(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g]);let I=(0,c.useMemo)(()=>{let e=`${-t/2} ${-t/2} ${t} ${t}`;if(N===1)return e;let n=t/N,r=(t-n)/2;return`${-t/2+r} ${-t/2+r} ${n} ${n}`},[t,N]),L=(0,c.useCallback)(e=>{let t=e.value??0,n=E.value??0;return{id:e.data.id??null,name:e.data.name,value:t||null,percentage:n>0?Math.round(t/n*1e4)/100:0,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}},[E]),R=(0,c.useRef)(null),z=(0,c.useRef)([E.x,E.y,E.r*2]),B=(0,c.useRef)(E),[V,H]=(0,c.useState)(E),U=(0,c.useCallback)(e=>{B.current=e,H(e)},[]),[W,G]=(0,c.useState)(e);W!==e&&(G(e),U(E),B.current=E);let K=(0,c.useCallback)(e=>{let n=R.current;if(!n)return;z.current=e;let r=t/e[2],o=B.current,c=n.querySelectorAll(`g[data-role='nodes'] > g`),l=n.querySelectorAll(`g[data-role='nodes'] > g > circle`);for(let t=0;t<D.length;t++){let n=D[t],i=c[t];i&&i.setAttribute(`transform`,`translate(${(n.x-e[0])*r},${(n.y-e[1])*r})`);let a=t-1;a>=0&&l[a]&&l[a].setAttribute(`r`,String(n.r*r))}if(i){let t=n.querySelectorAll(`g[data-role='labels'] > text`);for(let n=0;n<D.length;n++){let i=D[n],a=t[n];a&&(a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`))}}if(a){let t=n.querySelectorAll(`g[data-role='inner-labels'] > text`);for(let n=0;n<D.length;n++){let i=D[n],a=t[n];if(!a)continue;let c=i.r*r,l=c*1.6,u=o===E?i!==E:i.ancestors().includes(o),d=i.parent===o;if(u&&!d&&c>=14){let t=Mr(i.data.name,l,s);t?(a.textContent=t,a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`),a.style.display=`inline`):a.style.display=`none`}else a.style.display=`none`}}},[D,t,i,a,s,E]);(0,c.useLayoutEffect)(()=>{K([V.x,V.y,V.r*2])},[E,t,V,K]);let q=(0,c.useCallback)((e,t)=>{let n=R.current;if(!n)return;let r=V,i=z.current,a=[e.x,e.y,e.r*2];U(e),Z.select(n).transition().duration(t).ease(Z.easeCubic).tween(`zoom`,()=>{let e=Z.interpolateZoom(i,a);return t=>K(e(t))});let o=n.querySelectorAll(`g[data-role='labels'] > text`);Z.selectAll(o).transition().duration(t).ease(Z.easeCubic).style(`fill-opacity`,(t,n)=>+(D[n].parent===e)).on(`start`,function(t,n){D[n].parent===e&&(this.style.display=`inline`)}).on(`end`,function(t,n){D[n].parent!==e&&(this.style.display=`none`)}),b?.({previousName:r.data.name,currentName:e.data.name,currentDepth:e.depth,isRoot:e===E})},[V,D,E,K,b,U]),J=(0,c.useRef)(null),Y=e=>{J.current&&=(clearTimeout(J.current),null),J.current=setTimeout(()=>{e(),J.current=null},250)},X=()=>{J.current&&=(clearTimeout(J.current),null)};(0,c.useLayoutEffect)(()=>{if(_)return;let e=e=>{e.key===`Escape`&&(X(),q(E,h))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,E,h]);let ee=e=>{if(_||!(e.ctrlKey||e.metaKey))return;X(),e.preventDefault();let t=V.parent??E;t!==V&&q(t,e.altKey?Math.max(250,h*10):h)},te={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:_,slotProps:{tooltip:{sx:{maxWidth:220}}}};return(0,v.jsxs)(l.Box,{sx:{display:`inline-flex`,position:`relative`,opacity:_?.5:1,cursor:_?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsxs)(`svg`,{ref:R,width:t,height:t,viewBox:I,onWheel:F,style:{display:`block`,background:w,fontFamily:T??`sans-serif`,overflow:g&&N>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,onDoubleClick:ee,children:[(0,v.jsx)(`g`,{"data-role":`nodes`,children:D.map((e,n)=>{let r=L(e),i=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),(e.value??0)>0&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Value`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.value?.toLocaleString()})]}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Share`}),(0,v.jsxs)(l.Typography,{variant:`caption`,children:[r.percentage,`%`]})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Children`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(`g`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,children:n===0?null:(0,v.jsx)(l.Tooltip,{...te,title:i,children:(0,v.jsx)(`circle`,{r:e.r,fill:M(e),stroke:e.data.colorConfig?.stroke??x.palette.background.paper,strokeWidth:.75,style:{cursor:_?`not-allowed`:e.children?`pointer`:`default`,transition:`stroke-width 0.1s`},onMouseEnter:e=>{_||(e.currentTarget.style.strokeWidth=`2`)},onMouseLeave:e=>{e.currentTarget.style.strokeWidth=`0.75`},onClick:t=>{if(!_){if(t.ctrlKey||t.metaKey){if(e.children){let n=t.altKey?Math.max(250,h*10):h;Y(()=>q(e,n))}return}y?.(r,t)}},onDoubleClick:e=>{if(!_&&(e.ctrlKey||e.metaKey)){X(),e.preventDefault(),e.stopPropagation();let t=V.parent??E;t!==V&&q(t,e.altKey?Math.max(250,h*10):h)}}})})},`n-${n}`)})}),i&&(0,v.jsx)(`g`,{"data-role":`labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:o,fill:C,children:D.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:e.parent===E?`inline`:`none`,fillOpacity:+(e.parent===E)},children:e.data.name},`lbl-${n}`))}),a&&(0,v.jsx)(`g`,{"data-role":`inner-labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:s,fill:C,children:D.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:`none`}},`inner-lbl-${n}`))})]}),V!==E&&!_&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,bottom:6,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`},children:(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:[V.ancestors().map(e=>e.data.name).reverse().join(` › `),` · Ctrl / Cmd ⌘+DblClick to zoom out · Escape to reset`]})})]})}Nr.displayName=`CirclePackingChart`;var Pr={noData:`No data`},Fr={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Ir={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function Lr({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function Rr({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function zr({data:e,orientation:t=`LR`,width:n=800,height:r=500,levelSpacing:i=200,nodeRadius:a=10,sortBy:o=`name`,showLabels:s=!0,labelFontSize:u=12,labelColor:d,showIcons:f=!0,chartColors:p,linkStrokeOpacity:m=1,linkStrokeWidth:h=1.5,linkColor:g,zoomable:_=!1,drillable:y=!1,onFocusChange:b,showNodePopover:x=!1,renderNodePopoverContent:S,onNodeClick:C,duration:w=750,disabled:T=!1,translation:E}){let D=(0,l.useTheme)(),O={...Fr,...E},k=[D.palette.primary.main,D.palette.secondary.main,D.palette.error.main,D.palette.warning.main,D.palette.success.main,D.palette.info.main],A=p&&p.length>0?p:k,j=d||D.palette.text.primary,M=g||D.palette.text.secondary,N=D.palette.background.paper,P=D.typography.fontFamily,F=t===`TB`||t===`BT`,I=F?r:n,L=F?n:r,[R,z]=(0,c.useState)([e]),B=R[R.length-1],[V,H]=(0,c.useState)(e),[U,W]=(0,c.useState)(!1);V!==e&&(H(e),z([e]),W(!0));let G=(0,c.useMemo)(()=>{let e=Z.hierarchy(B);o===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(String(e.data.name),String(t.data.name)));let t=Z.max(e.descendants(),e=>e.depth)??1;return Z.tree().size([I*.8,Math.min(t*i,L*.85)])(e)},[B,o,I,L,i]),K=G.descendants(),q=G.links(),J=(0,c.useRef)(G),Y=(0,c.useRef)(null),[X,ee]=(0,c.useState)(null),[te,ne]=(0,c.useState)(0);(0,c.useEffect)(()=>{let e=J.current;if(J.current=G,e===G)return;if(Y.current!=null&&(cancelAnimationFrame(Y.current),Y.current=null),U||w<=0){W(!1),ee(null);return}ee(e),ne(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/w);ne(1-Z.easeCubic(r)),r<1?Y.current=requestAnimationFrame(n):(Y.current=null,ee(null))};return Y.current=requestAnimationFrame(n),()=>{Y.current!=null&&cancelAnimationFrame(Y.current)}},[G,w,U]);let re=(0,c.useCallback)(e=>e.data.colorConfig?.fill??A[e.depth%A.length],[A]),ie=(0,c.useCallback)(e=>{switch(t){case`LR`:return{x:e.y,y:e.x-I*.4};case`RL`:return{x:L*.85-e.y,y:e.x-I*.4};case`TB`:return{x:e.x-I*.4,y:e.y};case`BT`:return{x:e.x-I*.4,y:L*.85-e.y}}},[t,I,L]),ae=(0,c.useCallback)(e=>{let n=ie(e.source),r=ie(e.target);if(t===`LR`||t===`RL`){let e=(n.x+r.x)/2;return`M${n.x},${n.y} C${e},${n.y} ${e},${r.y} ${r.x},${r.y}`}let i=(n.y+r.y)/2;return`M${n.x},${n.y} C${n.x},${i} ${r.x},${i} ${r.x},${r.y}`},[ie,t]),oe=(0,c.useCallback)(e=>({id:e.data.id??null,name:e.data.name,subname:e.data.subname??null,value:e.value??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),[se,ce]=(0,c.useState)(`0 -${r/2} ${n} ${r}`),[le,ue]=(0,c.useState)(1),de=(0,c.useRef)(null),fe=(0,c.useMemo)(()=>{if(le===1)return se;let[e,t,n,r]=se.split(` `).map(Number),i=n/le,a=r/le;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[se,le]);(0,c.useLayoutEffect)(()=>{let e=de.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();ce(`${t.x-24} ${t.y-24} ${t.width+48} ${t.height+48}`)}catch{ce(`0 -${r/2} ${n} ${r}`)}});return()=>cancelAnimationFrame(t)},[G,n,r,t]);let pe=(0,c.useCallback)(e=>{if(!_||T||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;ue(e=>Math.max(.25,Math.min(8,e*t)))},[_,T]),me=(0,c.useRef)(null),he=e=>{me.current&&=(clearTimeout(me.current),null),me.current=setTimeout(()=>{e(),me.current=null},250)},ge=()=>{me.current&&=(clearTimeout(me.current),null)},_e=(0,c.useCallback)(()=>{z(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return b?.({focusedNode:{id:t[t.length-1].id??null,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]},isRoot:t.length<=1}),t})},[b]);(0,c.useLayoutEffect)(()=>{if(!_&&!y)return;let t=t=>{t.key===`Escape`&&(_&&ue(1),y&&(z([e]),b?.({focusedNode:{id:e.id??null,name:e.name,subname:e.subname??null,value:null,specialValueA:null,specialValueB:null,depth:0,path:[e.name],childrenCount:e.children?.length??0,data:e},isRoot:!0})))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[_,y,e,b]);let ve=(0,c.useRef)(null),ye=(0,c.useRef)(null),[be,xe]=(0,c.useState)(!1),[Se,Ce]=(0,c.useState)(null),[we,Te]=(0,c.useState)({left:0,top:0}),[Ee,De]=(0,c.useState)(null),Oe=(e,t)=>{if(T)return;let n=oe(e);if((t.ctrlKey||t.metaKey)&&y&&e.children){he(()=>{z(t=>[...t,e.data]),b?.({focusedNode:n,isRoot:!1})});return}if((t.ctrlKey||t.metaKey)&&y){ge(),_e();return}if(x){let e=ve.current?.getBoundingClientRect();Te({left:e?t.clientX-e.left:t.clientX,top:e?t.clientY-e.top:t.clientY}),Ce(ye.current),De(n),xe(!0)}C?.(n,t)},ke=(e,t)=>{T||!y||(t.ctrlKey||t.metaKey)&&(ge(),_e())},Ae={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:T,slotProps:{tooltip:{sx:{maxWidth:240}}}},je=Math.round(a*1.3);return(0,v.jsxs)(l.Box,{ref:ve,sx:{display:`inline-flex`,position:`relative`,opacity:T?.5:1,cursor:T?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsx)(l.Box,{ref:ye,sx:{position:`absolute`,left:we.left,top:we.top,width:0,height:0}}),y&&R.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:R.map(e=>e.name).join(` › `)})}),(0,v.jsx)(`svg`,{width:n,height:r,viewBox:fe,onWheel:pe,style:{fontFamily:P??`sans-serif`,overflow:_&&le>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:de,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:M,strokeOpacity:m,strokeWidth:h,children:q.map((e,t)=>(0,v.jsx)(`path`,{d:ae(e)},`link-${t}`))}),K.map((e,n)=>{let r=ie(e),i=re(e),o=oe(e),c=e.children?Ir.folder:Ir.person,d=t===`LR`,p=t===`RL`,m=d?a+6:p?-(a+6):0,h=!d&&!p?t===`TB`?a+16:-(a+6):0,g=d?`start`:p?`end`:`middle`,_=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:140},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(o.specialValueA!=null||o.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[o.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:O.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueA)})]}),o.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:O.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(l.Tooltip,{...Ae,title:_,children:(0,v.jsxs)(`g`,{transform:`translate(${r.x},${r.y})`,onClick:t=>Oe(e,t),onDoubleClick:t=>ke(e,t),style:{cursor:T?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:a+8,fill:`transparent`}),(0,v.jsx)(`circle`,{r:a+2,fill:i,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:a,fill:i}),f&&(0,v.jsx)(Lr,{path:c,size:je}),s&&(0,v.jsx)(`text`,{x:m,y:h,dy:`0.35em`,textAnchor:g,fontSize:u,fontWeight:e.children?`bold`:`normal`,fill:e.data.colorConfig?.textColor??j,paintOrder:`stroke`,stroke:N,strokeWidth:3,pointerEvents:`none`,children:e.data.name})]})},`node-${n}`)}),X&&((e,t)=>(0,v.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:M,strokeOpacity:m,strokeWidth:h,children:e.links().map((e,t)=>(0,v.jsx)(`path`,{d:ae(e)},`ghost-link-${t}`))}),(0,v.jsx)(`g`,{children:e.descendants().map((e,t)=>{let n=ie(e);return(0,v.jsxs)(`g`,{transform:`translate(${n.x},${n.y})`,children:[(0,v.jsx)(`circle`,{r:a+2,fill:re(e),fillOpacity:.15}),(0,v.jsx)(`circle`,{r:a,fill:re(e)}),f&&(0,v.jsx)(Lr,{path:e.children?Ir.folder:Ir.person,size:je})]},`ghost-node-${t}`)})})]}))(X,te)]})}),x&&(0,v.jsx)(l.Popover,{open:be,anchorEl:Se,onClose:()=>xe(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:Ee&&(S?S(Ee):(0,v.jsx)(Rr,{info:Ee,labelA:O.specialValueA??`Value A`,labelB:O.specialValueB??`Value B`}))})]})}zr.displayName=`HorizontalTreeChart`,exports.ChordChart=wr,exports.CirclePackingChart=Nr,exports.DEFAULT_CHECK_COLORS=mn,exports.DEFAULT_CHORD_CHART_TRANSLATION=Tr,exports.DEFAULT_CIRCLE_PACKING_TRANSLATION=Pr,exports.DEFAULT_GANTT_TRANSLATIONS=Ct,exports.DEFAULT_HORIZONTAL_TREE_TRANSLATION=Fr,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=Me,exports.DEFAULT_JSON_EDITOR_TRANSLATION=Ne,exports.DEFAULT_METER_COLORS=pn,exports.DEFAULT_PASSWORD_TRANSLATIONS=fn,exports.DEFAULT_RADIAL_TREE_CHART_TRANSLATION=Er,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=Pn,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=Fn,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=Qn,exports.DEFAULT_SQL_EDITOR_TRANSLATION=$n,exports.DEFAULT_SUNBURST_CHART_TRANSLATION=br,exports.DEFAULT_TAG_SELECTION_TRANSLATION=kn,exports.GanttChart=cn,exports.HorizontalTreeChart=zr,exports.JsonEditor=et,exports.PasswordStrengthMeter=_n,exports.RadialTreeChart=Ar,exports.RichTextEditor=Zn,exports.SqlEditor=dr,exports.SunburstChart=yr,exports.TagSelection=Nn,exports.useGanttChartStore=$,exports.useGanttTheme=nn,exports.useGanttTranslations=en,exports.useRawGanttChartStore=Qt;
|
|
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(`@codemirror/view`),d=require(`@codemirror/state`),f=require(`@codemirror/lang-json`),p=require(`@codemirror/commands`),m=require(`@codemirror/language`),h=require(`@codemirror/lint`),g=require(`@lezer/highlight`),_=require(`@replit/codemirror-minimap`),v=require(`react/jsx-runtime`),y=require(`@mui/icons-material/ContentCopy`);y=s(y,1);let b=require(`@mui/icons-material/Check`);b=s(b,1);let x=require(`@mui/icons-material/Delete`);x=s(x,1);let S=require(`@mui/icons-material/Undo`);S=s(S,1);let C=require(`@mui/icons-material/Redo`);C=s(C,1);let w=require(`@mui/icons-material/AutoFixHigh`);w=s(w,1);let T=require(`@mui/icons-material/Compress`);T=s(T,1);let E=require(`@mui/icons-material/CheckCircleOutlined`);E=s(E,1);let D=require(`@mui/icons-material/ErrorOutlined`);D=s(D,1);let O=require(`zustand`),k=require(`zustand/vanilla`),A=require(`@tanstack/react-virtual`),j=require(`@mui/icons-material/Add`);j=s(j,1);let M=require(`@mui/icons-material/Edit`);M=s(M,1);let N=require(`@mui/icons-material/Download`);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/CheckCircle`);z=s(z,1);let B=require(`@mui/icons-material/Cancel`);B=s(B,1);let V=require(`@mui/icons-material/Visibility`);V=s(V,1);let H=require(`@mui/icons-material/VisibilityOff`);H=s(H,1);let U=require(`@mui/icons-material/Close`);U=s(U,1);let W=require(`@tiptap/react`),G=require(`@tiptap/starter-kit`),K=require(`@tiptap/extension-text-style`),q=require(`@tiptap/extension-color`),J=require(`@tiptap/extension-highlight`),Y=require(`@tiptap/extension-placeholder`),ee=require(`@tiptap/extension-character-count`),X=require(`@tiptap/extension-table`),te=require(`@tiptap/extension-image`),ne=require(`tiptap-markdown`),re=require(`@mui/icons-material/Fullscreen`);re=s(re,1);let ie=require(`@mui/icons-material/FullscreenExit`);ie=s(ie,1);let ae=require(`@mui/icons-material/Image`);ae=s(ae,1);let oe=require(`@mui/icons-material/EmojiEmotions`);oe=s(oe,1);let se=require(`@mui/icons-material/FormatBold`);se=s(se,1);let ce=require(`@mui/icons-material/FormatItalic`);ce=s(ce,1);let le=require(`@mui/icons-material/FormatUnderlined`);le=s(le,1);let ue=require(`@mui/icons-material/StrikethroughS`);ue=s(ue,1);let de=require(`@mui/icons-material/FormatListBulleted`);de=s(de,1);let fe=require(`@mui/icons-material/FormatListNumbered`);fe=s(fe,1);let pe=require(`@mui/icons-material/FormatQuote`);pe=s(pe,1);let me=require(`@mui/icons-material/Code`);me=s(me,1);let he=require(`@mui/icons-material/InsertLink`);he=s(he,1);let ge=require(`@mui/icons-material/HorizontalRule`);ge=s(ge,1);let _e=require(`@mui/icons-material/FormatColorText`);_e=s(_e,1);let ve=require(`@mui/icons-material/BorderColor`);ve=s(ve,1);let ye=require(`@mui/icons-material/FormatClear`);ye=s(ye,1);let be=require(`@mui/icons-material/ContentPaste`);be=s(be,1);let xe=require(`@mui/icons-material/ContentPasteOff`);xe=s(xe,1);let Se=require(`@mui/icons-material/FormatColorReset`);Se=s(Se,1);let Ce=require(`@mui/icons-material/TableChart`);Ce=s(Ce,1);let we=require(`@mui/icons-material/Search`);we=s(we,1);let Te=require(`@codemirror/lang-sql`),Ee=require(`@codemirror/autocomplete`),De=require(`@mui/icons-material/PlayArrow`);De=s(De,1);let Oe=require(`sql-formatter`),ke=require(`@mui/icons-material/History`);ke=s(ke,1);let Ae=require(`@mui/icons-material/DeleteSweep`);Ae=s(Ae,1);let je=require(`@mui/icons-material/WarningAmber`);je=s(je,1);let Z=require(`d3`);Z=s(Z,1);var Me={showFormat:!0,showCompact:!0,showCopy:!0,showClear:!0,showUndoRedo:!0},Ne={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`},Pe=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Fe=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]);function Ie(e){return Pe.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Le(e,t){if(e.doc.length===0)return null;let n=(0,m.syntaxTree)(e).resolveInner(t,1);if(!n)return null;let r=[];for(;n;){let t=n.parent;if(!t)break;if(t.name===`Property`){let i=t.getChild(`PropertyName`);if(i){let t=e.sliceDoc(i.from,i.to);try{r.unshift(Ie(JSON.parse(t)))}catch{}}n=t.parent??t;continue}if(t.name===`Array`){let e=0,i=t.firstChild;for(;i&&i.from<n.from;)Fe.has(i.name)&&e++,i=i.nextSibling;r.unshift(`[${e}]`),n=t;continue}n=t}return r.length>0?`$${r.join(``)}`:`$`}var Re=new Set([`Object`,`Array`,`String`,`Number`,`True`,`False`,`Null`]),ze=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Be(e){return ze.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Ve(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:`object`}function He(e,t){let n=Ve(e);return n===t||t===`number`&&n===`integer`}function Ue(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>Ue(e,t[n]));if(e&&t&&typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>Ue(e[n],t[n])):!1}return!1}function We(e,t,n=`$`){let r=[];if(t.type){let i=Array.isArray(t.type)?t.type:[t.type];if(!i.some(t=>He(e,t)))return r.push({path:n,message:`Expected type ${i.join(` | `)}, got ${Ve(e)}.`}),r}if(t.enum&&!t.enum.some(t=>Ue(t,e))&&r.push({path:n,message:`Value must be one of: ${t.enum.map(e=>JSON.stringify(e)).join(`, `)}.`}),Ve(e)===`object`&&e!==null){let i=e;for(let e of t.required??[])e in i||r.push({path:n,message:`Missing required property "${e}".`});if(t.properties)for(let[e,a]of Object.entries(t.properties))e in i&&r.push(...We(i[e],a,`${n}${Be(e)}`))}return t.items&&Array.isArray(e)&&e.forEach((e,i)=>{r.push(...We(e,t.items,`${n}[${i}]`))}),r}var Ge=/\.([A-Za-z_$][A-Za-z0-9_$]*)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]/g;function Ke(e){let t=[];for(let n of e.matchAll(Ge))n[1]===void 0?n[2]===void 0?n[3]!==void 0&&t.push({type:`key`,value:JSON.parse(`"${n[3]}"`)}):t.push({type:`index`,value:Number(n[2])}):t.push({type:`key`,value:n[1]});return t}function qe(e){let t=e.topNode;for(;t&&!Re.has(t.name);){let e=t.firstChild;if(!e)return null;t=e}return t}function Je(e,t){let n=qe((0,m.syntaxTree)(e));if(!n)return null;for(let r of Ke(t))if(r.type===`key`){if(n.name!==`Object`)return null;let t=null;for(let i=n.firstChild;i;i=i.nextSibling){if(i.name!==`Property`)continue;let n=i.getChild(`PropertyName`);if(n)try{if(JSON.parse(e.sliceDoc(n.from,n.to))===r.value){t=i.lastChild;break}}catch{}}if(!t)return null;n=t}else{if(n.name!==`Array`)return null;let e=0,t=null;for(let i=n.firstChild;i;i=i.nextSibling)if(Re.has(i.name)){if(e===r.value){t=i;break}e++}if(!t)return null;n=t}return{from:n.from,to:n.to}}function Ye(e){return e?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[]}function Xe(e){return e?[(0,m.foldGutter)()]:[]}function Ze(e){return e?[(0,u.placeholder)(e)]:[]}function Qe({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,schema:a,showLineNumbers:o=!0,showMinimap:s=!1,showFolding:y=!0,enablePathFinder:b=!0,highlightColors:x,onViewReady:S,onCursorChange:C,onBlur:w,onFocus:T,onPathCopy:E}){let D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(null),A=(0,c.useRef)(t),j=(0,c.useRef)(C),M=(0,c.useRef)(w),N=(0,c.useRef)(T),P=(0,c.useRef)(S),F=(0,c.useRef)(E),I=(0,c.useRef)(b),L=(0,c.useRef)(a),[R,z]=(0,c.useState)(null),B=(0,c.useRef)(new d.Compartment),V=(0,c.useRef)(new d.Compartment),H=(0,c.useRef)(new d.Compartment),U=(0,c.useRef)(new d.Compartment),W=(0,c.useRef)(new d.Compartment),G=(0,l.useTheme)(),K=G.palette.mode===`dark`,q=x?.propertyName??G.palette.primary.main,J=x?.string??G.palette.success.main,Y=x?.number??G.palette.warning.main,ee=x?.boolean??G.palette.info.main,X=x?.null??G.palette.text.secondary;return(0,c.useEffect)(()=>{A.current=t},[t]),(0,c.useEffect)(()=>{j.current=C},[C]),(0,c.useEffect)(()=>{M.current=w},[w]),(0,c.useEffect)(()=>{N.current=T},[T]),(0,c.useEffect)(()=>{P.current=S},[S]),(0,c.useEffect)(()=>{F.current=E},[E]),(0,c.useEffect)(()=>{I.current=b},[b]),(0,c.useEffect)(()=>{L.current=a,k.current&&(0,h.forceLinting)(k.current)},[a]),(0,c.useEffect)(()=>{if(!O.current)return;let t=k.current?.state.doc.toString()??e??``,a=m.HighlightStyle.define([{tag:g.tags.propertyName,color:q,fontWeight:`bold`},{tag:g.tags.string,color:J},{tag:g.tags.number,color:Y},{tag:g.tags.bool,color:ee,fontWeight:`bold`},{tag:g.tags.null,color:X,fontStyle:`italic`},{tag:g.tags.bracket,color:G.palette.text.secondary},{tag:g.tags.punctuation,color:G.palette.text.disabled},{tag:g.tags.invalid,color:G.palette.error.main,textDecoration:`underline wavy`}]),c=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:G.palette.text.primary},".cm-gutters":{backgroundColor:K?G.palette.grey[900]:G.palette.grey[50],color:G.palette.text.disabled,border:`none`,borderRight:`1px solid ${G.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:G.palette.action.selected},".cm-activeLine":{backgroundColor:G.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:G.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:G.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:G.palette.text.disabled,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:G.palette.error.main},".cm-lint-marker-warning":{color:G.palette.warning.main},".cm-foldGutter .cm-gutterElement":{cursor:`pointer`,color:G.palette.text.disabled},".cm-foldPlaceholder":{backgroundColor:G.palette.action.selected,border:`1px solid ${G.palette.divider}`,borderRadius:`3px`,color:G.palette.text.secondary,padding:`0 4px`},".cm-tooltip.cm-tooltip-lint":{backgroundColor:G.palette.background.paper,border:`1px solid ${G.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${G.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${G.palette.warning.main}`}},{dark:K}),l=s?[_.showMinimap.of({create:()=>{let e=document.createElement(`div`);return e.style.width=`80px`,e.style.overflow=`hidden`,e.style.borderLeft=`1px solid ${G.palette.divider}`,e.style.backgroundColor=K?G.palette.grey[900]:G.palette.grey[50],{dom:e}},displayText:`blocks`,showOverlay:`always`})]:[],v=[c,(0,m.syntaxHighlighting)(a),(0,f.json)(),(0,h.lintGutter)(),(0,h.linter)((0,f.jsonParseLinter)()),(0,h.linter)(e=>{let t=L.current;if(!t)return[];let n;try{n=JSON.parse(e.state.doc.toString())}catch{return[]}let r=[];for(let i of We(n,t)){let t=Je(e.state,i.path);t&&r.push({from:t.from,to:t.to,severity:`error`,message:i.message})}return r}),(0,p.history)(),u.keymap.of([...p.defaultKeymap,...p.historyKeymap,...m.foldKeymap]),B.current.of(u.EditorView.editable.of(!r&&!i)),V.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),U.current.of(Ye(o)),H.current.of(Xe(y)),W.current.of(Ze(n)),...l,u.EditorView.updateListener.of(e=>{e.docChanged&&A.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);j.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{M.current?.()},focus:()=>{N.current?.()},click:(e,t)=>{if(!I.current||!(e.ctrlKey||e.metaKey))return!1;let n;try{n=t.posAtCoords({x:e.clientX,y:e.clientY})}catch{return!1}if(n===null)return!1;let r=Le(t.state,n);return r?(navigator.clipboard.writeText(r).then(()=>{let t=D.current?.getBoundingClientRect();z({x:e.clientX-(t?.left??0),y:e.clientY-(t?.top??0),path:r}),F.current?.(r)}),!0):!1}})],b=new u.EditorView({state:d.EditorState.create({doc:t,extensions:v}),parent:O.current});return k.current=b,P.current(b),()=>{P.current(null),b.destroy(),k.current=null}},[K,q,J,Y,ee,X,s]),(0,c.useEffect)(()=>{let t=k.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)(()=>{k.current?.dispatch({effects:[B.current.reconfigure(u.EditorView.editable.of(!r&&!i)),V.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,c.useEffect)(()=>{k.current?.dispatch({effects:U.current.reconfigure(Ye(o))})},[o]),(0,c.useEffect)(()=>{k.current?.dispatch({effects:H.current.reconfigure(Xe(y))})},[y]),(0,c.useEffect)(()=>{k.current?.dispatch({effects:W.current.reconfigure(Ze(n))})},[n]),(0,c.useEffect)(()=>{if(!R)return;let e=setTimeout(()=>z(null),1500);return()=>clearTimeout(e)},[R]),(0,v.jsxs)(l.Box,{ref:D,sx:{position:`relative`,flex:1,overflow:`hidden`,display:`flex`},children:[(0,v.jsx)(l.Box,{ref:O,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:G.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}}),R&&(0,v.jsx)(l.Fade,{in:!0,children:(0,v.jsx)(l.Paper,{elevation:3,sx:{position:`absolute`,left:R.x,top:R.y,transform:`translate(-50%, -130%)`,px:1,py:.5,pointerEvents:`none`,zIndex:10,bgcolor:`grey.900`,color:`common.white`},children:(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{fontFamily:`monospace`},children:[`Copied: `,R.path]})})})]})}function Q({label:e,icon:t,onClick:n,active:r,disabled:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.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 $e(e=2e3){let[t,n]=(0,c.useState)(!1),r=(0,c.useRef)(null),i=(0,c.useCallback)(()=>{r.current&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{n(!1),r.current=null},e)},[e]);return(0,c.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]),[t,i]}function et({editorView:e,toolbarConfig:t,translation:n,indent:r,disabled:i}){let[a,o]=$e(),s=i||!e;function c(){let t=e;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 u(){let t=e;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 d(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{o()})}function f(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function m(){let t=e;t&&((0,p.undo)(t),t.focus())}function h(){let t=e;t&&((0,p.redo)(t),t.focus())}let g=t.showFormat||t.showCompact,_=t.showCopy||t.showClear,E=t.showUndoRedo;return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`JSON editor actions`,children:[g&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showFormat&&(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:c,disabled:s}),t.showCompact&&(0,v.jsx)(Q,{label:n.compact,icon:(0,v.jsx)(T.default,{fontSize:`small`}),onClick:u,disabled:s})]}),g&&(_||E)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),_&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:a?n.copySuccess:n.copy,icon:a?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:d,disabled:s}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:f,disabled:s})]}),_&&E&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),E&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:m,disabled:s}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:h,disabled:s})]}),!g&&!_&&!E&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function tt({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[i?(0,v.jsx)(E.default,{sx:{fontSize:`0.875rem`,color:`success.main`},"data-testid":`json-valid-icon`}):(0,v.jsx)(D.default,{sx:{fontSize:`0.875rem`,color:`error.main`},"data-testid":`json-invalid-icon`}),(0,v.jsx)(l.FormHelperText,{sx:{color:i?`success.main`:`error.main`,m:0},children:i?s.validJson:s.invalidJson})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}function nt(e){if(!(e===``||e===void 0))return typeof e==`string`&&e!==`auto`&&!isNaN(Number(e))?Number(e):e}function rt(e){if(!e.trim())return!1;try{return JSON.parse(e),!0}catch{return!1}}function it({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,schema:m,showLineNumbers:h=!0,showLineColumn:g=!0,showMinimap:_=!1,showFolding:y=!0,showValidation:b=!1,enablePathFinder:x=!0,toolbarConfig:S,translation:C,highlightColors:w,onBlur:T,onFocus:E,onPathCopy:D}){let O={...Ne,...C},k={...Me,...S},A=nt(i),j=nt(a),M=A===`auto`,N=M?void 0:A??300,P=(0,c.useRef)(null),[F,I]=(0,c.useState)(null),[L,R]=(0,c.useState)({line:1,col:1}),[z,B]=(0,c.useState)(()=>rt(e??``)),V=(0,c.useCallback)(e=>{P.current=e,I(e)},[]),H=(0,c.useCallback)((e,t)=>{R({line:e,col:t})},[]),U=(0,c.useCallback)(e=>{let r=rt(e);B(r),n?.(r),t?.(e)},[t,n]),W=g||b||!!d;return(0,v.jsxs)(l.Box,{sx:{width:j??`100%`,...M?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...M?{flex:1}:{height:N},borderColor:u?`error.main`:void 0,"&:focus-within":{borderColor:u?`error.main`:`primary.main`,borderWidth:2}},children:[!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(et,{editorView:F,toolbarConfig:k,translation:O,indent:p,disabled:o}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(Qe,{value:e,onChange:U,placeholder:r,disabled:o,readonly:s,schema:m,showLineNumbers:h,showMinimap:_,showFolding:y,enablePathFinder:x,highlightColors:w,onViewReady:V,onCursorChange:H,onBlur:T,onFocus:E,onPathCopy:D})]}),W&&(0,v.jsx)(tt,{helperText:d,error:u,showLineColumn:g,showValidation:b,isValid:z,cursorLine:L.line,cursorCol:L.col,translation:O}),f&&(0,v.jsx)(`input`,{type:`hidden`,name:f,value:e??``})]})}function at(e){let t=new Date,n=Ct(t),r=wt(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=dt(pt(new Date(Math.min(...i)),-1)),s=ft(pt(new Date(Math.max(...a)),1));return{start:o<n?o:n,end:s>r?s:r}}function ot(e,t){return t===`weeks`?{start:yt(e.start),end:e.end}:t===`quarters`?{start:Ct(e.start),end:wt(e.end)}:e}function st(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 ct(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 lt(n,0),n}function lt(e,t){for(let n of e)n.depth=t,lt(n.children,t+1)}function ut(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 dt(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function ft(e){return new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59,999)}function pt(e,t){return new Date(e.getFullYear(),e.getMonth()+t,e.getDate())}function mt(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t,0,0,0,0)}function ht(e){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);return t}function gt(e,t,n){if(n===0)return e;let r=ht(e),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 _t(e,t){let n=ht(e),r=new Set,i=[...n.get(t)??[]];for(;i.length>0;){let e=i.shift();r.has(e)||(r.add(e),i.push(...n.get(e)??[]))}return r}function vt(e){let t=[],n=dt(e.start);for(;n<=e.end;)t.push(n),n=pt(n,1);return t}function yt(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 bt(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 xt(e){let t=[],n=yt(e.start);for(;n<=e.end;)t.push(new Date(n)),n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+7);return t}function St(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 Ct(e){let t=Math.floor(e.getMonth()/3)*3;return new Date(e.getFullYear(),t,1,0,0,0,0)}function wt(e){let t=Math.floor(e.getMonth()/3)*3+2;return ft(new Date(e.getFullYear(),t,1))}function Tt(e){let t=[],n=Ct(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 Et(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 Dt(e,t){let n=t.startDate<e.start?dt(pt(t.startDate,-1)):e.start,r=t.endDate>e.end?ft(pt(t.endDate,1)):e.end;return n===e.start&&r===e.end?e:{start:n,end:r}}function Ot(e,t=`months`,n=!1,r,i=!1){let a=at(e);return(0,k.createStore)((o,s)=>({tasks:e,taskTree:ct(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:ct(e),...t.isRangeCustomized?{}:{timelineRange:at(e)}}))},addTask:e=>{o(t=>{let n=[...t.tasks,e];return{tasks:n,taskTree:ct(n),timelineRange:Dt(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=gt(r,e.id,t)}let i=Dt(t.timelineRange,e);for(let e of r)i=Dt(i,e);return{tasks:r,taskTree:ct(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:ct(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:at(e.tasks),isRangeCustomized:!1}))},resetView:()=>{o(e=>({timeScale:e.defaultTimeScale,timelineRange:at(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 ut(e,t)}}))}var kt={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`,todayLabel:`Heute`,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`,columnAssignee:`Assignee`,exportCsvTooltip:`Als CSV exportieren`,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`},jt={planned:`warning`,"in-progress":`info`,done:`success`,blocked:`error`};function Mt(e){return e.toISOString().slice(0,10)}function Nt(e,t,n){return e<t?t:e>n?n:e}function Pt(e){return e.flatMap(e=>[e,...Pt(e.children)])}function Ft({label:e}){let t=(0,c.useRef)(null),[n,r]=(0,c.useState)(!1);return(0,v.jsx)(l.Tooltip,{title:e,disableHoverListener:!n,children:(0,v.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 It({open:e,mode:t,initialTask:n,defaultParentId:r,onSave:i,onClose:a}){let o=sn(),s=$(e=>e.taskTree),u=$(e=>e.timelineRange),d=(0,c.useMemo)(()=>Pt(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)),m=(0,c.useMemo)(()=>t===`add`||!n?new Set:_t(d,n.id),[t,n,d]),h=p.filter(e=>!m.has(e.id)),g=Mt(Nt(new Date,u.start,u.end)),[_,y]=(0,c.useState)({name:``,startDate:g,endDate:g,status:`planned`,isMilestone:!1,parentId:``,dependencies:[],assignee:``});(0,c.useEffect)(()=>{if(!e)return;let i=Mt(Nt(new Date,u.start,u.end));y(t===`edit`&&n?{name:n.name,startDate:Mt(n.startDate),endDate:Mt(n.endDate),status:n.status,isMilestone:n.isMilestone??!1,parentId:n.parentId??``,dependencies:n.dependencies??[],assignee:n.assignee??``}:{name:``,startDate:i,endDate:i,status:`planned`,isMilestone:!1,parentId:r??``,dependencies:[],assignee:``})},[e,t,n,r,u]);let b=e=>{y(t=>({...t,startDate:e,endDate:t.isMilestone||t.endDate<e?e:t.endDate}))},x=e=>{y(t=>({...t,endDate:e<t.startDate?t.startDate:e}))},S=e=>{y(t=>({...t,isMilestone:e,endDate:e?t.startDate:t.endDate}))},C=_.name.trim()!==``&&_.startDate!==``&&_.endDate!==``&&_.endDate>=_.startDate,w=()=>{C&&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,assignee:_.assignee.trim()||void 0})},T=[`planned`,`in-progress`,`done`,`blocked`],E={planned:o.statusPlanned,"in-progress":o.statusInProgress,done:o.statusDone,blocked:o.statusBlocked};return(0,v.jsxs)(l.Dialog,{open:e,onClose:a,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-task-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:t===`add`?o.dialogAddTitle:o.dialogEditTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.TextField,{label:o.dialogFieldName,value:_.name,onChange:e=>y(t=>({...t,name:e.target.value})),required:!0,fullWidth:!0,size:`small`,autoFocus:!0,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-name`}}}),(0,v.jsx)(l.TextField,{label:o.columnAssignee,value:_.assignee,onChange:e=>y(t=>({...t,assignee:e.target.value})),fullWidth:!0,size:`small`,placeholder:`e.g. Jane Smith`,slotProps:{htmlInput:{"data-testid":`gantt-dialog-field-assignee`}}}),(0,v.jsx)(l.TextField,{label:o.dialogFieldStartDate,type:`date`,value:_.startDate,onChange:e=>b(e.target.value),required:!0,fullWidth:!0,size:`small`,slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-dialog-field-start`}}}),(0,v.jsx)(l.TextField,{label:o.dialogFieldEndDate,type:`date`,value:_.endDate,onChange:e=>x(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,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldStatus}),(0,v.jsx)(l.Select,{value:_.status,label:o.dialogFieldStatus,onChange:e=>y(t=>({...t,status:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-status`},children:T.map(e=>(0,v.jsx)(l.MenuItem,{value:e,children:E[e]},e))})]}),(0,v.jsx)(l.FormControlLabel,{control:(0,v.jsx)(l.Checkbox,{checked:_.isMilestone,onChange:e=>S(e.target.checked),size:`small`,"data-testid":`gantt-dialog-field-milestone`}),label:o.dialogFieldMilestone}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldParent}),(0,v.jsxs)(l.Select,{value:_.parentId,label:o.dialogFieldParent,onChange:e=>y(t=>({...t,parentId:e.target.value})),inputProps:{"data-testid":`gantt-dialog-field-parent`},MenuProps:{slotProps:{paper:{sx:{maxHeight:280}}}},children:[(0,v.jsx)(l.MenuItem,{value:``,children:o.dialogFieldParentNone}),p.map(e=>(0,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.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,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(Ft,{label:e.name})]})},e.id))]})]}),(0,v.jsxs)(l.FormControl,{size:`small`,fullWidth:!0,children:[(0,v.jsx)(l.InputLabel,{children:o.dialogFieldDependencies}),(0,v.jsx)(l.Select,{multiple:!0,value:_.dependencies,label:o.dialogFieldDependencies,onChange:e=>{let t=e.target.value;y(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,v.jsx)(l.MenuItem,{value:e.id,sx:{minWidth:0},children:(0,v.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,v.jsx)(l.Typography,{component:`span`,variant:`caption`,sx:{color:`text.disabled`,lineHeight:1,flexShrink:0},children:`└`}),(0,v.jsx)(Ft,{label:e.name})]})},e.id))})]})]}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:a,children:o.dialogCancel}),(0,v.jsx)(l.Button,{onClick:w,variant:`contained`,disabled:!C,"data-testid":`gantt-dialog-save`,children:o.dialogSave})]})]})}function Lt({open:e,task:t,onConfirm:n,onClose:r}){let i=sn(),a=i.dialogDeleteConfirm.replace(`{name}`,t?.name??``);return(0,v.jsxs)(l.Dialog,{open:e,onClose:r,maxWidth:`xs`,fullWidth:!0,"data-testid":`gantt-delete-dialog`,children:[(0,v.jsx)(l.DialogTitle,{children:i.dialogDeleteTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.jsx)(l.DialogContentText,{children:a})}),(0,v.jsxs)(l.DialogActions,{children:[(0,v.jsx)(l.Button,{onClick:r,children:i.dialogCancel}),(0,v.jsx)(l.Button,{onClick:n,variant:`contained`,color:`error`,"data-testid":`gantt-dialog-delete-confirm`,children:i.dialogDelete})]})]})}function Rt(e,t){return{planned:t.statusPlanned,"in-progress":t.statusInProgress,done:t.statusDone,blocked:t.statusBlocked}[e]}function zt({task:e,expandedIds:t,toggleExpand:n,hasActionsColumn:r,showAssigneeColumn:i,onTaskClick:a,onAddTask:o,onEditTask:s,onDeleteTask:u,onStatusChange:d,inlineEdit:f,onInlineRename:p}){let[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),y=sn(),{statusColors:b}=ln(),S=()=>{g!==null&&g.trim()&&p?.(e,g.trim()),_(null)};return(0,v.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:a?`pointer`:`default`,"&:hover":a?{bgcolor:`action.hover`}:void 0},onClick:()=>a?.(e),children:[(0,v.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,v.jsx)(l.Box,{sx:{width:16,flexShrink:0,display:`flex`,justifyContent:`center`},children:e.children.length>0&&(0,v.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,v.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??b?.[e.status]??At[e.status]??`grey.400`}}),g===null?(0,v.jsx)(l.Typography,{variant:`body2`,noWrap:!0,sx:{flex:1,minWidth:0,cursor:f?`text`:`inherit`},onDoubleClick:f?t=>{t.stopPropagation(),_(e.name)}:void 0,children:e.name}):(0,v.jsx)(l.TextField,{size:`small`,variant:`standard`,value:g,autoFocus:!0,onChange:e=>_(e.target.value),onBlur:S,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S()),e.key===`Escape`&&(e.stopPropagation(),_(null))},onClick:e=>e.stopPropagation(),sx:{flex:1,minWidth:0},slotProps:{htmlInput:{"data-testid":`gantt-inline-edit-${e.id}`}}})]}),i&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1,overflow:`hidden`},children:(0,v.jsx)(l.Typography,{variant:`caption`,noWrap:!0,color:e.assignee?`text.primary`:`text.disabled`,children:e.assignee??`—`})}),r&&(0,v.jsxs)(l.Box,{className:`gantt-row-actions`,sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,pr:.5},children:[s&&(0,v.jsx)(l.Tooltip,{title:y.editTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.editTaskTooltip,"data-testid":`gantt-edit-task-${e.id}`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,v.jsx)(M.default,{fontSize:`inherit`})})}),o&&(0,v.jsx)(l.Tooltip,{title:y.addTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.addTaskTooltip,"data-testid":`gantt-add-task-${e.id}`,onClick:t=>{t.stopPropagation(),o(e)},children:(0,v.jsx)(j.default,{fontSize:`inherit`})})}),u&&(0,v.jsx)(l.Tooltip,{title:y.deleteTaskTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,"aria-label":y.deleteTaskTooltip,"data-testid":`gantt-delete-task-${e.id}`,onClick:t=>{t.stopPropagation(),u(e)},children:(0,v.jsx)(x.default,{fontSize:`inherit`})})})]}),(0,v.jsxs)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,v.jsx)(l.Chip,{label:Rt(e.status,y),size:`small`,variant:`outlined`,color:e.color??b?.[e.status]?`default`:jt[e.status]??`default`,sx:{height:20,fontSize:10,cursor:d?`pointer`:`default`,...(e.color??b?.[e.status])&&{borderColor:e.color??b?.[e.status],color:e.color??b?.[e.status]}},onClick:d?e=>{e.stopPropagation(),h(e.currentTarget)}:void 0}),d&&(0,v.jsx)(l.Menu,{anchorEl:m,open:!!m,onClose:()=>h(null),children:[`planned`,`in-progress`,`done`,`blocked`].map(t=>(0,v.jsx)(l.MenuItem,{selected:e.status===t,onClick:()=>{d(e,t),h(null)},children:Rt(t,y)},t))})]})]})}function Bt({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:m,inlineEdit:h,virtualizeRows:g=!1,showAssigneeColumn:_=!1}){let y=sn(),b=an(),x=$(e=>e.taskTree),S=$(e=>e.expandedIds),C=$(e=>e.toggleExpand),w=$(e=>e.timeScale),T=$(e=>e.addTask),E=$(e=>e.updateTask),D=$(e=>e.deleteTask),O=(0,c.useMemo)(()=>ut(x,S),[x,S]),k=(0,A.useVirtualizer)({count:O.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(!1),[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(null),z=e=>{let t={...e,id:crypto.randomUUID()};T(t),u?.(b.getState().tasks),f?.(t),M(!1)},B=e=>{if(!L)return;let t={...e,id:L.id};E(t),u?.(b.getState().tasks),p?.(t),P(!1)},V=()=>{L&&(D(L.id),u?.(b.getState().tasks),m?.(L.id),I(!1))},H=(e,t)=>{let n={...e,name:t};E(n),u?.(b.getState().tasks),p?.(n)},U=d?e=>{R(e),M(!0)}:i,W=d?e=>{R(e),P(!0)}:a,G=d?e=>{R(e),I(!0)}:o,K=!!(U||W||G),q=w===`days`?80:40;return(0,v.jsxs)(l.Box,{ref:e,onScroll:t,sx:{width:n,flexShrink:0,overflowY:`auto`,overflowX:`hidden`},children:[(0,v.jsxs)(l.Box,{sx:{height:q,position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderRight:`1px solid`,borderColor:`divider`,display:`flex`,flexDirection:`column`},children:[(0,v.jsxs)(l.Box,{sx:{height:40,display:`flex`,alignItems:`center`,borderBottom:w===`days`?`1px solid`:void 0,borderColor:w===`days`?`divider`:void 0},children:[(0,v.jsx)(l.Box,{sx:{flex:1,minWidth:0,pl:2},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnName})}),_&&(0,v.jsx)(l.Box,{sx:{width:110,flexShrink:0,display:`flex`,alignItems:`center`,px:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnAssignee})}),K&&(0,v.jsx)(l.Box,{sx:{width:96,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnActions})}),(0,v.jsx)(l.Box,{sx:{width:90,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:y.columnStatus})})]}),w===`days`&&(0,v.jsx)(l.Box,{sx:{flex:1}})]}),g?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:k.getTotalSize()},children:k.getVirtualItems().map(e=>(0,v.jsx)(l.Box,{style:{position:`absolute`,top:0,left:0,width:`100%`,height:40,transform:`translateY(${e.start}px)`},children:(0,v.jsx)(zt,{task:O[e.index],expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0})},e.key))}):O.map(e=>(0,v.jsx)(zt,{task:e,expandedIds:S,toggleExpand:C,hasActionsColumn:K,showAssigneeColumn:_,onTaskClick:r,onAddTask:U,onEditTask:W,onDeleteTask:G,onStatusChange:s,inlineEdit:h,onInlineRename:h?H:void 0},e.id)),d&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(It,{open:j,mode:`add`,defaultParentId:L?.id,onSave:z,onClose:()=>M(!1)}),(0,v.jsx)(It,{open:N,mode:`edit`,initialTask:L??void 0,onSave:B,onClose:()=>P(!1)}),(0,v.jsx)(Lt,{open:F,task:L,onConfirm:V,onClose:()=>I(!1)})]})]})}var Vt=864e5;function Ht({totalWidth:e,displayRange:t,onTaskMoved:n,onTaskResized:r,onTasksChange:i}){let a=$(e=>e.updateTask),o=an(),s=sn(),l=(0,c.useRef)(1),u=(0,c.useRef)(n),d=(0,c.useRef)(r),f=(0,c.useRef)(i);(0,c.useLayoutEffect)(()=>{l.current=e>0?e/((t.end.getTime()-t.start.getTime())/Vt):1,u.current=n,d.current=r,f.current=i});let p=(0,c.useRef)(null),m=(0,c.useRef)(null),[h,g]=(0,c.useState)(null),_=(0,c.useRef)(!1),v=(0,c.useRef)(null);return(0,c.useEffect)(()=>()=>{v.current?.()},[]),{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=mt(e.originalStart,t.deltaDays),i=mt(e.originalEnd,t.deltaDays);a({...n,startDate:r,endDate:i}),u.current?.(n,r,i)}else{let r=mt(e.originalEnd,t.deltaDays),i=r>e.originalStart?r:mt(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),v.current=null};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i),v.current=()=>{document.body.style.cursor=``,document.removeEventListener(`mousemove`,r),document.removeEventListener(`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),v.current=null};document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,s),v.current=()=>{document.body.style.cursor=``,document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,s)}},formatDragDate:e=>e.toLocaleDateString(s.dateLocale,{day:`2-digit`,month:`short`})}}function Ut({items:e}){return(0,v.jsx)(l.Box,{sx:{display:`flex`},children:e.map(e=>(0,v.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,v.jsx)(l.Typography,{variant:`caption`,color:e.isWeekend?`text.disabled`:`text.secondary`,children:e.label})},e.key))})}function Wt({columns:e,groups:t,todayX:n,todayLabel:r,todayTooltip:i,todayColor:a}){let o=(0,l.useTheme)(),s=t?80:40,c=a||o.palette.primary.main,u=o.palette.getContrastText(c);return(0,v.jsxs)(l.Box,{sx:{position:`sticky`,top:0,bgcolor:`background.paper`,zIndex:1,borderBottom:`1px solid`,borderColor:`divider`,height:s,overflow:`visible`},children:[t&&(0,v.jsx)(l.Box,{sx:{height:40,borderBottom:`1px solid`,borderColor:`divider`,overflow:`visible`},children:(0,v.jsx)(Ut,{items:t})}),(0,v.jsx)(Ut,{items:e}),n!=null&&r&&(0,v.jsx)(l.Tooltip,{title:i??``,placement:`top`,arrow:!0,children:(0,v.jsx)(l.Chip,{"data-testid":`gantt-today-chip`,size:`small`,label:r,sx:{position:`absolute`,bottom:0,left:n,transform:`translateX(-50%) translateY(50%)`,zIndex:3,height:20,fontSize:`0.65rem`,fontWeight:700,letterSpacing:`0.03em`,backgroundColor:c,color:u,border:`1.5px solid ${c}`,boxShadow:o.shadows[2],cursor:`default`,userSelect:`none`,"& .MuiChip-label":{px:`6px`,py:0},"&:hover":{backgroundColor:c,opacity:.9}}})})]})}function Gt({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:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_}){let y=(0,l.useTheme)(),{statusColors:b,criticalPathColor:x,milestoneColor:S,barBorderRadius:C}=ln(),w=n?.taskId===e.id,T=e;if(w&&n)if(n.type===`move`)T={...e,startDate:mt(e.startDate,n.deltaDays),endDate:mt(e.endDate,n.deltaDays)};else if(n.type===`resize`){let t=mt(e.endDate,n.deltaDays);T={...e,endDate:t>e.startDate?t:mt(e.startDate,1)}}else n.type===`progress`&&n.newProgress!==void 0&&(T={...e,progress:n.newProgress});let{left:E,width:D}=st(T,r);return(0,v.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,v.jsx)(Kt,{task:e,left:E,milestoneColor:S,criticalPathColor:x,isCritical:o.has(e.id),onMilestoneClick:f,theme:y}):(0,v.jsx)(qt,{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:m,handleBarMouseDown:h,handleProgressMouseDown:g,formatDragDate:_,theme:y})})}function Kt({task:e,left:t,milestoneColor:n,criticalPathColor:r,isCritical:i,onMilestoneClick:a,theme:o}){return t<0||t>100?null:(0,v.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 qt({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:m,onTaskClick:h,onContextMenu:g,suppressClickRef:_,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,v.jsxs)(v.Fragment,{children:[a&&o&&o.type!==`progress`&&o.deltaDays!==0&&(0,v.jsx)(Jt,{left:C,children:o.type===`move`?`${x(t.startDate)} – ${x(t.endDate)}`:`→ ${x(t.endDate)}`}),a&&o?.type===`progress`&&o.newProgress!==void 0&&(0,v.jsxs)(Jt,{left:C,children:[o.newProgress,`%`]}),(0,v.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:m===void 0?1:`${m}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`:h?`pointer`:`default`,userSelect:`none`,"&:hover":s||h?{opacity:a?.75:.8}:void 0},onMouseDown:s?t=>y(t,e,`move`):void 0,onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),g(e,t.clientX,t.clientY)},onClick:()=>{if(_.current){_.current=!1;return}h?.(e)},children:[t.progress!==void 0&&t.progress>0&&(0,v.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,v.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,v.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 Jt({left:e,children:t}){return(0,v.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 Yt({strips:e,totalWidth:t,height:n,top:r}){let{weekendColor:i}=ln();return e.length===0?null:(0,v.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,v.jsx)(l.Box,{sx:{position:`absolute`,left:e.left,width:20,top:0,height:`100%`,bgcolor:i||`action.hover`}},e.key))})}function Xt({contextMenu:e,onClose:t,onSelect:n}){let r=sn(),i={planned:r.statusPlanned,"in-progress":r.statusInProgress,done:r.statusDone,blocked:r.statusBlocked};return(0,v.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,v.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 Zt({dependencyLines:e,todayX:t,totalWidth:n,height:r,top:i,arrowMarkerId:a}){let o=(0,l.useTheme)(),{todayLineColor:s}=ln();return e.length===0&&t===null?null:(0,v.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,v.jsx)(`defs`,{children:(0,v.jsx)(`marker`,{id:a,markerWidth:`6`,markerHeight:`4`,refX:`5`,refY:`2`,orient:`auto`,children:(0,v.jsx)(`polygon`,{points:`0 0, 6 2, 0 4`,fill:`currentColor`})})}),e.map(e=>(0,v.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,v.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 Qt(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=st(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=st(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 $t({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:m}){let h=$(e=>e.taskTree),g=$(e=>e.tasks),_=$(e=>e.expandedIds),y=$(e=>e.timelineRange),b=$(e=>e.timeScale),x=$(e=>e.updateTask),S=an(),C=sn(),w=(0,l.useTheme)(),{todayLineColor:T}=ln(),E=`gantt-arrow-${(0,c.useId)().replace(/:/g,``)}`,D=(0,c.useMemo)(()=>ut(h,_),[h,_]),O=(0,c.useMemo)(()=>ot(y,b),[y,b]),k=(0,c.useMemo)(()=>b===`days`?St(O).map(e=>({key:e.toISOString(),label:String(e.getDate()),width:20,isWeekend:e.getDay()===0||e.getDay()===6})):b===`weeks`?xt(O).map(e=>({key:e.toISOString(),label:`${C.weekColumnPrefix}${bt(e)}`,width:40})):b===`quarters`?Tt(O).map(e=>({key:e.key,label:e.label,width:360})):vt(O).map(e=>({key:e.toISOString(),label:e.toLocaleString(C.dateLocale,{month:`short`,year:`2-digit`}),width:120})),[b,O,C.weekColumnPrefix,C.dateLocale]),j=(0,c.useMemo)(()=>k.reduce((e,t)=>e+t.width,0),[k]),M=(0,c.useMemo)(()=>{if(b!==`days`)return;let e=new Map;for(let t of k){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,k,C.dateLocale]),N=(0,c.useMemo)(()=>Qt(D,O,j),[D,O,j]),P=(0,c.useMemo)(()=>s?Et(g):new Set,[s,g]),F=(0,A.useVirtualizer)({count:D.length,getScrollElement:()=>e.current,estimateSize:()=>40,overscan:5}),I=(0,c.useMemo)(()=>{if(b!==`days`)return[];let e=0;return k.flatMap(t=>{let n=t.isWeekend?[{key:t.key,left:e}]:[];return e+=t.width,n})},[b,k]),L=(0,c.useMemo)(()=>{let e=Date.now(),t=O.start.getTime(),n=O.end.getTime();return e<t||e>n?null:(e-t)/(n-t)*j},[O,j]),R=(0,c.useMemo)(()=>new Date().toLocaleDateString(C.dateLocale,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),[C.dateLocale]),z=T||w.palette.primary.main;(0,c.useEffect)(()=>{if(L===null||!e.current)return;let t=e.current.clientWidth;e.current.scrollLeft=Math.max(0,L-t/2)},[]);let B=b===`days`?20:b===`weeks`?40:b===`quarters`?360:120,V=M?80:40,{activeDrag:H,suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K}=Ht({totalWidth:j,displayRange:O,onTaskMoved:d,onTaskResized:f,onTasksChange:p}),[q,J]=(0,c.useState)(null),Y=(0,c.useRef)(m);Y.current=m;let ee=(0,c.useRef)(p);return ee.current=p,(0,v.jsx)(l.Box,{ref:e,onScroll:t,"data-testid":`gantt-timeline-scroll`,sx:{flex:1,overflow:`auto`},children:(0,v.jsxs)(l.Box,{sx:{minWidth:j,position:`relative`},children:[(0,v.jsx)(Wt,{columns:k,groups:M,todayX:L,todayLabel:C.todayLabel,todayTooltip:R,todayColor:z}),(0,v.jsx)(Yt,{strips:I,totalWidth:j,height:D.length*40,top:V}),u?(0,v.jsx)(l.Box,{sx:{position:`relative`,height:F.getTotalSize()},children:F.getVirtualItems().map(e=>(0,v.jsx)(Gt,{task:D[e.index],virtualTop:e.start,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.key))}):(0,v.jsx)(v.Fragment,{children:D.map(e=>(0,v.jsx)(Gt,{task:e,activeDrag:H,displayRange:O,totalWidth:j,gridColumnWidth:B,criticalTaskIds:P,draggable:i,resizable:a,progressDraggable:o,onTaskClick:n,onMilestoneClick:r,onContextMenu:(e,t,n)=>J({task:e,mouseX:t,mouseY:n}),suppressClickRef:U,handleBarMouseDown:W,handleProgressMouseDown:G,formatDragDate:K},e.id))}),(0,v.jsx)(Xt,{contextMenu:q,onClose:()=>J(null),onSelect:(e,t)=>{let n=S.getState().tasks.find(t=>t.id===e.id)??e;x({...n,status:t}),Y.current?.(n,t),ee.current?.(S.getState().tasks),J(null)}}),(0,v.jsx)(Zt,{dependencyLines:N,todayX:L,totalWidth:j,height:D.length*40,top:V,arrowMarkerId:E})]})})}function en(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function tn(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 nn({onScrollToToday:e,config:t,onExportCSV:n}){let r=sn(),i=$(e=>e.timeScale),a=$(e=>e.defaultTimeScale),o=$(e=>e.setTimeScale),s=$(e=>e.timelineRange),u=$(e=>e.isRangeCustomized),d=$(e=>e.isExpandedCustomized),f=$(e=>e.setTimelineRange),p=$(e=>e.resetTimelineRange),m=$(e=>e.resetView),h=$(e=>e.tasks),g=$(e=>e.expandedIds),_=$(e=>e.expandAll),y=$(e=>e.collapseAll),b=h.length>0&&h.every(e=>g.has(e.id)),x=i!==a||u||d,S=(0,c.useMemo)(()=>Date.now(),[]),C=S>=s.start.getTime()&&S<=s.end.getTime(),w={days:r.scaleDays,weeks:r.scaleWeeks,months:r.scaleMonths,quarters:r.scaleQuarters},T={days:t.showScaleDays,weeks:t.showScaleWeeks,months:t.showScaleMonths,quarters:t.showScaleQuarters},E=Object.keys(w).filter(e=>T[e]);return(0,v.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:[E.length>0&&(0,v.jsx)(l.ToggleButtonGroup,{value:i,exclusive:!0,onChange:(e,t)=>{t&&o(t)},size:`small`,"aria-label":r.scaleMonths,children:E.map(e=>(0,v.jsx)(l.ToggleButton,{value:e,"data-testid":`gantt-scale-${e}`,children:w[e]},e))}),(0,v.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,alignItems:`center`,gap:1},children:[t.showExpandCollapseAll&&(0,v.jsx)(l.Tooltip,{title:b?r.collapseAllTooltip:r.expandAllTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:b?y:_,"aria-label":b?r.collapseAllTooltip:r.expandAllTooltip,"data-testid":`gantt-expand-collapse-all`,children:b?(0,v.jsx)(L.default,{fontSize:`small`}):(0,v.jsx)(R.default,{fontSize:`small`})})}),t.showScrollToToday&&e&&(0,v.jsx)(l.Tooltip,{title:r.scrollToTodayTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:e,disabled:!C,"aria-label":r.scrollToTodayTooltip,"data-testid":`gantt-scroll-to-today`,children:(0,v.jsx)(I.default,{fontSize:`small`})})})}),t.showDateRange&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeFrom,value:en(s.start),onChange:e=>{let t=tn(e.target.value);t&&f({start:t,end:s.end})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-start`}},sx:{width:148}}),(0,v.jsx)(l.TextField,{type:`date`,size:`small`,label:r.rangeTo,value:en(s.end),onChange:e=>{let t=tn(e.target.value);t&&f({start:s.start,end:t})},slotProps:{inputLabel:{shrink:!0},htmlInput:{"data-testid":`gantt-range-end`}},sx:{width:148}})]}),t.showRangeReset&&u&&(0,v.jsx)(l.Tooltip,{title:r.rangeResetTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:p,"aria-label":r.rangeResetTooltip,"data-testid":`gantt-range-reset`,children:(0,v.jsx)(F.default,{fontSize:`small`})})}),t.showExportCSV&&n&&(0,v.jsx)(l.Tooltip,{title:r.exportCsvTooltip,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:n,"aria-label":r.exportCsvTooltip,"data-testid":`gantt-export-csv`,children:(0,v.jsx)(N.default,{fontSize:`small`})})}),t.showResetView&&(0,v.jsx)(l.Tooltip,{title:r.resetViewTooltip,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:m,disabled:!x,"aria-label":r.resetViewTooltip,"data-testid":`gantt-reset-view`,children:(0,v.jsx)(P.default,{fontSize:`small`})})})})]})]})}var rn=(0,c.createContext)(null);function $(e){let t=(0,c.useContext)(rn);if(!t)throw Error(`GanttChartStoreContext is missing.`);return(0,O.useStore)(t,e)}function an(){let e=(0,c.useContext)(rn);if(!e)throw Error(`GanttChartStoreContext is missing.`);return e}var on=(0,c.createContext)(kt);function sn(){return(0,c.useContext)(on)}var cn=(0,c.createContext)({});function ln(){return(0,c.useContext)(cn)}function un(e,t){return e===void 0?t:e===`auto`?`100%`:typeof e==`string`&&/^\d+$/.test(e)?Number(e):e}var dn=[`days`,`weeks`,`months`,`quarters`],fn={showScaleDays:!0,showScaleWeeks:!0,showScaleMonths:!0,showScaleQuarters:!0,showExpandCollapseAll:!0,showScrollToToday:!0,showDateRange:!0,showRangeReset:!0,showResetView:!0,showExportCSV:!1};function pn({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:m=!0,toolbarConfig:h,height:g,width:_,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,showAssigneeColumn:O=!1,onExportCSV:k,onTaskMoved:A,onTaskResized:j}){let M=un(g,400),N=(0,c.useMemo)(()=>({...fn,...h}),[h]),P=un(_,`100%`),F=$(e=>e.setTasks),I=$(e=>e.timeScale),L=$(e=>e.setTimeScale),R=$(e=>e.timelineRange),z=(0,c.useRef)(null),B=(0,c.useRef)(null),V=(0,c.useRef)(!1),[H,U]=(0,c.useState)(320),W=an(),G=(0,c.useCallback)(()=>{let e=W.getState().tasks,t=[[`id`,`name`,`status`,`startDate`,`endDate`,`progress`,`assignee`,`parentId`,`isMilestone`,`dependencies`,`color`].join(`,`),...e.map(e=>[e.id,`"${e.name.replace(/"/g,`""`)}"`,e.status,e.startDate.toISOString().split(`T`)[0],e.endDate.toISOString().split(`T`)[0],e.progress??``,e.assignee?`"${e.assignee.replace(/"/g,`""`)}"`:``,e.parentId??``,e.isMilestone?`true`:`false`,(e.dependencies??[]).join(`;`),e.color??``].join(`,`))].join(`
|
|
2
|
+
`);if(k)k(t,e);else{let e=new Blob([t],{type:`text/csv;charset=utf-8;`}),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`gantt-tasks.csv`,r.click(),URL.revokeObjectURL(n)}},[W,k]);(0,c.useEffect)(()=>{F(e)},[e,F]);let K=()=>{V.current||=(V.current=!0,B.current&&z.current&&(B.current.scrollTop=z.current.scrollTop),!1)},q=()=>{V.current||=(V.current=!0,z.current&&B.current&&(z.current.scrollTop=B.current.scrollTop),!1)},J=(0,c.useCallback)(()=>{if(!B.current)return;let e=ot(R,I),t=Date.now(),n=e.start.getTime(),r=e.end.getTime(),i=(t-n)/(r-n)*B.current.scrollWidth;B.current.scrollLeft=Math.max(0,i-B.current.clientWidth/2)},[R,I]);(0,c.useEffect)(()=>{if(!x||!B.current)return;let e=B.current,t=e=>{if(!e.ctrlKey)return;e.preventDefault();let t=dn.indexOf(I);e.deltaY<0&&t>0?L(dn[t-1]):e.deltaY>0&&t<dn.length-1&&L(dn[t+1])};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[x,I,L]);let Y=(0,c.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=H,r=e=>{let r=e.clientX-t;U(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)},[H,y,b]);return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexDirection:`column`,height:M,width:P,border:`1px solid`,borderColor:`divider`,borderRadius:1,overflow:`hidden`},children:[m&&(0,v.jsx)(nn,{onScrollToToday:J,config:N,onExportCSV:N.showExportCSV?G:void 0}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,v.jsx)(Bt,{scrollRef:z,onScroll:K,panelWidth:H,onTaskClick:t,onAddTask:r,onEditTask:i,onDeleteTask:a,onStatusChange:o,onTasksChange:s,enableBuiltinDialogs:u,onTaskCreated:d,onTaskUpdated:f,onTaskDeleted:p,inlineEdit:w,virtualizeRows:D,showAssigneeColumn:O}),(0,v.jsx)(l.Box,{"data-testid":`gantt-panel-divider`,sx:{width:4,flexShrink:0,bgcolor:`divider`,cursor:`col-resize`,"&:hover":{bgcolor:`action.hover`}},onMouseDown:Y}),(0,v.jsx)($t,{scrollRef:B,onScroll:q,onTaskClick:t,onMilestoneClick:n,draggable:S,resizable:C,progressDraggable:T,showCriticalPath:E,virtualizeRows:D,onTaskMoved:A,onTaskResized:j,onTasksChange:s,onStatusChange:o})]})]})}function mn({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:m=!1,showCriticalPath:h=!1,virtualizeRows:g=!1,showAssigneeColumn:_=!1,cascadeDependencies:y=!1,statusColors:b,ganttTheme:x,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R}){let z=(0,c.useMemo)(()=>({...kt,...o}),[o]),[B]=(0,c.useState)(()=>{if(!(i!==void 0||a!==void 0))return Ot(e,t,n,void 0,y);let r=at(e);return Ot(e,t,n,{start:i??r.start,end:a??r.end},y)}),V=(0,c.useMemo)(()=>({...x,statusColors:{...b,...x?.statusColors}}),[b,x]);return(0,v.jsx)(on.Provider,{value:z,children:(0,v.jsx)(cn.Provider,{value:V,children:(0,v.jsx)(rn.Provider,{value:B,children:(0,v.jsx)(pn,{tasks:e,timeScale:t,enableBuiltinDialogs:s,showToolbar:r,toolbarConfig:l,zoomable:u,draggable:d,resizable:f,inlineEdit:p,progressDraggable:m,showCriticalPath:h,virtualizeRows:g,showAssigneeColumn:_,onExportCSV:S,onTaskClick:C,onMilestoneClick:w,onAddTask:T,onEditTask:E,onDeleteTask:D,onStatusChange:O,onTasksChange:k,onTaskMoved:A,onTaskResized:j,onTaskCreated:M,onTaskUpdated:N,onTaskDeleted:P,height:F,width:I,minPanelWidth:L,maxPanelWidth:R})})})})}var hn=e=>Math.max(0,Math.min(4,Math.round(e)));function gn(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=hn(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 _n({percent:e,color:t,ariaLabel:n,segments:r=!1}){if(r){let r=Math.round(e/25);return(0,v.jsx)(l.Box,{role:`progressbar`,"aria-label":n,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,sx:{width:`100%`,display:`flex`,gap:`3px`,mt:.5},children:[0,1,2,3].map(e=>(0,v.jsx)(l.Box,{"data-testid":e<r?`psm-meter-segment-active`:`psm-meter-segment`,sx:{flex:1,height:`8px`,borderRadius:`3px`,border:`1px solid`,borderColor:`divider`,backgroundColor:e<r?t:`transparent`,transition:`background-color 0.3s ease-in-out`}},e))})}return(0,v.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,v.jsx)(l.Box,{"data-testid":`psm-meter`,sx:{height:`100%`,width:`${e}%`,backgroundColor:t,borderRadius:`6px`,transition:`width 0.2s ease-in-out`}})})}var vn={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`,generatePasswordLabel:`Generate secure password`,confirmLabel:`Confirm password`,confirmMatchLabel:`Passwords match`,confirmMismatchLabel:`Passwords do not match`,copyPasswordLabel:`Copy password`,copiedLabel:`Copied!`},yn={weak:`#cc0000`,ok:`#fdc010`,good:`#8bc34a`,veryGood:`#43a047`},bn={failure:`#cc0000`,success:`#43a047`};function xn(e){let t=[];e.upper&&t.push(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`),e.lower&&t.push(`abcdefghijklmnopqrstuvwxyz`),e.numbers&&t.push(`0123456789`),e.symbols&&t.push(`!@#$%^&*()-_=+[]{}|;:,.<>?`),t.length===0&&t.push(`abcdefghijklmnopqrstuvwxyz`);let n=t.join(``),r=Math.max(e.length,t.length),i=new Uint32Array(Math.max(0,r-t.length));crypto.getRandomValues(i);let a=t.map(e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length]),o=Array.from(i).map(e=>n[e%n.length]),s=[...a,...o];for(let e=s.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1);[s[e],s[t]]=[s[t],s[e]]}return s.join(``)}function Sn({label:e,fulfilled:t,checkColors:n}){return(0,v.jsxs)(l.Stack,{direction:`row`,sx:{alignItems:`center`,mb:.25},spacing:.5,children:[(0,v.jsx)(l.Typography,{variant:`caption`,children:e}),t?(0,v.jsx)(E.default,{"data-testid":`psm-req-success`,style:{fontSize:16,color:n.success}}):(0,v.jsx)(D.default,{"data-testid":`psm-req-failure`,style:{fontSize:16,color:n.failure}})]})}function Cn({value:e,confirmValue:t,name:n,inputRef:r,disabled:i=!1,error:a=!1,helperText:o,autoComplete:s,customRequirements:u,generatorOptions:d,showConfirmField:f=!1,showPasswordAdornment:p=!0,showMeter:m=!0,showPasswordGenerator:h=!1,showSegmentedBar:g=!1,showSummary:_=!0,showCopyButton:x=!1,inputSize:S=`medium`,translation:C,meterColors:T,passwordMinLength:E=8,checkColors:D=bn,onPasswordChange:O,onConfirmChange:k,onPasswordGenerated:A}){let j={...vn,...C},M={...yn,...T},N=(0,c.useId)(),P=`${N}-password`,[F,I]=(0,c.useState)(!1),[L,R]=(0,c.useState)(!1),[U,W]=(0,c.useState)(``),[G,K]=(0,c.useState)(``),[q,J]=$e(),Y=e===void 0?U:e,ee=t===void 0?G:t,X=f&&ee.length>0,te=X&&Y===ee,ne=(0,c.useMemo)(()=>gn(Y,E),[Y,E]),re=()=>{I(e=>!e)},ie=e=>{e.preventDefault()},ae=e=>{e.preventDefault()};return(0,v.jsxs)(l.Stack,{children:[(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:a,children:[(0,v.jsx)(l.InputLabel,{htmlFor:P,size:S,children:j.label}),(0,v.jsx)(l.OutlinedInput,{id:P,type:F?`text`:`password`,fullWidth:!0,size:S,value:Y,onChange:t=>{let n=t.target.value;e===void 0&&W(n),O&&O(n,gn(n,E))},disabled:i,inputRef:r,inputProps:{"data-testid":`psm-input`,name:n,autoComplete:s},endAdornment:p||x&&Y.length>0?(0,v.jsxs)(l.InputAdornment,{position:`end`,children:[x&&Y.length>0&&(0,v.jsx)(l.Tooltip,{title:q?j.copiedLabel:j.copyPasswordLabel,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{"data-testid":`psm-copy`,disabled:i,"aria-label":q?j.copiedLabel:j.copyPasswordLabel,onClick:()=>{navigator.clipboard.writeText(Y).then(()=>{J()})},onMouseDown:ie,onMouseUp:ae,edge:p?!1:`end`,children:q?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`})})})}),p&&(0,v.jsx)(l.IconButton,{"data-testid":`psm-toggle`,disabled:i,"aria-label":F?j.hidePasswordLabel:j.showPasswordLabel,onClick:re,onMouseDown:ie,onMouseUp:ae,edge:`end`,children:F?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})]}):null,label:j.label}),o&&(0,v.jsx)(l.FormHelperText,{children:o})]}),h&&(0,v.jsx)(l.Tooltip,{title:j.generatePasswordLabel,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.Button,{"data-testid":`psm-generate`,size:`small`,variant:`text`,startIcon:(0,v.jsx)(w.default,{fontSize:`small`}),disabled:i,onClick:()=>{let n=xn({length:d?.length??Math.max(16,E),upper:d?.upper??!0,lower:d?.lower??!0,numbers:d?.numbers??!0,symbols:d?.symbols??!0});e===void 0&&W(n),t===void 0&&K(``),O?.(n,gn(n,E)),A?.(n),I(!0)},sx:{mt:.5,alignSelf:`flex-start`,textTransform:`none`},children:j.generatePasswordLabel})})}),f&&(0,v.jsxs)(l.FormControl,{variant:`outlined`,fullWidth:!0,error:X&&!te,sx:{mt:1},children:[(0,v.jsx)(l.InputLabel,{htmlFor:`${N}-confirm`,size:S,children:j.confirmLabel}),(0,v.jsx)(l.OutlinedInput,{id:`${N}-confirm`,type:L?`text`:`password`,fullWidth:!0,size:S,value:ee,onChange:e=>{let n=e.target.value;t===void 0&&K(n),k?.(n,n===Y)},disabled:i,inputProps:{"data-testid":`psm-confirm-input`},endAdornment:(0,v.jsxs)(l.InputAdornment,{position:`end`,children:[X&&(te?(0,v.jsx)(z.default,{"data-testid":`psm-confirm-match`,sx:{color:D.success,mr:.5},fontSize:`small`}):(0,v.jsx)(B.default,{"data-testid":`psm-confirm-mismatch`,sx:{color:D.failure,mr:.5},fontSize:`small`})),(0,v.jsx)(l.IconButton,{size:`small`,disabled:i,onClick:()=>R(e=>!e),onMouseDown:e=>e.preventDefault(),edge:`end`,"aria-label":L?j.hidePasswordLabel:j.showPasswordLabel,children:L?(0,v.jsx)(H.default,{}):(0,v.jsx)(V.default,{})})]}),label:j.confirmLabel}),X&&(0,v.jsx)(l.FormHelperText,{sx:{color:te?D.success:D.failure},children:te?j.confirmMatchLabel:j.confirmMismatchLabel})]}),m&&(0,v.jsx)(_n,{percent:ne.percent,color:(e=>{switch(e.meterStatus){case`weak`:return M.weak;case`ok`:return M.ok;case`good`:return M.good;case`very good`:return M.veryGood;default:return`transparent`}})(ne),ariaLabel:j.meterAriaLabel,segments:g}),_&&(0,v.jsxs)(l.Box,{"data-testid":`psm-summary`,sx:{mt:.5,p:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,gutterBottom:!0,sx:{display:`block`,fontSize:14},children:j.summaryHeaderLabel}),(0,v.jsxs)(l.Stack,{direction:`row`,spacing:6,children:[(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(Sn,{label:j.summaryMinChars.replace(`{n}`,String(E)),fulfilled:ne.length>=E,checkColors:D}),(0,v.jsx)(Sn,{label:j.summaryCapitalLetter,fulfilled:ne.hasUpper,checkColors:D}),(0,v.jsx)(Sn,{label:j.summaryLowerCaseLetter,fulfilled:ne.hasLower,checkColors:D})]}),(0,v.jsxs)(l.Stack,{direction:`column`,children:[(0,v.jsx)(Sn,{label:j.summaryNumber,fulfilled:ne.hasDigit,checkColors:D}),(0,v.jsx)(Sn,{label:j.summarySpecialChar,fulfilled:ne.hasSymbol,checkColors:D}),u?.map((e,t)=>(0,v.jsx)(Sn,{label:e.label,fulfilled:typeof e.fulfilled==`function`?e.fulfilled(Y):e.fulfilled,checkColors:D},t))]})]})]})]})}function wn(e){return(0,k.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 Tn=[`default`,`primary`,`secondary`,`error`,`info`,`success`,`warning`],En=[`#f44336`,`#e91e63`,`#9c27b0`,`#673ab7`,`#3f51b5`,`#2196f3`,`#03a9f4`,`#00bcd4`,`#009688`,`#4caf50`,`#8bc34a`,`#cddc39`,`#ffeb3b`,`#ffc107`,`#ff9800`,`#ff5722`,`#795548`,`#9e9e9e`,`#607d8b`,`#000000`];function Dn(e){return/^#[0-9A-Fa-f]{6}$/.test(e)}function On(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return(.299*t+.587*n+.114*r)/255>.5?`#000000`:`#ffffff`}function kn(e,t){let n=t.trim();if(!n)return e;let r=e.toLowerCase().indexOf(n.toLowerCase());return r===-1?e:(0,v.jsxs)(v.Fragment,{children:[e.slice(0,r),(0,v.jsx)(`strong`,{children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function An({color:e,selected:t,onClick:n}){return(0,v.jsx)(l.Box,{onClick:n,sx:{width:24,height:24,borderRadius:.5,backgroundColor:e,cursor:`pointer`,border:`2px solid`,borderColor:t?`primary.main`:`transparent`,outline:t?`1px solid`:`none`,outlineColor:`primary.main`,outlineOffset:1,flexShrink:0,"&:hover":{transform:`scale(1.2)`,borderColor:`primary.main`},transition:`transform 0.1s`}})}function jn({value:e,onChange:t,disabled:n=!1}){return(0,v.jsx)(l.TextField,{size:`small`,fullWidth:!0,value:e,onChange:e=>t(e.target.value),placeholder:`#rrggbb`,disabled:n,error:!n&&e.length>1&&!Dn(e),sx:{"& .MuiInputBase-root":{height:28},"& .MuiInputBase-input":{py:0,px:.5,fontSize:`0.72rem`,fontFamily:`monospace`}},slotProps:{input:{startAdornment:(0,v.jsx)(l.Box,{sx:{width:12,height:12,borderRadius:.25,flexShrink:0,mr:.5,backgroundColor:Dn(e)?e:`action.disabledBackground`,border:`1px solid`,borderColor:`divider`}})}}})}function Mn({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:m}){let[h,g]=(0,c.useState)(`default`),[_,y]=(0,c.useState)(null),[x,S]=(0,c.useState)(null),[C,w]=(0,c.useState)(!0),[T,E]=(0,c.useState)(!1),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(`#1976d2`),[j,M]=(0,c.useState)(`#ffffff`),N=u||f,P=_!==null,F=e.filter(e=>e.label.toLowerCase().includes(t.trim().toLowerCase())),I=p&&t.trim()!==``&&F.length===0,L=D&&!I,R=P?C?On(_):x??`#000000`:void 0,z=()=>{if(N)return;let e=t.trim(),n=e.toLowerCase().replace(/\s+/g,`-`);a?.(P&&_?{id:n,label:e,selected:!0,color:`default`,backgroundColor:_,foregroundColor:R}:{id:n,label:e,selected:!0,color:h}),g(`default`),y(null),S(null),w(!0),E(!1),r(``)},B=()=>{r(``),g(`default`),y(null),S(null),w(!0),E(!1)},V=e=>{y(e),A(e),g(`default`)},H=e=>{A(e),Dn(e)&&(y(e),g(`default`))},W=e=>{S(e),M(e)},G=e=>{M(e),Dn(e)&&S(e)},K=e=>{if(w(e),e)S(null);else if(_){let e=On(_);S(e),M(e)}},q=e=>e.preventDefault();return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[(0,v.jsx)(l.Autocomplete,{options:e,value:null,open:L,onOpen:()=>{I||O(!0)},onClose:()=>O(!1),size:o,disabled:N,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,...m!==void 0&&{maxHeight:m,overflowY:`auto`}}}},renderInput:e=>(0,v.jsx)(l.TextField,{...e,label:n.autoCompleteLabel,placeholder:n.placeholder,helperText:f&&!u?n.maxTagsReachedText:void 0,onKeyDown:e=>{I&&!N&&e.key===`Enter`&&(e.preventDefault(),z())},slotProps:{...e.slotProps,input:{...e.slotProps?.input,endAdornment:(0,v.jsxs)(v.Fragment,{children:[I&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.IconButton,{size:`small`,sx:{color:`success.main`},onMouseDown:q,onClick:z,disabled:N,"aria-label":n.confirmCreateLabel,children:(0,v.jsx)(b.default,{fontSize:`small`})}),(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:q,onClick:B,"aria-label":n.cancelCreateLabel,children:(0,v.jsx)(U.default,{fontSize:`small`})})]}),e.slotProps?.input?.endAdornment]})}}}),renderOption:({key:e,...n},r)=>{let i=!!(r.foregroundColor||r.backgroundColor);return(0,v.jsx)(`li`,{...n,style:{width:`auto`,padding:0,margin:0},children:(0,v.jsx)(l.Chip,{size:s,label:kn(r.label,t),color:i?void 0:r.color??`default`,sx:i?{color:r.foregroundColor??`inherit`,backgroundColor:r.backgroundColor??`transparent`}:void 0})},e)},isOptionEqualToValue:(e,t)=>e.id===t.id,noOptionsText:n.noAvailableTagsText,loadingText:n.loadingText}),I&&(0,v.jsxs)(l.Box,{sx:{position:`relative`},onMouseDown:q,children:[(0,v.jsxs)(l.Stack,{direction:`row`,sx:{mt:.5,flexWrap:`wrap`,gap:.5,alignItems:`center`},children:[Tn.map(e=>(0,v.jsx)(l.Chip,{size:s,color:e,label:e,variant:!P&&h===e?`filled`:`outlined`,onClick:()=>{g(e),y(null),S(null),E(!1)},clickable:!0},e)),(0,v.jsx)(l.Tooltip,{title:n.colorPickerLabel,children:(0,v.jsx)(l.Chip,{size:s,label:P?_:`···`,variant:`outlined`,onClick:()=>{E(e=>!e),_&&A(_),x&&M(x)},sx:e=>({cursor:`pointer`,fontFamily:`monospace`,fontSize:`0.7rem`,...P?{backgroundColor:_,color:R,border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${_}, ${_}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}:{border:`1.5px solid transparent`,backgroundImage:`linear-gradient(${e.palette.background.paper}, ${e.palette.background.paper}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,backgroundOrigin:`border-box`,backgroundClip:`padding-box, border-box`}}),clickable:!0})})]}),T&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:`calc(100% + 4px)`,left:0,zIndex:1400,backgroundColor:`background.paper`,border:`1px solid`,borderColor:`divider`,borderRadius:1,boxShadow:8,p:1.25,width:`max-content`},children:(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`auto auto`,gap:2},children:[(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.backgroundColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5},children:[En.map(e=>(0,v.jsx)(An,{color:e,selected:_===e,onClick:()=>V(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(jn,{value:k,onChange:H})})]})]}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:700,color:`text.primary`,display:`block`,mb:.5},children:n.textColorLabel}),(0,v.jsxs)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(5, 24px)`,gap:.5,opacity:C?.3:1,pointerEvents:C?`none`:`auto`,transition:`opacity 0.15s`},children:[En.map(e=>(0,v.jsx)(An,{color:e,selected:x===e,onClick:()=>W(e)},e)),(0,v.jsx)(l.Box,{sx:{gridColumn:`span 5`,mt:.25},children:(0,v.jsx)(jn,{value:C?R??`#000000`:j,onChange:G,disabled:C})})]}),(0,v.jsxs)(l.Stack,{direction:`row`,sx:{width:`100%`,alignItems:`center`,justifyContent:`flex-end`,gap:.5,mt:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n.autoTextColorLabel}),(0,v.jsx)(l.Switch,{size:`small`,checked:C,onChange:e=>K(e.target.checked)})]})]})]})})]})]})}function Nn({tag:e,onDelete:t,onClick:n,chipSize:r=`medium`,disabled:i=!1}){let a=!!(e.foregroundColor||e.backgroundColor);return(0,v.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 Pn({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),m=!!u&&p.length>0,h=s===`top`?{vertical:`top`,horizontal:`left`}:{vertical:`bottom`,horizontal:`left`},g=s===`top`?{vertical:`bottom`,horizontal:`left`}:{vertical:`top`,horizontal:`left`};return(0,v.jsxs)(l.Box,{sx:{mb:2},children:[r&&(0,v.jsx)(l.Typography,{variant:`subtitle2`,gutterBottom:!0,children:t.selectedTagsLabel}),e.length===0?(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:t.noSelectedTagsText}):(0,v.jsxs)(l.Stack,{direction:`row`,sx:{flexWrap:`wrap`,gap:1},children:[f.map(e=>(0,v.jsx)(Nn,{tag:e,onDelete:n,chipSize:i,disabled:a},e.id)),p.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Chip,{size:i,label:`+${p.length}`,variant:`outlined`,clickable:!0,onClick:e=>d(e.currentTarget)}),(0,v.jsx)(l.Popover,{open:m,anchorEl:u,onClose:()=>d(null),anchorOrigin:h,transformOrigin:g,children:(0,v.jsx)(l.Box,{sx:{p:1,display:`flex`,flexWrap:`wrap`,gap:.5,maxWidth:320},children:p.map(e=>(0,v.jsx)(Nn,{tag:e,onDelete:a?void 0:n,chipSize:i,disabled:a},e.id))})})]})]})]})}var Fn={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.`,colorPickerLabel:`Custom color`,backgroundColorLabel:`Background color`,textColorLabel:`Text color`,autoTextColorLabel:`Auto`,confirmCreateLabel:`Confirm new tag`,cancelCreateLabel:`Cancel new tag`},In=(0,c.createContext)(null);function Ln(e){let t=(0,c.useContext)(In);if(!t)throw Error(`TagSelectionStoreContext is missing.`);return(0,O.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:m,translation:h,onTagSelect:g,onTagDelete:_,onTagsChange:y,onSearchChange:b,onTagCreate:x}){let S=Ln(e=>e.tags),C=Ln(e=>e.searchValue),w=Ln(e=>e.setTags),T=Ln(e=>e.setSearchValue),E=Ln(e=>e.selectTag),D=Ln(e=>e.deleteTag),O=Ln(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,v.jsx)(l.Box,{sx:{width:`100%`},children:(0,v.jsxs)(l.Stack,{children:[t&&(0,v.jsx)(Pn,{selectedTags:k,translation:h,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&&_&&_(r,n,t),M(t)},showSelectedTagsLabel:n,chipSize:a,disabled:o,maxVisibleChips:f,popoverPlacement:p}),r&&(0,v.jsx)(Mn,{availableTags:A,searchValue:C,translation:h,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&&g&&g(r,n,t),M(t)},onTagCreate:e=>{O(e),M([...S,e]),x&&x(e)},inputSize:i,chipSize:a,disabled:o,loading:s,isMaxReached:j,allowCreate:d,listboxMaxHeight:m})]})})}function zn({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:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b}){let x={...Fn,...i},[S]=(0,c.useState)(()=>wn(e));return(0,v.jsx)(In.Provider,{value:S,children:(0,v.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:m,onTagSelect:h,onTagDelete:g,onTagsChange:_,onSearchChange:y,onTagCreate:b})})}var Bn={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,showTableButton:!1,showImageButton:!1,showEmojiButton:!1,showPasteAsPlainTextButton:!1,showMarkdownButton:!1},Vn={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`,table:`Table`,insertTable:`Insert 3×3 table`,addRowBefore:`Add row before`,addRowAfter:`Add row after`,deleteRow:`Delete row`,addColumnBefore:`Add column before`,addColumnAfter:`Add column after`,deleteColumn:`Delete column`,deleteTable:`Delete table`,image:`Insert image`,imageDialogTitle:`Insert image`,imageDialogUrlLabel:`Image URL`,imageDialogAltLabel:`Alt text (optional)`,imageDialogSave:`Insert`,imageDialogCancel:`Cancel`,emoji:`Emoji`,emojiSearchPlaceholder:`Search emoji…`,pasteAsPlainText:`Paste as plain text`,pasteAsHtml:`Paste with formatting`,markdown:`Markdown`,markdownDialogTitle:`Markdown`,markdownDialogDescription:`Edit as Markdown, then apply to replace the editor content. Copy to export.`,markdownDialogApply:`Apply`,markdownDialogCancel:`Cancel`,markdownDialogCopy:`Copy`,markdownDialogCopied:`Copied!`};function Hn({editor:e,error:t,disabled:n,readonly:r}){return(0,v.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},"& table":{borderCollapse:`collapse`,tableLayout:`fixed`,width:`100%`,margin:`8px 0`,overflowX:`auto`},"& table td, & table th":{border:`1px solid`,borderColor:`divider`,padding:`6px 8px`,verticalAlign:`top`,boxSizing:`border-box`,minWidth:`2em`,position:`relative`},"& table th":{fontWeight:`bold`,bgcolor:`action.hover`},"& table .selectedCell::after":{content:`""`,position:`absolute`,inset:0,bgcolor:`primary.main`,opacity:.12,pointerEvents:`none`,zIndex:2},"& img":{maxWidth:`100%`,height:`auto`,borderRadius:`4px`,display:`block`,my:1}}},children:(0,v.jsx)(W.EditorContent,{editor:e})})}function Un({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,v.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.linkDialogTitle}),(0,v.jsx)(l.DialogContent,{children:(0,v.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,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[o&&(0,v.jsx)(l.Button,{onClick:u,color:`error`,sx:{mr:`auto`},children:r.linkDialogRemove}),(0,v.jsx)(l.Button,{onClick:t,children:r.linkDialogCancel}),(0,v.jsx)(l.Button,{onClick:s,variant:`contained`,children:r.linkDialogSave})]})]})}var Wn=[`#000000`,`#434343`,`#666666`,`#999999`,`#b7b7b7`,`#ffffff`,`#ff0000`,`#ff4500`,`#ff8c00`,`#ffd700`,`#9acd32`,`#008000`,`#00ced1`,`#1e90ff`,`#0000ff`,`#8a2be2`,`#ff1493`,`#a52a2a`],Gn=[`#ffff00`,`#ffd700`,`#ffa500`,`#ff69b4`,`#ff6347`,`#fa8072`,`#adff2f`,`#90ee90`,`#00fa9a`,`#00ffff`,`#87ceeb`,`#add8e6`,`#dda0dd`,`#ee82ee`,`#d2b48c`,`#f5f5dc`,`#ffffff`,`#000000`];function Kn({color:e,active:t,onClick:n}){return(0,v.jsx)(l.Tooltip,{title:e,placement:`top`,arrow:!0,children:(0,v.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>n(e),"aria-label":e,"aria-pressed":t,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,v.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 qn({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`?Gn:Wn;function f(e){a(e.target.value)}return(0,v.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,v.jsx)(l.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(6, 22px)`,gap:.5,mb:1},children:d.map(e=>(0,v.jsx)(Kn,{color:e,active:i?.toLowerCase()===e.toLowerCase(),onClick:e=>{a(e),n()}},e))}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(l.Tooltip,{title:`Custom color`,arrow:!0,children:(0,v.jsx)(l.Box,{component:`button`,type:`button`,onClick:()=>u.current?.click(),"aria-label":`Custom color`,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,v.jsx)(`input`,{ref:u,type:`color`,defaultValue:i??`#000000`,onChange:f,onBlur:n,style:{visibility:`hidden`,width:0,height:0,position:`absolute`}}),(0,v.jsx)(l.Tooltip,{title:s,arrow:!0,children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:()=>{o(),n()},"aria-label":s,sx:{borderRadius:1,ml:`auto`},children:(0,v.jsx)(Se.default,{fontSize:`small`})})})]})]})}function Jn({editor:e,translation:t,disabled:n}){let[r,i]=(0,c.useState)(null),a=n||!e,o=e?.isActive(`table`)??!1;function s(){i(null)}function u(e){e(),s()}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Tooltip,{title:t.table,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>i(e.currentTarget),disabled:a,color:o?`primary`:`default`,sx:{borderRadius:1},"aria-label":t.table,"aria-pressed":o,children:(0,v.jsx)(Ce.default,{fontSize:`small`})})})}),(0,v.jsxs)(l.Menu,{anchorEl:r,open:!!r,onClose:s,slotProps:{paper:{sx:{minWidth:220}}},children:[(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(Ce.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.insertTable})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addRowAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addRowAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteRow().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteRow})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnBefore().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnBefore})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().addColumnAfter().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(j.default,{fontSize:`small`})}),(0,v.jsx)(l.ListItemText,{children:t.addColumnAfter})]}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteColumn().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteColumn})]}),o&&(0,v.jsx)(l.Divider,{}),o&&(0,v.jsxs)(l.MenuItem,{onClick:()=>u(()=>e?.chain().focus().deleteTable().run()),children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(x.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:t.deleteTable})]})]})]})}function Yn({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)(``);function u(){let e=i.trim();e&&(n.chain().focus().setImage({src:e,alt:o.trim()||void 0}).run(),a(``),s(``),t())}function d(){a(``),s(``),t()}function f(e){e.key===`Enter`&&u()}return(0,v.jsxs)(l.Dialog,{open:e,onClose:d,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.imageDialogTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:`16px !important`},children:[(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,label:r.imageDialogUrlLabel,value:i,onChange:e=>a(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`,placeholder:`https://example.com/image.png`}),(0,v.jsx)(l.TextField,{fullWidth:!0,label:r.imageDialogAltLabel,value:o,onChange:e=>s(e.target.value),onKeyDown:f,variant:`outlined`,size:`small`})]}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,v.jsx)(l.Button,{onClick:d,children:r.imageDialogCancel}),(0,v.jsx)(l.Button,{onClick:u,variant:`contained`,disabled:!i.trim(),children:r.imageDialogSave})]})]})}var Xn=[{label:`Smileys`,emojis:[{emoji:`😀`,name:`grinning face`},{emoji:`😃`,name:`grinning face with big eyes`},{emoji:`😄`,name:`grinning face with smiling eyes`},{emoji:`😁`,name:`beaming face with smiling eyes`},{emoji:`😆`,name:`grinning squinting face`},{emoji:`😅`,name:`grinning face with sweat`},{emoji:`😂`,name:`face with tears of joy`},{emoji:`🤣`,name:`rolling on the floor laughing`},{emoji:`😊`,name:`smiling face with smiling eyes`},{emoji:`😇`,name:`smiling face with halo`},{emoji:`🙂`,name:`slightly smiling face`},{emoji:`😉`,name:`winking face`},{emoji:`😍`,name:`smiling face with heart eyes`},{emoji:`🥰`,name:`smiling face with hearts`},{emoji:`😘`,name:`face blowing a kiss`},{emoji:`😋`,name:`face savoring food`},{emoji:`😎`,name:`smiling face with sunglasses`},{emoji:`🤩`,name:`star struck`},{emoji:`🥳`,name:`partying face`},{emoji:`😏`,name:`smirking face`},{emoji:`😒`,name:`unamused face`},{emoji:`😔`,name:`pensive face`},{emoji:`😢`,name:`crying face`},{emoji:`😭`,name:`loudly crying face`},{emoji:`😤`,name:`face with steam from nose`},{emoji:`😠`,name:`angry face`},{emoji:`🤬`,name:`face with symbols on mouth`},{emoji:`😱`,name:`face screaming in fear`},{emoji:`😳`,name:`flushed face`},{emoji:`🤔`,name:`thinking face`},{emoji:`🙄`,name:`face with rolling eyes`},{emoji:`😴`,name:`sleeping face`},{emoji:`🤢`,name:`nauseated face`},{emoji:`🤧`,name:`sneezing face`},{emoji:`😷`,name:`face with medical mask`}]},{label:`Gestures`,emojis:[{emoji:`👋`,name:`waving hand`},{emoji:`🤚`,name:`raised back of hand`},{emoji:`✋`,name:`raised hand`},{emoji:`🖐️`,name:`hand with fingers splayed`},{emoji:`👌`,name:`ok hand`},{emoji:`✌️`,name:`victory hand`},{emoji:`🤞`,name:`crossed fingers`},{emoji:`🤙`,name:`call me hand`},{emoji:`👈`,name:`backhand index pointing left`},{emoji:`👉`,name:`backhand index pointing right`},{emoji:`👆`,name:`backhand index pointing up`},{emoji:`👇`,name:`backhand index pointing down`},{emoji:`☝️`,name:`index pointing up`},{emoji:`👍`,name:`thumbs up`},{emoji:`👎`,name:`thumbs down`},{emoji:`✊`,name:`raised fist`},{emoji:`👊`,name:`oncoming fist`},{emoji:`👏`,name:`clapping hands`},{emoji:`🙌`,name:`raising hands`},{emoji:`🤝`,name:`handshake`},{emoji:`🙏`,name:`folded hands`},{emoji:`💪`,name:`flexed biceps`},{emoji:`🦾`,name:`mechanical arm`},{emoji:`👀`,name:`eyes`},{emoji:`👁️`,name:`eye`},{emoji:`👅`,name:`tongue`},{emoji:`💋`,name:`kiss mark`}]},{label:`Hearts & Symbols`,emojis:[{emoji:`❤️`,name:`red heart`},{emoji:`🧡`,name:`orange heart`},{emoji:`💛`,name:`yellow heart`},{emoji:`💚`,name:`green heart`},{emoji:`💙`,name:`blue heart`},{emoji:`💜`,name:`purple heart`},{emoji:`🖤`,name:`black heart`},{emoji:`🤍`,name:`white heart`},{emoji:`💔`,name:`broken heart`},{emoji:`💕`,name:`two hearts`},{emoji:`💞`,name:`revolving hearts`},{emoji:`💖`,name:`sparkling heart`},{emoji:`💘`,name:`heart with arrow`},{emoji:`💝`,name:`heart with ribbon`},{emoji:`✨`,name:`sparkles`},{emoji:`⭐`,name:`star`},{emoji:`🌟`,name:`glowing star`},{emoji:`💫`,name:`dizzy`},{emoji:`🔥`,name:`fire`},{emoji:`💧`,name:`droplet`},{emoji:`💯`,name:`hundred points`},{emoji:`✅`,name:`check mark button`},{emoji:`❌`,name:`cross mark`},{emoji:`⚠️`,name:`warning`},{emoji:`🎉`,name:`party popper`},{emoji:`🎊`,name:`confetti ball`},{emoji:`🏆`,name:`trophy`},{emoji:`🥇`,name:`first place medal`}]},{label:`Nature`,emojis:[{emoji:`🐶`,name:`dog face`},{emoji:`🐱`,name:`cat face`},{emoji:`🐭`,name:`mouse face`},{emoji:`🐹`,name:`hamster`},{emoji:`🐰`,name:`rabbit face`},{emoji:`🦊`,name:`fox`},{emoji:`🐻`,name:`bear`},{emoji:`🐼`,name:`panda`},{emoji:`🐨`,name:`koala`},{emoji:`🐯`,name:`tiger face`},{emoji:`🦁`,name:`lion`},{emoji:`🐸`,name:`frog`},{emoji:`🐧`,name:`penguin`},{emoji:`🐦`,name:`bird`},{emoji:`🦋`,name:`butterfly`},{emoji:`🌸`,name:`cherry blossom`},{emoji:`🌺`,name:`hibiscus`},{emoji:`🌻`,name:`sunflower`},{emoji:`🌹`,name:`rose`},{emoji:`🌿`,name:`herb`},{emoji:`🍀`,name:`four leaf clover`},{emoji:`🌲`,name:`evergreen tree`},{emoji:`🌴`,name:`palm tree`},{emoji:`🌊`,name:`water wave`},{emoji:`🌈`,name:`rainbow`},{emoji:`☀️`,name:`sun`},{emoji:`🌙`,name:`crescent moon`},{emoji:`❄️`,name:`snowflake`},{emoji:`⚡`,name:`lightning`},{emoji:`🌪️`,name:`tornado`}]},{label:`Food`,emojis:[{emoji:`🍎`,name:`red apple`},{emoji:`🍊`,name:`tangerine`},{emoji:`🍋`,name:`lemon`},{emoji:`🍇`,name:`grapes`},{emoji:`🍓`,name:`strawberry`},{emoji:`🍒`,name:`cherries`},{emoji:`🍑`,name:`peach`},{emoji:`🥭`,name:`mango`},{emoji:`🍍`,name:`pineapple`},{emoji:`🥥`,name:`coconut`},{emoji:`🥝`,name:`kiwi fruit`},{emoji:`🍅`,name:`tomato`},{emoji:`🥑`,name:`avocado`},{emoji:`🌽`,name:`ear of corn`},{emoji:`🍕`,name:`pizza`},{emoji:`🍔`,name:`hamburger`},{emoji:`🌮`,name:`taco`},{emoji:`🍜`,name:`steaming bowl`},{emoji:`🍣`,name:`sushi`},{emoji:`🍩`,name:`doughnut`},{emoji:`🎂`,name:`birthday cake`},{emoji:`🍰`,name:`shortcake`},{emoji:`🍦`,name:`soft ice cream`},{emoji:`🍫`,name:`chocolate bar`},{emoji:`☕`,name:`hot beverage`},{emoji:`🧃`,name:`beverage box`},{emoji:`🍺`,name:`beer mug`},{emoji:`🥂`,name:`clinking glasses`}]},{label:`Objects & Travel`,emojis:[{emoji:`📱`,name:`mobile phone`},{emoji:`💻`,name:`laptop`},{emoji:`🖥️`,name:`desktop computer`},{emoji:`⌨️`,name:`keyboard`},{emoji:`📷`,name:`camera`},{emoji:`📺`,name:`television`},{emoji:`🎮`,name:`video game`},{emoji:`🎸`,name:`guitar`},{emoji:`🎹`,name:`musical keyboard`},{emoji:`📚`,name:`books`},{emoji:`📝`,name:`memo`},{emoji:`✏️`,name:`pencil`},{emoji:`🔍`,name:`magnifying glass tilted left`},{emoji:`💡`,name:`light bulb`},{emoji:`🔑`,name:`key`},{emoji:`🔒`,name:`locked`},{emoji:`⚙️`,name:`gear`},{emoji:`🔧`,name:`wrench`},{emoji:`🏠`,name:`house`},{emoji:`🏢`,name:`office building`},{emoji:`✈️`,name:`airplane`},{emoji:`🚀`,name:`rocket`},{emoji:`🚗`,name:`automobile`},{emoji:`🚲`,name:`bicycle`},{emoji:`⛵`,name:`sailboat`},{emoji:`🗺️`,name:`world map`},{emoji:`🏔️`,name:`snow capped mountain`},{emoji:`🏖️`,name:`beach with umbrella`}]}];function Zn({anchorEl:e,open:t,onClose:n,onSelect:r,translation:i}){let[a,o]=(0,c.useState)(``),s=(0,c.useMemo)(()=>{let e=a.trim().toLowerCase();return e?Xn.map(t=>({...t,emojis:t.emojis.filter(t=>t.name.includes(e)||t.emoji===e)})).filter(e=>e.emojis.length>0):Xn},[a]);function u(e){r(e),n(),o(``)}function d(){n(),o(``)}return(0,v.jsxs)(l.Popover,{open:t,anchorEl:e,onClose:d,anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{sx:{width:320,maxHeight:380,display:`flex`,flexDirection:`column`}}},children:[(0,v.jsx)(l.Box,{sx:{p:1,borderBottom:1,borderColor:`divider`},children:(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,size:`small`,placeholder:i.emojiSearchPlaceholder,value:a,onChange:e=>o(e.target.value),slotProps:{input:{startAdornment:(0,v.jsx)(l.InputAdornment,{position:`start`,children:(0,v.jsx)(we.default,{fontSize:`small`})})}}})}),(0,v.jsxs)(l.Box,{sx:{overflowY:`auto`,flex:1,px:1,pb:1},children:[s.map(e=>(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,color:`text.secondary`,mt:1,mb:.5,px:.5},children:e.label}),(0,v.jsx)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.25},children:e.emojis.map(e=>(0,v.jsx)(l.Box,{component:`button`,title:e.name,"aria-label":e.name,onClick:()=>u(e.emoji),sx:{border:`none`,background:`none`,cursor:`pointer`,fontSize:`1.375rem`,lineHeight:1,p:.5,borderRadius:1,"&:hover":{bgcolor:`action.hover`}},children:e.emoji},e.emoji))})]},e.label)),s.length===0&&(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,sx:{p:2,textAlign:`center`},children:`No emoji found`})]})]})}function Qn({open:e,onClose:t,editor:n,translation:r}){let[i,a]=(0,c.useState)(``),[o,s]=$e();(0,c.useEffect)(()=>{e&&a(n.storage.markdown.getMarkdown())},[e,n]);function u(){n.commands.setContent(i),t()}function d(){navigator.clipboard.writeText(i).then(()=>{s()})}return(0,v.jsxs)(l.Dialog,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,v.jsx)(l.DialogTitle,{children:r.markdownDialogTitle}),(0,v.jsxs)(l.DialogContent,{sx:{display:`flex`,flexDirection:`column`,gap:1.5,pt:`16px !important`},children:[(0,v.jsx)(l.Typography,{variant:`body2`,color:`text.secondary`,children:r.markdownDialogDescription}),(0,v.jsx)(l.TextField,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:8,maxRows:16,value:i,onChange:e=>a(e.target.value),variant:`outlined`,size:`small`,sx:{fontFamily:`monospace`},slotProps:{htmlInput:{style:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})]}),(0,v.jsxs)(l.DialogActions,{sx:{px:3,pb:2,gap:1},children:[(0,v.jsx)(l.Box,{sx:{flex:1},children:(0,v.jsx)(l.Button,{onClick:d,startIcon:o?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),children:o?r.markdownDialogCopied:r.markdownDialogCopy})}),(0,v.jsx)(l.Button,{onClick:t,children:r.markdownDialogCancel}),(0,v.jsx)(l.Button,{onClick:u,variant:`contained`,children:r.markdownDialogApply})]})]})}function $n({label:e,icon:t,activeColor:n,disabled:r,onClick:i}){return(0,v.jsx)(l.Tooltip,{title:e,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.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,v.jsx)(l.Box,{sx:{display:`flex`,alignItems:`center`},children:t}),(0,v.jsx)(l.Box,{sx:{width:`80%`,height:3,bgcolor:n??`text.primary`,borderRadius:.5,mt:`1px`}})]})})})}function er({level:e}){return(0,v.jsxs)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.875rem`,lineHeight:1},children:[`H`,e]})}function tr({editor:e,toolbarConfig:t,translation:n,disabled:r,isFullscreen:i,onToggleFullscreen:a,pasteAsPlainText:o,onTogglePasteAsPlainText:s}){let[u,d]=(0,c.useState)(!1),[f,p]=(0,c.useState)(!1),[m,h]=(0,c.useState)(!1),[g,_]=(0,c.useState)(null),[y,b]=(0,c.useState)(null),[x,w]=(0,c.useState)(null),T=r||!e,E=e?.getAttributes(`textStyle`)?.color,D=e?.getAttributes(`highlight`)?.color,O=t.showBold||t.showItalic||t.showUnderline||t.showStrike,k=t.showHeading1||t.showHeading2||t.showHeading3,A=t.showBulletList||t.showOrderedList,j=t.showBlockquote||t.showCodeBlock||t.showLink||t.showHorizontalRule,M=t.showTextColor||t.showHighlight,N=t.showUndoRedo||t.showClearFormat,P=t.showTableButton||t.showImageButton||t.showEmojiButton,F=[O,k,A,j,M,N,P],I=F.filter(Boolean).length;function L(e,t){return!e||F.slice(t+1).findIndex(Boolean)===-1?null:(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}},`div-${t}`)}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`Text formatting`,children:[O&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBold&&(0,v.jsx)(Q,{label:n.bold,icon:(0,v.jsx)(se.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBold().run(),active:e?.isActive(`bold`),disabled:T}),t.showItalic&&(0,v.jsx)(Q,{label:n.italic,icon:(0,v.jsx)(ce.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleItalic().run(),active:e?.isActive(`italic`),disabled:T}),t.showUnderline&&(0,v.jsx)(Q,{label:n.underline,icon:(0,v.jsx)(le.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleUnderline().run(),active:e?.isActive(`underline`),disabled:T}),t.showStrike&&(0,v.jsx)(Q,{label:n.strike,icon:(0,v.jsx)(ue.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleStrike().run(),active:e?.isActive(`strike`),disabled:T})]}),L(O,0),k&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showHeading1&&(0,v.jsx)(Q,{label:n.heading1,icon:(0,v.jsx)(er,{level:1}),onClick:()=>e?.chain().focus().toggleHeading({level:1}).run(),active:e?.isActive(`heading`,{level:1}),disabled:T}),t.showHeading2&&(0,v.jsx)(Q,{label:n.heading2,icon:(0,v.jsx)(er,{level:2}),onClick:()=>e?.chain().focus().toggleHeading({level:2}).run(),active:e?.isActive(`heading`,{level:2}),disabled:T}),t.showHeading3&&(0,v.jsx)(Q,{label:n.heading3,icon:(0,v.jsx)(er,{level:3}),onClick:()=>e?.chain().focus().toggleHeading({level:3}).run(),active:e?.isActive(`heading`,{level:3}),disabled:T})]}),L(k,1),A&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBulletList&&(0,v.jsx)(Q,{label:n.bulletList,icon:(0,v.jsx)(de.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBulletList().run(),active:e?.isActive(`bulletList`),disabled:T}),t.showOrderedList&&(0,v.jsx)(Q,{label:n.orderedList,icon:(0,v.jsx)(fe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleOrderedList().run(),active:e?.isActive(`orderedList`),disabled:T})]}),L(A,2),j&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showBlockquote&&(0,v.jsx)(Q,{label:n.blockquote,icon:(0,v.jsx)(pe.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleBlockquote().run(),active:e?.isActive(`blockquote`),disabled:T}),t.showCodeBlock&&(0,v.jsx)(Q,{label:n.codeBlock,icon:(0,v.jsx)(me.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().toggleCodeBlock().run(),active:e?.isActive(`codeBlock`),disabled:T}),t.showLink&&(0,v.jsx)(Q,{label:n.link,icon:(0,v.jsx)(he.default,{fontSize:`small`}),onClick:()=>d(!0),active:e?.isActive(`link`),disabled:T}),t.showHorizontalRule&&(0,v.jsx)(Q,{label:n.horizontalRule,icon:(0,v.jsx)(ge.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().setHorizontalRule().run(),disabled:T})]}),L(j,3),M&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTextColor&&(0,v.jsx)($n,{label:n.textColor,icon:(0,v.jsx)(_e.default,{fontSize:`small`}),activeColor:E,disabled:T,onClick:e=>b(e.currentTarget)}),t.showHighlight&&(0,v.jsx)($n,{label:n.highlight,icon:(0,v.jsx)(ve.default,{fontSize:`small`}),activeColor:D,disabled:T,onClick:e=>w(e.currentTarget)})]}),L(M,4),N&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showUndoRedo&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().undo().run(),disabled:T||!e?.can().undo()}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().redo().run(),disabled:T||!e?.can().redo()})]}),t.showClearFormat&&(0,v.jsx)(Q,{label:n.clearFormat,icon:(0,v.jsx)(ye.default,{fontSize:`small`}),onClick:()=>e?.chain().focus().clearNodes().unsetAllMarks().run(),disabled:T})]}),L(N,5),P&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showTableButton&&(0,v.jsx)(Jn,{editor:e,translation:n,disabled:T}),t.showImageButton&&(0,v.jsx)(Q,{label:n.image,icon:(0,v.jsx)(ae.default,{fontSize:`small`}),onClick:()=>p(!0),disabled:T}),t.showEmojiButton&&(0,v.jsx)(l.Tooltip,{title:n.emoji,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onMouseDown:e=>e.preventDefault(),onClick:e=>_(e.currentTarget),disabled:T,sx:{borderRadius:1},"aria-label":n.emoji,children:(0,v.jsx)(oe.default,{fontSize:`small`})})})})]}),I===0&&(0,v.jsx)(l.Box,{sx:{height:32}}),(t.showPasteAsPlainTextButton||t.showMarkdownButton||t.showFullscreenButton)&&(0,v.jsxs)(l.Box,{sx:{ml:`auto`,display:`flex`,gap:.25},children:[t.showPasteAsPlainTextButton&&(0,v.jsx)(Q,{label:o?n.pasteAsHtml:n.pasteAsPlainText,icon:o?(0,v.jsx)(xe.default,{fontSize:`small`}):(0,v.jsx)(be.default,{fontSize:`small`}),onClick:s,active:o,disabled:r||!e}),t.showMarkdownButton&&(0,v.jsx)(Q,{label:n.markdown,icon:(0,v.jsx)(l.Box,{component:`span`,sx:{fontWeight:`bold`,fontSize:`0.7rem`,lineHeight:1},children:`MD`}),onClick:()=>h(!0),disabled:r||!e}),t.showFullscreenButton&&(0,v.jsx)(l.Tooltip,{title:i?n.exitFullscreen:n.fullscreen,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.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,v.jsx)(ie.default,{fontSize:`small`}):(0,v.jsx)(re.default,{fontSize:`small`})})})})]})]}),t.showLink&&e&&(0,v.jsx)(Un,{open:u,onClose:()=>d(!1),editor:e,translation:n}),t.showTextColor&&(0,v.jsx)(qn,{anchorEl:y,open:!!y,onClose:()=>b(null),mode:`textColor`,activeColor:E,onSelectColor:t=>e?.chain().focus().setColor(t).run(),onRemoveColor:()=>e?.chain().focus().unsetColor().run(),removeLabel:n.removeTextColor}),t.showHighlight&&(0,v.jsx)(qn,{anchorEl:x,open:!!x,onClose:()=>w(null),mode:`highlight`,activeColor:D,onSelectColor:t=>e?.chain().focus().setHighlight({color:t}).run(),onRemoveColor:()=>e?.chain().focus().unsetHighlight().run(),removeLabel:n.removeHighlight}),t.showImageButton&&e&&(0,v.jsx)(Yn,{open:f,onClose:()=>p(!1),editor:e,translation:n}),t.showMarkdownButton&&e&&(0,v.jsx)(Qn,{open:m,onClose:()=>h(!1),editor:e,translation:n}),t.showEmojiButton&&(0,v.jsx)(Zn,{anchorEl:g,open:!!g,onClose:()=>_(null),onSelect:t=>e?.chain().focus().insertContent(t).run(),translation:n})]})}function nr({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mt:.5,px:.5},children:[(0,v.jsx)(l.FormHelperText,{error:t,children:e??``}),(n||a)&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:1.5,alignItems:`center`},children:[a&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.secondary`},children:d}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:u},children:c})]})]})}function rr({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:m,value:h,width:g,onBlur:_,onChange:y,onFocus:b,onMarkdownChange:x}){let S={...Vn,...m},C={...Bn,...p},[w,T]=(0,c.useState)(!1),[E,D]=(0,c.useState)(!1),O=(0,c.useRef)(E);(0,c.useEffect)(()=>{O.current=E},[E]);let k=nt(n),A=nt(g),j=k===`auto`,M=j?void 0:k??200,N=i!==void 0&&i>0||u||f,P=(0,W.useEditor)({shouldRerenderOnTransaction:!0,extensions:[G.StarterKit.configure({link:{openOnClick:!1}}),K.TextStyle,q.Color,J.Highlight.configure({multicolor:!0}),ne.Markdown.configure({transformPastedText:!0,transformCopiedText:!1}),Y.Placeholder.configure({placeholder:o??``}),...C.showTableButton?[X.TableKit]:[],...C.showImageButton?[te.Image.configure({inline:!1,allowBase64:!0})]:[],...N?i!==void 0&&i>0?[ee.CharacterCount.configure({limit:i})]:[ee.CharacterCount]:[]],content:h??``,editable:!e&&!s,editorProps:{handlePaste(e,t){if(!O.current)return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;t.preventDefault();let{state:r}=e;return e.dispatch(r.tr.insertText(n,r.selection.from,r.selection.to)),!0}},onUpdate({editor:e}){y?.(e.getHTML()),x?.(e.storage.markdown.getMarkdown())},onBlur(){_?.()},onFocus(){b?.()}});(0,c.useEffect)(()=>{!P||h===void 0||P.getHTML()!==h&&P.commands.setContent(h,{emitUpdate:!1})},[P,h]),(0,c.useEffect)(()=>{P&&P.setEditable(!e&&!s)},[P,e,s]);let F=P?.storage.characterCount?.characters?.()??0,I=P?.storage.characterCount?.words?.()??0,L=u||i!==void 0&&i>0||f||!!r;return(0,v.jsxs)(l.Box,{sx:w?{position:`fixed`,top:0,left:0,width:`100vw`,height:`100vh`,zIndex:1300,display:`flex`,flexDirection:`column`,bgcolor:`background.default`,p:1}:{width:A??`100%`,...j?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...w||j?{flex:1}:{height:M},borderColor:t?`error.main`:void 0,"&:focus-within":{borderColor:t?`error.main`:`primary.main`,borderWidth:2}},children:[d&&!s&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(tr,{editor:P,toolbarConfig:C,translation:S,disabled:e,isFullscreen:w,onToggleFullscreen:()=>T(e=>!e),pasteAsPlainText:E,onTogglePasteAsPlainText:()=>D(e=>!e)}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(Hn,{editor:P,error:t,disabled:e,readonly:s})]}),L&&(0,v.jsx)(nr,{helperText:r,error:t,showCharacterCount:u||i!==void 0&&i>0,charCount:F,maxCharacters:i&&i>0?i:void 0,showWordCount:f,wordCount:I,translation:S}),a&&(0,v.jsx)(`input`,{type:`hidden`,name:a,value:P?P.getHTML():``})]})}var ir={showFormat:!0,showCopy:!0,showClear:!0,showExecute:!1,showUndoRedo:!0,showHistory:!1},ar={format:`Format SQL`,copy:`Copy`,copySuccess:`Copied!`,clear:`Clear`,execute:`Execute`,undo:`Undo`,redo:`Redo`,lineColumn:`Ln {line}, Col {col}`,errorCount:`{count} error(s)`,history:`Query history`,historyEmpty:`No queries yet`,clearHistory:`Clear history`},or={standard:Te.StandardSQL,mysql:Te.MySQL,postgresql:Te.PostgreSQL,sqlite:Te.SQLite,mssql:Te.MSSQL};function sr({value:e,onChange:t,placeholder:n,disabled:r=!1,readonly:i=!1,showLineNumbers:a=!0,dialect:o=`standard`,keywordColor:s,stringColor:f,identifierColor:_,schema:y,onExecute:b,onLint:x,onDiagnosticsChange:S,onViewReady:C,onCursorChange:w,onBlur:T,onFocus:E}){let D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(t),A=(0,c.useRef)(w),j=(0,c.useRef)(T),M=(0,c.useRef)(E),N=(0,c.useRef)(C),P=(0,c.useRef)(b),F=(0,c.useRef)(x),I=(0,c.useRef)(S),L=(0,c.useRef)(new d.Compartment),R=(0,c.useRef)(new d.Compartment),z=(0,l.useTheme)(),B=z.palette.mode===`dark`,V=!!x,H=JSON.stringify(y);return(0,c.useEffect)(()=>{k.current=t},[t]),(0,c.useEffect)(()=>{A.current=w},[w]),(0,c.useEffect)(()=>{j.current=T},[T]),(0,c.useEffect)(()=>{M.current=E},[E]),(0,c.useEffect)(()=>{N.current=C},[C]),(0,c.useEffect)(()=>{P.current=b},[b]),(0,c.useEffect)(()=>{F.current=x},[x]),(0,c.useEffect)(()=>{I.current=S},[S]),(0,c.useEffect)(()=>{if(!D.current)return;let t=O.current?.state.doc.toString()??e??``,c=s??z.palette.primary.main,l=f??z.palette.success.main,v=_??z.palette.info.main,b=m.HighlightStyle.define([{tag:g.tags.keyword,color:c,fontWeight:`bold`},{tag:g.tags.name,color:v},{tag:[g.tags.string,g.tags.special(g.tags.string)],color:l,fontWeight:`bold`},{tag:g.tags.number,color:z.palette.warning.main},{tag:[g.tags.lineComment,g.tags.blockComment],color:z.palette.text.disabled,fontStyle:`italic`},{tag:g.tags.operator,color:z.palette.text.secondary},{tag:[g.tags.function(g.tags.variableName),g.tags.function(g.tags.name)],color:z.palette.secondary.main},{tag:g.tags.typeName,color:z.palette.info.main},{tag:g.tags.invalid,color:z.palette.error.main,textDecoration:`underline wavy`}]),x=u.EditorView.theme({"&":{height:`100%`,fontFamily:`'Fira Code', 'JetBrains Mono', 'Consolas', monospace`,fontSize:`0.875rem`},".cm-scroller":{overflow:`auto`},".cm-content":{padding:`8px 4px`,caretColor:z.palette.text.primary},".cm-gutters":{backgroundColor:B?z.palette.grey[900]:z.palette.grey[50],color:z.palette.text.disabled,border:`none`,borderRight:`1px solid ${z.palette.divider}`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`4px`,paddingRight:`8px`},".cm-activeLineGutter":{backgroundColor:z.palette.action.selected},".cm-activeLine":{backgroundColor:z.palette.action.hover},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:z.palette.primary.main+`40`},".cm-cursor, .cm-dropCursor":{borderLeftColor:z.palette.text.primary},"&.cm-focused":{outline:`none`},".cm-placeholder":{color:z.palette.text.disabled,fontStyle:`italic`},".cm-tooltip":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`,boxShadow:z.shadows[4]},".cm-tooltip-autocomplete > ul > li":{color:z.palette.text.primary},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:z.palette.primary.main+`20`,color:z.palette.primary.main},".cm-completionMatchedText":{color:z.palette.primary.main,textDecoration:`none`,fontWeight:`bold`},".cm-completionDetail":{color:z.palette.text.secondary,fontStyle:`italic`},".cm-gutter-lint":{width:`16px`},".cm-lint-marker-error":{color:z.palette.error.main},".cm-lint-marker-warning":{color:z.palette.warning.main},".cm-tooltip.cm-tooltip-lint":{backgroundColor:z.palette.background.paper,border:`1px solid ${z.palette.divider}`,borderRadius:`4px`},".cm-diagnostic-error":{borderLeft:`3px solid ${z.palette.error.main}`},".cm-diagnostic-warning":{borderLeft:`3px solid ${z.palette.warning.main}`},".cm-diagnostic-info":{borderLeft:`3px solid ${z.palette.info.main}`}},{dark:B}),S=y?Object.fromEntries(y.tables.map(e=>[e.name,(e.columns??[]).map(e=>({label:e.name,detail:e.type,type:`property`}))])):void 0,C=async e=>{let t=F.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 I.current?.(r.length),r}catch{return[]}},w=u.keymap.of([{key:`Mod-Enter`,run:e=>(P.current?.(e.state.doc.toString()),!0)}]),T=[x,(0,m.syntaxHighlighting)(b),(0,Te.sql)({dialect:or[o],schema:S}),(0,p.history)(),(0,Ee.autocompletion)(),w,u.keymap.of([...p.defaultKeymap,...p.historyKeymap,...Ee.completionKeymap]),L.current.of(u.EditorView.editable.of(!r&&!i)),R.current.of(d.EditorState.readOnly.of(i)),(0,u.highlightActiveLine)(),...a?[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)()]:[],...n?[(0,u.placeholder)(n)]:[],...V?[(0,h.lintGutter)(),(0,h.linter)(C,{delay:600})]:[],u.EditorView.updateListener.of(e=>{e.docChanged&&k.current?.(e.state.doc.toString());let t=e.state.selection.main.head,n=e.state.doc.lineAt(t);A.current(n.number,t-n.from+1)}),u.EditorView.domEventHandlers({blur:()=>{j.current?.()},focus:()=>{M.current?.()}})],E=new u.EditorView({state:d.EditorState.create({doc:t,extensions:T}),parent:D.current});return O.current=E,N.current(E),()=>{N.current(null),E.destroy(),O.current=null}},[B,o,V,s,f,_,H]),(0,c.useEffect)(()=>{let t=O.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)(()=>{O.current?.dispatch({effects:[L.current.reconfigure(u.EditorView.editable.of(!r&&!i)),R.current.reconfigure(d.EditorState.readOnly.of(i))]})},[r,i]),(0,v.jsx)(l.Box,{ref:D,sx:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,opacity:r?.5:1,backgroundColor:z.palette.background.paper,"& .cm-editor":{flex:1,display:`flex`,flexDirection:`column`}}})}function cr(e,t=60){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}function lr({history:e,onSelect:t,onClear:n,translation:r,disabled:i}){let[a,o]=(0,c.useState)(null);function s(){o(null)}function u(e){t(e),s()}function d(){n(),s()}return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Tooltip,{title:r.history,arrow:!0,children:(0,v.jsx)(`span`,{children:(0,v.jsx)(l.IconButton,{size:`small`,onClick:e=>o(e.currentTarget),disabled:i,"aria-label":r.history,children:(0,v.jsx)(ke.default,{fontSize:`small`})})})}),(0,v.jsxs)(l.Menu,{anchorEl:a,open:!!a,onClose:s,slotProps:{paper:{sx:{minWidth:280,maxWidth:400}}},children:[e.length===0&&(0,v.jsx)(l.MenuItem,{disabled:!0,children:(0,v.jsx)(l.ListItemText,{children:r.historyEmpty})}),e.map(e=>(0,v.jsx)(l.MenuItem,{onClick:()=>u(e.sql),children:(0,v.jsx)(l.ListItemText,{primary:cr(e.sql),secondary:(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:new Date(e.timestamp).toLocaleString()}),slotProps:{primary:{sx:{fontFamily:`monospace`,fontSize:`0.8125rem`}}}})},e.id)),e.length>0&&(0,v.jsx)(l.Divider,{}),e.length>0&&(0,v.jsxs)(l.MenuItem,{onClick:d,children:[(0,v.jsx)(l.ListItemIcon,{children:(0,v.jsx)(Ae.default,{fontSize:`small`,color:`error`})}),(0,v.jsx)(l.ListItemText,{sx:{color:`error.main`},children:r.clearHistory})]})]})]})}var ur={standard:`sql`,mysql:`mysql`,postgresql:`postgresql`,sqlite:`sqlite`,mssql:`tsql`};function dr({editorView:e,toolbarConfig:t,translation:n,dialect:r,disabled:i,onExecute:a,queryHistory:o=[],onSelectHistoryEntry:s,onClearHistory:u}){let[d,f]=(0,c.useState)(!1),m=i||!e;function h(){let t=e?.state.doc.toString()??``;navigator.clipboard.writeText(t).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)})}function g(){let t=e;t&&(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:``}}),t.focus())}function _(){let t=e;t&&((0,p.undo)(t),t.focus())}function T(){let t=e;t&&((0,p.redo)(t),t.focus())}function E(){let t=e;if(!t)return;let n=t.state.doc.toString();try{let e=(0,Oe.format)(n,{language:ur[r]});t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})}catch{}t.focus()}function D(){let t=e;!t||!a||a(t.state.doc.toString())}let O=t.showFormat,k=t.showCopy||t.showClear,A=t.showUndoRedo,j=t.showExecute&&!!a,M=t.showHistory&&!!a&&!!s&&!!u;return(0,v.jsxs)(l.Box,{sx:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:.25,px:1,py:.5},role:`toolbar`,"aria-label":`SQL editor actions`,children:[O&&(0,v.jsx)(l.Box,{sx:{display:`flex`,gap:.25},children:(0,v.jsx)(Q,{label:n.format,icon:(0,v.jsx)(w.default,{fontSize:`small`}),onClick:E,disabled:m})}),O&&(k||A)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),k&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[t.showCopy&&(0,v.jsx)(Q,{label:d?n.copySuccess:n.copy,icon:d?(0,v.jsx)(b.default,{fontSize:`small`,color:`success`}):(0,v.jsx)(y.default,{fontSize:`small`}),onClick:h,disabled:m}),t.showClear&&(0,v.jsx)(Q,{label:n.clear,icon:(0,v.jsx)(x.default,{fontSize:`small`}),onClick:g,disabled:m})]}),k&&A&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),A&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,gap:.25},children:[(0,v.jsx)(Q,{label:n.undo,icon:(0,v.jsx)(S.default,{fontSize:`small`}),onClick:_,disabled:m}),(0,v.jsx)(Q,{label:n.redo,icon:(0,v.jsx)(C.default,{fontSize:`small`}),onClick:T,disabled:m})]}),M&&(0,v.jsxs)(v.Fragment,{children:[(k||A)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,v.jsx)(lr,{history:o,onSelect:s,onClear:u,translation:n,disabled:i})]}),j&&(0,v.jsxs)(v.Fragment,{children:[(k||A||M)&&(0,v.jsx)(l.Divider,{orientation:`vertical`,flexItem:!0,sx:{mx:.5}}),(0,v.jsx)(Q,{label:n.execute,icon:(0,v.jsx)(De.default,{fontSize:`small`}),onClick:D,disabled:m})]}),!O&&!k&&!A&&!M&&!j&&(0,v.jsx)(l.Box,{sx:{height:32}})]})}function fr({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,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`,mt:.5,px:.5},children:[(0,v.jsxs)(l.Box,{children:[r&&i>0&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,v.jsx)(je.default,{sx:{fontSize:`0.875rem`,color:`error.main`}}),(0,v.jsx)(l.FormHelperText,{sx:{color:`error.main`,m:0},children:u})]}),(0,v.jsx)(l.FormHelperText,{error:t,children:e??``})]}),n&&(0,v.jsx)(l.FormHelperText,{sx:{color:`text.disabled`,fontFamily:`monospace`,whiteSpace:`nowrap`},children:c})]})}var pr=0;function mr(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(pr+=1,`${Date.now()}-${pr}`)}function hr(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e?.sql==`string`&&typeof e?.timestamp==`number`).map(e=>({...e,id:typeof e.id==`string`?e.id:mr()})):[]}catch{return[]}}function gr(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function _r(e,t,n){let r=t.trim();if(!r)return e;let i=e.filter(e=>e.sql!==r);return[{id:mr(),sql:r,timestamp:Date.now()},...i].slice(0,Math.max(0,n))}function vr(e,t){let[n,r]=(0,c.useState)(()=>hr(e));return(0,c.useEffect)(()=>{r(hr(e))},[e]),{history:n,addEntry:(0,c.useCallback)(n=>{r(r=>{let i=_r(r,n,t);return gr(e,i),i})},[e,t]),clearHistory:(0,c.useCallback)(()=>{r([]),gr(e,[])},[e])}}function yr({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:m=!0,showErrorCount:h=!1,toolbarConfig:g,translation:_,highlightColors:y,schema:b,queryHistoryKey:x=`sql-editor-query-history`,queryHistoryMaxEntries:S=20,onExecute:C,onLint:w,onBlur:T,onFocus:E}){let D={...ar,..._},O={...ir,...g},{history:k,addEntry:A,clearHistory:j}=vr(x,S),M=nt(r),N=nt(i),P=M===`auto`,F=P?void 0:M??300,I=(0,c.useRef)(null),[L,R]=(0,c.useState)(null),[z,B]=(0,c.useState)({line:1,col:1}),[V,H]=(0,c.useState)(0),U=(0,c.useCallback)(e=>{I.current=e,R(e)},[]),W=(0,c.useCallback)((e,t)=>{B({line:e,col:t})},[]),G=(0,c.useCallback)(e=>{H(e)},[]),K=C?e=>{A(e),C(e)}:void 0,q=(0,c.useCallback)(e=>{let n=I.current;n&&(n.dispatch({changes:{from:0,to:n.state.doc.length,insert:e}}),n.focus()),t?.(e)},[t]),J=m||h||!!u;return(0,v.jsxs)(l.Box,{sx:{width:N??`100%`,...P?{display:`flex`,flexDirection:`column`,flex:1}:{}},children:[(0,v.jsxs)(l.Paper,{variant:`outlined`,sx:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...P?{flex:1}:{height:F},borderColor:s?`error.main`:void 0,"&:focus-within":{borderColor:s?`error.main`:`primary.main`,borderWidth:2}},children:[!o&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(dr,{editorView:L,toolbarConfig:O,translation:D,dialect:f,disabled:a,onExecute:K,queryHistory:k,onSelectHistoryEntry:q,onClearHistory:j}),(0,v.jsx)(l.Divider,{})]}),(0,v.jsx)(sr,{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,onExecute:K,onLint:w,onDiagnosticsChange:w?G:void 0,onViewReady:U,onCursorChange:W,onBlur:T,onFocus:E})]}),J&&(0,v.jsx)(fr,{helperText:u,error:s,showLineColumn:m,showErrorCount:h,diagnosticsCount:V,cursorLine:z.line,cursorCol:z.col,translation:D}),d&&(0,v.jsx)(`input`,{type:`hidden`,name:d,value:e??``})]})}var br={noData:`No data`},xr=2*Math.PI,Sr=11,Cr=Sr*.5,wr=5;function Tr(e,t=0,n=`.`,r=`,`){if(e==null||!isFinite(e))return`0`;let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function Er(e,t){let n=Math.floor(t/Cr);return n<=0?``:e.length<=n?e:n<wr?``:e.slice(0,n-1)+`…`}function Dr({node:e,valueDecimalCount:t,valueDecimalSep:n,valueThousandsSep:r}){let i=(e.value??0)>0,a=e.ancestors().map(e=>e.data.name).reverse().join(` › `);return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e.data.name}),i&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:Tr(e.value??0,t,n,r)}),e.depth>0&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.65,mt:.25},children:a})]})}function Or({data:e,size:t=500,showSegmentLabels:n=!0,innerRadius:r=0,sortBy:i=`value`,chartColors:a,showRootLabel:o=!0,onSegmentClick:s,onZoomChange:u,valueDecimalCount:d=0,valueDecimalSeparator:f=`.`,valueThousandsSeparator:p=`,`,zoomable:m=!1,duration:h=750,disabled:g=!1,translation:_}){let y=(0,l.useTheme)(),b={...br,..._},x=!e.children?.length&&!e.value,S=(0,c.useRef)(null),[C,w]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[T,E]=(0,c.useState)(1),D=(0,c.useMemo)(()=>{if(T===1)return C;let[e,t,n,r]=C.split(` `).map(Number),i=n/T,a=r/T;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[C,T]),O=t/2,k=Math.max(0,Math.min(r,Math.max(0,O-1))),A=Math.max(1,O-k),j=[y.palette.primary.main,y.palette.secondary.main,y.palette.error.main,y.palette.warning.main,y.palette.success.main,y.palette.info.main],M=a&&a.length>0?a:j,{root:N,ringThickness:P}=(0,c.useMemo)(()=>{let t=Z.hierarchy(e).sum(e=>e.value??0);i===`value`?t.sort((e,t)=>(t.value??0)-(e.value??0)):t.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`}));let n=Z.partition().size([xr,A])(t),r=Z.max(n.descendants(),e=>e.depth)??0,a=r>0?A/r:A;return r>0&&n.descendants().forEach(e=>{e.depth===0?(e.y0=0,e.y1=0):(e.y0=(e.depth-1)*a,e.y1=e.depth*a)}),{root:n,ringThickness:a}},[e,A,i]),[F,I]=(0,c.useState)(N),[L,R]=(0,c.useState)(N),z=e=>({x0:e.x0,x1:e.x1,yShift:e.depth===0?0:(e.depth-1)*P}),[B,V]=(0,c.useState)(()=>z(N)),H=(0,c.useRef)(B);if(L!==N){R(N),I(N);let e=z(N);H.current=e,V(e)}let U=(0,c.useMemo)(()=>N.children?.map(e=>e.data.name)??[N.data.name],[N]),W=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(U).range(M),[M,U]),G=e=>{if(e.data.colorConfig?.fill)return e.data.colorConfig.fill;let t=e;for(;t.depth>1;)t=t.parent;return W(t.data.name)},K=(0,c.useMemo)(()=>Z.arc().startAngle(e=>e.x0).endAngle(e=>e.x1).padAngle(e=>Math.min((e.x1-e.x0)/2,.005)).padRadius(O/2).innerRadius(e=>k+e.y0).outerRadius(e=>k+e.y1-1),[O,k]),q=(0,c.useCallback)(e=>{let t=xr/(B.x1-B.x0);return{x0:Math.max(0,Math.min(xr,(e.x0-B.x0)*t)),x1:Math.max(0,Math.min(xr,(e.x1-B.x0)*t)),y0:Math.max(0,e.y0-B.yShift),y1:Math.max(0,e.y1-B.yShift)}},[B]);(0,c.useEffect)(()=>{let e=z(F),t=H.current;if(t.x0===e.x0&&t.x1===e.x1&&t.yShift===e.yShift)return;if(h<=0){H.current=e,V(e);return}let n=null,r=Z.interpolateNumber(t.x0,e.x0),i=Z.interpolateNumber(t.x1,e.x1),a=Z.interpolateNumber(t.yShift,e.yShift),o=performance.now(),s=e=>{let t=Math.min(1,(e-o)/h),c=Z.easeCubic(t),l={x0:r(c),x1:i(c),yShift:a(c)};H.current=l,V(l),n=t<1?requestAnimationFrame(s):null};return n=requestAnimationFrame(s),()=>{n!=null&&cancelAnimationFrame(n)}},[F,P,h]);let J=e=>e.x1>e.x0&&e.y1>e.y0,Y=e=>(k+(e.y0+e.y1)/2)*(e.x1-e.x0)>12,ee=e=>{let t=(e.x0+e.x1)/2*180/Math.PI,n=k+(e.y0+e.y1)/2,r=t<180?0:180;return`rotate(${t-90}) translate(${n},0) rotate(${r})`},X=(0,c.useCallback)(e=>e.ancestors().includes(F),[F]),te=(0,c.useCallback)(e=>{let t=e.ancestors().reverse(),n=e.value??0,r=N.value??0;return{id:e.data.id,name:e.data.name,value:n||null,percentage:r>0?Math.round(n/r*1e4)/100:0,depth:e.depth,path:t.map(e=>e.data.name),pathIds:t.map(e=>e.data.id),childrenCount:e.children?.length??0,data:e.data}},[N]),ne=(0,c.useCallback)(e=>{I(e),u&&u({focusNode:te(e),isRoot:e===N})},[N,te,u]);(0,c.useLayoutEffect)(()=>{let e=S.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();w(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{w(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,N,F,k,P,o]);let re=(0,c.useRef)(null),ie=e=>{re.current&&=(clearTimeout(re.current),null),re.current=setTimeout(()=>{e(),re.current=null},250)},ae=()=>{re.current&&=(clearTimeout(re.current),null)};(0,c.useLayoutEffect)(()=>{if(g)return;let e=e=>{e.key===`Escape`&&(ae(),ne(N),E(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,N,ne]);let oe=(0,c.useCallback)(e=>{if(!m||g||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;E(e=>Math.max(.25,Math.min(8,e*t)))},[m,g]),se=N.descendants().filter(e=>e.depth>0),ce=e=>{if(g)return;let t=se[Number(e.currentTarget.getAttribute(`data-idx`))];if(t){if(e.ctrlKey||e.metaKey){t.children&&ie(()=>ne(t));return}s?.(te(t),e)}},le=e=>{g||(e.ctrlKey||e.metaKey)&&(ae(),ne(F.parent??N))},ue=e=>{if(!g){if(e.ctrlKey||e.metaKey){ae(),ne(F.parent??N);return}s?.(te(F.parent??N),e)}},de={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:g,slotProps:{tooltip:{sx:{maxWidth:260}}}},fe=y.palette.text.primary,pe=y.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:g?.5:1,cursor:g?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:D,onWheel:oe,style:{fontFamily:pe??`sans-serif`,overflow:m&&T>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:S,children:[x&&(0,v.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:y.palette.text.secondary,children:b.noData}),k>0&&(0,v.jsx)(l.Tooltip,{...de,title:F.data.name,placement:`top`,children:(0,v.jsx)(`circle`,{cx:0,cy:0,r:k,fill:`transparent`,pointerEvents:g?`none`:`auto`,onClick:ue,style:{cursor:g?`not-allowed`:`pointer`}})}),(0,v.jsx)(`g`,{children:se.map((e,t)=>{let n=q(e),r=J(n),i=!!e.children;return(0,v.jsx)(l.Tooltip,{...de,placement:`top`,title:r?(0,v.jsx)(Dr,{node:e,valueDecimalCount:d,valueDecimalSep:f,valueThousandsSep:p}):``,children:(0,v.jsx)(`path`,{"data-idx":t,d:K(n)||``,fill:G(e),fillOpacity:r?i?.75:.5:0,style:{pointerEvents:r&&!g?`auto`:`none`,cursor:i&&!g?`pointer`:`default`,transition:`fill-opacity 0.15s`},onClick:ce,onDoubleClick:le})},`tt-${e.data.id}-${t}`)})}),n&&(0,v.jsx)(`g`,{pointerEvents:`none`,textAnchor:`middle`,fill:fe,children:se.map((e,t)=>{if(!X(e))return null;let n=q(e);if(!Y(n))return null;let r=(k+(n.y0+n.y1)/2)*(n.x1-n.x0)*.88,i=Er(e.data.name,r);return i?(0,v.jsx)(`text`,{transform:ee(n),dy:`0.35em`,fontSize:Sr,children:i},`lbl-${e.data.id}-${t}`):null})}),o&&!x&&(0,v.jsx)(l.Tooltip,{...de,placement:`top`,title:``,children:(0,v.jsx)(`g`,{textAnchor:`middle`,fill:fe,pointerEvents:g?`none`:`auto`,onClick:ue,style:{cursor:F!==N&&!g?`pointer`:`default`},children:(0,v.jsx)(`text`,{fontSize:13,dy:`0.35em`,fontWeight:`bold`,children:F.data.name})})})]})})})}Or.displayName=`SunburstChart`;var kr={noData:`No data`};function Ar(e,t=0,n=`.`,r=`,`){if(!isFinite(e))return String(e);let[i,a]=e.toFixed(Math.max(0,t)).split(`.`),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,r);return a?`${o}${n}${a}`:o}function jr({name:e,valueOut:t,valueIn:n,fmt:r}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:e}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(t),` outgoing →`]}),(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:[r(n),` incoming ←`]})]})}function Mr({sourceName:e,targetName:t,sourceValue:n,targetValue:r,directed:i,fmt:a}){return(0,v.jsxs)(l.Box,{sx:{py:.25},children:[(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`},children:[e,` → `,t]}),(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:a(n)}),i&&r>0&&r!==n&&(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.7,mt:.25},children:[t,` → `,e,`: `,a(r)]})]})}function Nr({data:e,size:t=500,innerRadius:n,ringThickness:r=20,padAngle:i,ribbonPadAngle:a,sortSubgroups:o=`descending`,sortChords:s=`descending`,chartColors:u,groupColorConfigs:d,showGroupLabels:f=!0,labelOffset:p=8,ribbonOpacity:m=.75,ribbonBlendMode:h,directed:g=!0,valueDecimalCount:_=0,valueDecimalSeparator:y=`.`,valueThousandsSeparator:b=`,`,onGroupClick:x,onChordClick:S,zoomable:C=!1,disabled:w=!1,translation:T}){let E=(0,l.useTheme)(),D={...kr,...T},O=e.length===0,k=h??(E.palette.mode===`dark`?`normal`:`multiply`),A=[E.palette.primary.main,E.palette.secondary.main,E.palette.error.main,E.palette.warning.main,E.palette.success.main,E.palette.info.main],j=u&&u.length>0?u:A,M=n??Math.min(t,t)*.5-90,N=Math.max(10,M),P=N+Math.max(1,r),F=i??10/N,I=a??1/N,L=(0,c.useCallback)(e=>Ar(e,_,y,b),[_,y,b]),{names:R,matrix:z}=(0,c.useMemo)(()=>{let t=Z.sort(Z.union(e.map(e=>e.source),e.map(e=>e.target))),n=new Map(t.map((e,t)=>[e,t])),r=Array.from({length:t.length},()=>Array(t.length).fill(0));for(let{source:t,target:i,value:a}of e){let e=n.get(t),o=n.get(i);e==null||o==null||(r[e][o]+=a)}return{names:t,matrix:r}},[e]),B=(0,c.useMemo)(()=>{let e=(g?Z.chordDirected():Z.chord()).padAngle(F);return o===`ascending`&&(e=e.sortSubgroups(Z.ascending)),o===`descending`&&(e=e.sortSubgroups(Z.descending)),s===`ascending`&&(e=e.sortChords(Z.ascending)),s===`descending`&&(e=e.sortChords(Z.descending)),e(z)},[z,F,g,o,s]),V=(0,c.useMemo)(()=>Z.arc().innerRadius(N).outerRadius(P),[N,P]),H=(0,c.useMemo)(()=>(g?Z.ribbonArrow():Z.ribbon()).radius(N-1).padAngle(I),[N,I,g]),U=(0,c.useCallback)(e=>H({source:{startAngle:e.source.startAngle,endAngle:e.source.endAngle,radius:N-1},target:{startAngle:e.target.startAngle,endAngle:e.target.endAngle,radius:N-1}})??``,[H,N]),W=(0,c.useMemo)(()=>Z.scaleOrdinal().domain(Z.range(R.length)).range(j.length>=R.length?j:[...Array(Math.ceil(R.length/j.length))].flatMap(()=>j).slice(0,R.length)),[j,R.length]),G=(0,c.useCallback)(e=>d?.[R[e]]?.fill??W(e),[d,R,W]),K=(0,c.useRef)(null),[q,J]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[Y,ee]=(0,c.useState)(1),X=(0,c.useMemo)(()=>{if(Y===1)return q;let[e,t,n,r]=q.split(` `).map(Number),i=n/Y,a=r/Y;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[q,Y]);(0,c.useLayoutEffect)(()=>{let e=K.current;if(!e)return;let n=requestAnimationFrame(()=>{try{let t=e.getBBox();J(`${t.x-8} ${t.y-8} ${t.width+16} ${t.height+16}`)}catch{J(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(n)},[t,N,P,R.length,B]);let[te,ne]=(0,c.useState)(null),re=(0,c.useCallback)(e=>({name:R[e.index],index:e.index,valueOut:Z.sum(B,t=>(t.source.index===e.index?t.source.value:0)+(!g&&t.target.index===e.index?t.target.value:0)),valueIn:Z.sum(B,t=>(t.target.index===e.index?t.source.value:0)+(!g&&t.source.index===e.index?t.target.value:0))}),[R,B,g]),ie=(0,c.useCallback)(e=>({source:{name:R[e.source.index],index:e.source.index,value:e.source.value},target:{name:R[e.target.index],index:e.target.index,value:e.target.value}}),[R]),ae=e=>{let t=(e.startAngle+e.endAngle)/2,n=t*180/Math.PI-90,r=t>Math.PI?` rotate(180)`:``;return`rotate(${n}) translate(${P+p})${r}`},oe=e=>(e.startAngle+e.endAngle)/2>Math.PI?`end`:`start`,se=(0,c.useCallback)(e=>{if(!C||w||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;ee(e=>Math.max(.25,Math.min(8,e*t)))},[C,w]);(0,c.useLayoutEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&ee(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]);let ce={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:w,slotProps:{tooltip:{sx:{maxWidth:240}}}},le=E.palette.text.primary,ue=E.typography.fontFamily;return(0,v.jsx)(l.Box,{sx:{display:`inline-flex`,opacity:w?.5:1,cursor:w?`not-allowed`:`default`,userSelect:`none`},children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:X,onWheel:se,style:{fontFamily:ue??`sans-serif`,overflow:C&&Y>1?`hidden`:`visible`},role:`img`,"aria-label":`Chord chart`,children:(0,v.jsxs)(`g`,{ref:K,children:[O&&(0,v.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:E.palette.text.secondary,children:D.noData}),(0,v.jsx)(`g`,{children:B.groups.map(e=>{let t=re(e),n=te===e.index,r=te!==null&&!n;return(0,v.jsx)(l.Tooltip,{...ce,title:(0,v.jsx)(jr,{name:t.name,valueOut:t.valueOut,valueIn:t.valueIn,fmt:L}),children:(0,v.jsxs)(`g`,{style:{cursor:w?`not-allowed`:`pointer`},onMouseEnter:()=>!w&&ne(e.index),onMouseLeave:()=>ne(null),onClick:e=>!w&&x?.(t,e),children:[(0,v.jsx)(`path`,{d:V(e)||``,fill:G(e.index),stroke:E.palette.divider,opacity:r?.35:1,style:{transition:`opacity 0.15s`}}),f&&(0,v.jsx)(`text`,{dy:`0.35em`,fontSize:11,fill:le,transform:ae(e),textAnchor:oe(e),pointerEvents:`none`,children:R[e.index]})]})},`grp-tt-${e.index}`)})}),(0,v.jsx)(`g`,{fillOpacity:m,style:{mixBlendMode:k},children:B.map((e,t)=>{let n=ie(e),r=te===null||e.source.index===te||e.target.index===te;return(0,v.jsx)(l.Tooltip,{...ce,title:(0,v.jsx)(Mr,{sourceName:n.source.name,targetName:n.target.name,sourceValue:n.source.value,targetValue:n.target.value,directed:g,fmt:L}),children:(0,v.jsx)(`path`,{d:U(e),fill:G(e.target.index),stroke:`none`,opacity:r?1:.12,style:{cursor:w?`not-allowed`:`pointer`,transition:`opacity 0.15s`},onClick:e=>!w&&S?.(n,e)})},`chord-tt-${t}`)})})]})})})}Nr.displayName=`ChordChart`;var Pr={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Fr={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function Ir({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function Lr({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function Rr({data:e,size:t=600,autoFit:n=!0,sortBy:r=`name`,showLabels:i=!0,showIcons:a=!0,chartColors:o,rootNodeRadius:s=22,branchNodeRadius:u=16,leafNodeRadius:d=11,linkColor:f,linkStrokeOpacity:p=1,linkStrokeWidth:m=1.5,labelFontSize:h=12,labelColor:g,separationSibling:_=1,separationCousin:y=2,zoomable:b=!1,drillable:x=!1,onFocusChange:S,duration:C=750,showNodePopover:w=!1,renderNodePopoverContent:T,onNodeClick:E,disabled:D=!1,translation:O}){let k=(0,l.useTheme)(),A={...Pr,...O},j=[k.palette.primary.main,k.palette.secondary.main,k.palette.info.main,k.palette.success.main,k.palette.warning.main,k.palette.error.main],M=o&&o.length>0?o:j,N=(0,c.useCallback)(e=>e.depth===0?s:e.children?u:d,[s,u,d]),P=(0,c.useCallback)(e=>e.data.colorConfig?.fill??M[e.depth%M.length],[M]),[F,I]=(0,c.useState)([e]),L=F[F.length-1],[R,z]=(0,c.useState)(e),[B,V]=(0,c.useState)(!1);R!==e&&(z(e),I([e]),V(!0));let H=!e.children?.length&&!e.value,U=Math.max(1,t/2-70),W=(0,c.useMemo)(()=>{let e=Z.hierarchy(L);return r===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(e.data.name,t.data.name)),Z.tree().size([2*Math.PI,U]).separation((e,t)=>(e.parent===t.parent?_:y)*1.4/Math.max(1,e.depth))(e)},[L,r,U,_,y]),G=W.links(),K=W.descendants(),q=(0,c.useRef)(W),J=(0,c.useRef)(null),[Y,ee]=(0,c.useState)(null),[X,te]=(0,c.useState)(0);(0,c.useEffect)(()=>{let e=q.current;if(q.current=W,e===W)return;if(J.current!=null&&(cancelAnimationFrame(J.current),J.current=null),B||C<=0){V(!1),ee(null);return}ee(e),te(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/C);te(1-Z.easeCubic(r)),r<1?J.current=requestAnimationFrame(n):(J.current=null,ee(null))};return J.current=requestAnimationFrame(n),()=>{J.current!=null&&cancelAnimationFrame(J.current)}},[W,C,B]);let ne=(0,c.useMemo)(()=>Z.linkRadial().angle(e=>e.x).radius(e=>e.y),[]),re=(0,c.useCallback)(e=>({id:e.data.id,name:e.data.name,subname:e.data.subname??null,value:(typeof e.value==`number`?e.value:null)??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),ie=(0,c.useRef)(null),[ae,oe]=(0,c.useState)(`-${t/2} -${t/2} ${t} ${t}`),[se,ce]=(0,c.useState)(1);(0,c.useLayoutEffect)(()=>{if(!n){oe(`-${t/2} -${t/2} ${t} ${t}`);return}let e=ie.current;if(!e)return;let r=requestAnimationFrame(()=>{try{let t=e.getBBox();oe(`${t.x-20} ${t.y-20} ${t.width+40} ${t.height+40}`)}catch{oe(`-${t/2} -${t/2} ${t} ${t}`)}});return()=>cancelAnimationFrame(r)},[t,W,i,n]);let le=(0,c.useMemo)(()=>{if(se===1)return ae;let[e,t,n,r]=ae.split(` `).map(Number),i=n/se,a=r/se;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[ae,se]),ue=(0,c.useCallback)(e=>{if(!b||D||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;ce(e=>Math.max(.25,Math.min(8,e*t)))},[b,D]),de=(0,c.useRef)(null),fe=e=>{de.current&&=(clearTimeout(de.current),null),de.current=setTimeout(()=>{e(),de.current=null},250)},pe=()=>{de.current&&=(clearTimeout(de.current),null)};(0,c.useEffect)(()=>()=>pe(),[]),(0,c.useLayoutEffect)(()=>{if(!b&&!x)return;let t=t=>{t.key===`Escape`&&(b&&ce(1),x&&(pe(),I([e]),S?.(null)))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[b,x,e,S]);let[me,he]=(0,c.useState)(null),ge=(0,c.useRef)(null),_e=(0,c.useRef)(null),[ve,ye]=(0,c.useState)(!1),[be,xe]=(0,c.useState)(null),[Se,Ce]=(0,c.useState)({left:0,top:0}),[we,Te]=(0,c.useState)(null),Ee=(0,c.useCallback)(()=>{I(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return S?.(t.length<=1?null:{id:t[t.length-1].id,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]}),t})},[S]),De=e=>{D||!x||(e.ctrlKey||e.metaKey)&&(pe(),Ee())},Oe=e=>{if(D)return;let t=K[Number(e.currentTarget.getAttribute(`data-idx`))];if(!t)return;let n=re(t);if((e.ctrlKey||e.metaKey)&&x&&t.children){fe(()=>{I(e=>[...e,t.data]),S?.(n)});return}if(w){let t=ge.current?.getBoundingClientRect();Ce({left:t?e.clientX-t.left:e.clientX,top:t?e.clientY-t.top:e.clientY}),xe(_e.current),Te(n),ye(!0)}E?.(n,e)},ke=g||k.palette.text.primary,Ae=f||k.palette.text.secondary,je=k.palette.background.paper,Me=k.typography.fontFamily;return(0,v.jsxs)(l.Box,{ref:ge,sx:{display:`inline-flex`,position:`relative`,opacity:D?.5:1,cursor:D?`not-allowed`:`default`,userSelect:`none`},children:[x&&F.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,gap:.5,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:F.map(e=>e.name).join(` › `)})}),(0,v.jsx)(l.Box,{ref:_e,sx:{position:`absolute`,left:Se.left,top:Se.top,width:0,height:0}}),(0,v.jsx)(`svg`,{width:t,height:t,viewBox:le,onWheel:ue,style:{fontFamily:Me??`sans-serif`,overflow:b&&se>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:ie,children:[H&&(0,v.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:ke,children:A.noData}),(0,v.jsx)(`g`,{fill:`none`,stroke:Ae,strokeOpacity:p,strokeWidth:m,children:G.map((e,t)=>(0,v.jsx)(`path`,{d:ne(e)},`link-${t}`))}),(0,v.jsx)(`g`,{children:K.map((e,t)=>{let n=N(e),r=P(e),i=re(e),o=me===t,s=e.children?Fr.folder:Fr.person,c=Math.round(n*1.3);return(0,v.jsx)(l.Tooltip,{title:(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(i.specialValueA!=null||i.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[i.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:A.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueA)})]}),i.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:A.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(i.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]}),followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:D,slotProps:{tooltip:{sx:{maxWidth:260}}},children:(0,v.jsxs)(`g`,{"data-idx":t,transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,onClick:Oe,onDoubleClick:De,onMouseEnter:()=>!D&&he(t),onMouseLeave:()=>he(null),style:{cursor:D?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:Math.max(n+8,24),fill:`transparent`}),(0,v.jsx)(`circle`,{r:n+2,fill:r,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:n,fill:r,fillOpacity:o?.85:1,style:{transition:`fill-opacity 0.15s`}}),a&&(0,v.jsx)(Ir,{path:s,size:c})]})},`node-${e.data.id}-${t}`)})}),Y&&((e,t)=>(0,v.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:Ae,strokeOpacity:p,strokeWidth:m,children:e.links().map((e,t)=>(0,v.jsx)(`path`,{d:ne(e)},`ghost-link-${t}`))}),(0,v.jsx)(`g`,{children:e.descendants().map((e,t)=>(0,v.jsxs)(`g`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0)`,children:[(0,v.jsx)(`circle`,{r:N(e)+2,fill:P(e),fillOpacity:.15}),(0,v.jsx)(`circle`,{r:N(e),fill:P(e)}),a&&(0,v.jsx)(Ir,{path:e.children?Fr.folder:Fr.person,size:Math.round(N(e)*1.3)})]},`ghost-node-${t}`))})]}))(Y,X),i&&(0,v.jsx)(`g`,{children:K.map((e,t)=>{let n=N(e),r=e.x<Math.PI==!e.children,i=n+6,a=r?i:-i,o=r?`start`:`end`;return(0,v.jsx)(`text`,{transform:`rotate(${e.x*180/Math.PI-90}) translate(${e.y},0) rotate(${e.x>=Math.PI?180:0})`,dy:`0.35em`,x:a,textAnchor:o,paintOrder:`stroke`,stroke:je,strokeWidth:3,fill:ke,fontSize:h,fontWeight:e.depth===0?`bold`:`normal`,pointerEvents:`none`,children:e.data.name},`lbl-${e.data.id}-${t}`)})})]})}),w&&(0,v.jsx)(l.Popover,{open:ve,anchorEl:be,onClose:()=>ye(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:we&&(T?T(we):(0,v.jsx)(Lr,{info:we,labelA:A.specialValueA??`Value A`,labelB:A.specialValueB??`Value B`}))})]})}Rr.displayName=`RadialTreeChart`;var zr={noData:`No data`},Br=.56;function Vr(e,t,n){return e.length*n*Br<=t?e:t>=3*n*Br+n*2?`…`:``}function Hr({data:e,size:t=600,padding:n=3,sortBy:r=`value`,showLabels:i=!0,showAllLabels:a=!1,labelFontSize:o=13,innerLabelFontSize:s=9,labelColor:u,chartColors:d,depthColorStart:f,depthColorEnd:p,background:m,duration:h=750,zoomable:g=!1,disabled:_=!1,onCircleClick:y,onZoomChange:b,translation:x}){let S=(0,l.useTheme)(),C={...zr,...x},w=!e.children?.length&&!e.value,T=[S.palette.primary.main,S.palette.secondary.main,S.palette.error.main,S.palette.warning.main,S.palette.success.main,S.palette.info.main],E=u||S.palette.text.primary,D=m||S.palette.background.default,O=S.typography.fontFamily,k=(0,c.useMemo)(()=>{let i=Z.hierarchy(e).sum(e=>e.value??0);return r===`value`?i.sort((e,t)=>(t.value??0)-(e.value??0)):i.sort((e,t)=>String(e.data.name).localeCompare(String(t.data.name),void 0,{numeric:!0,sensitivity:`base`})),Z.pack().size([t,t]).padding(n)(i)},[e,t,n,r]),A=k.descendants(),j=(0,c.useMemo)(()=>Z.max(A,e=>e.depth)??0,[A]),M=!!(f&&p),N=(0,c.useMemo)(()=>M?Z.scaleSequential(Z.interpolateHcl(f,p)).domain([0,Math.max(1,j)]):null,[M,f,p,j]),P=d&&d.length>0?d:T,F=(0,c.useCallback)(e=>e.data.colorConfig?.fill?e.data.colorConfig.fill:M&&N?e.children?N(e.depth):S.palette.background.paper:P[e.depth%P.length],[M,N,P,S]),[I,L]=(0,c.useState)(1),R=(0,c.useCallback)(e=>{if(!g||_||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;L(e=>Math.max(.25,Math.min(8,e*t)))},[g,_]);(0,c.useLayoutEffect)(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&L(1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g]);let z=(0,c.useMemo)(()=>{let e=`${-t/2} ${-t/2} ${t} ${t}`;if(I===1)return e;let n=t/I,r=(t-n)/2;return`${-t/2+r} ${-t/2+r} ${n} ${n}`},[t,I]),B=(0,c.useCallback)(e=>{let t=e.value??0,n=k.value??0;return{id:e.data.id??null,name:e.data.name,value:t||null,percentage:n>0?Math.round(t/n*1e4)/100:0,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}},[k]),V=(0,c.useRef)(null),H=(0,c.useRef)([k.x,k.y,k.r*2]),U=(0,c.useRef)(k),[W,G]=(0,c.useState)(k),K=(0,c.useCallback)(e=>{U.current=e,G(e)},[]),[q,J]=(0,c.useState)(k);q!==k&&(J(k),K(k),U.current=k);let Y=(0,c.useCallback)(e=>{let n=V.current;if(!n)return;H.current=e;let r=t/e[2],o=U.current,c=n.querySelectorAll(`g[data-role='nodes'] > g`),l=n.querySelectorAll(`g[data-role='nodes'] > g > circle`);for(let t=0;t<A.length;t++){let n=A[t],i=c[t];i&&i.setAttribute(`transform`,`translate(${(n.x-e[0])*r},${(n.y-e[1])*r})`);let a=t-1;a>=0&&l[a]&&l[a].setAttribute(`r`,String(n.r*r))}if(i){let t=n.querySelectorAll(`g[data-role='labels'] > text`);for(let n=0;n<A.length;n++){let i=A[n],a=t[n];a&&(a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`))}}if(a){let t=n.querySelectorAll(`g[data-role='inner-labels'] > text`);for(let n=0;n<A.length;n++){let i=A[n],a=t[n];if(!a)continue;let c=i.r*r,l=c*1.6,u=o===k?i!==k:i.ancestors().includes(o),d=i.parent===o;if(u&&!d&&c>=14){let t=Vr(i.data.name,l,s);t?(a.textContent=t,a.setAttribute(`transform`,`translate(${(i.x-e[0])*r},${(i.y-e[1])*r})`),a.setAttribute(`font-weight`,i.children?`bold`:`normal`),a.style.display=`inline`):a.style.display=`none`}else a.style.display=`none`}}},[A,t,i,a,s,k]);(0,c.useLayoutEffect)(()=>{Y([W.x,W.y,W.r*2])},[k,t,W,Y]);let ee=(0,c.useCallback)((e,t)=>{let n=V.current;if(!n)return;let r=W,i=H.current,a=[e.x,e.y,e.r*2];K(e),Z.select(n).transition().duration(t).ease(Z.easeCubic).tween(`zoom`,()=>{let e=Z.interpolateZoom(i,a);return t=>Y(e(t))});let o=n.querySelectorAll(`g[data-role='labels'] > text`);Z.selectAll(o).transition().duration(t).ease(Z.easeCubic).style(`fill-opacity`,(t,n)=>+(A[n].parent===e)).on(`start`,function(t,n){A[n].parent===e&&(this.style.display=`inline`)}).on(`end`,function(t,n){A[n].parent!==e&&(this.style.display=`none`)}),b?.({previousName:r.data.name,currentName:e.data.name,currentDepth:e.depth,isRoot:e===k})},[W,A,k,Y,b,K]),X=(0,c.useRef)(null),te=e=>{X.current&&=(clearTimeout(X.current),null),X.current=setTimeout(()=>{e(),X.current=null},250)},ne=()=>{X.current&&=(clearTimeout(X.current),null)},re=(0,c.useRef)(ee);(0,c.useEffect)(()=>{re.current=ee},[ee]),(0,c.useLayoutEffect)(()=>{if(_)return;let e=e=>{e.key===`Escape`&&(ne(),re.current(k,h))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,k,h]);let ie=e=>{if(_||!(e.ctrlKey||e.metaKey))return;ne(),e.preventDefault();let t=W.parent??k;t!==W&&ee(t,e.altKey?Math.max(250,h*10):h)},ae={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:_,slotProps:{tooltip:{sx:{maxWidth:220}}}};return(0,v.jsxs)(l.Box,{sx:{display:`inline-flex`,position:`relative`,opacity:_?.5:1,cursor:_?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsxs)(`svg`,{ref:V,width:t,height:t,viewBox:z,onWheel:R,style:{display:`block`,background:D,fontFamily:O??`sans-serif`,overflow:g&&I>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,onDoubleClick:ie,children:[w&&(0,v.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:S.palette.text.secondary,children:C.noData}),(0,v.jsx)(`g`,{"data-role":`nodes`,children:A.map((e,n)=>{let r=B(e),i=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:160},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),(e.value??0)>0&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Value`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.value?.toLocaleString()})]}),(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Share`}),(0,v.jsxs)(l.Typography,{variant:`caption`,children:[r.percentage,`%`]})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Children`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(`g`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,children:n===0?null:(0,v.jsx)(l.Tooltip,{...ae,title:i,children:(0,v.jsx)(`circle`,{r:e.r,fill:F(e),stroke:e.data.colorConfig?.stroke??S.palette.background.paper,strokeWidth:.75,style:{cursor:_?`not-allowed`:e.children?`pointer`:`default`,transition:`stroke-width 0.1s`},onMouseEnter:e=>{_||(e.currentTarget.style.strokeWidth=`2`)},onMouseLeave:e=>{e.currentTarget.style.strokeWidth=`0.75`},onClick:t=>{if(!_){if(t.ctrlKey||t.metaKey){if(e.children){let n=t.altKey?Math.max(250,h*10):h;te(()=>ee(e,n))}return}y?.(r,t)}},onDoubleClick:e=>{if(!_&&(e.ctrlKey||e.metaKey)){ne(),e.preventDefault(),e.stopPropagation();let t=W.parent??k;t!==W&&ee(t,e.altKey?Math.max(250,h*10):h)}}})})},`n-${n}`)})}),i&&(0,v.jsx)(`g`,{"data-role":`labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:o,fill:E,children:A.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:e.parent===k?`inline`:`none`,fillOpacity:+(e.parent===k)},children:e.data.name},`lbl-${n}`))}),a&&(0,v.jsx)(`g`,{"data-role":`inner-labels`,textAnchor:`middle`,dominantBaseline:`middle`,pointerEvents:`none`,fontSize:s,fill:E,children:A.map((e,n)=>(0,v.jsx)(`text`,{transform:`translate(${e.x-t/2},${e.y-t/2})`,style:{display:`none`}},`inner-lbl-${n}`))})]}),W!==k&&!_&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,bottom:6,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`},children:(0,v.jsxs)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:[W.ancestors().map(e=>e.data.name).reverse().join(` › `),` · Ctrl / Cmd ⌘+DblClick to zoom out · Escape to reset`]})})]})}Hr.displayName=`CirclePackingChart`;var Ur={noData:`No data`,specialValueA:`Value A`,specialValueB:`Value B`},Wr={folder:`M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z`,person:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`};function Gr({path:e,size:t}){let n=t/2;return(0,v.jsx)(`g`,{transform:`translate(${-n},${-n})`,pointerEvents:`none`,children:(0,v.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,overflow:`visible`,children:(0,v.jsx)(`path`,{d:e,fill:`white`})})})}function Kr({info:e,labelA:t,labelB:n}){return(0,v.jsxs)(l.Box,{sx:{p:2,minWidth:200,maxWidth:280},children:[(0,v.jsxs)(l.Box,{sx:{display:`flex`,alignItems:`center`,gap:1.5,mb:1.5},children:[(0,v.jsx)(l.Avatar,{sx:{bgcolor:`primary.main`,width:40,height:40},children:e.name.charAt(0).toUpperCase()}),(0,v.jsxs)(l.Box,{children:[(0,v.jsx)(l.Typography,{variant:`body2`,sx:{fontWeight:`bold`},children:e.name}),e.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:e.subname})]})]}),(e.specialValueA!=null||e.specialValueB!=null)&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(l.Divider,{sx:{mb:1.5}}),e.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,mb:.5},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:t}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueA)})]}),e.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`},children:[(0,v.jsx)(l.Typography,{variant:`caption`,color:`text.secondary`,children:n}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(e.specialValueB)})]})]})]})}function qr({data:e,orientation:t=`LR`,width:n=800,height:r=500,levelSpacing:i=200,nodeRadius:a=10,sortBy:o=`name`,showLabels:s=!0,labelFontSize:u=12,labelColor:d,showIcons:f=!0,chartColors:p,linkStrokeOpacity:m=1,linkStrokeWidth:h=1.5,linkColor:g,zoomable:_=!1,drillable:y=!1,onFocusChange:b,showNodePopover:x=!1,renderNodePopoverContent:S,onNodeClick:C,duration:w=750,disabled:T=!1,translation:E}){let D=(0,l.useTheme)(),O={...Ur,...E},k=[D.palette.primary.main,D.palette.secondary.main,D.palette.error.main,D.palette.warning.main,D.palette.success.main,D.palette.info.main],A=p&&p.length>0?p:k,j=d||D.palette.text.primary,M=g||D.palette.text.secondary,N=D.palette.background.paper,P=D.typography.fontFamily,F=!e.children?.length&&!e.value,I=t===`TB`||t===`BT`,L=I?r:n,R=I?n:r,[z,B]=(0,c.useState)([e]),V=z[z.length-1],[H,U]=(0,c.useState)(e),[W,G]=(0,c.useState)(!1);H!==e&&(U(e),B([e]),G(!0));let K=(0,c.useMemo)(()=>{let e=Z.hierarchy(V);o===`value`?(e.sum(e=>e.value??0),e.sort((e,t)=>(t.value??0)-(e.value??0))):e.sort((e,t)=>Z.ascending(String(e.data.name),String(t.data.name)));let t=Z.max(e.descendants(),e=>e.depth)??1;return Z.tree().size([L*.8,Math.min(t*i,R*.85)])(e)},[V,o,L,R,i]),q=(0,c.useMemo)(()=>{let e=Z.max(Z.hierarchy(V).descendants(),e=>e.depth)??1;return Math.min(e*i,R*.85)},[V,i,R]),J=K.descendants(),Y=K.links(),ee=(0,c.useRef)(K),X=(0,c.useRef)(null),[te,ne]=(0,c.useState)(null),[re,ie]=(0,c.useState)(0);(0,c.useEffect)(()=>{let e=ee.current;if(ee.current=K,e===K)return;if(X.current!=null&&(cancelAnimationFrame(X.current),X.current=null),W||w<=0){G(!1),ne(null);return}ne(e),ie(1);let t=performance.now(),n=e=>{let r=Math.min(1,(e-t)/w);ie(1-Z.easeCubic(r)),r<1?X.current=requestAnimationFrame(n):(X.current=null,ne(null))};return X.current=requestAnimationFrame(n),()=>{X.current!=null&&cancelAnimationFrame(X.current)}},[K,w,W]);let ae=(0,c.useCallback)(e=>e.data.colorConfig?.fill??A[e.depth%A.length],[A]),oe=(0,c.useCallback)(e=>{switch(t){case`LR`:return{x:e.y,y:e.x-L*.4};case`RL`:return{x:q-e.y,y:e.x-L*.4};case`TB`:return{x:e.x-L*.4,y:e.y};case`BT`:return{x:e.x-L*.4,y:q-e.y}}},[t,L,q]),se=(0,c.useCallback)(e=>{let n=oe(e.source),r=oe(e.target);if(t===`LR`||t===`RL`){let e=(n.x+r.x)/2;return`M${n.x},${n.y} C${e},${n.y} ${e},${r.y} ${r.x},${r.y}`}let i=(n.y+r.y)/2;return`M${n.x},${n.y} C${n.x},${i} ${r.x},${i} ${r.x},${r.y}`},[oe,t]),ce=(0,c.useCallback)(e=>({id:e.data.id??null,name:e.data.name,subname:e.data.subname??null,value:e.value??e.data.value??null,specialValueA:e.data.specialValueA??null,specialValueB:e.data.specialValueB??null,depth:e.depth,path:e.ancestors().map(e=>e.data.name).reverse(),childrenCount:e.children?.length??0,data:e.data}),[]),[le,ue]=(0,c.useState)(`0 -${r/2} ${n} ${r}`),[de,fe]=(0,c.useState)(1),pe=(0,c.useRef)(null),me=(0,c.useMemo)(()=>{if(de===1)return le;let[e,t,n,r]=le.split(` `).map(Number),i=n/de,a=r/de;return`${e+(n-i)/2} ${t+(r-a)/2} ${i} ${a}`},[le,de]);(0,c.useLayoutEffect)(()=>{let e=pe.current;if(!e)return;let t=requestAnimationFrame(()=>{try{let t=e.getBBox();ue(`${t.x-24} ${t.y-24} ${t.width+48} ${t.height+48}`)}catch{ue(`0 -${r/2} ${n} ${r}`)}});return()=>cancelAnimationFrame(t)},[K,n,r,t]);let he=(0,c.useCallback)(e=>{if(!_||T||!e.ctrlKey)return;e.preventDefault();let t=e.deltaY<0?1.15:1/1.15;fe(e=>Math.max(.25,Math.min(8,e*t)))},[_,T]),ge=(0,c.useRef)(null),_e=e=>{ge.current&&=(clearTimeout(ge.current),null),ge.current=setTimeout(()=>{e(),ge.current=null},250)},ve=()=>{ge.current&&=(clearTimeout(ge.current),null)};(0,c.useEffect)(()=>()=>ve(),[]);let ye=(0,c.useCallback)(()=>{B(e=>{if(e.length<=1)return e;let t=e.slice(0,-1);return b?.({focusedNode:{id:t[t.length-1].id??null,name:t[t.length-1].name,subname:t[t.length-1].subname??null,value:null,specialValueA:null,specialValueB:null,depth:t.length-1,path:t.map(e=>e.name),childrenCount:t[t.length-1].children?.length??0,data:t[t.length-1]},isRoot:t.length<=1}),t})},[b]);(0,c.useLayoutEffect)(()=>{if(!_&&!y)return;let t=t=>{t.key===`Escape`&&(_&&fe(1),y&&(ve(),B([e]),b?.({focusedNode:{id:e.id??null,name:e.name,subname:e.subname??null,value:null,specialValueA:null,specialValueB:null,depth:0,path:[e.name],childrenCount:e.children?.length??0,data:e},isRoot:!0})))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[_,y,e,b]);let be=(0,c.useRef)(null),xe=(0,c.useRef)(null),[Se,Ce]=(0,c.useState)(!1),[we,Te]=(0,c.useState)(null),[Ee,De]=(0,c.useState)({left:0,top:0}),[Oe,ke]=(0,c.useState)(null),Ae=(e,t)=>{if(T)return;let n=ce(e);if((t.ctrlKey||t.metaKey)&&y&&e.children){_e(()=>{B(t=>[...t,e.data]),b?.({focusedNode:n,isRoot:!1})});return}if((t.ctrlKey||t.metaKey)&&y){ve(),ye();return}if(x){let e=be.current?.getBoundingClientRect();De({left:e?t.clientX-e.left:t.clientX,top:e?t.clientY-e.top:t.clientY}),Te(xe.current),ke(n),Ce(!0)}C?.(n,t)},je=(e,t)=>{T||!y||(t.ctrlKey||t.metaKey)&&(ve(),ye())},Me={followCursor:!0,enterDelay:50,enterNextDelay:0,disableHoverListener:T,slotProps:{tooltip:{sx:{maxWidth:240}}}},Ne=Math.round(a*1.3);return(0,v.jsxs)(l.Box,{ref:be,sx:{display:`inline-flex`,position:`relative`,opacity:T?.5:1,cursor:T?`not-allowed`:`default`,userSelect:`none`},children:[(0,v.jsx)(l.Box,{ref:xe,sx:{position:`absolute`,left:Ee.left,top:Ee.top,width:0,height:0}}),y&&z.length>1&&(0,v.jsx)(l.Box,{sx:{position:`absolute`,top:4,left:0,right:0,display:`flex`,justifyContent:`center`,pointerEvents:`none`,zIndex:1},children:(0,v.jsx)(l.Typography,{variant:`caption`,sx:{bgcolor:`action.hover`,borderRadius:1,px:1,py:.25,color:`text.secondary`,fontSize:`0.7rem`},children:z.map(e=>e.name).join(` › `)})}),(0,v.jsx)(`svg`,{width:n,height:r,viewBox:me,onWheel:he,style:{fontFamily:P??`sans-serif`,overflow:_&&de>1?`hidden`:`visible`},role:`img`,"aria-label":e.name,children:(0,v.jsxs)(`g`,{ref:pe,children:[F&&(0,v.jsx)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fill:j,children:O.noData}),(0,v.jsx)(`g`,{fill:`none`,stroke:M,strokeOpacity:m,strokeWidth:h,children:Y.map((e,t)=>(0,v.jsx)(`path`,{d:se(e)},`link-${t}`))}),J.map((e,n)=>{let r=oe(e),i=ae(e),o=ce(e),c=e.children?Wr.folder:Wr.person,d=t===`LR`,p=t===`RL`,m=d?a+6:p?-(a+6):0,h=!d&&!p?t===`TB`?a+16:-(a+6):0,g=d?`start`:p?`end`:`middle`,_=(0,v.jsxs)(l.Box,{sx:{py:.5,minWidth:140},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{fontWeight:`bold`,display:`block`,fontSize:`0.8rem`},children:e.data.name}),e.data.subname&&(0,v.jsx)(l.Typography,{variant:`caption`,sx:{display:`block`,opacity:.85},children:e.data.subname}),(o.specialValueA!=null||o.specialValueB!=null||e.children)&&(0,v.jsxs)(l.Box,{sx:{mt:.75,borderTop:`1px solid rgba(255,255,255,0.2)`,pt:.75},children:[o.specialValueA!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:O.specialValueA??`A`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueA)})]}),o.specialValueB!=null&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:O.specialValueB??`B`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:String(o.specialValueB)})]}),e.children&&(0,v.jsxs)(l.Box,{sx:{display:`flex`,justifyContent:`space-between`,gap:2},children:[(0,v.jsx)(l.Typography,{variant:`caption`,sx:{opacity:.6},children:`Reports`}),(0,v.jsx)(l.Typography,{variant:`caption`,children:e.children.length})]})]})]});return(0,v.jsx)(l.Tooltip,{...Me,title:_,children:(0,v.jsxs)(`g`,{transform:`translate(${r.x},${r.y})`,onClick:t=>Ae(e,t),onDoubleClick:t=>je(e,t),style:{cursor:T?`not-allowed`:`pointer`},children:[(0,v.jsx)(`circle`,{r:a+8,fill:`transparent`}),(0,v.jsx)(`circle`,{r:a+2,fill:i,fillOpacity:.15}),(0,v.jsx)(`circle`,{r:a,fill:i}),f&&(0,v.jsx)(Gr,{path:c,size:Ne}),s&&(0,v.jsx)(`text`,{x:m,y:h,dy:`0.35em`,textAnchor:g,fontSize:u,fontWeight:e.children?`bold`:`normal`,fill:e.data.colorConfig?.textColor??j,paintOrder:`stroke`,stroke:N,strokeWidth:3,pointerEvents:`none`,children:e.data.name})]})},`node-${n}`)}),te&&((e,t)=>(0,v.jsxs)(`g`,{"data-testid":`drill-ghost-layer`,opacity:t,pointerEvents:`none`,children:[(0,v.jsx)(`g`,{fill:`none`,stroke:M,strokeOpacity:m,strokeWidth:h,children:e.links().map((e,t)=>(0,v.jsx)(`path`,{d:se(e)},`ghost-link-${t}`))}),(0,v.jsx)(`g`,{children:e.descendants().map((e,t)=>{let n=oe(e);return(0,v.jsxs)(`g`,{transform:`translate(${n.x},${n.y})`,children:[(0,v.jsx)(`circle`,{r:a+2,fill:ae(e),fillOpacity:.15}),(0,v.jsx)(`circle`,{r:a,fill:ae(e)}),f&&(0,v.jsx)(Gr,{path:e.children?Wr.folder:Wr.person,size:Ne})]},`ghost-node-${t}`)})})]}))(te,re)]})}),x&&(0,v.jsx)(l.Popover,{open:Se,anchorEl:we,onClose:()=>Ce(!1),anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`left`},slotProps:{paper:{elevation:4}},children:Oe&&(S?S(Oe):(0,v.jsx)(Kr,{info:Oe,labelA:O.specialValueA??`Value A`,labelB:O.specialValueB??`Value B`}))})]})}qr.displayName=`HorizontalTreeChart`,exports.ChordChart=Nr,exports.CirclePackingChart=Hr,exports.DEFAULT_CHECK_COLORS=bn,exports.DEFAULT_CHORD_CHART_TRANSLATION=kr,exports.DEFAULT_CIRCLE_PACKING_TRANSLATION=zr,exports.DEFAULT_GANTT_TRANSLATIONS=kt,exports.DEFAULT_HORIZONTAL_TREE_TRANSLATION=Ur,exports.DEFAULT_JSON_EDITOR_TOOLBAR_CONFIG=Me,exports.DEFAULT_JSON_EDITOR_TRANSLATION=Ne,exports.DEFAULT_METER_COLORS=yn,exports.DEFAULT_PASSWORD_TRANSLATIONS=vn,exports.DEFAULT_RADIAL_TREE_CHART_TRANSLATION=Pr,exports.DEFAULT_RICH_TEXT_EDITOR_TOOLBAR_CONFIG=Bn,exports.DEFAULT_RICH_TEXT_EDITOR_TRANSLATION=Vn,exports.DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG=ir,exports.DEFAULT_SQL_EDITOR_TRANSLATION=ar,exports.DEFAULT_SUNBURST_CHART_TRANSLATION=br,exports.DEFAULT_TAG_SELECTION_TRANSLATION=Fn,exports.GanttChart=mn,exports.HorizontalTreeChart=qr,exports.JsonEditor=it,exports.PasswordStrengthMeter=Cn,exports.RadialTreeChart=Rr,exports.RichTextEditor=rr,exports.SqlEditor=yr,exports.SunburstChart=Or,exports.TagSelection=zn,exports.useGanttChartStore=$,exports.useGanttTheme=ln,exports.useGanttTranslations=sn,exports.useRawGanttChartStore=an;
|