@desktalk/miniapp-note 0.1.0-alpha.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/frontend.js CHANGED
@@ -1,4 +1,4 @@
1
- var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h.PureComponent,Xe=h.StrictMode,Ge=h.Suspense,Ke=h.cloneElement,Je=h.createContext,Qe=h.createElement,Ze=h.createRef,ft=h.forwardRef,tr=h.isValidElement,er=h.lazy,rr=h.memo,ir=h.startTransition,x=h.useCallback,nr=h.useContext,sr=h.useDebugValue,ar=h.useDeferredValue,W=h.useEffect,or=h.useId,_t=h.useImperativeHandle,dr=h.useInsertionEffect,lr=h.useLayoutEffect,cr=h.useMemo,hr=h.useReducer,H=h.useRef,I=h.useState,ur=h.useSyncExternalStore,pr=h.useTransition,mr=h.version,at=window.ReactDOM,xt=at.createRoot,gr=at.hydrateRoot;import{useCommand as B,MiniAppIdProvider as wt,WindowIdProvider as yt}from"@desktalk/sdk";var v={root:"NoteApp_root",rootCompact:"NoteApp_rootCompact",listPanel:"NoteApp_listPanel",listHeader:"NoteApp_listHeader",searchInput:"NoteApp_searchInput",newNoteBtn:"NoteApp_newNoteBtn",noteList:"NoteApp_noteList",noteItem:"NoteApp_noteItem",noteItemActive:"NoteApp_noteItem NoteApp_noteItemActive",emptyState:"NoteApp_emptyState",noteTitle:"NoteApp_noteTitle",notePreview:"NoteApp_notePreview",noteDate:"NoteApp_noteDate",editorPanel:"NoteApp_editorPanel",editorHeader:"NoteApp_editorHeader",editorTitle:"NoteApp_editorTitle",editorTags:"NoteApp_editorTags",editorTag:"NoteApp_editorTag",editorBody:"NoteApp_editorBody",editorPlaceholder:"NoteApp_editorPlaceholder",saveStatus:"NoteApp_saveStatus",saveStatusSaving:"NoteApp_saveStatus NoteApp_saveStatusSaving"},G=window.__desktalk_jsx_runtime,u=G.jsx,T=G.jsxs,vr=G.jsxDEV,fr=G.Fragment;function kt(t){try{const e=new Date(t),i=new Date().getTime()-e.getTime(),n=Math.floor(i/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);if(s<24)return`${s}h ago`;const a=Math.floor(s/24);return a<7?`${a}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return""}}function Ct({notes:t,selectedId:e,onSelect:r,onCreate:i,searchQuery:n,onSearchChange:s}){const a=H(null);return T("div",{className:v.listPanel,children:[T("div",{className:v.listHeader,children:[u("input",{ref:a,type:"text",className:v.searchInput,placeholder:"Search notes...",value:n,onChange:o=>s(o.target.value)}),u("button",{className:v.newNoteBtn,onClick:i,title:"New note",children:"+"})]}),u("div",{className:v.noteList,children:t.length===0?u("div",{className:v.emptyState,children:n?"No notes match your search":"No notes yet"}):t.map(o=>T("div",{className:o.id===e?v.noteItemActive:v.noteItem,onClick:()=>r(o.id),children:[u("div",{className:v.noteTitle,children:o.title}),u("div",{className:v.notePreview,children:o.preview}),u("div",{className:v.noteDate,children:kt(o.updatedAt)})]},o.id))})]})}var Et=`.dt-tooltip-popup {
1
+ var h=window.React,Be=h.Children,qe=h.Component,je=h.Fragment,Ue=h.Profiler,Ge=h.PureComponent,Ye=h.StrictMode,Xe=h.Suspense,Ke=h.cloneElement,Je=h.createContext,Qe=h.createElement,Ze=h.createRef,ft=h.forwardRef,tr=h.isValidElement,er=h.lazy,rr=h.memo,ir=h.startTransition,x=h.useCallback,nr=h.useContext,or=h.useDebugValue,sr=h.useDeferredValue,B=h.useEffect,ar=h.useId,_t=h.useImperativeHandle,dr=h.useInsertionEffect,lr=h.useLayoutEffect,cr=h.useMemo,hr=h.useReducer,H=h.useRef,I=h.useState,ur=h.useSyncExternalStore,pr=h.useTransition,mr=h.version,st=window.ReactDOM,xt=st.createRoot,gr=st.hydrateRoot;import{useCommand as q,MiniAppIdProvider as wt,WindowIdProvider as yt}from"@desktalk/sdk";var v={root:"NoteApp_root",rootCompact:"NoteApp_rootCompact",listPanel:"NoteApp_listPanel",listHeader:"NoteApp_listHeader",searchInput:"NoteApp_searchInput",newNoteBtn:"NoteApp_newNoteBtn",noteList:"NoteApp_noteList",noteItem:"NoteApp_noteItem",noteItemActive:"NoteApp_noteItem NoteApp_noteItemActive",emptyState:"NoteApp_emptyState",noteTitle:"NoteApp_noteTitle",notePreview:"NoteApp_notePreview",noteDate:"NoteApp_noteDate",editorPanel:"NoteApp_editorPanel",editorHeader:"NoteApp_editorHeader",editorTitle:"NoteApp_editorTitle",editorTags:"NoteApp_editorTags",editorTag:"NoteApp_editorTag",editorBody:"NoteApp_editorBody",editorPlaceholder:"NoteApp_editorPlaceholder",saveStatus:"NoteApp_saveStatus",saveStatusSaving:"NoteApp_saveStatus NoteApp_saveStatusSaving"},X=window.__desktalk_jsx_runtime,p=X.jsx,T=X.jsxs,vr=X.jsxDEV,fr=X.Fragment;function kt(t){try{const e=new Date(t),i=new Date().getTime()-e.getTime(),n=Math.floor(i/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const o=Math.floor(n/60);if(o<24)return`${o}h ago`;const s=Math.floor(o/24);return s<7?`${s}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return""}}function Ct({notes:t,selectedId:e,onSelect:r,onCreate:i,searchQuery:n,onSearchChange:o}){const s=H(null);return T("div",{className:v.listPanel,children:[T("div",{className:v.listHeader,children:[p("input",{ref:s,type:"text",className:v.searchInput,placeholder:"Search notes...",value:n,onChange:a=>o(a.target.value)}),p("button",{className:v.newNoteBtn,onClick:i,title:"New note",children:"+"})]}),p("div",{className:v.noteList,children:t.length===0?p("div",{className:v.emptyState,children:n?"No notes match your search":"No notes yet"}):t.map(a=>T("div",{className:a.id===e?v.noteItemActive:v.noteItem,onClick:()=>r(a.id),children:[p("div",{className:v.noteTitle,children:a.title}),p("div",{className:v.notePreview,children:a.preview}),p("div",{className:v.noteDate,children:kt(a.updatedAt)})]},a.id))})]})}var Et=`.dt-tooltip-popup {
2
2
  position: fixed;
3
3
  z-index: 2147483647;
4
4
  padding: 6px 10px;
@@ -41,13 +41,13 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
41
41
 
42
42
  /* Arrow styling - tech/minimal */
43
43
  .dt-tooltip-popup[data-actual-placement='top'] {
44
- transform: translateX(-50%);
44
+ transform: none;
45
45
  }
46
46
 
47
47
  .dt-tooltip-popup[data-actual-placement='top']::before {
48
48
  top: auto;
49
49
  bottom: -4px;
50
- left: 50%;
50
+ left: var(--dt-tooltip-arrow-left, 50%);
51
51
  transform: translateX(-50%);
52
52
  width: 0;
53
53
  height: 0;
@@ -58,13 +58,13 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
58
58
  }
59
59
 
60
60
  .dt-tooltip-popup[data-actual-placement='bottom'] {
61
- transform: translateX(-50%);
61
+ transform: none;
62
62
  }
63
63
 
64
64
  .dt-tooltip-popup[data-actual-placement='bottom']::before {
65
65
  bottom: auto;
66
66
  top: -4px;
67
- left: 50%;
67
+ left: var(--dt-tooltip-arrow-left, 50%);
68
68
  transform: translateX(-50%);
69
69
  width: 0;
70
70
  height: 0;
@@ -75,12 +75,12 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
75
75
  }
76
76
 
77
77
  .dt-tooltip-popup[data-actual-placement='left'] {
78
- transform: translateY(-50%);
78
+ transform: none;
79
79
  }
80
80
 
81
81
  .dt-tooltip-popup[data-actual-placement='left']::before {
82
82
  left: auto;
83
- top: 50%;
83
+ top: var(--dt-tooltip-arrow-top, 50%);
84
84
  right: -4px;
85
85
  transform: translateY(-50%);
86
86
  width: 0;
@@ -92,12 +92,12 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
92
92
  }
93
93
 
94
94
  .dt-tooltip-popup[data-actual-placement='right'] {
95
- transform: translateY(-50%);
95
+ transform: none;
96
96
  }
97
97
 
98
98
  .dt-tooltip-popup[data-actual-placement='right']::before {
99
99
  right: auto;
100
- top: 50%;
100
+ top: var(--dt-tooltip-arrow-top, 50%);
101
101
  left: -4px;
102
102
  transform: translateY(-50%);
103
103
  width: 0;
@@ -107,7 +107,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
107
107
  border-top: none;
108
108
  border-bottom: none;
109
109
  }
110
- `,At="dt-tooltip-popup",L=8,ot=!1;function St(){if(ot)return;let t=document.createElement("style");t.setAttribute("data-dt-tooltip",""),t.textContent=Et,document.head.appendChild(t),ot=!0}var zt=class extends HTMLElement{_popup=null;_showTimeout=null;_tooltipId="";_visible=!1;static get observedAttributes(){return["content","placement","delay","disabled"]}get content(){return this.getAttribute("content")??""}set content(t){this.setAttribute("content",t)}get placement(){let t=this.getAttribute("placement");return t==="bottom"||t==="left"||t==="right"?t:"top"}set placement(t){this.setAttribute("placement",t)}get delay(){let t=Number(this.getAttribute("delay"));return Number.isFinite(t)&&t>0?t:0}set delay(t){this.setAttribute("delay",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}constructor(){super();let t=this.attachShadow({mode:"open"});t.innerHTML="<slot></slot>",this._tooltipId=`dt-tip-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){St(),this.addEventListener("mouseenter",this._onEnter),this.addEventListener("mouseleave",this._onLeave),this.addEventListener("focusin",this._onEnter),this.addEventListener("focusout",this._onLeave)}disconnectedCallback(){this.removeEventListener("mouseenter",this._onEnter),this.removeEventListener("mouseleave",this._onLeave),this.removeEventListener("focusin",this._onEnter),this.removeEventListener("focusout",this._onLeave),this._hide()}attributeChangedCallback(t,e,r){t==="disabled"&&this.disabled&&this._hide(),t==="content"&&this._popup&&(this._popup.textContent=this.content)}_onEnter=()=>{if(this.disabled||!this.content)return;this._showTimeout!==null&&clearTimeout(this._showTimeout);let t=()=>{this._createPopup(),this._position(),this._visible=!0};this.delay>0?this._showTimeout=setTimeout(t,this.delay):t()};_onLeave=()=>{this._hide()};_createPopup(){if(this._popup)return;let t=document.createElement("div");t.className=At,t.id=this._tooltipId,t.setAttribute("role","tooltip"),t.textContent=this.content,document.body.appendChild(t),this._popup=t;let e=this._getTrigger();e&&e.setAttribute("aria-describedby",this._tooltipId)}_hide(){if(this._showTimeout!==null&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._popup){let t=this._getTrigger();t&&t.removeAttribute("aria-describedby"),this._popup.remove(),this._popup=null,this._visible=!1}}_getTrigger(){let t=this.shadowRoot?.querySelector("slot")?.assignedElements();return t&&t.length>0?t[0]:null}_position(){let t=this._popup;if(!t)return;let e=this.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,s=this.placement;s==="top"&&e.top-r.height-L<0?s="bottom":s==="bottom"&&e.bottom+r.height+L>n?s="top":s==="left"&&e.left-r.width-L<0?s="right":s==="right"&&e.right+r.width+L>i&&(s="left"),t.setAttribute("data-actual-placement",s);let a,o;switch(s){case"top":o=e.left+e.width/2,a=e.top-r.height-L;break;case"bottom":o=e.left+e.width/2,a=e.bottom+L;break;case"left":o=e.left-r.width-L,a=e.top+e.height/2;break;case"right":o=e.right+L,a=e.top+e.height/2;break}t.style.left=`${o}px`,t.style.top=`${a}px`}},Mt=`:host {
110
+ `,At="dt-tooltip-popup",L=8,at=!1;function St(){if(at)return;let t=document.createElement("style");t.setAttribute("data-dt-tooltip",""),t.textContent=Et,document.head.appendChild(t),at=!0}var zt=class extends HTMLElement{_popup=null;_showTimeout=null;_tooltipId="";_visible=!1;static get observedAttributes(){return["content","placement","align","delay","disabled"]}get content(){return this.getAttribute("content")??""}set content(t){this.setAttribute("content",t)}get placement(){let t=this.getAttribute("placement");return t==="bottom"||t==="left"||t==="right"?t:"top"}set placement(t){this.setAttribute("placement",t)}get align(){let t=this.getAttribute("align");return t==="left"||t==="right"?t:"center"}set align(t){this.setAttribute("align",t)}get delay(){let t=Number(this.getAttribute("delay"));return Number.isFinite(t)&&t>0?t:0}set delay(t){this.setAttribute("delay",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}constructor(){super();let t=this.attachShadow({mode:"open"});t.innerHTML="<slot></slot>",this._tooltipId=`dt-tip-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){St(),this.addEventListener("mouseenter",this._onEnter),this.addEventListener("mouseleave",this._onLeave),this.addEventListener("focusin",this._onEnter),this.addEventListener("focusout",this._onLeave)}disconnectedCallback(){this.removeEventListener("mouseenter",this._onEnter),this.removeEventListener("mouseleave",this._onLeave),this.removeEventListener("focusin",this._onEnter),this.removeEventListener("focusout",this._onLeave),this._hide()}attributeChangedCallback(t,e,r){t==="disabled"&&this.disabled&&this._hide(),t==="content"&&this._popup&&(this._popup.textContent=this.content)}_onEnter=()=>{if(this.disabled||!this.content)return;this._showTimeout!==null&&clearTimeout(this._showTimeout);let t=()=>{this._createPopup(),this._position(),this._visible=!0};this.delay>0?this._showTimeout=setTimeout(t,this.delay):t()};_onLeave=()=>{this._hide()};_createPopup(){if(this._popup)return;let t=document.createElement("div");t.className=At,t.id=this._tooltipId,t.setAttribute("role","tooltip"),t.textContent=this.content,document.body.appendChild(t),this._popup=t;let e=this._getTrigger();e&&e.setAttribute("aria-describedby",this._tooltipId)}_hide(){if(this._showTimeout!==null&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._popup){let t=this._getTrigger();t&&t.removeAttribute("aria-describedby"),this._popup.remove(),this._popup=null,this._visible=!1}}_getTrigger(){let t=this.shadowRoot?.querySelector("slot")?.assignedElements();return t&&t.length>0?t[0]:null}_position(){let t=this._popup;if(!t)return;let e=this.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,o=8,s=this.placement;s==="top"&&e.top-r.height-L<0?s="bottom":s==="bottom"&&e.bottom+r.height+L>n?s="top":s==="left"&&e.left-r.width-L<0?s="right":s==="right"&&e.right+r.width+L>i&&(s="left"),t.setAttribute("data-actual-placement",s);let a,d,l=e.left+e.width/2,u=e.top+e.height/2;switch(s){case"top":l=this.align==="left"?e.left:this.align==="right"?e.right:e.left+e.width/2,d=this.align==="left"?e.left:this.align==="right"?e.right-r.width:e.left+e.width/2-r.width/2,a=e.top-r.height-L;break;case"bottom":l=this.align==="left"?e.left:this.align==="right"?e.right:e.left+e.width/2,d=this.align==="left"?e.left:this.align==="right"?e.right-r.width:e.left+e.width/2-r.width/2,a=e.bottom+L;break;case"left":d=e.left-r.width-L,a=e.top+e.height/2-r.height/2,u=e.top+e.height/2;break;case"right":d=e.right+L,a=e.top+e.height/2-r.height/2,u=e.top+e.height/2;break}s==="top"||s==="bottom"?(d=Math.max(o,Math.min(d,i-r.width-o)),t.style.setProperty("--dt-tooltip-arrow-left",`${Math.max(8,Math.min(l-d,r.width-8))}px`),t.style.removeProperty("--dt-tooltip-arrow-top")):(a=Math.max(o,Math.min(a,n-r.height-o)),t.style.setProperty("--dt-tooltip-arrow-top",`${Math.max(8,Math.min(u-a,r.height-8))}px`),t.style.removeProperty("--dt-tooltip-arrow-left")),t.style.left=`${d}px`,t.style.top=`${a}px`}},Mt=`:host {
111
111
  display: block;
112
112
  margin-bottom: 12px;
113
113
  }
@@ -356,7 +356,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
356
356
  .dt-select-trigger[aria-expanded='true'] .dt-select-chevron {
357
357
  transform: rotate(180deg);
358
358
  }
359
- `,It="dt-select-trigger",dt="dt-select-label",Rt="dt-select-chevron",Ft="dt-select-menu",$t="dt-select-option",Dt="dt-select-option--active",lt=!1;function Pt(){if(lt)return;let t=document.createElement("style");t.setAttribute("data-dt-select",""),t.textContent=Lt,document.head.appendChild(t),lt=!0}var Vt=class extends HTMLElement{_menu=null;_trigger=null;_options=[];_open=!1;_menuId="";static get observedAttributes(){return["value","placeholder","disabled","align"]}get value(){return this.getAttribute("value")??""}set value(t){this.setAttribute("value",t)}get placeholder(){return this.getAttribute("placeholder")??"Select\u2026"}set placeholder(t){this.setAttribute("placeholder",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get align(){return this.getAttribute("align")==="right"?"right":"left"}set align(t){this.setAttribute("align",t)}get options(){return this._options}set options(t){this._options=t,this._updateLabel(),this._open&&this._renderMenuItems()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ht,t.appendChild(e);let r=document.createElement("button");r.type="button",r.className=It,r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let i=document.createElement("span");i.className=dt,r.appendChild(i);let n=document.createElement("span");n.className=Rt,n.setAttribute("aria-hidden","true"),n.textContent="\u25BE",r.appendChild(n),t.appendChild(r),this._trigger=r,this._menuId=`dt-sel-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){Pt(),this._trigger.addEventListener("click",this._onTriggerClick),this._updateLabel()}disconnectedCallback(){this._trigger.removeEventListener("click",this._onTriggerClick),this._close()}attributeChangedCallback(t){t==="value"&&(this._updateLabel(),this._open&&this._renderMenuItems()),t==="placeholder"&&!this.value&&this._updateLabel(),t==="disabled"&&this.disabled&&this._close()}_updateLabel(){let t=this._trigger.querySelector(`.${dt}`),e=this._options.find(r=>r.value===this.value);t.textContent=e?.label??this.placeholder}_onTriggerClick=()=>{this.disabled||(this._open?this._close():this._openMenu())};_openMenu(){if(this._open)return;let t=document.createElement("div");t.className=Ft,t.id=this._menuId,t.setAttribute("role","listbox"),document.body.appendChild(t),this._menu=t,this._renderMenuItems(),this._position(),requestAnimationFrame(()=>{t.setAttribute("data-open","")}),this._open=!0,this._trigger.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{document.addEventListener("mousedown",this._onOutsideClick),document.addEventListener("keydown",this._onKeyDown)})}_close(){if(this._open){if(document.removeEventListener("mousedown",this._onOutsideClick),document.removeEventListener("keydown",this._onKeyDown),this._menu){this._menu.removeAttribute("data-open");let t=this._menu;setTimeout(()=>t.remove(),140),this._menu=null}this._open=!1,this._trigger.setAttribute("aria-expanded","false")}}_onOutsideClick=t=>{let e=t.target;this._menu?.contains(e)||this.contains(e)||this._close()};_onKeyDown=t=>{t.key==="Escape"&&(this._close(),this._trigger.focus())};_renderMenuItems(){let t=this._menu;if(t){t.innerHTML="";for(let e of this._options){let r=document.createElement("button");r.type="button",r.className=$t,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(e.value===this.value)),e.value===this.value&&r.classList.add(Dt);let i=document.createElement("span");i.textContent=e.label,r.appendChild(i),r.addEventListener("click",()=>{this._selectValue(e.value)}),t.appendChild(r)}}}_selectValue(t){let e=this.value;this.value=t,this._updateLabel(),this._close(),t!==e&&this.dispatchEvent(new CustomEvent("dt-change",{detail:{value:t},bubbles:!0,composed:!0}))}_position(){let t=this._menu;if(!t)return;let e=this.getBoundingClientRect(),r=10,i=Math.max(e.width,240),n=e.bottom+r,s=t.scrollHeight||260,a=window.innerHeight;if(n+s>a&&e.top-s-r>0&&(n=e.top-s-r),t.style.minWidth=`${i}px`,this.align==="right"){let o=window.innerWidth;t.style.right=`${o-e.right}px`,t.style.left="auto"}else t.style.left=`${e.left}px`,t.style.right="auto";t.style.top=`${n}px`}},Ot=`:host {
359
+ `,It="dt-select-trigger",dt="dt-select-label",Rt="dt-select-chevron",Ft="dt-select-menu",$t="dt-select-option",Pt="dt-select-option--active",lt=!1;function Dt(){if(lt)return;let t=document.createElement("style");t.setAttribute("data-dt-select",""),t.textContent=Lt,document.head.appendChild(t),lt=!0}var Vt=class extends HTMLElement{_menu=null;_trigger=null;_options=[];_open=!1;_menuId="";static get observedAttributes(){return["value","placeholder","disabled","align"]}get value(){return this.getAttribute("value")??""}set value(t){this.setAttribute("value",t)}get placeholder(){return this.getAttribute("placeholder")??"Select\u2026"}set placeholder(t){this.setAttribute("placeholder",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get align(){return this.getAttribute("align")==="right"?"right":"left"}set align(t){this.setAttribute("align",t)}get options(){return this._options}set options(t){this._options=t,this._updateLabel(),this._open&&this._renderMenuItems()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ht,t.appendChild(e);let r=document.createElement("button");r.type="button",r.className=It,r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let i=document.createElement("span");i.className=dt,r.appendChild(i);let n=document.createElement("span");n.className=Rt,n.setAttribute("aria-hidden","true"),n.textContent="\u25BE",r.appendChild(n),t.appendChild(r),this._trigger=r,this._menuId=`dt-sel-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){Dt(),this._trigger.addEventListener("click",this._onTriggerClick),this._updateLabel()}disconnectedCallback(){this._trigger.removeEventListener("click",this._onTriggerClick),this._close()}attributeChangedCallback(t){t==="value"&&(this._updateLabel(),this._open&&this._renderMenuItems()),t==="placeholder"&&!this.value&&this._updateLabel(),t==="disabled"&&this.disabled&&this._close()}_updateLabel(){let t=this._trigger.querySelector(`.${dt}`),e=this._options.find(r=>r.value===this.value);t.textContent=e?.label??this.placeholder}_onTriggerClick=()=>{this.disabled||(this._open?this._close():this._openMenu())};_openMenu(){if(this._open)return;let t=document.createElement("div");t.className=Ft,t.id=this._menuId,t.setAttribute("role","listbox"),document.body.appendChild(t),this._menu=t,this._renderMenuItems(),this._position(),requestAnimationFrame(()=>{t.setAttribute("data-open","")}),this._open=!0,this._trigger.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{document.addEventListener("mousedown",this._onOutsideClick),document.addEventListener("keydown",this._onKeyDown),window.addEventListener("blur",this._onWindowBlur)})}_close(){if(this._open){if(document.removeEventListener("mousedown",this._onOutsideClick),document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("blur",this._onWindowBlur),this._menu){this._menu.removeAttribute("data-open");let t=this._menu;setTimeout(()=>t.remove(),140),this._menu=null}this._open=!1,this._trigger.setAttribute("aria-expanded","false")}}_onOutsideClick=t=>{let e=t.target;this._menu?.contains(e)||this.contains(e)||this._close()};_onWindowBlur=()=>{requestAnimationFrame(()=>{document.activeElement?.tagName==="IFRAME"&&this._close()})};_onKeyDown=t=>{t.key==="Escape"&&(this._close(),this._trigger.focus())};_renderMenuItems(){let t=this._menu;if(t){t.innerHTML="";for(let e of this._options){let r=document.createElement("button");r.type="button",r.className=$t,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(e.value===this.value)),e.value===this.value&&r.classList.add(Pt);let i=document.createElement("span");i.textContent=e.label,r.appendChild(i),r.addEventListener("click",()=>{this._selectValue(e.value)}),t.appendChild(r)}}}_selectValue(t){let e=this.value;this.value=t,this._updateLabel(),this._close(),t!==e&&this.dispatchEvent(new CustomEvent("dt-change",{detail:{value:t},bubbles:!0,composed:!0}))}_position(){let t=this._menu;if(!t)return;let e=this.getBoundingClientRect(),r=10,i=Math.max(e.width,240),n=e.bottom+r,o=t.scrollHeight||260,s=window.innerHeight;if(n+o>s&&e.top-o-r>0&&(n=e.top-o-r),t.style.minWidth=`${i}px`,this.align==="right"){let a=window.innerWidth;t.style.right=`${a-e.right}px`,t.style.left="auto"}else t.style.left=`${e.left}px`,t.style.right="auto";t.style.top=`${n}px`}},Ot=`:host {
360
360
  display: block;
361
361
  margin-bottom: 12px;
362
362
  }
@@ -448,7 +448,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
448
448
  ::slotted(*) {
449
449
  min-width: 0;
450
450
  }
451
- `,qt="dt-grid-inner",Wt=class extends HTMLElement{static get observedAttributes(){return["cols","gap","min-width"]}get cols(){let t=this.getAttribute("cols");return t==="1"||t==="2"||t==="3"||t==="4"||t==="5"||t==="6"?t:null}set cols(t){t===null?this.removeAttribute("cols"):this.setAttribute("cols",t)}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get minWidth(){let t=this.getAttribute("min-width");return t==="150"||t==="180"||t==="200"||t==="260"||t==="300"?t:"220"}set minWidth(t){this.setAttribute("min-width",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ot,t.appendChild(e);let r=document.createElement("div");r.className=qt,r.innerHTML="<slot></slot>",t.appendChild(r)}},Bt=`:host {
451
+ `,Wt="dt-grid-inner",Bt=class extends HTMLElement{static get observedAttributes(){return["cols","gap","min-width"]}get cols(){let t=this.getAttribute("cols");return t==="1"||t==="2"||t==="3"||t==="4"||t==="5"||t==="6"?t:null}set cols(t){t===null?this.removeAttribute("cols"):this.setAttribute("cols",t)}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get minWidth(){let t=this.getAttribute("min-width");return t==="150"||t==="180"||t==="200"||t==="260"||t==="300"?t:"220"}set minWidth(t){this.setAttribute("min-width",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ot,t.appendChild(e);let r=document.createElement("div");r.className=Wt,r.innerHTML="<slot></slot>",t.appendChild(r)}},qt=`:host {
452
452
  display: block;
453
453
  margin-bottom: 12px;
454
454
  }
@@ -514,7 +514,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
514
514
  ::slotted(*) {
515
515
  min-width: 0;
516
516
  }
517
- `,jt="dt-stack-inner";function Q(t){return t==="row"||t==="horizontal"?"row":"column"}var Ut=class extends HTMLElement{static get observedAttributes(){return["direction","gap","align"]}get direction(){return Q(this.getAttribute("direction"))}set direction(t){this.setAttribute("direction",Q(t))}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get align(){let t=this.getAttribute("align");return t==="start"||t==="center"||t==="end"?t:"stretch"}set align(t){this.setAttribute("align",t)}connectedCallback(){this.#t()}attributeChangedCallback(t){t==="direction"&&this.#t()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Bt,t.appendChild(e);let r=document.createElement("div");r.className=jt,r.innerHTML="<slot></slot>",t.appendChild(r)}#t(){let t=this.getAttribute("direction"),e=Q(t);t!==null&&t!==e&&this.setAttribute("direction",e)}},Yt=`:host {
517
+ `,jt="dt-stack-inner";function Q(t){return t==="row"||t==="horizontal"?"row":"column"}var Ut=class extends HTMLElement{static get observedAttributes(){return["direction","gap","align"]}get direction(){return Q(this.getAttribute("direction"))}set direction(t){this.setAttribute("direction",Q(t))}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get align(){let t=this.getAttribute("align");return t==="start"||t==="center"||t==="end"?t:"stretch"}set align(t){this.setAttribute("align",t)}connectedCallback(){this.#t()}attributeChangedCallback(t){t==="direction"&&this.#t()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=qt,t.appendChild(e);let r=document.createElement("div");r.className=jt,r.innerHTML="<slot></slot>",t.appendChild(r)}#t(){let t=this.getAttribute("direction"),e=Q(t);t!==null&&t!==e&&this.setAttribute("direction",e)}},Gt=`:host {
518
518
  display: block;
519
519
  }
520
520
 
@@ -619,7 +619,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
619
619
  .dt-stat-inner .trend.neutral {
620
620
  color: var(--dt-text-muted);
621
621
  }
622
- `,Xt="dt-stat-inner",Gt=class extends HTMLElement{static get observedAttributes(){return["label","value","description","size","variant","trend","trend-value"]}_container;_labelEl;_valueEl;_descEl;_trendEl;get label(){return this.getAttribute("label")}set label(t){t===null?this.removeAttribute("label"):this.setAttribute("label",t)}get value(){return this.getAttribute("value")}set value(t){t===null?this.removeAttribute("value"):this.setAttribute("value",t)}get description(){return this.getAttribute("description")}set description(t){t===null?this.removeAttribute("description"):this.setAttribute("description",t)}get size(){let t=this.getAttribute("size");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get variant(){let t=this.getAttribute("variant");return t==="outlined"||t==="filled"?t:"default"}set variant(t){this.setAttribute("variant",t)}get trend(){let t=this.getAttribute("trend");return t==="up"||t==="down"||t==="neutral"?t:null}set trend(t){t===null?this.removeAttribute("trend"):this.setAttribute("trend",t)}get trendValue(){return this.getAttribute("trend-value")}set trendValue(t){t===null?this.removeAttribute("trend-value"):this.setAttribute("trend-value",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Yt,t.appendChild(e),this._container=document.createElement("div"),this._container.className=Xt,this._labelEl=document.createElement("div"),this._labelEl.className="label",this._container.appendChild(this._labelEl),this._valueEl=document.createElement("div"),this._valueEl.className="value",this._container.appendChild(this._valueEl),this._descEl=document.createElement("div"),this._descEl.className="description",this._container.appendChild(this._descEl),this._trendEl=document.createElement("div"),this._trendEl.className="trend",this._container.appendChild(this._trendEl),t.appendChild(this._container),this._render()}attributeChangedCallback(t,e,r){(t==="label"||t==="value"||t==="description"||t==="size"||t==="variant"||t==="trend"||t==="trend-value")&&this._render()}_render(){this._labelEl.textContent=this.label??"",this._labelEl.style.display=this.label?"block":"none",this._valueEl.textContent=this.value??"",this._valueEl.style.display=this.value?"block":"none",this._descEl.textContent=this.description??"",this._descEl.style.display=this.description?"block":"none";let t=this.trend,e=this.trendValue;if(t&&e){this._trendEl.style.display="inline-flex",this._trendEl.className=`trend ${t==="up"?"positive":t==="down"?"negative":"neutral"}`;let r="";t==="up"?r="\u2191":t==="down"?r="\u2193":r="\u2192",this._trendEl.textContent=`${r} ${e}`}else this._trendEl.style.display="none"}},Kt=`:host {
622
+ `,Yt="dt-stat-inner",Xt=class extends HTMLElement{static get observedAttributes(){return["label","value","description","size","variant","trend","trend-value"]}_container;_labelEl;_valueEl;_descEl;_trendEl;get label(){return this.getAttribute("label")}set label(t){t===null?this.removeAttribute("label"):this.setAttribute("label",t)}get value(){return this.getAttribute("value")}set value(t){t===null?this.removeAttribute("value"):this.setAttribute("value",t)}get description(){return this.getAttribute("description")}set description(t){t===null?this.removeAttribute("description"):this.setAttribute("description",t)}get size(){let t=this.getAttribute("size");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get variant(){let t=this.getAttribute("variant");return t==="outlined"||t==="filled"?t:"default"}set variant(t){this.setAttribute("variant",t)}get trend(){let t=this.getAttribute("trend");return t==="up"||t==="down"||t==="neutral"?t:null}set trend(t){t===null?this.removeAttribute("trend"):this.setAttribute("trend",t)}get trendValue(){return this.getAttribute("trend-value")}set trendValue(t){t===null?this.removeAttribute("trend-value"):this.setAttribute("trend-value",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Gt,t.appendChild(e),this._container=document.createElement("div"),this._container.className=Yt,this._labelEl=document.createElement("div"),this._labelEl.className="label",this._container.appendChild(this._labelEl),this._valueEl=document.createElement("div"),this._valueEl.className="value",this._container.appendChild(this._valueEl),this._descEl=document.createElement("div"),this._descEl.className="description",this._container.appendChild(this._descEl),this._trendEl=document.createElement("div"),this._trendEl.className="trend",this._container.appendChild(this._trendEl),t.appendChild(this._container),this._render()}attributeChangedCallback(t,e,r){(t==="label"||t==="value"||t==="description"||t==="size"||t==="variant"||t==="trend"||t==="trend-value")&&this._render()}_render(){this._labelEl.textContent=this.label??"",this._labelEl.style.display=this.label?"block":"none",this._valueEl.textContent=this.value??"",this._valueEl.style.display=this.value?"block":"none",this._descEl.textContent=this.description??"",this._descEl.style.display=this.description?"block":"none";let t=this.trend,e=this.trendValue;if(t&&e){this._trendEl.style.display="inline-flex",this._trendEl.className=`trend ${t==="up"?"positive":t==="down"?"negative":"neutral"}`;let r="";t==="up"?r="\u2191":t==="down"?r="\u2193":r="\u2192",this._trendEl.textContent=`${r} ${e}`}else this._trendEl.style.display="none"}},Kt=`:host {
623
623
  display: inline-flex;
624
624
  vertical-align: middle;
625
625
  }
@@ -718,6 +718,9 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
718
718
  font-weight: 600;
719
719
  font-family: var(--font-ui, 'Work Sans', system-ui, sans-serif);
720
720
  line-height: 1.2;
721
+ white-space: nowrap;
722
+ overflow: hidden;
723
+ text-overflow: ellipsis;
721
724
  cursor: pointer;
722
725
  transition: all 0.1s ease;
723
726
  background: var(--dt-surface);
@@ -925,7 +928,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
925
928
  :host([direction='vertical'][spacing='lg']) .dt-divider-inner {
926
929
  margin: 0 18px;
927
930
  }
928
- `,ie="dt-divider-inner",ne=class extends HTMLElement{static get observedAttributes(){return["direction","style-variant","spacing"]}get direction(){return this.getAttribute("direction")==="vertical"?"vertical":"horizontal"}set direction(t){this.setAttribute("direction",t)}get styleVariant(){let t=this.getAttribute("style-variant");return t==="subtle"||t==="strong"?t:"default"}set styleVariant(t){this.setAttribute("style-variant",t)}get spacing(){let t=this.getAttribute("spacing");return t==="sm"||t==="md"||t==="lg"?t:null}set spacing(t){t===null?this.removeAttribute("spacing"):this.setAttribute("spacing",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=re,t.appendChild(e);let r=document.createElement("hr");r.className=ie,t.appendChild(r)}},se=`:host {
931
+ `,ie="dt-divider-inner",ne=class extends HTMLElement{static get observedAttributes(){return["direction","style-variant","spacing"]}get direction(){return this.getAttribute("direction")==="vertical"?"vertical":"horizontal"}set direction(t){this.setAttribute("direction",t)}get styleVariant(){let t=this.getAttribute("style-variant");return t==="subtle"||t==="strong"?t:"default"}set styleVariant(t){this.setAttribute("style-variant",t)}get spacing(){let t=this.getAttribute("spacing");return t==="sm"||t==="md"||t==="lg"?t:null}set spacing(t){t===null?this.removeAttribute("spacing"):this.setAttribute("spacing",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=re,t.appendChild(e);let r=document.createElement("hr");r.className=ie,t.appendChild(r)}},oe=`:host {
929
932
  display: block;
930
933
  min-height: 180px;
931
934
  color: var(--dt-text);
@@ -1093,7 +1096,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
1093
1096
  letter-spacing: 0.08em;
1094
1097
  font-size: 0.75rem;
1095
1098
  }
1096
- `;function ae(t){return t==null||t===!1?null:t===!0?"":String(t)}function oe(t,e){let r=t.querySelectorAll("*");for(let i of r){let n=i.getAttribute("data-field");if(n){let s=e[n];i.textContent=s==null?"":String(s)}for(let s of i.getAttributeNames()){if(s==="data-field"||!s.startsWith("data-field-"))continue;let a=s.slice(11);if(!a)continue;let o=i.getAttribute(s);if(!o)continue;let d=ae(e[o]);d===null?i.removeAttribute(a):i.setAttribute(a,d)}}}function ct(t,e){let r=t.content.cloneNode(!0);return oe(r,e),r}var ht=class{_count=0;_estimateSize=56;_overscan=5;_fixedSize=null;_viewportHeight=0;_scrollTop=0;_sizes=new Map;constructor(t={}){this._count=t.count??0,this._estimateSize=t.estimateSize??56,this._overscan=t.overscan??5,this._fixedSize=t.fixedSize??null}setCount(t){this._count=Math.max(0,t);for(let e of this._sizes.keys())e>=this._count&&this._sizes.delete(e)}setViewportHeight(t){this._viewportHeight=Math.max(0,t)}setScrollTop(t){this._scrollTop=Math.max(0,t)}setEstimateSize(t){this._estimateSize=Math.max(1,t)}setFixedSize(t){this._fixedSize=t&&t>0?t:null}resetMeasurements(){this._sizes.clear()}measure(t,e){if(this._fixedSize!==null||t<0||t>=this._count)return 0;let r=Math.max(1,Math.round(e)),i=this._sizes.get(t);return i===r?0:(this._sizes.set(t,r),this.getOffset(t+1)<=this._scrollTop?r-(i??this._estimateSize):0)}getOffset(t){if(t<=0)return 0;let e=Math.min(t,this._count);if(this._fixedSize!==null)return e*this._fixedSize;let r=0;for(let i=0;i<e;i+=1)r+=this._sizes.get(i)??this._estimateSize;return r}getTotalHeight(){return this.getOffset(this._count)}getRange(){if(this._count===0)return{start:0,end:0,paddingTop:0,paddingBottom:0,totalHeight:0};if(this._fixedSize!==null){let o=Math.max(1,Math.ceil(this._viewportHeight/this._fixedSize)),d=Math.max(0,Math.floor(this._scrollTop/this._fixedSize)-this._overscan),l=Math.min(this._count,d+o+this._overscan*2),g=d*this._fixedSize,_=this._count*this._fixedSize,b=Math.max(0,_-g-(l-d)*this._fixedSize);return{start:d,end:l,paddingTop:g,paddingBottom:b,totalHeight:_}}let t=0,e=0;for(;t<this._count;){let o=this._sizes.get(t)??this._estimateSize;if(e+o>this._scrollTop)break;e+=o,t+=1}t=Math.max(0,t-this._overscan);let r=this.getOffset(t),i=t,n=0;for(;i<this._count&&n<this._viewportHeight;)n+=this._sizes.get(i)??this._estimateSize,i+=1;i=Math.min(this._count,i+this._overscan);let s=this.getTotalHeight(),a=Math.max(0,s-this.getOffset(i));return{start:t,end:i,paddingTop:r,paddingBottom:a,totalHeight:s}}};function de(t){return t&&typeof t=="object"?t:{value:t}}function le(t){return t==="center"||t==="right"?t:"left"}var ut=class extends HTMLElement{static get observedAttributes(){return["field","header","width","min-width","align"]}get field(){return this.getAttribute("field")??""}get header(){return this.getAttribute("header")??this.field}get width(){return this.getAttribute("width")??"auto"}get minWidth(){return this.getAttribute("min-width")??"0"}get align(){return le(this.getAttribute("align"))}connectedCallback(){this.hidden=!0}attributeChangedCallback(){this.dispatchEvent(new CustomEvent("dt-column-change",{bubbles:!0,composed:!0}))}},ce=class extends HTMLElement{_rows=[];_columns=[];_virtualizer=new ht({estimateSize:40,overscan:5,fixedSize:40});_root;_scroll;_header;_body;_canvas;_emptyState;_resizeObserver=null;_mutationObserver=null;_sortField=null;_sortDirection="asc";static get observedAttributes(){return["row-height","sortable","striped","bordered","empty-text"]}get rows(){return this._rows}set rows(t){this._rows=Array.isArray(t)?t:[],this._virtualizer.setCount(this._rows.length),this._render()}get rowHeight(){let t=Number(this.getAttribute("row-height")??"40");return Number.isFinite(t)&&t>0?t:40}set rowHeight(t){this.setAttribute("row-height",String(t))}get sortable(){return this.hasAttribute("sortable")}get emptyText(){return this.getAttribute("empty-text")??"No data"}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=se,t.appendChild(e),this._root=document.createElement("div"),this._root.className="dt-table-view",this._scroll=document.createElement("div"),this._scroll.className="dt-table-scroll",this._scroll.addEventListener("scroll",this._onScroll,{passive:!0}),this._header=document.createElement("div"),this._header.className="dt-table-header",this._body=document.createElement("div"),this._body.className="dt-table-body",this._canvas=document.createElement("div"),this._canvas.className="dt-table-canvas",this._emptyState=document.createElement("div"),this._emptyState.className="dt-table-empty",this._body.append(this._canvas,this._emptyState),this._scroll.append(this._header,this._body),this._root.appendChild(this._scroll),t.appendChild(this._root)}connectedCallback(){this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight),this._syncColumns(),this._resizeObserver=new ResizeObserver(t=>{for(let e of t)if(e.target===this._scroll){let r=this._header.offsetHeight;this._virtualizer.setViewportHeight(Math.max(0,e.contentRect.height-r)),this._render()}}),this._resizeObserver.observe(this._scroll),this._mutationObserver=new MutationObserver(()=>{this._syncColumns(),this._render()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["field","header","width","min-width","align"]}),this._virtualizer.setCount(this._rows.length),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight)),this._render()}disconnectedCallback(){this._scroll.removeEventListener("scroll",this._onScroll),this._resizeObserver?.disconnect(),this._mutationObserver?.disconnect(),this._resizeObserver=null,this._mutationObserver=null}attributeChangedCallback(t){t==="row-height"&&(this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight)),this._render()}_onScroll=()=>{this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._renderBody()};_syncColumns(){this._columns=Array.from(this.children).filter(t=>t instanceof ut).map(t=>({field:t.field,header:t.header,width:t.width,minWidth:t.minWidth,align:t.align,template:Array.from(t.children).find(e=>e instanceof HTMLTemplateElement)??null})).filter(t=>t.field)}_render(){if(!this.isConnected)return;this._emptyState.textContent=this.emptyText;let t=this._columns.length>0?this._columns.map(e=>this._toGridColumn(e)).join(" "):"minmax(0, 1fr)";this._header.style.setProperty("--dt-table-columns",t),this._canvas.style.setProperty("--dt-table-columns",t),this._renderHeader(),this._renderBody()}_renderHeader(){let t=document.createDocumentFragment();for(let e of this._columns){let r=document.createElement("div");r.className="dt-table-header-cell",r.dataset.align=e.align,this.sortable&&(r.classList.add("dt-table-header-cell--sortable"),r.tabIndex=0,r.setAttribute("role","button"),r.setAttribute("aria-label",`Sort by ${e.header}`),r.addEventListener("click",()=>this._requestSort(e.field)),r.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._requestSort(e.field))}));let i=document.createElement("span");if(i.className="dt-table-header-label",i.textContent=e.header,this.sortable){let n=document.createElement("span");n.className="dt-table-sort-indicator",this._sortField===e.field?n.textContent=this._sortDirection==="asc"?"\u25B2":"\u25BC":n.textContent="\u2195",i.appendChild(n)}r.appendChild(i),t.appendChild(r)}this._header.replaceChildren(t)}_renderBody(){if(this._rows.length===0||this._columns.length===0){this._emptyState.hidden=!1,this._canvas.replaceChildren(),this._body.style.height="140px",this._canvas.style.height="0px";return}this._emptyState.hidden=!0,this._virtualizer.setCount(this._rows.length),this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight));let t=this._virtualizer.getRange();this._body.style.height=`${Math.max(t.totalHeight,this._scroll.clientHeight-this._header.offsetHeight)}px`,this._canvas.style.height=`${t.totalHeight}px`;let e=document.createDocumentFragment();for(let r=t.start;r<t.end;r+=1)e.appendChild(this._renderRow(r));this._canvas.replaceChildren(e)}_renderRow(t){let e=this._rows[t],r=document.createElement("div");r.className="dt-table-row dt-table-row--clickable",r.style.top=`${this._virtualizer.getOffset(t)}px`,r.style.height=`${this.rowHeight}px`,r.style.setProperty("--dt-table-columns",this._header.style.getPropertyValue("--dt-table-columns")),r.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("dt-row-click",{detail:{row:e,index:t},bubbles:!0,composed:!0}))});let i=de(e);for(let n of this._columns){let s=document.createElement("div");if(s.className="dt-table-cell",s.dataset.align=n.align,n.template)s.appendChild(ct(n.template,i));else{let a=i[n.field];s.textContent=a==null?"":String(a)}r.appendChild(s)}return r}_requestSort(t){this._sortField===t?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortField=t,this._sortDirection="asc"),this._renderHeader(),this.dispatchEvent(new CustomEvent("dt-sort",{detail:{field:t,direction:this._sortDirection},bubbles:!0,composed:!0}))}_toGridColumn(t){let e=/^\d+$/.test(t.minWidth)?`${t.minWidth}px`:t.minWidth;if(t.width==="auto")return`minmax(${e}, 1fr)`;let r=/^\d+$/.test(t.width)?`${t.width}px`:t.width;return`minmax(${e}, ${r})`}},he=`:host {
1099
+ `;function se(t){return t==null||t===!1?null:t===!0?"":String(t)}function ae(t,e){let r=t.querySelectorAll("*");for(let i of r){let n=i.getAttribute("data-field");if(n){let o=e[n];i.textContent=o==null?"":String(o)}for(let o of i.getAttributeNames()){if(o==="data-field"||!o.startsWith("data-field-"))continue;let s=o.slice(11);if(!s)continue;let a=i.getAttribute(o);if(!a)continue;let d=se(e[a]);d===null?i.removeAttribute(s):i.setAttribute(s,d)}}}function ct(t,e){let r=t.content.cloneNode(!0);return ae(r,e),r}var ht=class{_count=0;_estimateSize=56;_overscan=5;_fixedSize=null;_viewportHeight=0;_scrollTop=0;_sizes=new Map;constructor(t={}){this._count=t.count??0,this._estimateSize=t.estimateSize??56,this._overscan=t.overscan??5,this._fixedSize=t.fixedSize??null}setCount(t){this._count=Math.max(0,t);for(let e of this._sizes.keys())e>=this._count&&this._sizes.delete(e)}setViewportHeight(t){this._viewportHeight=Math.max(0,t)}setScrollTop(t){this._scrollTop=Math.max(0,t)}setEstimateSize(t){this._estimateSize=Math.max(1,t)}setFixedSize(t){this._fixedSize=t&&t>0?t:null}resetMeasurements(){this._sizes.clear()}measure(t,e){if(this._fixedSize!==null||t<0||t>=this._count)return 0;let r=Math.max(1,Math.round(e)),i=this._sizes.get(t);return i===r?0:(this._sizes.set(t,r),this.getOffset(t+1)<=this._scrollTop?r-(i??this._estimateSize):0)}getOffset(t){if(t<=0)return 0;let e=Math.min(t,this._count);if(this._fixedSize!==null)return e*this._fixedSize;let r=0;for(let i=0;i<e;i+=1)r+=this._sizes.get(i)??this._estimateSize;return r}getTotalHeight(){return this.getOffset(this._count)}getRange(){if(this._count===0)return{start:0,end:0,paddingTop:0,paddingBottom:0,totalHeight:0};if(this._fixedSize!==null){let a=Math.max(1,Math.ceil(this._viewportHeight/this._fixedSize)),d=Math.max(0,Math.floor(this._scrollTop/this._fixedSize)-this._overscan),l=Math.min(this._count,d+a+this._overscan*2),u=d*this._fixedSize,_=this._count*this._fixedSize,b=Math.max(0,_-u-(l-d)*this._fixedSize);return{start:d,end:l,paddingTop:u,paddingBottom:b,totalHeight:_}}let t=0,e=0;for(;t<this._count;){let a=this._sizes.get(t)??this._estimateSize;if(e+a>this._scrollTop)break;e+=a,t+=1}t=Math.max(0,t-this._overscan);let r=this.getOffset(t),i=t,n=0;for(;i<this._count&&n<this._viewportHeight;)n+=this._sizes.get(i)??this._estimateSize,i+=1;i=Math.min(this._count,i+this._overscan);let o=this.getTotalHeight(),s=Math.max(0,o-this.getOffset(i));return{start:t,end:i,paddingTop:r,paddingBottom:s,totalHeight:o}}};function de(t){return t&&typeof t=="object"?t:{value:t}}function le(t){return t==="center"||t==="right"?t:"left"}var ut=class extends HTMLElement{static get observedAttributes(){return["field","header","width","min-width","align"]}get field(){return this.getAttribute("field")??""}get header(){return this.getAttribute("header")??this.field}get width(){return this.getAttribute("width")??"auto"}get minWidth(){return this.getAttribute("min-width")??"0"}get align(){return le(this.getAttribute("align"))}connectedCallback(){this.hidden=!0}attributeChangedCallback(){this.dispatchEvent(new CustomEvent("dt-column-change",{bubbles:!0,composed:!0}))}},ce=class extends HTMLElement{_rows=[];_columns=[];_virtualizer=new ht({estimateSize:40,overscan:5,fixedSize:40});_root;_scroll;_header;_body;_canvas;_emptyState;_resizeObserver=null;_mutationObserver=null;_sortField=null;_sortDirection="asc";static get observedAttributes(){return["row-height","sortable","striped","bordered","empty-text"]}get rows(){return this._rows}set rows(t){this._rows=Array.isArray(t)?t:[],this._virtualizer.setCount(this._rows.length),this._render()}get rowHeight(){let t=Number(this.getAttribute("row-height")??"40");return Number.isFinite(t)&&t>0?t:40}set rowHeight(t){this.setAttribute("row-height",String(t))}get sortable(){return this.hasAttribute("sortable")}get emptyText(){return this.getAttribute("empty-text")??"No data"}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=oe,t.appendChild(e),this._root=document.createElement("div"),this._root.className="dt-table-view",this._scroll=document.createElement("div"),this._scroll.className="dt-table-scroll",this._scroll.addEventListener("scroll",this._onScroll,{passive:!0}),this._header=document.createElement("div"),this._header.className="dt-table-header",this._body=document.createElement("div"),this._body.className="dt-table-body",this._canvas=document.createElement("div"),this._canvas.className="dt-table-canvas",this._emptyState=document.createElement("div"),this._emptyState.className="dt-table-empty",this._body.append(this._canvas,this._emptyState),this._scroll.append(this._header,this._body),this._root.appendChild(this._scroll),t.appendChild(this._root)}connectedCallback(){this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight),this._syncColumns(),this._resizeObserver=new ResizeObserver(t=>{for(let e of t)if(e.target===this._scroll){let r=this._header.offsetHeight;this._virtualizer.setViewportHeight(Math.max(0,e.contentRect.height-r)),this._render()}}),this._resizeObserver.observe(this._scroll),this._mutationObserver=new MutationObserver(()=>{this._syncColumns(),this._render()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["field","header","width","min-width","align"]}),this._virtualizer.setCount(this._rows.length),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight)),this._render()}disconnectedCallback(){this._scroll.removeEventListener("scroll",this._onScroll),this._resizeObserver?.disconnect(),this._mutationObserver?.disconnect(),this._resizeObserver=null,this._mutationObserver=null}attributeChangedCallback(t){t==="row-height"&&(this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight)),this._render()}_onScroll=()=>{this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._renderBody()};_syncColumns(){this._columns=Array.from(this.children).filter(t=>t instanceof ut).map(t=>({field:t.field,header:t.header,width:t.width,minWidth:t.minWidth,align:t.align,template:Array.from(t.children).find(e=>e instanceof HTMLTemplateElement)??null})).filter(t=>t.field)}_render(){if(!this.isConnected)return;this._emptyState.textContent=this.emptyText;let t=this._columns.length>0?this._columns.map(e=>this._toGridColumn(e)).join(" "):"minmax(0, 1fr)";this._header.style.setProperty("--dt-table-columns",t),this._canvas.style.setProperty("--dt-table-columns",t),this._renderHeader(),this._renderBody()}_renderHeader(){let t=document.createDocumentFragment();for(let e of this._columns){let r=document.createElement("div");r.className="dt-table-header-cell",r.dataset.align=e.align,this.sortable&&(r.classList.add("dt-table-header-cell--sortable"),r.tabIndex=0,r.setAttribute("role","button"),r.setAttribute("aria-label",`Sort by ${e.header}`),r.addEventListener("click",()=>this._requestSort(e.field)),r.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._requestSort(e.field))}));let i=document.createElement("span");if(i.className="dt-table-header-label",i.textContent=e.header,this.sortable){let n=document.createElement("span");n.className="dt-table-sort-indicator",this._sortField===e.field?n.textContent=this._sortDirection==="asc"?"\u25B2":"\u25BC":n.textContent="\u2195",i.appendChild(n)}r.appendChild(i),t.appendChild(r)}this._header.replaceChildren(t)}_renderBody(){if(this._rows.length===0||this._columns.length===0){this._emptyState.hidden=!1,this._canvas.replaceChildren(),this._body.style.height="140px",this._canvas.style.height="0px";return}this._emptyState.hidden=!0,this._virtualizer.setCount(this._rows.length),this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight));let t=this._virtualizer.getRange();this._body.style.height=`${Math.max(t.totalHeight,this._scroll.clientHeight-this._header.offsetHeight)}px`,this._canvas.style.height=`${t.totalHeight}px`;let e=document.createDocumentFragment();for(let r=t.start;r<t.end;r+=1)e.appendChild(this._renderRow(r));this._canvas.replaceChildren(e)}_renderRow(t){let e=this._rows[t],r=document.createElement("div");r.className="dt-table-row dt-table-row--clickable",r.style.top=`${this._virtualizer.getOffset(t)}px`,r.style.height=`${this.rowHeight}px`,r.style.setProperty("--dt-table-columns",this._header.style.getPropertyValue("--dt-table-columns")),r.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("dt-row-click",{detail:{row:e,index:t},bubbles:!0,composed:!0}))});let i=de(e);for(let n of this._columns){let o=document.createElement("div");if(o.className="dt-table-cell",o.dataset.align=n.align,n.template)o.appendChild(ct(n.template,i));else{let s=i[n.field];o.textContent=s==null?"":String(s)}r.appendChild(o)}return r}_requestSort(t){this._sortField===t?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortField=t,this._sortDirection="asc"),this._renderHeader(),this.dispatchEvent(new CustomEvent("dt-sort",{detail:{field:t,direction:this._sortDirection},bubbles:!0,composed:!0}))}_toGridColumn(t){let e=/^\d+$/.test(t.minWidth)?`${t.minWidth}px`:t.minWidth;if(t.width==="auto")return`minmax(${e}, 1fr)`;let r=/^\d+$/.test(t.width)?`${t.width}px`:t.width;return`minmax(${e}, ${r})`}},he=`:host {
1097
1100
  display: block;
1098
1101
  min-height: 120px;
1099
1102
  color: var(--dt-text);
@@ -1279,7 +1282,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
1279
1282
  .dt-chart__status[hidden] {
1280
1283
  display: none;
1281
1284
  }
1282
- `,Z=null;function ge(){return window.__DtChart?Promise.resolve(window.__DtChart):Z||(Z=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/chart.umd.js",r.async=!0,r.dataset.dtChart="true",r.onload=()=>{if(window.__DtChart){t(window.__DtChart);return}e(new Error("Chart runtime loaded without a __DtChart export."))},r.onerror=()=>e(new Error("Failed to load the Chart.js runtime bundle.")),document.head.appendChild(r)}),Z)}function j(t,e,r){return Math.min(r,Math.max(e,t))}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function tt(t){let e=t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(e){let n=e[1],s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,a=parseInt(s.slice(0,2),16)/255,o=parseInt(s.slice(2,4),16)/255,d=parseInt(s.slice(4,6),16)/255;return mt(a,o,d)}let r=t.trim().match(/^rgba?\((\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)(?:[,/\s]+[\d.]+)?\)$/i);if(r)return mt(Number(r[1])/255,Number(r[2])/255,Number(r[3])/255);let i=t.trim().match(/^hsla?\(([-\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%(?:[,/\s]+[\d.]+)?\)$/i);return i?{h:(Number(i[1])%360+360)%360,s:j(Number(i[2]),0,100),l:j(Number(i[3]),0,100)}:null}function mt(t,e,r){let i=Math.max(t,e,r),n=Math.min(t,e,r),s=i-n,a=0,o=(i+n)/2,d=s===0?0:s/(1-Math.abs(2*o-1));if(s!==0)switch(i){case t:a=60*((e-r)/s%6);break;case e:a=60*((r-t)/s+2);break;default:a=60*((t-e)/s+4);break}return{h:(a+360)%360,s:Math.round(d*100),l:Math.round(o*100)}}function P(t,e=1){return`hsla(${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}% / ${e})`}function ve(t){let e=tt(t)??{h:185,s:88,l:56};return[0,32,68,118,164,212,258,304].map((r,i)=>({h:(e.h+r)%360,s:j(e.s-i*2,55,90),l:j(e.l+(i%2===0?0:6)-i,38,66)}))}function K(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function gt(t,e){if(!K(t)||!K(e))return e??t;let r={...t};for(let[i,n]of Object.entries(e)){let s=r[i];r[i]=K(s)&&K(n)?gt(s,n):n}return r}function fe(t){return t==="top"||t==="bottom"||t==="left"||t==="right"?t:"none"}function _e(t){return t==="bar"||t==="line"||t==="area"||t==="pie"||t==="doughnut"||t==="radar"||t==="scatter"||t==="bubble"?t:"bar"}function xe(t){return t==="bar"||t==="line"||t==="area"||t==="scatter"||t==="bubble"}function we(t){return t.map(e=>e.trim()).filter(Boolean)}var ye=class extends HTMLElement{_canvas;_status;_runtime=null;_loadPromise=null;_chart=null;_renderedType=null;_dataInput=null;_optionsOverride=null;_syncFrame=0;static get observedAttributes(){return["type","legend","stacked","labels"]}get type(){return _e(this.getAttribute("type"))}set type(t){this.setAttribute("type",t)}get legend(){return fe(this.getAttribute("legend"))}set legend(t){this.setAttribute("legend",t)}get stacked(){return this.hasAttribute("stacked")}set stacked(t){this.toggleAttribute("stacked",t)}get labels(){return we(be(this.getAttribute("labels")))}set labels(t){this.setAttribute("labels",t.join(","))}get data(){return this._dataInput}set data(t){this._dataInput=t?structuredClone(t):null,this._scheduleSync()}get options(){return this._optionsOverride}set options(t){this._optionsOverride=t?structuredClone(t):null,this._renderChart()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=me,t.appendChild(e);let r=document.createElement("div");r.className="dt-chart",this._canvas=document.createElement("canvas"),this._canvas.className="dt-chart__canvas",this._status=document.createElement("div"),this._status.className="dt-chart__status",this._status.textContent="Loading chart",r.append(this._canvas,this._status),t.appendChild(r)}connectedCallback(){this._canvas.addEventListener("click",this._handleCanvasClick),this._ensureRuntime().then(()=>this._renderChart()),this._scheduleSync()}disconnectedCallback(){this._canvas.removeEventListener("click",this._handleCanvasClick),this._syncFrame!==0&&(cancelAnimationFrame(this._syncFrame),this._syncFrame=0),this._chart?.destroy(),this._chart=null,this._renderedType=null}attributeChangedCallback(){this._scheduleSync()}_handleCanvasClick=t=>{if(!this._chart)return;let e=this._chart.getElementsAtEventForMode(t,"nearest",{intersect:!0},!0)[0];if(!e)return;let r=Array.isArray(this._chart.data.labels)?this._chart.data.labels[e.index]??null:null,i=this._chart.data.datasets[e.datasetIndex],n=Array.isArray(i?.data)?i.data[e.index]:void 0;this.dispatchEvent(new CustomEvent("dt-chart-click",{bubbles:!0,composed:!0,detail:{label:r,datasetIndex:e.datasetIndex,index:e.index,value:n}}))};_scheduleSync(){this._syncFrame===0&&(this._syncFrame=requestAnimationFrame(()=>{this._syncFrame=0,this._syncFromCurrentSource()}))}_syncFromCurrentSource(){this._renderChart()}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=ge().then(t=>(this._runtime=t,t))),this._loadPromise)}async _renderChart(){let t=this._dataInput;if(!t){this._setStatus("Waiting for data");return}let e=await this._ensureRuntime(),r=this._buildConfig(e,t),i=r.type;!this._chart||this._renderedType!==i?(this._chart?.destroy(),this._chart=new e.Chart(this._canvas,r),this._renderedType=i):(this._chart.data=r.data,this._chart.options=r.options,this._chart.update()),this._setStatus(t.datasets.length>0?null:"Waiting for data")}_buildConfig(t,e){let r=getComputedStyle(this),i=r.getPropertyValue("--dt-accent").trim()||"#42d4ff",n=r.getPropertyValue("--dt-text").trim()||"#d6ebff",s=r.getPropertyValue("--dt-text-muted").trim()||"#7b93a6",a=r.getPropertyValue("--dt-border").trim()||"rgba(123, 147, 166, 0.3)",o=r.getPropertyValue("--font-mono").trim()||"'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace",d=ve(i),l=this.type==="area"?"line":this.type,g={labels:e.labels??this.labels,datasets:e.datasets.map((b,w)=>{let C=d[w%d.length],m=b.color??P(C,1),M={label:b.label??"",data:b.data,backgroundColor:l==="line"||l==="radar"||l==="scatter"?P(C,l==="scatter"?.95:.24):m,borderColor:m,pointBackgroundColor:m,pointBorderColor:m,pointHoverBackgroundColor:m,pointRadius:this.type==="line"||this.type==="area"?3:4,pointHoverRadius:this.type==="line"||this.type==="area"?5:6,borderWidth:2,tension:l==="line"||this.type==="area"?.32:void 0,fill:this.type==="area"};return l==="pie"||l==="doughnut"?{...M,backgroundColor:Array.isArray(b.data)?b.data.map((F,E)=>P(d[E%d.length],.86)):m,borderColor:Array.isArray(b.data)?b.data.map((F,E)=>P(d[E%d.length],1)):m,borderWidth:1}:l==="scatter"||l==="bubble"?{...M,showLine:!1,backgroundColor:P(C,.78)}:M})},_={responsive:!0,maintainAspectRatio:!1,animation:{duration:320},interaction:{mode:"nearest",intersect:!0},plugins:{legend:{display:this.legend!=="none",position:this.legend==="none"?"top":this.legend,labels:{color:n,boxWidth:12,boxHeight:12,padding:14,font:{family:o,size:11}}},tooltip:{backgroundColor:"rgba(10, 18, 24, 0.92)",borderColor:ke(a,i,.35),borderWidth:1,titleColor:n,bodyColor:n,footerColor:s,titleFont:{family:o,size:11},bodyFont:{family:o,size:11},padding:10}},scales:xe(this.type)?{x:{stacked:this.stacked,grid:{display:!1,color:a},border:{color:a},ticks:{color:s,font:{family:o,size:11}}},y:{stacked:this.stacked,beginAtZero:!0,grid:{display:!1,color:a},border:{color:a},ticks:{color:s,font:{family:o,size:11}}}}:l==="radar"?{r:{angleLines:{color:a},grid:{color:a},pointLabels:{color:s,font:{family:o,size:11}},ticks:{color:s,backdropColor:"transparent",font:{family:o,size:10}}}}:void 0};return{type:l,data:g,options:gt(_,this._optionsOverride??{})}}_setStatus(t){if(!t){this._status.hidden=!0;return}this._status.hidden=!1,this._status.textContent=t}};function ke(t,e,r){let i=tt(t),n=tt(e);if(!i||!n)return t;let s=j(r,0,1),a=((n.h-i.h)%360+540)%360-180;return P({h:(i.h+a*s+360)%360,s:i.s+(n.s-i.s)*s,l:i.l+(n.l-i.l)*s})}var Ce=`:host {
1285
+ `,Z=null;function ge(){return window.__DtChart?Promise.resolve(window.__DtChart):Z||(Z=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/chart.umd.js",r.async=!0,r.dataset.dtChart="true",r.onload=()=>{if(window.__DtChart){t(window.__DtChart);return}e(new Error("Chart runtime loaded without a __DtChart export."))},r.onerror=()=>e(new Error("Failed to load the Chart.js runtime bundle.")),document.head.appendChild(r)}),Z)}function j(t,e,r){return Math.min(r,Math.max(e,t))}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function tt(t){let e=t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(e){let n=e[1],o=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,s=parseInt(o.slice(0,2),16)/255,a=parseInt(o.slice(2,4),16)/255,d=parseInt(o.slice(4,6),16)/255;return mt(s,a,d)}let r=t.trim().match(/^rgba?\((\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)(?:[,/\s]+[\d.]+)?\)$/i);if(r)return mt(Number(r[1])/255,Number(r[2])/255,Number(r[3])/255);let i=t.trim().match(/^hsla?\(([-\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%(?:[,/\s]+[\d.]+)?\)$/i);return i?{h:(Number(i[1])%360+360)%360,s:j(Number(i[2]),0,100),l:j(Number(i[3]),0,100)}:null}function mt(t,e,r){let i=Math.max(t,e,r),n=Math.min(t,e,r),o=i-n,s=0,a=(i+n)/2,d=o===0?0:o/(1-Math.abs(2*a-1));if(o!==0)switch(i){case t:s=60*((e-r)/o%6);break;case e:s=60*((r-t)/o+2);break;default:s=60*((t-e)/o+4);break}return{h:(s+360)%360,s:Math.round(d*100),l:Math.round(a*100)}}function D(t,e=1){return`hsla(${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}% / ${e})`}function ve(t){let e=tt(t)??{h:185,s:88,l:56};return[0,32,68,118,164,212,258,304].map((r,i)=>({h:(e.h+r)%360,s:j(e.s-i*2,55,90),l:j(e.l+(i%2===0?0:6)-i,38,66)}))}function K(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function gt(t,e){if(!K(t)||!K(e))return e??t;let r={...t};for(let[i,n]of Object.entries(e)){let o=r[i];r[i]=K(o)&&K(n)?gt(o,n):n}return r}function fe(t){return t==="top"||t==="bottom"||t==="left"||t==="right"?t:"none"}function _e(t){return t==="bar"||t==="line"||t==="area"||t==="pie"||t==="doughnut"||t==="radar"||t==="scatter"||t==="bubble"?t:"bar"}function xe(t){return t==="bar"||t==="line"||t==="area"||t==="scatter"||t==="bubble"}function we(t){return t.map(e=>e.trim()).filter(Boolean)}var ye=class extends HTMLElement{_canvas;_status;_runtime=null;_loadPromise=null;_chart=null;_renderedType=null;_dataInput=null;_optionsOverride=null;_syncFrame=0;static get observedAttributes(){return["type","legend","stacked","labels"]}get type(){return _e(this.getAttribute("type"))}set type(t){this.setAttribute("type",t)}get legend(){return fe(this.getAttribute("legend"))}set legend(t){this.setAttribute("legend",t)}get stacked(){return this.hasAttribute("stacked")}set stacked(t){this.toggleAttribute("stacked",t)}get labels(){return we(be(this.getAttribute("labels")))}set labels(t){this.setAttribute("labels",t.join(","))}get data(){return this._dataInput}set data(t){this._dataInput=t?structuredClone(t):null,this._scheduleSync()}get options(){return this._optionsOverride}set options(t){this._optionsOverride=t?structuredClone(t):null,this._renderChart()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=me,t.appendChild(e);let r=document.createElement("div");r.className="dt-chart",this._canvas=document.createElement("canvas"),this._canvas.className="dt-chart__canvas",this._status=document.createElement("div"),this._status.className="dt-chart__status",this._status.textContent="Loading chart",r.append(this._canvas,this._status),t.appendChild(r)}connectedCallback(){this._canvas.addEventListener("click",this._handleCanvasClick),this._ensureRuntime().then(()=>this._renderChart()),this._scheduleSync()}disconnectedCallback(){this._canvas.removeEventListener("click",this._handleCanvasClick),this._syncFrame!==0&&(cancelAnimationFrame(this._syncFrame),this._syncFrame=0),this._chart?.destroy(),this._chart=null,this._renderedType=null}attributeChangedCallback(){this._scheduleSync()}_handleCanvasClick=t=>{if(!this._chart)return;let e=this._chart.getElementsAtEventForMode(t,"nearest",{intersect:!0},!0)[0];if(!e)return;let r=Array.isArray(this._chart.data.labels)?this._chart.data.labels[e.index]??null:null,i=this._chart.data.datasets[e.datasetIndex],n=Array.isArray(i?.data)?i.data[e.index]:void 0;this.dispatchEvent(new CustomEvent("dt-chart-click",{bubbles:!0,composed:!0,detail:{label:r,datasetIndex:e.datasetIndex,index:e.index,value:n}}))};_scheduleSync(){this._syncFrame===0&&(this._syncFrame=requestAnimationFrame(()=>{this._syncFrame=0,this._syncFromCurrentSource()}))}_syncFromCurrentSource(){this._renderChart()}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=ge().then(t=>(this._runtime=t,t))),this._loadPromise)}async _renderChart(){let t=this._dataInput;if(!t){this._setStatus("Waiting for data");return}let e=await this._ensureRuntime(),r=this._buildConfig(e,t),i=r.type;!this._chart||this._renderedType!==i?(this._chart?.destroy(),this._chart=new e.Chart(this._canvas,r),this._renderedType=i):(this._chart.data=r.data,this._chart.options=r.options,this._chart.update()),this._setStatus(t.datasets.length>0?null:"Waiting for data")}_buildConfig(t,e){let r=getComputedStyle(this),i=r.getPropertyValue("--dt-accent").trim()||"#42d4ff",n=r.getPropertyValue("--dt-text").trim()||"#d6ebff",o=r.getPropertyValue("--dt-text-muted").trim()||"#7b93a6",s=r.getPropertyValue("--dt-border").trim()||"rgba(123, 147, 166, 0.3)",a=r.getPropertyValue("--font-mono").trim()||"'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace",d=ve(i),l=this.type==="area"?"line":this.type,u={labels:e.labels??this.labels,datasets:e.datasets.map((b,w)=>{let C=d[w%d.length],g=b.color??D(C,1),M={label:b.label??"",data:b.data,backgroundColor:l==="line"||l==="radar"||l==="scatter"?D(C,l==="scatter"?.95:.24):g,borderColor:g,pointBackgroundColor:g,pointBorderColor:g,pointHoverBackgroundColor:g,pointRadius:this.type==="line"||this.type==="area"?3:4,pointHoverRadius:this.type==="line"||this.type==="area"?5:6,borderWidth:2,tension:l==="line"||this.type==="area"?.32:void 0,fill:this.type==="area"};return l==="pie"||l==="doughnut"?{...M,backgroundColor:Array.isArray(b.data)?b.data.map((F,E)=>D(d[E%d.length],.86)):g,borderColor:Array.isArray(b.data)?b.data.map((F,E)=>D(d[E%d.length],1)):g,borderWidth:1}:l==="scatter"||l==="bubble"?{...M,showLine:!1,backgroundColor:D(C,.78)}:M})},_={responsive:!0,maintainAspectRatio:!1,animation:{duration:320},interaction:{mode:"nearest",intersect:!0},plugins:{legend:{display:this.legend!=="none",position:this.legend==="none"?"top":this.legend,labels:{color:n,boxWidth:12,boxHeight:12,padding:14,font:{family:a,size:11}}},tooltip:{backgroundColor:"rgba(10, 18, 24, 0.92)",borderColor:ke(s,i,.35),borderWidth:1,titleColor:n,bodyColor:n,footerColor:o,titleFont:{family:a,size:11},bodyFont:{family:a,size:11},padding:10}},scales:xe(this.type)?{x:{stacked:this.stacked,grid:{display:!1,color:s},border:{color:s},ticks:{color:o,font:{family:a,size:11}}},y:{stacked:this.stacked,beginAtZero:!0,grid:{display:!1,color:s},border:{color:s},ticks:{color:o,font:{family:a,size:11}}}}:l==="radar"?{r:{angleLines:{color:s},grid:{color:s},pointLabels:{color:o,font:{family:a,size:11}},ticks:{color:o,backdropColor:"transparent",font:{family:a,size:10}}}}:void 0};return{type:l,data:u,options:gt(_,this._optionsOverride??{})}}_setStatus(t){if(!t){this._status.hidden=!0;return}this._status.hidden=!1,this._status.textContent=t}};function ke(t,e,r){let i=tt(t),n=tt(e);if(!i||!n)return t;let o=j(r,0,1),s=((n.h-i.h)%360+540)%360-180;return D({h:(i.h+s*o+360)%360,s:i.s+(n.s-i.s)*o,l:i.l+(n.l-i.l)*o})}var Ce=`:host {
1283
1286
  display: block;
1284
1287
  color: var(--dt-text);
1285
1288
  font-family: var(--font-sans, 'Inter', sans-serif);
@@ -1564,6 +1567,34 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
1564
1567
  color: var(--dt-text);
1565
1568
  }
1566
1569
 
1570
+ .milkdown .ProseMirror.editor {
1571
+ padding: 0px 54px;
1572
+ }
1573
+
1574
+ .milkdown .ProseMirror.editor h1 {
1575
+ font-size: 36px;
1576
+ }
1577
+
1578
+ .milkdown .ProseMirror.editor h2 {
1579
+ font-size: 30px;
1580
+ }
1581
+
1582
+ .milkdown .ProseMirror.editor h3 {
1583
+ font-size: 24px;
1584
+ }
1585
+
1586
+ .milkdown .ProseMirror.editor h4 {
1587
+ font-size: 20px;
1588
+ }
1589
+
1590
+ .milkdown .ProseMirror.editor h5 {
1591
+ font-size: 16px;
1592
+ }
1593
+
1594
+ .milkdown .ProseMirror.editor h6 {
1595
+ font-size: 16px;
1596
+ }
1597
+
1567
1598
  .milkdown .editor {
1568
1599
  min-height: 100%;
1569
1600
  padding: 16px 18px 20px;
@@ -1574,10 +1605,6 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
1574
1605
  line-height: 1.7;
1575
1606
  }
1576
1607
 
1577
- .milkdown .editor > :first-child {
1578
- margin-top: 0;
1579
- }
1580
-
1581
1608
  .milkdown .editor h1,
1582
1609
  .milkdown .editor h2,
1583
1610
  .milkdown .editor h3,
@@ -1603,10 +1630,6 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
1603
1630
  font-size: 1.08rem;
1604
1631
  }
1605
1632
 
1606
- .milkdown .editor p {
1607
- margin: 0.65em 0;
1608
- }
1609
-
1610
1633
  .milkdown .editor code {
1611
1634
  padding: 2px 5px;
1612
1635
  border-radius: 2px;
@@ -1663,6 +1686,38 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
1663
1686
  padding-left: 1.5rem;
1664
1687
  }
1665
1688
 
1689
+ /* Runtime Milkdown styles are injected after this file, so use scoped CSS
1690
+ variables instead of direct property overrides. */
1691
+ .milkdown .milkdown-list-item-block {
1692
+ --crepe-color-outline: var(--dt-text-secondary);
1693
+ }
1694
+
1695
+ .milkdown .milkdown-block-handle {
1696
+ --crepe-color-outline: var(--dt-text-muted);
1697
+ }
1698
+
1699
+ .milkdown .milkdown-block-handle .operation-item:hover {
1700
+ --crepe-color-outline: var(--dt-text-secondary);
1701
+ }
1702
+
1703
+ .milkdown .milkdown-toolbar {
1704
+ --crepe-color-outline: var(--dt-text-muted);
1705
+ --crepe-color-hover: color-mix(
1706
+ in srgb,
1707
+ var(--dt-surface-hover) 88%,
1708
+ var(--dt-text-secondary) 12%
1709
+ );
1710
+ --crepe-color-selected: color-mix(in srgb, var(--dt-surface-active) 74%, var(--dt-accent) 26%);
1711
+ }
1712
+
1713
+ .milkdown .milkdown-toolbar .toolbar-item:hover {
1714
+ --crepe-color-outline: var(--dt-text-secondary);
1715
+ }
1716
+
1717
+ .milkdown .milkdown-toolbar .toolbar-item.active {
1718
+ --crepe-color-primary: var(--dt-accent);
1719
+ }
1720
+
1666
1721
  .milkdown .editor img {
1667
1722
  max-width: 100%;
1668
1723
  border-radius: 2px;
@@ -1677,15 +1732,15 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
1677
1732
  .milkdown .editor td {
1678
1733
  border: 1px solid var(--dt-border);
1679
1734
  }
1680
- `,rt=null;function Ne(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):rt||(rt=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){t(window.__DtMilkdown);return}e(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>e(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),rt)}var Te=class extends HTMLElement{_runtimeStyle;_surface;_content;_status;_runtime=null;_loadPromise=null;_editor=null;_pendingValue="";_changeTimer=null;_setupToken=0;_suppressNextChange=!1;static get observedAttributes(){return["placeholder","readonly"]}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(t){this.setAttribute("placeholder",t)}get readonly(){return this.hasAttribute("readonly")}set readonly(t){this.toggleAttribute("readonly",t)}get value(){return this._editor&&(this._pendingValue=this._editor.getMarkdown()),this._pendingValue}set value(t){let e=String(t??"");this._pendingValue=e,this._editor&&this._runtime&&this._editor.getMarkdown()!==e&&(this._suppressNextChange=!0,this._editor.editor.action(this._runtime.replaceAll(e)))}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Me,t.appendChild(e),this._runtimeStyle=document.createElement("style"),t.appendChild(this._runtimeStyle),this._surface=document.createElement("div"),this._surface.className="dt-markdown-editor",this._content=document.createElement("div"),this._content.className="dt-markdown-editor__surface";let r=document.createElement("div");r.className="dt-markdown-editor__content",this._content.appendChild(r),this._status=document.createElement("div"),this._status.className="dt-markdown-editor__status",this._status.textContent="Loading editor",this._surface.append(this._content,this._status),t.appendChild(this._surface)}connectedCallback(){this._initializeEditor()}disconnectedCallback(){this._setupToken+=1,this._clearChangeTimer(),this._destroyEditor()}attributeChangedCallback(t){if(t==="readonly"){this._editor?.setReadonly(this.readonly);return}t==="placeholder"&&this.isConnected&&this._initializeEditor(!0)}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=Ne().then(t=>(this._runtime=t,this._runtimeStyle.textContent=t.cssText,t))),this._loadPromise)}async _initializeEditor(t=!1){let e=++this._setupToken;if(this._setStatus("Loading editor"),t)await this._destroyEditor();else if(this._editor){this._setStatus(null);return}try{let r=await this._ensureRuntime();if(!this.isConnected||e!==this._setupToken)return;this._content.replaceChildren();let i=document.createElement("div");i.className="dt-markdown-editor__content",this._content.appendChild(i);let n=new r.Crepe({root:i,defaultValue:this._pendingValue,features:{[r.Crepe.Feature.CodeMirror]:!1,[r.Crepe.Feature.ImageBlock]:!1,[r.Crepe.Feature.Latex]:!1},featureConfigs:{[r.Crepe.Feature.Placeholder]:{text:this.placeholder,mode:"doc"}}});if(n.on(s=>{s.markdownUpdated((a,o)=>{if(this._pendingValue=o,this._suppressNextChange){this._suppressNextChange=!1;return}this._queueChange(o)}),s.focus(()=>{this.dispatchEvent(new CustomEvent("dt-focus",{bubbles:!0,composed:!0}))}),s.blur(()=>{this.dispatchEvent(new CustomEvent("dt-blur",{bubbles:!0,composed:!0}))})}),await n.create(),!this.isConnected||e!==this._setupToken){await n.destroy();return}this._editor=n,this._editor.setReadonly(this.readonly),this._pendingValue=this._editor.getMarkdown(),this._setStatus(null)}catch{e===this._setupToken&&this._setStatus("Failed to load editor")}}async _destroyEditor(){let t=this._editor;if(this._editor=null,!!t)try{await t.destroy()}catch{}}_queueChange(t){this._clearChangeTimer(),this._changeTimer=setTimeout(()=>{this._changeTimer=null,this.dispatchEvent(new CustomEvent("dt-change",{bubbles:!0,composed:!0,detail:{value:t}}))},300)}_clearChangeTimer(){this._changeTimer&&(clearTimeout(this._changeTimer),this._changeTimer=null)}_setStatus(t){if(t){this._status.hidden=!1,this._status.textContent=t;return}this._status.hidden=!0}};customElements.get("dt-tooltip")||customElements.define("dt-tooltip",zt),customElements.get("dt-card")||customElements.define("dt-card",Tt),customElements.get("dt-select")||customElements.define("dt-select",Vt),customElements.get("dt-grid")||customElements.define("dt-grid",Wt),customElements.get("dt-stack")||customElements.define("dt-stack",Ut),customElements.get("dt-stat")||customElements.define("dt-stat",Gt),customElements.get("dt-badge")||customElements.define("dt-badge",Qt),customElements.get("dt-button")||customElements.define("dt-button",ee),customElements.get("dt-divider")||customElements.define("dt-divider",ne),customElements.get("dt-list-view")||customElements.define("dt-list-view",pe),customElements.get("dt-table-view")||customElements.define("dt-table-view",ce),customElements.get("dt-column")||customElements.define("dt-column",ut),customElements.get("dt-chart")||customElements.define("dt-chart",ye),customElements.get("dt-markdown")||customElements.define("dt-markdown",ze),customElements.get("dt-markdown-editor")||customElements.define("dt-markdown-editor",Te);function Le(t){const e=t.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?([\s\S]*)$/);return e?e[1]:t}var He=ft(function({note:e,loading:r,onSave:i},n){const s=H(null),[a,o]=I("idle"),d=H(null),l=H(i);return l.current=i,W(()=>{if(s.current&&e){const g=Le(e.content);s.current.value=g}},[e?.id]),W(()=>{const g=s.current;if(!g)return;const _=b=>{const w=b.detail;w&&(d.current&&clearTimeout(d.current),o("saving"),d.current=setTimeout(()=>{l.current(w.value),o("saved")},500))};return g.addEventListener("dt-change",_),()=>g.removeEventListener("dt-change",_)},[]),W(()=>()=>{d.current&&clearTimeout(d.current)},[]),_t(n,()=>({getMarkdown(){return s.current?.value??null},setMarkdown(g){s.current&&(s.current.value=g)},getCursorLine(){return 1},getSelectedText(){return""}}),[]),e?T("div",{className:v.editorPanel,children:[T("div",{className:v.editorHeader,children:[T("div",{children:[u("div",{className:v.editorTitle,children:e.title}),e.tags.length>0&&u("div",{className:v.editorTags,children:e.tags.map(g=>u("span",{className:v.editorTag,children:g},g))})]}),u("span",{className:a==="saving"?v.saveStatusSaving:v.saveStatus,children:a==="saving"?"Saving...":a==="saved"?"Saved":""})]}),u("div",{className:v.editorBody,children:u("dt-markdown-editor",{ref:s,placeholder:"Start writing...",style:{height:"100%"}})})]}):u("div",{className:v.editorPanel,children:u("div",{className:v.editorPlaceholder,children:r?"Loading...":"Select a note or create a new one"})})});import{ActionsProvider as Ie,Action as R,useCommand as J}from"@desktalk/sdk";var Re=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;function Fe(t){const e=t.match(Re);if(!e){const d=t.match(/^#\s+(.+)$/m);return{title:d?d[1].trim():"Untitled",tags:[],created:null,body:t}}const r=e[1],i=e[2];let n="Untitled",s=[],a=null,o=!1;for(const d of r.split(`
1681
- `)){const l=d.trim();if(l.startsWith("title:"))n=l.slice(6).trim().replace(/^["']|["']$/g,""),o=!1;else if(l.startsWith("created:"))a=l.slice(8).trim(),o=!1;else if(l.startsWith("tags:")){o=!0;const g=l.slice(5).trim();g.startsWith("[")&&g.endsWith("]")&&(s=g.slice(1,-1).split(",").map(_=>_.trim().replace(/^["']|["']$/g,"")).filter(Boolean),o=!1)}else o&&l.startsWith("- ")?s.push(l.slice(2).trim().replace(/^["']|["']$/g,"")):o=!1}return{title:n,tags:s,created:a,body:i}}function $e(t,e,r,i){const n=["---",`title: "${t.replace(/"/g,'\\"')}"`];if(e.length>0){n.push("tags:");for(const s of e)n.push(` - ${s}`)}return n.push(`created: ${r}`,"---","",i),n.join(`
1682
- `)}function De(t,e,r,i,n){const a=t.substring(0,n).split(`
1683
- `).length,o=r.split(`
1735
+ `,rt=null;function Ne(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):rt||(rt=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){t(window.__DtMilkdown);return}e(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>e(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),rt)}var Te=class extends HTMLElement{_shadow;_runtimeStyleAnchor;_surface;_content;_status;_runtime=null;_loadPromise=null;_editor=null;_pendingValue="";_changeTimer=null;_setupToken=0;_suppressNextChange=!1;static get observedAttributes(){return["placeholder","readonly"]}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(t){this.setAttribute("placeholder",t)}get readonly(){return this.hasAttribute("readonly")}set readonly(t){this.toggleAttribute("readonly",t)}get value(){return this._editor&&(this._pendingValue=this._editor.getMarkdown()),this._pendingValue}set value(t){let e=String(t??"");this._pendingValue=e,this._editor&&this._runtime&&this._editor.getMarkdown()!==e&&(this._suppressNextChange=!0,this._editor.editor.action(this._runtime.replaceAll(e)))}constructor(){super();let t=this.attachShadow({mode:"open"});this._shadow=t;let e=document.createElement("style");e.textContent=Me,t.appendChild(e),this._runtimeStyleAnchor=document.createComment("runtime-styles"),t.appendChild(this._runtimeStyleAnchor),this._surface=document.createElement("div"),this._surface.className="dt-markdown-editor",this._content=document.createElement("div"),this._content.className="dt-markdown-editor__surface";let r=document.createElement("div");r.className="dt-markdown-editor__content",this._content.appendChild(r),this._status=document.createElement("div"),this._status.className="dt-markdown-editor__status",this._status.textContent="Loading editor",this._surface.append(this._content,this._status),t.appendChild(this._surface)}connectedCallback(){this._initializeEditor()}disconnectedCallback(){this._setupToken+=1,this._clearChangeTimer(),this._destroyEditor()}attributeChangedCallback(t){if(t==="readonly"){this._editor?.setReadonly(this.readonly);return}t==="placeholder"&&this.isConnected&&this._initializeEditor(!0)}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=Ne().then(t=>{this._runtime=t;let e=this._runtimeStyleAnchor;for(let r of t.cssEntries){let i=document.createElement("style");i.dataset.css=r.name,i.textContent=r.css,e.parentNode.insertBefore(i,e.nextSibling)}return t})),this._loadPromise)}async _initializeEditor(t=!1){let e=++this._setupToken;if(this._setStatus("Loading editor"),t)await this._destroyEditor();else if(this._editor){this._setStatus(null);return}try{let r=await this._ensureRuntime();if(!this.isConnected||e!==this._setupToken)return;this._content.replaceChildren();let i=document.createElement("div");i.className="dt-markdown-editor__content",this._content.appendChild(i);let n=new r.Crepe({root:i,defaultValue:this._pendingValue,features:{[r.Crepe.Feature.CodeMirror]:!1,[r.Crepe.Feature.ImageBlock]:!1,[r.Crepe.Feature.Latex]:!1},featureConfigs:{[r.Crepe.Feature.Placeholder]:{text:this.placeholder,mode:"doc"}}});if(n.on(o=>{o.markdownUpdated((s,a)=>{if(this._pendingValue=a,this._suppressNextChange){this._suppressNextChange=!1;return}this._queueChange(a)}),o.focus(()=>{this.dispatchEvent(new CustomEvent("dt-focus",{bubbles:!0,composed:!0}))}),o.blur(()=>{this.dispatchEvent(new CustomEvent("dt-blur",{bubbles:!0,composed:!0}))})}),await n.create(),!this.isConnected||e!==this._setupToken){await n.destroy();return}this._editor=n,this._editor.setReadonly(this.readonly),this._pendingValue=this._editor.getMarkdown(),this._setStatus(null)}catch{e===this._setupToken&&this._setStatus("Failed to load editor")}}async _destroyEditor(){let t=this._editor;if(this._editor=null,!!t)try{await t.destroy()}catch{}}_queueChange(t){this._clearChangeTimer(),this._changeTimer=setTimeout(()=>{this._changeTimer=null,this.dispatchEvent(new CustomEvent("dt-change",{bubbles:!0,composed:!0,detail:{value:t}}))},300)}_clearChangeTimer(){this._changeTimer&&(clearTimeout(this._changeTimer),this._changeTimer=null)}_setStatus(t){if(t){this._status.hidden=!1,this._status.textContent=t;return}this._status.hidden=!0}};customElements.get("dt-tooltip")||customElements.define("dt-tooltip",zt),customElements.get("dt-card")||customElements.define("dt-card",Tt),customElements.get("dt-select")||customElements.define("dt-select",Vt),customElements.get("dt-grid")||customElements.define("dt-grid",Bt),customElements.get("dt-stack")||customElements.define("dt-stack",Ut),customElements.get("dt-stat")||customElements.define("dt-stat",Xt),customElements.get("dt-badge")||customElements.define("dt-badge",Qt),customElements.get("dt-button")||customElements.define("dt-button",ee),customElements.get("dt-divider")||customElements.define("dt-divider",ne),customElements.get("dt-list-view")||customElements.define("dt-list-view",pe),customElements.get("dt-table-view")||customElements.define("dt-table-view",ce),customElements.get("dt-column")||customElements.define("dt-column",ut),customElements.get("dt-chart")||customElements.define("dt-chart",ye),customElements.get("dt-markdown")||customElements.define("dt-markdown",ze),customElements.get("dt-markdown-editor")||customElements.define("dt-markdown-editor",Te);function Le(t){const e=t.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?([\s\S]*)$/);return e?e[1]:t}var He=ft(function({note:e,loading:r,onSave:i},n){const o=H(null),[s,a]=I("idle"),d=H(null),l=H(i);return l.current=i,B(()=>{if(o.current&&e){const u=Le(e.content);o.current.value=u}},[e?.id]),B(()=>{const u=o.current;if(!u)return;const _=b=>{const w=b.detail;w&&(d.current&&clearTimeout(d.current),a("saving"),d.current=setTimeout(()=>{l.current(w.value),a("saved")},500))};return u.addEventListener("dt-change",_),()=>u.removeEventListener("dt-change",_)},[]),B(()=>()=>{d.current&&clearTimeout(d.current)},[]),_t(n,()=>({getMarkdown(){return o.current?.value??null},setMarkdown(u){o.current&&(o.current.value=u)},getCursorLine(){return 1},getSelectedText(){return""}}),[]),e?T("div",{className:v.editorPanel,children:[T("div",{className:v.editorHeader,children:[T("div",{children:[p("div",{className:v.editorTitle,children:e.title}),e.tags.length>0&&p("div",{className:v.editorTags,children:e.tags.map(u=>p("span",{className:v.editorTag,children:u},u))})]}),p("span",{className:s==="saving"?v.saveStatusSaving:v.saveStatus,children:s==="saving"?"Saving...":s==="saved"?"Saved":""})]}),p("div",{className:v.editorBody,children:p("dt-markdown-editor",{ref:o,placeholder:"Start writing...",style:{height:"100%"}})})]}):p("div",{className:v.editorPanel,children:p("div",{className:v.editorPlaceholder,children:r?"Loading...":"Select a note or create a new one"})})});import{ActionsProvider as Ie,Action as R,useCommand as J}from"@desktalk/sdk";var Re=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;function Fe(t){const e=t.match(Re);if(!e){const d=t.match(/^#\s+(.+)$/m);return{title:d?d[1].trim():"Untitled",tags:[],created:null,body:t}}const r=e[1],i=e[2];let n="Untitled",o=[],s=null,a=!1;for(const d of r.split(`
1736
+ `)){const l=d.trim();if(l.startsWith("title:"))n=l.slice(6).trim().replace(/^["']|["']$/g,""),a=!1;else if(l.startsWith("created:"))s=l.slice(8).trim(),a=!1;else if(l.startsWith("tags:")){a=!0;const u=l.slice(5).trim();u.startsWith("[")&&u.endsWith("]")&&(o=u.slice(1,-1).split(",").map(_=>_.trim().replace(/^["']|["']$/g,"")).filter(Boolean),a=!1)}else a&&l.startsWith("- ")?o.push(l.slice(2).trim().replace(/^["']|["']$/g,"")):a=!1}return{title:n,tags:o,created:s,body:i}}function $e(t,e,r,i){const n=["---",`title: "${t.replace(/"/g,'\\"')}"`];if(e.length>0){n.push("tags:");for(const o of e)n.push(` - ${o}`)}return n.push(`created: ${r}`,"---","",i),n.join(`
1737
+ `)}function Pe(t,e,r,i,n){const s=t.substring(0,n).split(`
1738
+ `).length,a=r.split(`
1684
1739
  `),d=i.split(`
1685
- `),l=Math.max(0,a-4),g=t.split(`
1740
+ `),l=Math.max(0,s-4),u=t.split(`
1686
1741
  `),_=e.split(`
1687
- `),b=[];b.push(`@@ -${a},${o.length} +${a},${d.length} @@`);for(let m=l;m<a-1;m++)b.push(` ${g[m]}`);for(const m of o)b.push(`-${m}`);for(const m of d)b.push(`+${m}`);const w=a-1+o.length,C=Math.min(_.length,w+3);for(let m=w;m<C;m++)_[m]!==void 0&&b.push(` ${_[m]}`);return{diff:b.join(`
1688
- `),firstChangedLine:a}}function Pe({children:t,selectedNoteId:e,selectedNote:r,notes:i,editorRef:n,onNoteCreated:s,onNoteDeleted:a,onSearch:o,onNoteUpdated:d,onSelectNote:l,onRefresh:g}){const _=J("notes.create"),b=J("notes.delete"),w=J("notes.search"),C=J("notes.update"),m=x(async f=>{const p=await _({title:f?.title||void 0,content:f?.content||void 0,tags:f?.tags||void 0,path:f?.path||void 0});return s(p),p},[_,s]),M=x(async()=>{e&&(await b({id:e}),a(e))},[b,e,a]),F=x(async f=>{const p=f?.query||"";return o(p),await w({query:p})},[w,o]),E=x(()=>{if(!r)return null;const f=n.current;if(!f)return null;const p=f.getMarkdown();return p===null?null:$e(r.title,r.tags,r.createdAt,p)},[r,n]),$=x(async()=>({notes:i.slice(0,20).map(p=>({id:p.id,title:p.title,updatedAt:p.updatedAt,selected:p.id===e}))}),[i,e]),A=x(async f=>{const p=f?.id;return p?i.find(N=>N.id===p)?(await l(p),{success:!0}):{success:!1,error:`Note not found: ${p}`}:{success:!1,error:"id parameter is required"}},[i,l]),U=x(async()=>{if(!e||!r)return{error:"No note is currently open"};const f=n.current;if(!f)return{error:"Editor is not ready"};const p=E();return p===null?{error:"Editor is not ready"}:{id:r.id,title:r.title,content:p,cursorLine:f.getCursorLine(),selectedText:f.getSelectedText()}},[e,r,n,E]),V=x(async f=>{if(!e||!r)return{success:!1,error:"No note is currently open"};const p=n.current;if(!p)return{success:!1,error:"Editor is not ready"};const y=f?.old_text,N=f?.new_text;if(y===void 0||N===void 0)return{success:!1,error:"Both old_text and new_text are required"};const S=E();if(S===null)return{success:!1,error:"Editor is not ready"};let D,O;if(y==="")D=N+S,O=0;else{const z=S.indexOf(y);if(z===-1)return{success:!1,error:"Text not found in note"};const X=S.indexOf(y,z+1);if(X!==-1){let it=2,nt=X+1;for(;;){const st=S.indexOf(y,nt);if(st===-1)break;it++,nt=st+1}return{success:!1,error:`Text appears ${it} times; provide more surrounding context to make it unique`}}D=S.substring(0,z)+N+S.substring(z+y.length),O=z}const c=Fe(D);p.setMarkdown(c.body);const k=c.tags.length!==r.tags.length||c.tags.some((z,X)=>z!==r.tags[X]),q=c.title!==r.title;if(k||q){const z=await C({id:e,tags:c.tags,content:c.body});d(z)}const{diff:Y,firstChangedLine:vt}=De(S,D,y,N,O);return{success:!0,diff:Y,firstChangedLine:vt}},[e,r,n,E,C,d]);return T(Ie,{children:[u(R,{name:"Create Note",description:"Create a new note with optional title, content, and path",params:{title:{type:"string",description:"Note title",required:!1},content:{type:"string",description:"Note content in Markdown",required:!1},tags:{type:"string",description:"Comma-separated tags",required:!1},path:{type:"string",description:'Relative path for the note (e.g. "work/meeting-notes"). Becomes the note ID. Auto-generated if omitted.',required:!1}},handler:m}),u(R,{name:"Delete Note",description:"Delete the currently selected note",handler:M}),u(R,{name:"Search Notes",description:"Search notes by keyword",params:{query:{type:"string",description:"Search query",required:!0}},handler:F}),u(R,{name:"List Notes",description:"Return the 20 most recent notes with selection status",handler:$}),u(R,{name:"Select Note",description:"Select a note by ID and open it in the editor",params:{id:{type:"string",description:"Note ID (relative path without .md)",required:!0}},handler:A}),u(R,{name:"Get Editing Context",description:"Return the current editor state for the selected note including content, cursor position, and selected text",handler:U}),u(R,{name:"Edit Note",description:"Apply a text replacement to the current note content including front matter. Use old_text to find exact text and new_text to replace it. To edit tags or title, modify the YAML front matter directly.",params:{old_text:{type:"string",description:"Exact text to find in the note content (must appear exactly once). Searches the full content including YAML front matter. Use empty string to insert at beginning.",required:!0},new_text:{type:"string",description:"Replacement text",required:!0}},handler:V}),t]})}var Ve=720;function Oe(){const[t,e]=I([]),[r,i]=I(null),[n,s]=I(null),[a,o]=I(""),[d,l]=I(!1),[g,_]=I(!1),b=H(null),w=H(null),C=B("notes.list"),m=B("notes.get"),M=B("notes.update"),F=B("notes.search"),E=B("notes.create"),$=x(async()=>{try{let c;a?c=await F({query:a}):c=await C(),e(c)}catch(c){console.error("Failed to fetch notes:",c)}},[C,F,a]),A=x(()=>{$()},[$]);W(()=>{A()},[A]),W(()=>{if(!w.current)return;const c=q=>{_(q<=Ve)};c(w.current.clientWidth);const k=new ResizeObserver(q=>{const Y=q[0];Y&&c(Y.contentRect.width)});return k.observe(w.current),()=>k.disconnect()},[]);const U=x(async c=>{i(c),l(!0);try{const k=await m({id:c});s(k)}catch(k){console.error("Failed to load note:",k),s(null)}finally{l(!1)}},[m]),V=H(null),f=x(c=>{o(c),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{},300)},[]),p=x(async c=>{if(!(!r||!n))try{const k=await M({id:r,content:c});s(k),$()}catch(k){console.error("Failed to save note:",k)}},[r,n,M,$]),y=x(c=>{A(),i(c.id),s(c)},[A]),N=x(c=>{r===c&&(i(null),s(null)),A()},[r,A]),S=x(c=>{r===c.id&&s(c),A()},[r,A]),D=x(c=>{o(c)},[]),O=x(async()=>{try{const c=await E({});y(c)}catch(c){console.error("Failed to create note:",c)}},[E,y]);return u(Pe,{selectedNoteId:r,selectedNote:n,notes:t,editorRef:b,onNoteCreated:y,onNoteDeleted:N,onSearch:D,onNoteUpdated:S,onSelectNote:U,onRefresh:A,children:T("div",{ref:w,className:`${v.root}${g?` ${v.rootCompact}`:""}`,children:[u(Ct,{notes:t,selectedId:r,onSelect:U,onCreate:O,searchQuery:a,onSearchChange:f}),u(He,{ref:b,note:n,loading:d,onSave:p})]})})}function qe(t){const e=xt(t.root);return e.render(u(yt,{windowId:t.windowId,children:u(wt,{miniAppId:t.miniAppId,children:u(Oe,{})})})),{deactivate(){e.unmount()}}}export{qe as activate};
1742
+ `),b=[];b.push(`@@ -${s},${a.length} +${s},${d.length} @@`);for(let g=l;g<s-1;g++)b.push(` ${u[g]}`);for(const g of a)b.push(`-${g}`);for(const g of d)b.push(`+${g}`);const w=s-1+a.length,C=Math.min(_.length,w+3);for(let g=w;g<C;g++)_[g]!==void 0&&b.push(` ${_[g]}`);return{diff:b.join(`
1743
+ `),firstChangedLine:s}}function De({children:t,selectedNoteId:e,selectedNote:r,notes:i,editorRef:n,onNoteCreated:o,onNoteDeleted:s,onSearch:a,onNoteUpdated:d,onSelectNote:l,onRefresh:u}){const _=J("notes.create"),b=J("notes.delete"),w=J("notes.search"),C=J("notes.update"),g=x(async f=>{const m=await _({title:f?.title||void 0,content:f?.content||void 0,tags:f?.tags||void 0,path:f?.path||void 0});return o(m),m},[_,o]),M=x(async()=>{e&&(await b({id:e}),s(e))},[b,e,s]),F=x(async f=>{const m=f?.query||"";return a(m),await w({query:m})},[w,a]),E=x(()=>{if(!r)return null;const f=n.current;if(!f)return null;const m=f.getMarkdown();return m===null?null:$e(r.title,r.tags,r.createdAt,m)},[r,n]),$=x(async()=>({notes:i.slice(0,20).map(m=>({id:m.id,title:m.title,updatedAt:m.updatedAt,selected:m.id===e}))}),[i,e]),A=x(async f=>{const m=f?.id;return m?i.find(N=>N.id===m)?(await l(m),{success:!0}):{success:!1,error:`Note not found: ${m}`}:{success:!1,error:"id parameter is required"}},[i,l]),U=x(async()=>{if(!e||!r)return{error:"No note is currently open"};const f=n.current;if(!f)return{error:"Editor is not ready"};const m=E();return m===null?{error:"Editor is not ready"}:{id:r.id,title:r.title,content:m,cursorLine:f.getCursorLine(),selectedText:f.getSelectedText()}},[e,r,n,E]),V=x(async f=>{if(!e||!r)return{success:!1,error:"No note is currently open"};const m=n.current;if(!m)return{success:!1,error:"Editor is not ready"};const y=f?.old_text,N=f?.new_text;if(y===void 0||N===void 0)return{success:!1,error:"Both old_text and new_text are required"};const S=E();if(S===null)return{success:!1,error:"Editor is not ready"};let P,O;if(y==="")P=N+S,O=0;else{const z=S.indexOf(y);if(z===-1)return{success:!1,error:"Text not found in note"};const Y=S.indexOf(y,z+1);if(Y!==-1){let it=2,nt=Y+1;for(;;){const ot=S.indexOf(y,nt);if(ot===-1)break;it++,nt=ot+1}return{success:!1,error:`Text appears ${it} times; provide more surrounding context to make it unique`}}P=S.substring(0,z)+N+S.substring(z+y.length),O=z}const c=Fe(P);m.setMarkdown(c.body);const k=c.tags.length!==r.tags.length||c.tags.some((z,Y)=>z!==r.tags[Y]),W=c.title!==r.title;if(k||W){const z=await C({id:e,tags:c.tags,content:c.body});d(z)}const{diff:G,firstChangedLine:vt}=Pe(S,P,y,N,O);return{success:!0,diff:G,firstChangedLine:vt}},[e,r,n,E,C,d]);return T(Ie,{children:[p(R,{name:"Create Note",description:"Create a new note with optional title, content, and path",params:{title:{type:"string",description:"Note title",required:!1},content:{type:"string",description:"Note content in Markdown",required:!1},tags:{type:"string",description:"Comma-separated tags",required:!1},path:{type:"string",description:'Relative path for the note (e.g. "work/meeting-notes"). Becomes the note ID. Auto-generated if omitted.',required:!1}},handler:g}),p(R,{name:"Delete Note",description:"Delete the currently selected note",handler:M}),p(R,{name:"Search Notes",description:"Search notes by keyword",params:{query:{type:"string",description:"Search query",required:!0}},handler:F}),p(R,{name:"List Notes",description:"Return the 20 most recent notes with selection status",handler:$}),p(R,{name:"Select Note",description:"Select a note by ID and open it in the editor",params:{id:{type:"string",description:"Note ID (relative path without .md)",required:!0}},handler:A}),p(R,{name:"Get Editing Context",description:"Return the current editor state for the selected note including content, cursor position, and selected text",handler:U}),p(R,{name:"Edit Note",description:"Apply a text replacement to the current note content including front matter. Use old_text to find exact text and new_text to replace it. To edit tags or title, modify the YAML front matter directly.",params:{old_text:{type:"string",description:"Exact text to find in the note content (must appear exactly once). Searches the full content including YAML front matter. Use empty string to insert at beginning.",required:!0},new_text:{type:"string",description:"Replacement text",required:!0}},handler:V}),t]})}var Ve=720;function Oe(){const[t,e]=I([]),[r,i]=I(null),[n,o]=I(null),[s,a]=I(""),[d,l]=I(!1),[u,_]=I(!1),b=H(null),w=H(null),C=q("notes.list"),g=q("notes.get"),M=q("notes.update"),F=q("notes.search"),E=q("notes.create"),$=x(async()=>{try{let c;s?c=await F({query:s}):c=await C(),e(c)}catch(c){console.error("Failed to fetch notes:",c)}},[C,F,s]),A=x(()=>{$()},[$]);B(()=>{A()},[A]),B(()=>{if(!w.current)return;const c=W=>{_(W<=Ve)};c(w.current.clientWidth);const k=new ResizeObserver(W=>{const G=W[0];G&&c(G.contentRect.width)});return k.observe(w.current),()=>k.disconnect()},[]);const U=x(async c=>{i(c),l(!0);try{const k=await g({id:c});o(k)}catch(k){console.error("Failed to load note:",k),o(null)}finally{l(!1)}},[g]),V=H(null),f=x(c=>{a(c),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{},300)},[]),m=x(async c=>{if(!(!r||!n))try{const k=await M({id:r,content:c});o(k),$()}catch(k){console.error("Failed to save note:",k)}},[r,n,M,$]),y=x(c=>{A(),i(c.id),o(c)},[A]),N=x(c=>{r===c&&(i(null),o(null)),A()},[r,A]),S=x(c=>{r===c.id&&o(c),A()},[r,A]),P=x(c=>{a(c)},[]),O=x(async()=>{try{const c=await E({});y(c)}catch(c){console.error("Failed to create note:",c)}},[E,y]);return p(De,{selectedNoteId:r,selectedNote:n,notes:t,editorRef:b,onNoteCreated:y,onNoteDeleted:N,onSearch:P,onNoteUpdated:S,onSelectNote:U,onRefresh:A,children:T("div",{ref:w,className:`${v.root}${u?` ${v.rootCompact}`:""}`,children:[p(Ct,{notes:t,selectedId:r,onSelect:U,onCreate:O,searchQuery:s,onSearchChange:f}),p(He,{ref:b,note:n,loading:d,onSave:m})]})})}function We(t){const e=xt(t.root);return e.render(p(yt,{windowId:t.windowId,children:p(wt,{miniAppId:t.miniAppId,children:p(Oe,{})})})),{deactivate(){e.unmount()}}}export{We as activate};
1689
1744
  (() => {
1690
1745
  if (typeof document === 'undefined') return;
1691
1746
  const styleId = "desktalk-style-desktalk-miniapp-note-emi3yz";