Files
mission-control-v2/frontend/dist/assets/CommandPalette-BsUl2rJn.js
T
HitonabiandClaude Opus 5 5aa5a484a7 feat(frontend): v3-Umbau P3 — ein Store, eine Statusleiste, endlich aria-live
Vierte Etappe. Der Client-Zustand hatte bisher keinen Ort: zwei handgebaute
useSyncExternalStore-Speicher, drei CustomEvent-Kanaele und ein localStorage-Griff
mitten in einem useState — verteilt ueber fuenf Dateien.

## Ein Store (Befund B-08/B-09)

app/store.ts (Zustand, 1,2 kB gzip) haelt genau vier Dinge: Bedienvorlieben
(Schiene, Expertenmodus, Palette), die Lage des Ereignisstroms und die
Meldungs-Warteschlange. Der Kopfkommentar nennt die Regel, nach der etwas dort
landen darf — und ein Test prueft sie: gespeichert werden AUSSCHLIESSLICH
Schienen- und Expertenmodus-Zustand, kein Strom, keine Meldungen, kein Geheimnis.

Der Metrik-Verlauf bleibt bewusst DRAUSSEN (lib/metricsStore.ts): Er nimmt ab P4
jede Sekunde einen Messpunkt entgegen, ein Store-Update pro Sekunde wuerde jede
abonnierende Komponente neu rendern.

Die drei CustomEvent-Kanaele sind ERSATZLOS weg — `grep -r dispatchEvent src`
liefert nichts mehr. Wer die Schublade oeffnen will, setzt `?system=`; wer springen
will, navigiert. Auch der letzte Rest von P2 (`mc-palette-open`) ist aufgeloest.

## Statusleiste (Spezifikation §4.1)

Der Zustand der Box stand bisher verstreut: die Ampel unten in der Sidebar, die
Auslastung nur im Cockpit, das aktive Modell nur im Modell-Manager. Wer in der
Konsole arbeitete, sah gar nichts.

Jetzt eine feste Leiste ueber allen Ansichten: Motor/Hirn-Ampel (klickbar zum
Agenten) · aktive Rolle + Durchsatz mit Sparkline · geteilter Speicher ALS BALKEN
(nicht als Prozent — 128 GB Unified Memory ist die Kernzahl dieser Box) · CPU/GPU
· Temperatur (ab 85 °C bernstein) · Betriebszeit · Token-Summe · Live-Anzeige.

Die Sparklines sind eigenes SVG, ~20 Zeilen. Fuer eine 56-Pixel-Linie waere eine
Diagramm-Bibliothek Verschwendung.

Dafuer neu im Backend: `uptime_s` in /api/system/status (psutil.boot_time).
Gehoert dorthin, weil die Box sich woechentlich selbst neu startet — dann ist
"laeuft seit 20 Minuten" die Antwort auf eine ganze Klasse von Fragen.
Liefert psutil nichts, steht dort None und die Leiste blendet das Feld aus,
statt eine Zahl zu erfinden.

## aria-live (Befund B-11) — und diesmal mit Absender

Im ganzen Frontend gab es KEIN einziges aria-live. app/shell/Meldungen.tsx ist
jetzt die eine Stelle fuer beilaeufige Rueckmeldungen; Fehler bekommen
`assertive` und bleiben stehen, alles andere `polite` und raeumt sich weg.

Wichtig: Die Region ist keine Attrappe. Gespeist wird sie von den Uebergaengen des
Ereignisstroms und vom Konsolen-Neustart (mit dem echten Grund aus ApiError.detail).
Der erste Verbindungsaufbau wird bewusst NICHT gemeldet — sonst begruesst jede
Seite den Nutzer mit "Verbindung wieder da".

## Ehrliche Anzeige statt stillem Altern (Befund B-15/B-18)

lib/events.ts fuehrt die Stromlage jetzt im Store: live · nachlauf · getrennt.
Beim Wechsel wird EINMAL invalidiert — vorher las relax() den Zustand erst beim
naechsten Refetch, nach einem Riss blieb die UI bis zu 150 s im langsamen Modus.

## Bahnbreiten-Deckel (Befund B-10)

Die Arbeitsflaeche endet bei 1600 px. Ohne Deckel zog sich das Cockpit auf einem
3440-px-Ultrawide auf ueber 3 000 px, waehrend die Wurzel-Schriftgroesse mitwuchs
und die Zeilen GROESSER statt lesbarer machte.

## Nebenbei

Der Buendel-Budget-Check aus P0 war fragil: `ls dist/assets/index-*.js | head -1`
kann den falschen treffen, weil Rollup auch kleine geteilte Module "index-*.js"
nennt (gemessen: ein 67-Byte-Chunk neben dem 374-kB-Einstieg). Er waere dann still
immer gruen gewesen. Beide Ampel-Dateien lesen den Einstieg jetzt aus index.html.

## Verifiziert im Browser

  Statusleiste: alle Felder mit Live-Daten, "Laeuft seit 1 Std 10 min"
  Backend abgewuergt  -> Leiste springt auf "Nachlauf" UND die aria-live-Region
                         meldet "Verbindung zur Zentrale verloren" (polite)
  Backend zurueck     -> "Live", ohne Begruessungs-Meldung
  Cockpit-Kachel      -> /cockpit?system=logs, Schublade offen, Reiter "System-Logs"
  Arbeitsflaeche      -> max-width 1600 px

33/33 Tests gruen (7 neue fuer den Store) · ESLint 0 Fehler · tsc sauber ·
Einstieg 118 153 B gzip / Budget 125 000.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 09:07:09 +02:00

42 lines
46 KiB
JavaScript

import{r as a,j as C,as as Be,z as Gt,at as qt}from"./index-CB2Jz083.js";import{r as mt}from"./index-BgjhTkvl.js";var qe=1,Zt=.9,Qt=.8,Jt=.17,Pe=.1,Oe=.999,en=.9999,tn=.99,nn=/[\\\/_+.#"@\[\(\{&]/,rn=/[\\\/_+.#"@\[\(\{&]/g,on=/[\s-]/,pt=/[\s-]/g;function Fe(e,t,n,r,o,i,u){if(i===t.length)return o===e.length?qe:tn;var c=`${o},${i}`;if(u[c]!==void 0)return u[c];for(var v=r.charAt(i),s=n.indexOf(v,o),l=0,d,h,p,S;s>=0;)d=Fe(e,t,n,r,s+1,i+1,u),d>l&&(s===o?d*=qe:nn.test(e.charAt(s-1))?(d*=Qt,p=e.slice(o,s-1).match(rn),p&&o>0&&(d*=Math.pow(Oe,p.length))):on.test(e.charAt(s-1))?(d*=Zt,S=e.slice(o,s-1).match(pt),S&&o>0&&(d*=Math.pow(Oe,S.length))):(d*=Jt,o>0&&(d*=Math.pow(Oe,s-o))),e.charAt(s)!==t.charAt(i)&&(d*=en)),(d<Pe&&n.charAt(s-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(s-1)!==r.charAt(i))&&(h=Fe(e,t,n,r,s+1,i+2,u),h*Pe>d&&(d=h*Pe)),d>l&&(l=d),s=n.indexOf(v,s+1);return u[c]=l,l}function Ze(e){return e.toLowerCase().replace(pt," ")}function an(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Fe(e,t,Ze(e),Ze(t),0,0,{})}function z(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Qe(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function re(...e){return t=>{let n=!1;const r=e.map(o=>{const i=Qe(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():Qe(e[o],null)}}}}function X(...e){return a.useCallback(re(...e),e)}function cn(e,t=[]){let n=[];function r(i,u){const c=a.createContext(u);c.displayName=i+"Context";const v=n.length;n=[...n,u];const s=d=>{var w;const{scope:h,children:p,...S}=d,m=((w=h==null?void 0:h[e])==null?void 0:w[v])||c,g=a.useMemo(()=>S,Object.values(S));return C.jsx(m.Provider,{value:g,children:p})};s.displayName=i+"Provider";function l(d,h){var m;const p=((m=h==null?void 0:h[e])==null?void 0:m[v])||c,S=a.useContext(p);if(S)return S;if(u!==void 0)return u;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[s,l]}const o=()=>{const i=n.map(u=>a.createContext(u));return function(c){const v=(c==null?void 0:c[e])||i;return a.useMemo(()=>({[`__scope${e}`]:{...c,[e]:v}}),[c,v])}};return o.scopeName=e,[r,un(o,...t)]}function un(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const u=r.reduce((c,{useScope:v,scopeName:s})=>{const d=v(i)[`__scope${s}`];return{...c,...d}},{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])}};return n.scopeName=t.scopeName,n}var ce=globalThis!=null&&globalThis.document?a.useLayoutEffect:()=>{},sn=Be[" useId ".trim().toString()]||(()=>{}),ln=0;function K(e){const[t,n]=a.useState(sn());return ce(()=>{n(r=>r??String(ln++))},[e]),t?`radix-${t}`:""}var dn=Be[" useInsertionEffect ".trim().toString()]||ce;function fn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,u]=vn({defaultProp:t,onChange:n}),c=e!==void 0,v=c?e:o;{const l=a.useRef(e!==void 0);a.useEffect(()=>{const d=l.current;d!==c&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),l.current=c},[c,r])}const s=a.useCallback(l=>{var d;if(c){const h=mn(l)?l(e):l;h!==e&&((d=u.current)==null||d.call(u,h))}else i(l)},[c,e,i,u]);return[v,s]}function vn({defaultProp:e,onChange:t}){const[n,r]=a.useState(e),o=a.useRef(n),i=a.useRef(t);return dn(()=>{i.current=t},[t]),a.useEffect(()=>{var u;o.current!==n&&((u=i.current)==null||u.call(i,n),o.current=n)},[n,o]),[n,r,i]}function mn(e){return typeof e=="function"}function ht(e){const t=a.forwardRef((n,r)=>{let{children:o,...i}=n,u=null,c=!1;const v=[];Je(o)&&typeof de=="function"&&(o=de(o._payload)),a.Children.forEach(o,h=>{var p;if(bn(h)){c=!0;const S=h;let m="child"in S.props?S.props.child:S.props.children;Je(m)&&typeof de=="function"&&(m=de(m._payload)),u=hn(S,m),v.push((p=u==null?void 0:u.props)==null?void 0:p.children)}else v.push(h)}),u?u=a.cloneElement(u,void 0,v):!c&&a.Children.count(o)===1&&a.isValidElement(o)&&(u=o);const s=u?yn(u):void 0,l=X(r,s);if(!u){if(o||o===0)throw new Error(c?Cn(e):Sn(e));return o}const d=gn(i,u.props??{});return u.type!==a.Fragment&&(d.ref=r?l:s),a.cloneElement(u,d)});return t.displayName=`${e}.Slot`,t}var pn=Symbol.for("radix.slottable"),hn=(e,t)=>{if("child"in e.props){const n=e.props.child;return a.isValidElement(n)?a.cloneElement(n,void 0,e.props.children(n.props.children)):null}return a.isValidElement(t)?t:null};function gn(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...c)=>{const v=i(...c);return o(...c),v}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function yn(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function bn(e){return a.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pn}var En=Symbol.for("react.lazy");function Je(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===En&&"_payload"in e&&wn(e._payload)}function wn(e){return typeof e=="object"&&e!==null&&"then"in e}var Sn=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Cn=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,de=Be[" use ".trim().toString()],Rn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],M=Rn.reduce((e,t)=>{const n=ht(`Primitive.${t}`),r=a.forwardRef((o,i)=>{const{asChild:u,...c}=o,v=u?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),C.jsx(v,{...c,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function xn(e,t){e&&mt.flushSync(()=>e.dispatchEvent(t))}function ue(e){const t=a.useRef(e);return a.useEffect(()=>{t.current=e}),a.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}function Dn(e,t=globalThis==null?void 0:globalThis.document){const n=ue(e);a.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Pn="DismissableLayer",_e="dismissableLayer.update",On="dismissableLayer.pointerDownOutside",Nn="dismissableLayer.focusOutside",et,$e=a.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),gt=a.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:u,onInteractOutside:c,onDismiss:v,...s}=e,l=a.useContext($e),[d,h]=a.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,S]=a.useState({}),m=X(t,A=>h(A)),g=Array.from(l.layers),[w]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(w),R=d?g.indexOf(d):-1,O=l.layersWithOutsidePointerEventsDisabled.size>0,x=R>=b,D=a.useRef(!1),I=Mn(A=>{const F=A.target;if(!(F instanceof Node))return;const _=[...l.branches].some(W=>W.contains(F));!x||_||(i==null||i(A),c==null||c(A),A.defaultPrevented||v==null||v())},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:D,dismissableSurfaces:l.dismissableSurfaces}),U=Tn(A=>{if(r&&D.current)return;const F=A.target;[...l.branches].some(W=>W.contains(F))||(u==null||u(A),c==null||c(A),A.defaultPrevented||v==null||v())},p);return Dn(A=>{R===l.layers.size-1&&(o==null||o(A),!A.defaultPrevented&&v&&(A.preventDefault(),v()))},p),a.useEffect(()=>{if(d)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(et=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),tt(),()=>{n&&(l.layersWithOutsidePointerEventsDisabled.delete(d),l.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=et))}},[d,p,n,l]),a.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),tt())},[d,l]),a.useEffect(()=>{const A=()=>S({});return document.addEventListener(_e,A),()=>document.removeEventListener(_e,A)},[]),C.jsx(M.div,{...s,ref:m,style:{pointerEvents:O?x?"auto":"none":void 0,...e.style},onFocusCapture:z(e.onFocusCapture,U.onFocusCapture),onBlurCapture:z(e.onBlurCapture,U.onBlurCapture),onPointerDownCapture:z(e.onPointerDownCapture,I.onPointerDownCapture)})});gt.displayName=Pn;var In="DismissableLayerBranch",An=a.forwardRef((e,t)=>{const n=a.useContext($e),r=a.useRef(null),o=X(t,r);return a.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),C.jsx(M.div,{...e,ref:o})});An.displayName=In;function kn(){const e=a.useContext($e),[t,n]=a.useState(null);return a.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function Mn(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i}=t,u=ue(e),c=a.useRef(!1),v=a.useRef(!1),s=a.useRef(new Map),l=a.useRef(()=>{});return a.useEffect(()=>{function d(){v.current=!1,o.current=!1,s.current.clear()}function h(){return Array.from(s.current.values()).some(Boolean)}function p(b){if(!v.current)return;const R=b.target;R instanceof Node&&[...i].some(x=>x.contains(R))||s.current.set(b.type,!0),b.type==="click"&&window.setTimeout(()=>{v.current&&l.current()},0)}function S(b){v.current&&s.current.set(b.type,!1)}const m=b=>{if(b.target&&!c.current){let R=function(){n.removeEventListener("click",l.current);const x=h();d(),x||yt(On,u,O,{discrete:!0})};const O={originalEvent:b};v.current=!0,o.current=r&&b.button===0,s.current.clear(),!r||b.button!==0?R():(n.removeEventListener("click",l.current),l.current=R,n.addEventListener("click",l.current,{once:!0}))}else n.removeEventListener("click",l.current),d();c.current=!1},g=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const b of g)n.addEventListener(b,p,!0),n.addEventListener(b,S);const w=window.setTimeout(()=>{n.addEventListener("pointerdown",m)},0);return()=>{window.clearTimeout(w),n.removeEventListener("pointerdown",m),n.removeEventListener("click",l.current);for(const b of g)n.removeEventListener(b,p,!0),n.removeEventListener(b,S)}},[n,u,r,o,i]),{onPointerDownCapture:()=>c.current=!0}}function Tn(e,t=globalThis==null?void 0:globalThis.document){const n=ue(e),r=a.useRef(!1);return a.useEffect(()=>{const o=i=>{i.target&&!r.current&&yt(Nn,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function tt(){const e=new CustomEvent(_e);document.dispatchEvent(e)}function yt(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?xn(o,i):o.dispatchEvent(i)}var Ne="focusScope.autoFocusOnMount",Ie="focusScope.autoFocusOnUnmount",nt={bubbles:!1,cancelable:!0},Ln="FocusScope",bt=a.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...u}=e,[c,v]=a.useState(null),s=ue(o),l=ue(i),d=a.useRef(null),h=X(t,m=>v(m)),p=a.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;a.useEffect(()=>{if(r){let m=function(R){if(p.paused||!c)return;const O=R.target;c.contains(O)?d.current=O:V(d.current,{select:!0})},g=function(R){if(p.paused||!c)return;const O=R.relatedTarget;O!==null&&(c.contains(O)||V(d.current,{select:!0}))},w=function(R){if(document.activeElement===document.body)for(const x of R)x.removedNodes.length>0&&V(c)};document.addEventListener("focusin",m),document.addEventListener("focusout",g);const b=new MutationObserver(w);return c&&b.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",g),b.disconnect()}}},[r,c,p.paused]),a.useEffect(()=>{if(c){ot.add(p);const m=document.activeElement;if(!c.contains(m)){const w=new CustomEvent(Ne,nt);c.addEventListener(Ne,s),c.dispatchEvent(w),w.defaultPrevented||(Fn($n(Et(c)),{select:!0}),document.activeElement===m&&V(c))}return()=>{c.removeEventListener(Ne,s),setTimeout(()=>{const w=new CustomEvent(Ie,nt);c.addEventListener(Ie,l),c.dispatchEvent(w),w.defaultPrevented||V(m??document.body,{select:!0}),c.removeEventListener(Ie,l),ot.remove(p)},0)}}},[c,s,l,p]);const S=a.useCallback(m=>{if(!n&&!r||p.paused)return;const g=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,w=document.activeElement;if(g&&w){const b=m.currentTarget,[R,O]=_n(b);R&&O?!m.shiftKey&&w===O?(m.preventDefault(),n&&V(R,{select:!0})):m.shiftKey&&w===R&&(m.preventDefault(),n&&V(O,{select:!0})):w===b&&m.preventDefault()}},[n,r,p.paused]);return C.jsx(M.div,{tabIndex:-1,...u,ref:h,onKeyDown:S})});bt.displayName=Ln;function Fn(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(V(r,{select:t}),document.activeElement!==n)return}function _n(e){const t=Et(e),n=rt(t,e),r=rt(t.reverse(),e);return[n,r]}function Et(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function rt(e,t){for(const n of e)if(!jn(n,{upTo:t}))return n}function jn(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Wn(e){return e instanceof HTMLInputElement&&"select"in e}function V(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wn(e)&&t&&e.select()}}var ot=Bn();function Bn(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=at(e,t),e.unshift(t)},remove(t){var n;e=at(e,t),(n=e[0])==null||n.resume()}}}function at(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function $n(e){return e.filter(t=>t.tagName!=="A")}var Un="Portal",wt=a.forwardRef((e,t)=>{var c;const{container:n,...r}=e,[o,i]=a.useState(!1);ce(()=>i(!0),[]);const u=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return u?mt.createPortal(C.jsx(M.div,{...r,ref:t}),u):null});wt.displayName=Un;function Kn(e,t){return a.useReducer((n,r)=>t[n][r]??n,e)}var we=e=>{const{present:t,children:n}=e,r=Vn(t),o=typeof n=="function"?n({present:r.isPresent}):a.Children.only(n),i=zn(r.ref,Yn(o));return typeof n=="function"||r.isPresent?a.cloneElement(o,{ref:i}):null};we.displayName="Presence";function Vn(e){const[t,n]=a.useState(),r=a.useRef(null),o=a.useRef(e),i=a.useRef("none"),u=e?"mounted":"unmounted",[c,v]=Kn(u,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return a.useEffect(()=>{const s=fe(r.current);i.current=c==="mounted"?s:"none"},[c]),ce(()=>{const s=r.current,l=o.current;if(l!==e){const h=i.current,p=fe(s);e?v("MOUNT"):p==="none"||(s==null?void 0:s.display)==="none"?v("UNMOUNT"):v(l&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,v]),ce(()=>{if(t){let s;const l=t.ownerDocument.defaultView??window,d=p=>{const m=fe(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&m&&(v("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",s=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(i.current=fe(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{l.clearTimeout(s),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else v("ANIMATION_END")},[t,v]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:a.useCallback(s=>{r.current=s?getComputedStyle(s):null,n(s)},[])}}function it(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function zn(...e){const t=a.useRef(e);return t.current=e,a.useCallback(n=>{const r=t.current;let o=!1;const i=r.map(u=>{const c=it(u,n);return!o&&typeof c=="function"&&(o=!0),c});if(o)return()=>{for(let u=0;u<i.length;u++){const c=i[u];typeof c=="function"?c():it(r[u],null)}}},[])}function fe(e){return(e==null?void 0:e.animationName)||"none"}function Yn(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ve=0,B=null;function Hn(){a.useEffect(()=>{B||(B={start:ct(),end:ct()});const{start:e,end:t}=B;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ve++,()=>{ve===1&&(B==null||B.start.remove(),B==null||B.end.remove(),B=null),ve=Math.max(0,ve-1)}},[])}function ct(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var $=function(){return $=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},$.apply(this,arguments)};function St(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Xn(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var ye="right-scroll-bar-position",be="width-before-scroll-bar",Gn="with-scroll-bars-hidden",qn="--removed-body-scroll-bar-size";function Ae(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Zn(e,t){var n=a.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Qn=typeof window<"u"?a.useLayoutEffect:a.useEffect,ut=new WeakMap;function Jn(e,t){var n=Zn(null,function(r){return e.forEach(function(o){return Ae(o,r)})});return Qn(function(){var r=ut.get(n);if(r){var o=new Set(r),i=new Set(e),u=n.current;o.forEach(function(c){i.has(c)||Ae(c,null)}),i.forEach(function(c){o.has(c)||Ae(c,u)})}ut.set(n,e)},[e]),n}function er(e){return e}function tr(e,t){t===void 0&&(t=er);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var u=t(i,r);return n.push(u),function(){n=n.filter(function(c){return c!==u})}},assignSyncMedium:function(i){for(r=!0;n.length;){var u=n;n=[],u.forEach(i)}n={push:function(c){return i(c)},filter:function(){return n}}},assignMedium:function(i){r=!0;var u=[];if(n.length){var c=n;n=[],c.forEach(i),u=n}var v=function(){var l=u;u=[],l.forEach(i)},s=function(){return Promise.resolve().then(v)};s(),n={push:function(l){u.push(l),s()},filter:function(l){return u=u.filter(l),n}}}};return o}function nr(e){e===void 0&&(e={});var t=tr(null);return t.options=$({async:!0,ssr:!1},e),t}var Ct=function(e){var t=e.sideCar,n=St(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return a.createElement(r,$({},n))};Ct.isSideCarExport=!0;function rr(e,t){return e.useMedium(t),Ct}var Rt=nr(),ke=function(){},Se=a.forwardRef(function(e,t){var n=a.useRef(null),r=a.useState({onScrollCapture:ke,onWheelCapture:ke,onTouchMoveCapture:ke}),o=r[0],i=r[1],u=e.forwardProps,c=e.children,v=e.className,s=e.removeScrollBar,l=e.enabled,d=e.shards,h=e.sideCar,p=e.noRelative,S=e.noIsolation,m=e.inert,g=e.allowPinchZoom,w=e.as,b=w===void 0?"div":w,R=e.gapMode,O=St(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=h,D=Jn([n,t]),I=$($({},O),o);return a.createElement(a.Fragment,null,l&&a.createElement(x,{sideCar:Rt,removeScrollBar:s,shards:d,noRelative:p,noIsolation:S,inert:m,setCallbacks:i,allowPinchZoom:!!g,lockRef:n,gapMode:R}),u?a.cloneElement(a.Children.only(c),$($({},I),{ref:D})):a.createElement(b,$({},I,{className:v,ref:D}),c))});Se.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Se.classNames={fullWidth:be,zeroRight:ye};var or=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ar(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=or();return t&&e.setAttribute("nonce",t),e}function ir(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function cr(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ur=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ar())&&(ir(t,n),cr(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},sr=function(){var e=ur();return function(t,n){a.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},xt=function(){var e=sr(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},lr={left:0,top:0,right:0,gap:0},Me=function(e){return parseInt(e||"",10)||0},dr=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Me(n),Me(r),Me(o)]},fr=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return lr;var t=dr(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},vr=xt(),ne="data-scroll-locked",mr=function(e,t,n,r){var o=e.left,i=e.top,u=e.right,c=e.gap;return n===void 0&&(n="margin"),`
.`.concat(Gn,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(c,"px ").concat(r,`;
}
body[`).concat(ne,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(o,`px;
padding-top: `).concat(i,`px;
padding-right: `).concat(u,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(c,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(ye,` {
right: `).concat(c,"px ").concat(r,`;
}
.`).concat(be,` {
margin-right: `).concat(c,"px ").concat(r,`;
}
.`).concat(ye," .").concat(ye,` {
right: 0 `).concat(r,`;
}
.`).concat(be," .").concat(be,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(ne,`] {
`).concat(qn,": ").concat(c,`px;
}
`)},st=function(){var e=parseInt(document.body.getAttribute(ne)||"0",10);return isFinite(e)?e:0},pr=function(){a.useEffect(function(){return document.body.setAttribute(ne,(st()+1).toString()),function(){var e=st()-1;e<=0?document.body.removeAttribute(ne):document.body.setAttribute(ne,e.toString())}},[])},hr=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;pr();var i=a.useMemo(function(){return fr(o)},[o]);return a.createElement(vr,{styles:mr(i,!t,o,n?"":"!important")})},je=!1;if(typeof window<"u")try{var me=Object.defineProperty({},"passive",{get:function(){return je=!0,!0}});window.addEventListener("test",me,me),window.removeEventListener("test",me,me)}catch{je=!1}var q=je?{passive:!1}:!1,gr=function(e){return e.tagName==="TEXTAREA"},Dt=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!gr(e)&&n[t]==="visible")},yr=function(e){return Dt(e,"overflowY")},br=function(e){return Dt(e,"overflowX")},lt=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Pt(e,r);if(o){var i=Ot(e,r),u=i[1],c=i[2];if(u>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Er=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},wr=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Pt=function(e,t){return e==="v"?yr(t):br(t)},Ot=function(e,t){return e==="v"?Er(t):wr(t)},Sr=function(e,t){return e==="h"&&t==="rtl"?-1:1},Cr=function(e,t,n,r,o){var i=Sr(e,window.getComputedStyle(t).direction),u=i*r,c=n.target,v=t.contains(c),s=!1,l=u>0,d=0,h=0;do{if(!c)break;var p=Ot(e,c),S=p[0],m=p[1],g=p[2],w=m-g-i*S;(S||w)&&Pt(e,c)&&(d+=w,h+=S);var b=c.parentNode;c=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!v&&c!==document.body||v&&(t.contains(c)||t===c));return(l&&Math.abs(d)<1||!l&&Math.abs(h)<1)&&(s=!0),s},pe=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},dt=function(e){return[e.deltaX,e.deltaY]},ft=function(e){return e&&"current"in e?e.current:e},Rr=function(e,t){return e[0]===t[0]&&e[1]===t[1]},xr=function(e){return`
.block-interactivity-`.concat(e,` {pointer-events: none;}
.allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},Dr=0,Z=[];function Pr(e){var t=a.useRef([]),n=a.useRef([0,0]),r=a.useRef(),o=a.useState(Dr++)[0],i=a.useState(xt)[0],u=a.useRef(e);a.useEffect(function(){u.current=e},[e]),a.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var m=Xn([e.lockRef.current],(e.shards||[]).map(ft),!0).filter(Boolean);return m.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=a.useCallback(function(m,g){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!u.current.allowPinchZoom;var w=pe(m),b=n.current,R="deltaX"in m?m.deltaX:b[0]-w[0],O="deltaY"in m?m.deltaY:b[1]-w[1],x,D=m.target,I=Math.abs(R)>Math.abs(O)?"h":"v";if("touches"in m&&I==="h"&&D.type==="range")return!1;var U=window.getSelection(),A=U&&U.anchorNode,F=A?A===D||A.contains(D):!1;if(F)return!1;var _=lt(I,D);if(!_)return!0;if(_?x=I:(x=I==="v"?"h":"v",_=lt(I,D)),!_)return!1;if(!r.current&&"changedTouches"in m&&(R||O)&&(r.current=x),!x)return!0;var W=r.current||x;return Cr(W,g,m,W==="h"?R:O)},[]),v=a.useCallback(function(m){var g=m;if(!(!Z.length||Z[Z.length-1]!==i)){var w="deltaY"in g?dt(g):pe(g),b=t.current.filter(function(x){return x.name===g.type&&(x.target===g.target||g.target===x.shadowParent)&&Rr(x.delta,w)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var R=(u.current.shards||[]).map(ft).filter(Boolean).filter(function(x){return x.contains(g.target)}),O=R.length>0?c(g,R[0]):!u.current.noIsolation;O&&g.cancelable&&g.preventDefault()}}},[]),s=a.useCallback(function(m,g,w,b){var R={name:m,delta:g,target:w,should:b,shadowParent:Or(w)};t.current.push(R),setTimeout(function(){t.current=t.current.filter(function(O){return O!==R})},1)},[]),l=a.useCallback(function(m){n.current=pe(m),r.current=void 0},[]),d=a.useCallback(function(m){s(m.type,dt(m),m.target,c(m,e.lockRef.current))},[]),h=a.useCallback(function(m){s(m.type,pe(m),m.target,c(m,e.lockRef.current))},[]);a.useEffect(function(){return Z.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",v,q),document.addEventListener("touchmove",v,q),document.addEventListener("touchstart",l,q),function(){Z=Z.filter(function(m){return m!==i}),document.removeEventListener("wheel",v,q),document.removeEventListener("touchmove",v,q),document.removeEventListener("touchstart",l,q)}},[]);var p=e.removeScrollBar,S=e.inert;return a.createElement(a.Fragment,null,S?a.createElement(i,{styles:xr(o)}):null,p?a.createElement(hr,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Or(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Nr=rr(Rt,Pr);var Nt=a.forwardRef(function(e,t){return a.createElement(Se,$({},e,{ref:t,sideCar:Nr}))});Nt.classNames=Se.classNames;var Ir=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Q=new WeakMap,he=new WeakMap,ge={},Te=0,It=function(e){return e&&(e.host||It(e.parentNode))},Ar=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=It(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},kr=function(e,t,n,r){var o=Ar(t,Array.isArray(e)?e:[e]);ge[n]||(ge[n]=new WeakMap);var i=ge[n],u=[],c=new Set,v=new Set(o),s=function(d){!d||c.has(d)||(c.add(d),s(d.parentNode))};o.forEach(s);var l=function(d){!d||v.has(d)||Array.prototype.forEach.call(d.children,function(h){if(c.has(h))l(h);else try{var p=h.getAttribute(r),S=p!==null&&p!=="false",m=(Q.get(h)||0)+1,g=(i.get(h)||0)+1;Q.set(h,m),i.set(h,g),u.push(h),m===1&&S&&he.set(h,!0),g===1&&h.setAttribute(n,"true"),S||h.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",h,w)}})};return l(t),c.clear(),Te++,function(){u.forEach(function(d){var h=Q.get(d)-1,p=i.get(d)-1;Q.set(d,h),i.set(d,p),h||(he.has(d)||d.removeAttribute(r),he.delete(d)),p||d.removeAttribute(n)}),Te--,Te||(Q=new WeakMap,Q=new WeakMap,he=new WeakMap,ge={})}},Mr=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ir(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),kr(r,o,n,"aria-hidden")):function(){return null}},Ce="Dialog",[At]=cn(Ce),[Tr,j]=At(Ce),kt=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:u=!0}=e,c=a.useRef(null),v=a.useRef(null),[s,l]=fn({prop:r,defaultProp:o??!1,onChange:i,caller:Ce});return C.jsx(Tr,{scope:t,triggerRef:c,contentRef:v,contentId:K(),titleId:K(),descriptionId:K(),open:s,onOpenChange:l,onOpenToggle:a.useCallback(()=>l(d=>!d),[l]),modal:u,children:n})};kt.displayName=Ce;var Mt="DialogTrigger",Lr=a.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=j(Mt,n),i=X(t,o.triggerRef);return C.jsx(M.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":Ke(o.open),...r,ref:i,onClick:z(e.onClick,o.onOpenToggle)})});Lr.displayName=Mt;var Ue="DialogPortal",[Fr,Tt]=At(Ue,{forceMount:void 0}),Lt=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=j(Ue,t);return C.jsx(Fr,{scope:t,forceMount:n,children:a.Children.map(r,u=>C.jsx(we,{present:n||i.open,children:C.jsx(wt,{asChild:!0,container:o,children:u})}))})};Lt.displayName=Ue;var Ee="DialogOverlay",Ft=a.forwardRef((e,t)=>{const n=Tt(Ee,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=j(Ee,e.__scopeDialog);return i.modal?C.jsx(we,{present:r||i.open,children:C.jsx(jr,{...o,ref:t})}):null});Ft.displayName=Ee;var _r=ht("DialogOverlay.RemoveScroll"),jr=a.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=j(Ee,n),i=kn(),u=X(t,i);return C.jsx(Nt,{as:_r,allowPinchZoom:!0,shards:[o.contentRef],children:C.jsx(M.div,{"data-state":Ke(o.open),...r,ref:u,style:{pointerEvents:"auto",...r.style}})})}),oe="DialogContent",_t=a.forwardRef((e,t)=>{const n=Tt(oe,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=j(oe,e.__scopeDialog);return C.jsx(we,{present:r||i.open,children:i.modal?C.jsx(Wr,{...o,ref:t}):C.jsx(Br,{...o,ref:t})})});_t.displayName=oe;var Wr=a.forwardRef((e,t)=>{const n=j(oe,e.__scopeDialog),r=a.useRef(null),o=X(t,n.contentRef,r);return a.useEffect(()=>{const i=r.current;if(i)return Mr(i)},[]),C.jsx(jt,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:z(e.onCloseAutoFocus,i=>{var u;i.preventDefault(),(u=n.triggerRef.current)==null||u.focus()}),onPointerDownOutside:z(e.onPointerDownOutside,i=>{const u=i.detail.originalEvent,c=u.button===0&&u.ctrlKey===!0;(u.button===2||c)&&i.preventDefault()}),onFocusOutside:z(e.onFocusOutside,i=>i.preventDefault())})}),Br=a.forwardRef((e,t)=>{const n=j(oe,e.__scopeDialog),r=a.useRef(!1),o=a.useRef(!1);return C.jsx(jt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var u,c;(u=e.onCloseAutoFocus)==null||u.call(e,i),i.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var v,s;(v=e.onInteractOutside)==null||v.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const u=i.target;((s=n.triggerRef.current)==null?void 0:s.contains(u))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),jt=a.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...u}=e,c=j(oe,n);return Hn(),C.jsx(C.Fragment,{children:C.jsx(bt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:C.jsx(gt,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Ke(c.open),...u,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),Wt="DialogTitle",$r=a.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=j(Wt,n);return C.jsx(M.h2,{id:o.titleId,...r,ref:t})});$r.displayName=Wt;var Bt="DialogDescription",Ur=a.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=j(Bt,n);return C.jsx(M.p,{id:o.descriptionId,...r,ref:t})});Ur.displayName=Bt;var $t="DialogClose",Kr=a.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=j($t,n);return C.jsx(M.button,{type:"button",...r,ref:t,onClick:z(e.onClick,()=>o.onOpenChange(!1))})});Kr.displayName=$t;function Ke(e){return e?"open":"closed"}var ie='[cmdk-group=""]',Le='[cmdk-group-items=""]',Vr='[cmdk-group-heading=""]',Ut='[cmdk-item=""]',vt=`${Ut}:not([aria-disabled="true"])`,We="cmdk-item-select",ee="data-value",zr=(e,t,n)=>an(e,t,n),Kt=a.createContext(void 0),se=()=>a.useContext(Kt),Vt=a.createContext(void 0),Ve=()=>a.useContext(Vt),zt=a.createContext(void 0),Yt=a.forwardRef((e,t)=>{let n=te(()=>{var f,E;return{search:"",value:(E=(f=e.value)!=null?f:e.defaultValue)!=null?E:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=te(()=>new Set),o=te(()=>new Map),i=te(()=>new Map),u=te(()=>new Set),c=Ht(e),{label:v,children:s,value:l,onValueChange:d,filter:h,shouldFilter:p,loop:S,disablePointerSelection:m=!1,vimBindings:g=!0,...w}=e,b=K(),R=K(),O=K(),x=a.useRef(null),D=no();H(()=>{if(l!==void 0){let f=l.trim();n.current.value=f,I.emit()}},[l]),H(()=>{D(6,ze)},[]);let I=a.useMemo(()=>({subscribe:f=>(u.current.add(f),()=>u.current.delete(f)),snapshot:()=>n.current,setState:(f,E,P)=>{var y,N,k,L;if(!Object.is(n.current[f],E)){if(n.current[f]=E,f==="search")W(),F(),D(1,_);else if(f==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let T=document.getElementById(O);T?T.focus():(y=document.getElementById(b))==null||y.focus()}if(D(7,()=>{var T;n.current.selectedItemId=(T=G())==null?void 0:T.id,I.emit()}),P||D(5,ze),((N=c.current)==null?void 0:N.value)!==void 0){let T=E??"";(L=(k=c.current).onValueChange)==null||L.call(k,T);return}}I.emit()}},emit:()=>{u.current.forEach(f=>f())}}),[]),U=a.useMemo(()=>({value:(f,E,P)=>{var y;E!==((y=i.current.get(f))==null?void 0:y.value)&&(i.current.set(f,{value:E,keywords:P}),n.current.filtered.items.set(f,A(E,P)),D(2,()=>{F(),I.emit()}))},item:(f,E)=>(r.current.add(f),E&&(o.current.has(E)?o.current.get(E).add(f):o.current.set(E,new Set([f]))),D(3,()=>{W(),F(),n.current.value||_(),I.emit()}),()=>{i.current.delete(f),r.current.delete(f),n.current.filtered.items.delete(f);let P=G();D(4,()=>{W(),(P==null?void 0:P.getAttribute("id"))===f&&_(),I.emit()})}),group:f=>(o.current.has(f)||o.current.set(f,new Set),()=>{i.current.delete(f),o.current.delete(f)}),filter:()=>c.current.shouldFilter,label:v||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:b,inputId:O,labelId:R,listInnerRef:x}),[]);function A(f,E){var P,y;let N=(y=(P=c.current)==null?void 0:P.filter)!=null?y:zr;return f?N(f,n.current.search,E):0}function F(){if(!n.current.search||c.current.shouldFilter===!1)return;let f=n.current.filtered.items,E=[];n.current.filtered.groups.forEach(y=>{let N=o.current.get(y),k=0;N.forEach(L=>{let T=f.get(L);k=Math.max(T,k)}),E.push([y,k])});let P=x.current;ae().sort((y,N)=>{var k,L;let T=y.getAttribute("id"),le=N.getAttribute("id");return((k=f.get(le))!=null?k:0)-((L=f.get(T))!=null?L:0)}).forEach(y=>{let N=y.closest(Le);N?N.appendChild(y.parentElement===N?y:y.closest(`${Le} > *`)):P.appendChild(y.parentElement===P?y:y.closest(`${Le} > *`))}),E.sort((y,N)=>N[1]-y[1]).forEach(y=>{var N;let k=(N=x.current)==null?void 0:N.querySelector(`${ie}[${ee}="${encodeURIComponent(y[0])}"]`);k==null||k.parentElement.appendChild(k)})}function _(){let f=ae().find(P=>P.getAttribute("aria-disabled")!=="true"),E=f==null?void 0:f.getAttribute(ee);I.setState("value",E||void 0)}function W(){var f,E,P,y;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let N=0;for(let k of r.current){let L=(E=(f=i.current.get(k))==null?void 0:f.value)!=null?E:"",T=(y=(P=i.current.get(k))==null?void 0:P.keywords)!=null?y:[],le=A(L,T);n.current.filtered.items.set(k,le),le>0&&N++}for(let[k,L]of o.current)for(let T of L)if(n.current.filtered.items.get(T)>0){n.current.filtered.groups.add(k);break}n.current.filtered.count=N}function ze(){var f,E,P;let y=G();y&&(((f=y.parentElement)==null?void 0:f.firstChild)===y&&((P=(E=y.closest(ie))==null?void 0:E.querySelector(Vr))==null||P.scrollIntoView({block:"nearest"})),y.scrollIntoView({block:"nearest"}))}function G(){var f;return(f=x.current)==null?void 0:f.querySelector(`${Ut}[aria-selected="true"]`)}function ae(){var f;return Array.from(((f=x.current)==null?void 0:f.querySelectorAll(vt))||[])}function xe(f){let E=ae()[f];E&&I.setState("value",E.getAttribute(ee))}function De(f){var E;let P=G(),y=ae(),N=y.findIndex(L=>L===P),k=y[N+f];(E=c.current)!=null&&E.loop&&(k=N+f<0?y[y.length-1]:N+f===y.length?y[0]:y[N+f]),k&&I.setState("value",k.getAttribute(ee))}function Ye(f){let E=G(),P=E==null?void 0:E.closest(ie),y;for(;P&&!y;)P=f>0?eo(P,ie):to(P,ie),y=P==null?void 0:P.querySelector(vt);y?I.setState("value",y.getAttribute(ee)):De(f)}let He=()=>xe(ae().length-1),Xe=f=>{f.preventDefault(),f.metaKey?He():f.altKey?Ye(1):De(1)},Ge=f=>{f.preventDefault(),f.metaKey?xe(0):f.altKey?Ye(-1):De(-1)};return a.createElement(M.div,{ref:t,tabIndex:-1,...w,"cmdk-root":"",onKeyDown:f=>{var E;(E=w.onKeyDown)==null||E.call(w,f);let P=f.nativeEvent.isComposing||f.keyCode===229;if(!(f.defaultPrevented||P))switch(f.key){case"n":case"j":{g&&f.ctrlKey&&Xe(f);break}case"ArrowDown":{Xe(f);break}case"p":case"k":{g&&f.ctrlKey&&Ge(f);break}case"ArrowUp":{Ge(f);break}case"Home":{f.preventDefault(),xe(0);break}case"End":{f.preventDefault(),He();break}case"Enter":{f.preventDefault();let y=G();if(y){let N=new Event(We);y.dispatchEvent(N)}}}}},a.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:oo},v),Re(e,f=>a.createElement(Vt.Provider,{value:I},a.createElement(Kt.Provider,{value:U},f))))}),Yr=a.forwardRef((e,t)=>{var n,r;let o=K(),i=a.useRef(null),u=a.useContext(zt),c=se(),v=Ht(e),s=(r=(n=v.current)==null?void 0:n.forceMount)!=null?r:u==null?void 0:u.forceMount;H(()=>{if(!s)return c.item(o,u==null?void 0:u.id)},[s]);let l=Xt(o,i,[e.value,e.children,i],e.keywords),d=Ve(),h=Y(D=>D.value&&D.value===l.current),p=Y(D=>s||c.filter()===!1?!0:D.search?D.filtered.items.get(o)>0:!0);a.useEffect(()=>{let D=i.current;if(!(!D||e.disabled))return D.addEventListener(We,S),()=>D.removeEventListener(We,S)},[p,e.onSelect,e.disabled]);function S(){var D,I;m(),(I=(D=v.current).onSelect)==null||I.call(D,l.current)}function m(){d.setState("value",l.current,!0)}if(!p)return null;let{disabled:g,value:w,onSelect:b,forceMount:R,keywords:O,...x}=e;return a.createElement(M.div,{ref:re(i,t),...x,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||c.getDisablePointerSelection()?void 0:m,onClick:g?void 0:S},e.children)}),Hr=a.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,u=K(),c=a.useRef(null),v=a.useRef(null),s=K(),l=se(),d=Y(p=>o||l.filter()===!1?!0:p.search?p.filtered.groups.has(u):!0);H(()=>l.group(u),[]),Xt(u,c,[e.value,e.heading,v]);let h=a.useMemo(()=>({id:u,forceMount:o}),[o]);return a.createElement(M.div,{ref:re(c,t),...i,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&a.createElement("div",{ref:v,"cmdk-group-heading":"","aria-hidden":!0,id:s},n),Re(e,p=>a.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?s:void 0},a.createElement(zt.Provider,{value:h},p))))}),Xr=a.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=a.useRef(null),i=Y(u=>!u.search);return!n&&!i?null:a.createElement(M.div,{ref:re(o,t),...r,"cmdk-separator":"",role:"separator"})}),Gr=a.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=Ve(),u=Y(s=>s.search),c=Y(s=>s.selectedItemId),v=se();return a.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),a.createElement(M.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":v.listId,"aria-labelledby":v.labelId,"aria-activedescendant":c,id:v.inputId,type:"text",value:o?e.value:u,onChange:s=>{o||i.setState("search",s.target.value),n==null||n(s.target.value)}})}),qr=a.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=a.useRef(null),u=a.useRef(null),c=Y(s=>s.selectedItemId),v=se();return a.useEffect(()=>{if(u.current&&i.current){let s=u.current,l=i.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let p=s.offsetHeight;l.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(s),()=>{cancelAnimationFrame(d),h.unobserve(s)}}},[]),a.createElement(M.div,{ref:re(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:v.listId},Re(e,s=>a.createElement("div",{ref:re(u,v.listInnerRef),"cmdk-list-sizer":""},s)))}),Zr=a.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:u,...c}=e;return a.createElement(kt,{open:n,onOpenChange:r},a.createElement(Lt,{container:u},a.createElement(Ft,{"cmdk-overlay":"",className:o}),a.createElement(_t,{"aria-label":e.label,"cmdk-dialog":"",className:i},a.createElement(Yt,{ref:t,...c}))))}),Qr=a.forwardRef((e,t)=>Y(n=>n.filtered.count===0)?a.createElement(M.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Jr=a.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...i}=e;return a.createElement(M.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Re(e,u=>a.createElement("div",{"aria-hidden":!0},u)))}),J=Object.assign(Yt,{List:qr,Item:Yr,Input:Gr,Group:Hr,Separator:Xr,Dialog:Zr,Empty:Qr,Loading:Jr});function eo(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function to(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Ht(e){let t=a.useRef(e);return H(()=>{t.current=e}),t}var H=typeof window>"u"?a.useEffect:a.useLayoutEffect;function te(e){let t=a.useRef();return t.current===void 0&&(t.current=e()),t}function Y(e){let t=Ve(),n=()=>e(t.snapshot());return a.useSyncExternalStore(t.subscribe,n,n)}function Xt(e,t,n,r=[]){let o=a.useRef(),i=se();return H(()=>{var u;let c=(()=>{var s;for(let l of n){if(typeof l=="string")return l.trim();if(typeof l=="object"&&"current"in l)return l.current?(s=l.current.textContent)==null?void 0:s.trim():o.current}})(),v=r.map(s=>s.trim());i.value(e,c,v),(u=t.current)==null||u.setAttribute(ee,c),o.current=c}),o}var no=()=>{let[e,t]=a.useState(),n=te(()=>new Map);return H(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function ro(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Re({asChild:e,children:t},n){return e&&a.isValidElement(t)?a.cloneElement(ro(t),{ref:t.ref},n(t.props.children)):n(t)}var oo={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function co(){const[e,t]=a.useState(!1),n=Gt();return a.useEffect(()=>{const r=o=>{(o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="k"&&(o.preventDefault(),t(i=>!i))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[]),a.useEffect(()=>{const r=()=>t(!0);return window.addEventListener("mc-palette-open",r),()=>window.removeEventListener("mc-palette-open",r)},[]),C.jsx(J.Dialog,{open:e,onOpenChange:t,label:"Befehlspalette",className:"fixed inset-0 z-50 flex items-start justify-center bg-black/50 p-4 pt-[12vh] overscroll-contain",onClick:()=>t(!1),children:C.jsxs("div",{className:"w-full max-w-lg overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-2xl",onClick:r=>r.stopPropagation(),children:[C.jsx(J.Input,{autoFocus:!0,placeholder:"Springe zu… (Modelle, Routing, System …)",className:"w-full border-b border-border bg-transparent px-4 py-3 text-sm outline-none placeholder:text-muted-foreground"}),C.jsxs(J.List,{className:"max-h-80 overflow-y-auto p-2",children:[C.jsx(J.Empty,{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Nichts gefunden."}),C.jsx(J.Group,{heading:"Bereiche",className:"px-1 py-1 text-xs text-muted-foreground",children:qt.map(r=>C.jsxs(J.Item,{value:`${r.label} ${r.hint}`,onSelect:()=>{n({to:r.pfad}),t(!1)},className:"flex cursor-pointer items-center gap-3 rounded-md px-3 py-2 text-sm text-foreground aria-selected:bg-accent aria-selected:text-accent-foreground",children:[C.jsx(r.icon,{className:"h-4 w-4 text-primary"}),C.jsx("span",{children:r.label}),C.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",children:r.hint})]},r.id))})]})]})})}export{co as CommandPalette};