@desktalk/core 0.1.3 → 0.1.4
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/assets/{frontend-BIEc2N7M.js → frontend-BIX1osqf.js} +2 -2
- package/dist/frontend/assets/{frontend-BIEc2N7M.js.map → frontend-BIX1osqf.js.map} +1 -1
- package/dist/frontend/assets/{frontend-BG-YLJqZ.js → frontend-BzdZVdad.js} +2 -2
- package/dist/frontend/assets/{frontend-BG-YLJqZ.js.map → frontend-BzdZVdad.js.map} +1 -1
- package/dist/frontend/assets/{frontend-DHFvbI_u.js → frontend-CNI9ZWUx.js} +2 -2
- package/dist/frontend/assets/{frontend-DHFvbI_u.js.map → frontend-CNI9ZWUx.js.map} +1 -1
- package/dist/frontend/assets/{frontend-BNhxRpOo.js → frontend-CSSNHa7X.js} +2 -2
- package/dist/frontend/assets/{frontend-BNhxRpOo.js.map → frontend-CSSNHa7X.js.map} +1 -1
- package/dist/frontend/assets/{frontend-D9i707Nm.js → frontend-Da6BeHSp.js} +2 -2
- package/dist/frontend/assets/{frontend-D9i707Nm.js.map → frontend-Da6BeHSp.js.map} +1 -1
- package/dist/frontend/assets/{frontend-Dy9eRAQd.js → frontend-f1PcGFgm.js} +67 -25
- package/dist/frontend/assets/frontend-f1PcGFgm.js.map +1 -0
- package/dist/frontend/assets/{frontend-CrQvPdit.js → frontend-zfGj9snS.js} +2 -2
- package/dist/frontend/assets/{frontend-CrQvPdit.js.map → frontend-zfGj9snS.js.map} +1 -1
- package/dist/frontend/assets/{highlighted-body-TPN3WLV5-B8LPaWFP.js → highlighted-body-TPN3WLV5-g134n7tc.js} +2 -2
- package/dist/frontend/assets/{highlighted-body-TPN3WLV5-B8LPaWFP.js.map → highlighted-body-TPN3WLV5-g134n7tc.js.map} +1 -1
- package/dist/frontend/assets/index-AQaNuL08.css +1 -0
- package/dist/frontend/assets/{index-DCZC2uPI.js → index-D4gDxl9-.js} +99 -99
- package/dist/frontend/assets/index-D4gDxl9-.js.map +1 -0
- package/dist/frontend/index.html +2 -2
- package/dist/server/api-routes.d.ts.map +1 -1
- package/dist/server/api-routes.js +88 -7
- package/dist/server/api-routes.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -1
- package/dist/services/ai/pi-session-service.d.ts +8 -0
- package/dist/services/ai/pi-session-service.d.ts.map +1 -1
- package/dist/services/ai/pi-session-service.js +17 -1
- package/dist/services/ai/pi-session-service.js.map +1 -1
- package/dist/services/ai/providers.d.ts.map +1 -1
- package/dist/services/ai/providers.js +40 -14
- package/dist/services/ai/providers.js.map +1 -1
- package/package.json +12 -10
- package/dist/frontend/assets/frontend-Dy9eRAQd.js.map +0 -1
- package/dist/frontend/assets/index-BljFdF__.css +0 -1
- package/dist/frontend/assets/index-DCZC2uPI.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{W as
|
|
1
|
+
import{W as fe,a as _e,u as $,d as Q,A as xe,b as B,_ as ee}from"./index-D4gDxl9-.js";var _=window.React;_.Children;_.Component;_.Fragment;_.Profiler;_.PureComponent;_.StrictMode;_.Suspense;_.cloneElement;_.createContext;_.createElement;_.createRef;_.forwardRef;_.isValidElement;_.lazy;_.memo;_.startTransition;var f=_.useCallback;_.useContext;_.useDebugValue;_.useDeferredValue;var w=_.useEffect;_.useId;_.useImperativeHandle;_.useInsertionEffect;_.useLayoutEffect;var G=_.useMemo;_.useReducer;var X=_.useRef,k=_.useState;_.useSyncExternalStore;_.useTransition;_.version;var se=window.ReactDOM,ye=se.createRoot;se.hydrateRoot;var Y=["General","Server","AI","Voice"],L="openai",we={copilot:"github-copilot"};function de(e){return we[e]??e}var T=[{id:"github-copilot",label:"GitHub Copilot",authType:"subscription",supportsApiKey:!1,supportsBaseUrl:!1},{id:"openai-codex",label:"OpenAI Codex",authType:"subscription",supportsApiKey:!1,supportsBaseUrl:!1},{id:"claude-pro",label:"Claude Pro/Max",authType:"subscription",supportsApiKey:!1,supportsBaseUrl:!1},{id:"gemini-cli",label:"Google Gemini CLI",authType:"subscription",supportsApiKey:!1,supportsBaseUrl:!1},{id:"google-antigravity",label:"Google Antigravity",authType:"subscription",supportsApiKey:!1,supportsBaseUrl:!1},{id:"anthropic",label:"Anthropic",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"azure-openai-responses",label:"Azure OpenAI",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:L,label:"OpenAI",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"google",label:"Google Gemini",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"mistral",label:"Mistral",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"groq",label:"Groq",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"cerebras",label:"Cerebras",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"xai",label:"xAI",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"openrouter",label:"OpenRouter",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"vercel-ai-gateway",label:"Vercel AI Gateway",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"zai",label:"ZAI",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"opencode",label:"OpenCode Zen",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"opencode-go",label:"OpenCode Go",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"huggingface",label:"Hugging Face",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!0},{id:"kimi-coding",label:"Kimi For Coding",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"minimax",label:"MiniMax",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"minimax-cn",label:"MiniMax China",authType:"api-key",supportsApiKey:!0,supportsBaseUrl:!1},{id:"ollama",label:"Ollama",authType:"api-key",supportsApiKey:!1,supportsBaseUrl:!0}],M="openai-whisper",N=[{id:M,label:"OpenAI Whisper",supportsApiKey:!0,supportsBaseUrl:!0,supportsModel:!0,supportsAzureDeployment:!1,supportsAzureApiVersion:!1},{id:"azure-openai-whisper",label:"Azure OpenAI Whisper",supportsApiKey:!0,supportsBaseUrl:!0,supportsModel:!1,supportsAzureDeployment:!0,supportsAzureApiVersion:!0}],Ae=new Set(T.map(e=>e.id)),ke=new Set(N.map(e=>e.id));function le(e){const t=de(e);return T.find(r=>r.id===t)}function Ce(e){const t=le(e);if(!t)return[];const r=[`ai.providers.${e}.model`];return t.supportsApiKey&&r.push(`ai.providers.${e}.apiKey`),t.supportsBaseUrl&&r.push(`ai.providers.${e}.baseUrl`),r}function ce(e){if(typeof e!="string")return[L];const t=e.split(",").map(r=>de(r.trim())).filter((r,n,i)=>r&&i.indexOf(r)===n&&Ae.has(r));return t.length>0?t:[L]}function Pe(e){return ce(e.join(",")).join(",")}function pe(e){return N.find(t=>t.id===e)}function Ee(e){const t=pe(e);if(!t)return[];const r=[];return t.supportsApiKey&&r.push(`voice.providers.${e}.apiKey`),t.supportsModel&&r.push(`voice.providers.${e}.model`),t.supportsBaseUrl&&r.push(`voice.providers.${e}.baseUrl`),t.supportsAzureDeployment&&r.push(`voice.providers.${e}.azureDeployment`),t.supportsAzureApiVersion&&r.push(`voice.providers.${e}.azureApiVersion`),r}function ue(e){if(typeof e!="string")return[M];const t=e.split(",").map(r=>r.trim()).filter((r,n,i)=>r&&i.indexOf(r)===n&&ke.has(r));return t.length>0?t:[M]}function ze(e){return ue(e.join(",")).join(",")}function Se(){const e=[{key:"ai.enabledProviders",label:"Enabled Providers",description:"Ordered list of configured AI providers.",type:"string",default:L,category:"AI"},{key:"ai.defaultProvider",label:"Default Provider",description:"Provider selected by default for chat and tool execution.",type:"string",default:L,options:T.map(t=>t.id),category:"AI"}];for(const t of T)e.push({key:`ai.providers.${t.id}.model`,label:`${t.label} Model`,description:`Model identifier to use when ${t.label} is selected.`,type:"string",default:"",category:"AI"}),t.supportsApiKey&&e.push({key:`ai.providers.${t.id}.apiKey`,label:`${t.label} API Key`,description:`API key for ${t.label}.`,type:"string",default:"",category:"AI",sensitive:!0}),t.supportsBaseUrl&&e.push({key:`ai.providers.${t.id}.baseUrl`,label:`${t.label} Base URL`,description:`Optional custom API base URL for ${t.label}.`,type:"string",default:"",category:"AI"});return e.push({key:"ai.maxTokens",label:"Max Tokens",description:"Maximum tokens per AI response.",type:"number",default:4096,min:256,max:128e3,category:"AI"}),e}var Ie=Se();function Me(){const e=[{key:"voice.enabledProviders",label:"Enabled Providers",description:"Ordered list of configured STT providers.",type:"string",default:M,category:"Voice"},{key:"voice.defaultProvider",label:"Default Provider",description:"Provider selected by default for voice transcription.",type:"string",default:M,options:N.map(t=>t.id),category:"Voice"}];for(const t of N)t.supportsApiKey&&e.push({key:`voice.providers.${t.id}.apiKey`,label:`${t.label} API Key`,description:`API key for ${t.label}.`,type:"string",default:"",category:"Voice",sensitive:!0}),t.supportsModel&&e.push({key:`voice.providers.${t.id}.model`,label:`${t.label} Model`,description:`Model identifier to use when ${t.label} is selected.`,type:"string",default:"whisper-1",category:"Voice"}),t.supportsBaseUrl&&e.push({key:`voice.providers.${t.id}.baseUrl`,label:`${t.label} Base URL`,description:t.id==="azure-openai-whisper"?"Base URL for Azure OpenAI Whisper requests.":`Optional custom API base URL for ${t.label}.`,type:"string",default:t.id===M?"https://api.openai.com/v1":"",category:"Voice"}),t.supportsAzureDeployment&&e.push({key:`voice.providers.${t.id}.azureDeployment`,label:`${t.label} Deployment`,description:"Azure OpenAI deployment name for Whisper transcription.",type:"string",default:"",category:"Voice"}),t.supportsAzureApiVersion&&e.push({key:`voice.providers.${t.id}.azureApiVersion`,label:`${t.label} API Version`,description:"Azure OpenAI API version used for transcription requests.",type:"string",default:"2024-06-01",category:"Voice"});return e}var Te=Me(),J=[{key:"general.theme",label:"Theme",description:"UI theme: light or dark.",type:"string",default:"light",options:["light","dark"],category:"General"},{key:"general.accentColor",label:"Accent Color",description:"Primary theme color. Accepts hex values or any CSS color string.",type:"string",default:"#7c6ff7",category:"General"},{key:"general.language",label:"Language",description:"UI language/locale.",type:"string",default:"en",options:["en","zh"],category:"General"},{key:"general.dataDirectory",label:"Data Directory",description:"Override the base data directory. Leave empty for platform default (resolved via env-paths).",type:"string",default:"",category:"General",requiresRestart:!0},{key:"server.host",label:"Host",description:"Server bind address.",type:"string",default:"localhost",category:"Server",requiresRestart:!0},{key:"server.port",label:"Port",description:"Server listen port.",type:"number",default:3e3,min:1,max:65535,category:"Server",requiresRestart:!0},...Ie,...Te,{key:"voice.silenceTimeoutMs",label:"Silence Timeout",description:"Silence duration (ms) before finalizing an utterance.",type:"number",default:800,min:200,max:5e3,category:"Voice"},{key:"voice.energyThreshold",label:"Energy Threshold",description:"RMS energy threshold for voice activity detection (0–32767).",type:"number",default:500,min:50,max:1e4,category:"Voice"}];function Ne(){const e={};for(const t of J)e[t.key]=t.default;return e}function Le(e){return J.find(t=>t.key===e)}function He(e){return J.filter(t=>t.category===e)}var $e=`.dt-tooltip-popup {
|
|
2
2
|
position: fixed;
|
|
3
3
|
z-index: 2147483647;
|
|
4
4
|
padding: 6px 10px;
|
|
@@ -107,7 +107,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
107
107
|
border-top: none;
|
|
108
108
|
border-bottom: none;
|
|
109
109
|
}
|
|
110
|
-
`,
|
|
110
|
+
`,Re="dt-tooltip-popup",I=8,te=!1;function Fe(){if(te)return;let e=document.createElement("style");e.setAttribute("data-dt-tooltip",""),e.textContent=$e,document.head.appendChild(e),te=!0}var Be=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(e){this.setAttribute("content",e)}get placement(){let e=this.getAttribute("placement");return e==="bottom"||e==="left"||e==="right"?e:"top"}set placement(e){this.setAttribute("placement",e)}get align(){let e=this.getAttribute("align");return e==="left"||e==="right"?e:"center"}set align(e){this.setAttribute("align",e)}get delay(){let e=Number(this.getAttribute("delay"));return Number.isFinite(e)&&e>0?e:0}set delay(e){this.setAttribute("delay",String(e))}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}constructor(){super();let e=this.attachShadow({mode:"open"});e.innerHTML="<slot></slot>",this._tooltipId=`dt-tip-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){Fe(),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(e,t,r){e==="disabled"&&this.disabled&&this._hide(),e==="content"&&this._popup&&(this._popup.textContent=this.content)}_onEnter=()=>{if(this.disabled||!this.content)return;this._showTimeout!==null&&clearTimeout(this._showTimeout);let e=()=>{this._createPopup(),this._position(),this._visible=!0};this.delay>0?this._showTimeout=setTimeout(e,this.delay):e()};_onLeave=()=>{this._hide()};_createPopup(){if(this._popup)return;let e=document.createElement("div");e.className=Re,e.id=this._tooltipId,e.setAttribute("role","tooltip"),e.textContent=this.content,document.body.appendChild(e),this._popup=e;let t=this._getTrigger();t&&t.setAttribute("aria-describedby",this._tooltipId)}_hide(){if(this._showTimeout!==null&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._popup){let e=this._getTrigger();e&&e.removeAttribute("aria-describedby"),this._popup.remove(),this._popup=null,this._visible=!1}}_getTrigger(){let e=this.shadowRoot?.querySelector("slot")?.assignedElements();return e&&e.length>0?e[0]:null}_position(){let e=this._popup;if(!e)return;let t=this.getBoundingClientRect(),r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,o=8,d=this.placement;d==="top"&&t.top-r.height-I<0?d="bottom":d==="bottom"&&t.bottom+r.height+I>i?d="top":d==="left"&&t.left-r.width-I<0?d="right":d==="right"&&t.right+r.width+I>n&&(d="left"),e.setAttribute("data-actual-placement",d);let p,l,h=t.left+t.width/2,m=t.top+t.height/2;switch(d){case"top":h=this.align==="left"?t.left:this.align==="right"?t.right:t.left+t.width/2,l=this.align==="left"?t.left:this.align==="right"?t.right-r.width:t.left+t.width/2-r.width/2,p=t.top-r.height-I;break;case"bottom":h=this.align==="left"?t.left:this.align==="right"?t.right:t.left+t.width/2,l=this.align==="left"?t.left:this.align==="right"?t.right-r.width:t.left+t.width/2-r.width/2,p=t.bottom+I;break;case"left":l=t.left-r.width-I,p=t.top+t.height/2-r.height/2,m=t.top+t.height/2;break;case"right":l=t.right+I,p=t.top+t.height/2-r.height/2,m=t.top+t.height/2;break}d==="top"||d==="bottom"?(l=Math.max(o,Math.min(l,n-r.width-o)),e.style.setProperty("--dt-tooltip-arrow-left",`${Math.max(8,Math.min(h-l,r.width-8))}px`),e.style.removeProperty("--dt-tooltip-arrow-top")):(p=Math.max(o,Math.min(p,i-r.height-o)),e.style.setProperty("--dt-tooltip-arrow-top",`${Math.max(8,Math.min(m-p,r.height-8))}px`),e.style.removeProperty("--dt-tooltip-arrow-left")),e.style.left=`${l}px`,e.style.top=`${p}px`}},De=`:host {
|
|
111
111
|
display: block;
|
|
112
112
|
margin-bottom: 12px;
|
|
113
113
|
}
|
|
@@ -183,7 +183,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
183
183
|
::slotted(p:last-child) {
|
|
184
184
|
margin-bottom: 0;
|
|
185
185
|
}
|
|
186
|
-
`,
|
|
186
|
+
`,Ve="dt-card-inner",Oe=class extends HTMLElement{static get observedAttributes(){return["variant"]}get variant(){let e=this.getAttribute("variant");return e==="outlined"||e==="filled"?e:"default"}set variant(e){this.setAttribute("variant",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=De,e.appendChild(t);let r=document.createElement("div");r.className=Ve,r.innerHTML="<slot></slot>",e.appendChild(r)}},We=`.dt-select-menu {
|
|
187
187
|
position: fixed;
|
|
188
188
|
z-index: 2147483646;
|
|
189
189
|
display: flex;
|
|
@@ -253,7 +253,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
253
253
|
text-overflow: ellipsis;
|
|
254
254
|
white-space: nowrap;
|
|
255
255
|
}
|
|
256
|
-
`,
|
|
256
|
+
`,Ke=`:host {
|
|
257
257
|
display: block;
|
|
258
258
|
width: 100%;
|
|
259
259
|
min-width: 0;
|
|
@@ -356,7 +356,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
356
356
|
.dt-select-trigger[aria-expanded='true'] .dt-select-chevron {
|
|
357
357
|
transform: rotate(180deg);
|
|
358
358
|
}
|
|
359
|
-
`,
|
|
359
|
+
`,Ue="dt-select-trigger",re="dt-select-label",je="dt-select-chevron",qe="dt-select-menu",Ge="dt-select-option",Xe="dt-select-option--active",ne=!1;function Ye(){if(ne)return;let e=document.createElement("style");e.setAttribute("data-dt-select",""),e.textContent=We,document.head.appendChild(e),ne=!0}var Ze=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(e){this.setAttribute("value",e)}get placeholder(){return this.getAttribute("placeholder")??"Select…"}set placeholder(e){this.setAttribute("placeholder",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get align(){return this.getAttribute("align")==="right"?"right":"left"}set align(e){this.setAttribute("align",e)}get options(){return this._options}set options(e){this._options=e,this._updateLabel(),this._open&&this._renderMenuItems()}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=Ke,e.appendChild(t);let r=document.createElement("button");r.type="button",r.className=Ue,r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let n=document.createElement("span");n.className=re,r.appendChild(n);let i=document.createElement("span");i.className=je,i.setAttribute("aria-hidden","true"),i.textContent="▾",r.appendChild(i),e.appendChild(r),this._trigger=r,this._menuId=`dt-sel-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){Ye(),this._trigger.addEventListener("click",this._onTriggerClick),this._updateLabel()}disconnectedCallback(){this._trigger.removeEventListener("click",this._onTriggerClick),this._close()}attributeChangedCallback(e){e==="value"&&(this._updateLabel(),this._open&&this._renderMenuItems()),e==="placeholder"&&!this.value&&this._updateLabel(),e==="disabled"&&this.disabled&&this._close()}_updateLabel(){let e=this._trigger.querySelector(`.${re}`),t=this._options.find(r=>r.value===this.value);e.textContent=t?.label??this.placeholder}_onTriggerClick=()=>{this.disabled||(this._open?this._close():this._openMenu())};_openMenu(){if(this._open)return;let e=document.createElement("div");e.className=qe,e.id=this._menuId,e.setAttribute("role","listbox"),document.body.appendChild(e),this._menu=e,this._renderMenuItems(),this._position(),requestAnimationFrame(()=>{e.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 e=this._menu;setTimeout(()=>e.remove(),140),this._menu=null}this._open=!1,this._trigger.setAttribute("aria-expanded","false")}}_onOutsideClick=e=>{let t=e.target;this._menu?.contains(t)||this.contains(t)||this._close()};_onWindowBlur=()=>{requestAnimationFrame(()=>{document.activeElement?.tagName==="IFRAME"&&this._close()})};_onKeyDown=e=>{e.key==="Escape"&&(this._close(),this._trigger.focus())};_renderMenuItems(){let e=this._menu;if(e){e.innerHTML="";for(let t of this._options){let r=document.createElement("button");r.type="button",r.className=Ge,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(t.value===this.value)),t.value===this.value&&r.classList.add(Xe);let n=document.createElement("span");n.textContent=t.label,r.appendChild(n),r.addEventListener("click",()=>{this._selectValue(t.value)}),e.appendChild(r)}}}_selectValue(e){let t=this.value;this.value=e,this._updateLabel(),this._close(),e!==t&&this.dispatchEvent(new CustomEvent("dt-change",{detail:{value:e},bubbles:!0,composed:!0}))}_position(){let e=this._menu;if(!e)return;let t=this.getBoundingClientRect(),r=10,n=Math.max(t.width,240),i=t.bottom+r,o=e.scrollHeight||260,d=window.innerHeight;if(i+o>d&&t.top-o-r>0&&(i=t.top-o-r),e.style.minWidth=`${n}px`,this.align==="right"){let p=window.innerWidth;e.style.right=`${p-t.right}px`,e.style.left="auto"}else e.style.left=`${t.left}px`,e.style.right="auto";e.style.top=`${i}px`}},Je=`:host {
|
|
360
360
|
display: block;
|
|
361
361
|
margin-bottom: 12px;
|
|
362
362
|
}
|
|
@@ -448,7 +448,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
448
448
|
::slotted(*) {
|
|
449
449
|
min-width: 0;
|
|
450
450
|
}
|
|
451
|
-
`,
|
|
451
|
+
`,Qe="dt-grid-inner",et=class extends HTMLElement{static get observedAttributes(){return["cols","gap","min-width"]}get cols(){let e=this.getAttribute("cols");return e==="1"||e==="2"||e==="3"||e==="4"||e==="5"||e==="6"?e:null}set cols(e){e===null?this.removeAttribute("cols"):this.setAttribute("cols",e)}get gap(){let e=this.getAttribute("gap");return e==="0"||e==="4"||e==="8"||e==="12"||e==="20"||e==="24"||e==="32"?e:"16"}set gap(e){this.setAttribute("gap",e)}get minWidth(){let e=this.getAttribute("min-width");return e==="150"||e==="180"||e==="200"||e==="260"||e==="300"?e:"220"}set minWidth(e){this.setAttribute("min-width",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=Je,e.appendChild(t);let r=document.createElement("div");r.className=Qe,r.innerHTML="<slot></slot>",e.appendChild(r)}},tt=`:host {
|
|
452
452
|
display: block;
|
|
453
453
|
margin-bottom: 12px;
|
|
454
454
|
}
|
|
@@ -514,7 +514,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
514
514
|
::slotted(*) {
|
|
515
515
|
min-width: 0;
|
|
516
516
|
}
|
|
517
|
-
`,
|
|
517
|
+
`,rt="dt-stack-inner";function O(e){return e==="row"||e==="horizontal"?"row":"column"}var nt=class extends HTMLElement{static get observedAttributes(){return["direction","gap","align"]}get direction(){return O(this.getAttribute("direction"))}set direction(e){this.setAttribute("direction",O(e))}get gap(){let e=this.getAttribute("gap");return e==="0"||e==="4"||e==="8"||e==="12"||e==="20"||e==="24"||e==="32"?e:"16"}set gap(e){this.setAttribute("gap",e)}get align(){let e=this.getAttribute("align");return e==="start"||e==="center"||e==="end"?e:"stretch"}set align(e){this.setAttribute("align",e)}connectedCallback(){this.#e()}attributeChangedCallback(e){e==="direction"&&this.#e()}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=tt,e.appendChild(t);let r=document.createElement("div");r.className=rt,r.innerHTML="<slot></slot>",e.appendChild(r)}#e(){let e=this.getAttribute("direction"),t=O(e);e!==null&&e!==t&&this.setAttribute("direction",t)}},it=`:host {
|
|
518
518
|
display: block;
|
|
519
519
|
}
|
|
520
520
|
|
|
@@ -619,7 +619,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
619
619
|
.dt-stat-inner .trend.neutral {
|
|
620
620
|
color: var(--dt-text-muted);
|
|
621
621
|
}
|
|
622
|
-
`,
|
|
622
|
+
`,ot="dt-stat-inner",at=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(e){e===null?this.removeAttribute("label"):this.setAttribute("label",e)}get value(){return this.getAttribute("value")}set value(e){e===null?this.removeAttribute("value"):this.setAttribute("value",e)}get description(){return this.getAttribute("description")}set description(e){e===null?this.removeAttribute("description"):this.setAttribute("description",e)}get size(){let e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}get variant(){let e=this.getAttribute("variant");return e==="outlined"||e==="filled"?e:"default"}set variant(e){this.setAttribute("variant",e)}get trend(){let e=this.getAttribute("trend");return e==="up"||e==="down"||e==="neutral"?e:null}set trend(e){e===null?this.removeAttribute("trend"):this.setAttribute("trend",e)}get trendValue(){return this.getAttribute("trend-value")}set trendValue(e){e===null?this.removeAttribute("trend-value"):this.setAttribute("trend-value",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=it,e.appendChild(t),this._container=document.createElement("div"),this._container.className=ot,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),e.appendChild(this._container),this._render()}attributeChangedCallback(e,t,r){(e==="label"||e==="value"||e==="description"||e==="size"||e==="variant"||e==="trend"||e==="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 e=this.trend,t=this.trendValue;if(e&&t){this._trendEl.style.display="inline-flex",this._trendEl.className=`trend ${e==="up"?"positive":e==="down"?"negative":"neutral"}`;let r="";e==="up"?r="↑":e==="down"?r="↓":r="→",this._trendEl.textContent=`${r} ${t}`}else this._trendEl.style.display="none"}},st=`:host {
|
|
623
623
|
display: inline-flex;
|
|
624
624
|
vertical-align: middle;
|
|
625
625
|
}
|
|
@@ -701,7 +701,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
701
701
|
padding: 3px 8px;
|
|
702
702
|
font-size: 0.75rem;
|
|
703
703
|
}
|
|
704
|
-
`,
|
|
704
|
+
`,dt="dt-badge-inner",lt=class extends HTMLElement{static get observedAttributes(){return["variant","size","text"]}_container;_slot;get variant(){let e=this.getAttribute("variant");return e==="success"||e==="danger"||e==="warning"||e==="info"||e==="default"||e==="neutral"?e:"accent"}set variant(e){this.setAttribute("variant",e)}get size(){let e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}get text(){return this.getAttribute("text")}set text(e){e===null?this.removeAttribute("text"):this.setAttribute("text",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=st,e.appendChild(t),this._container=document.createElement("span"),this._container.className=dt;let r=this.text;r!==null?this._container.textContent=r:(this._slot=document.createElement("slot"),this._container.appendChild(this._slot)),e.appendChild(this._container)}attributeChangedCallback(e,t,r){e==="text"&&this._render()}_render(){let e=this.text;e!==null&&(this._container.textContent=e)}},ct=`:host {
|
|
705
705
|
display: inline-flex;
|
|
706
706
|
vertical-align: middle;
|
|
707
707
|
}
|
|
@@ -863,7 +863,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
863
863
|
width: 1em;
|
|
864
864
|
height: 1em;
|
|
865
865
|
}
|
|
866
|
-
`,
|
|
866
|
+
`,pt="dt-button-inner",ut=class extends HTMLElement{static get observedAttributes(){return["variant","size","disabled","fullwidth","type"]}_button;_slot;get variant(){let e=this.getAttribute("variant");return e==="secondary"||e==="ghost"||e==="danger"?e:"primary"}set variant(e){this.setAttribute("variant",e)}get size(){let e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get fullwidth(){return this.hasAttribute("fullwidth")}set fullwidth(e){e?this.setAttribute("fullwidth",""):this.removeAttribute("fullwidth")}get type(){let e=this.getAttribute("type");return e==="submit"||e==="reset"?e:"button"}set type(e){this.setAttribute("type",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=ct,e.appendChild(t),this._button=document.createElement("button"),this._button.className=pt,this._button.type=this.type,this._button.disabled=this.disabled,this._slot=document.createElement("slot"),this._button.appendChild(this._slot),this._button.addEventListener("click",()=>{if(this.type==="submit"&&!this.disabled){let r=this.closest("form");r&&r.requestSubmit()}}),e.appendChild(this._button)}attributeChangedCallback(e,t,r){switch(e){case"disabled":this._button.disabled=this.disabled;break;case"type":this._button.type=this.type;break}}},ht=`:host {
|
|
867
867
|
display: block;
|
|
868
868
|
}
|
|
869
869
|
|
|
@@ -928,7 +928,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
928
928
|
:host([direction='vertical'][spacing='lg']) .dt-divider-inner {
|
|
929
929
|
margin: 0 18px;
|
|
930
930
|
}
|
|
931
|
-
`,
|
|
931
|
+
`,mt="dt-divider-inner",gt=class extends HTMLElement{static get observedAttributes(){return["direction","style-variant","spacing"]}get direction(){return this.getAttribute("direction")==="vertical"?"vertical":"horizontal"}set direction(e){this.setAttribute("direction",e)}get styleVariant(){let e=this.getAttribute("style-variant");return e==="subtle"||e==="strong"?e:"default"}set styleVariant(e){this.setAttribute("style-variant",e)}get spacing(){let e=this.getAttribute("spacing");return e==="sm"||e==="md"||e==="lg"?e:null}set spacing(e){e===null?this.removeAttribute("spacing"):this.setAttribute("spacing",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=ht,e.appendChild(t);let r=document.createElement("hr");r.className=mt,e.appendChild(r)}},bt=`:host {
|
|
932
932
|
display: block;
|
|
933
933
|
min-height: 180px;
|
|
934
934
|
color: var(--dt-text);
|
|
@@ -1096,7 +1096,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
1096
1096
|
letter-spacing: 0.08em;
|
|
1097
1097
|
font-size: 0.75rem;
|
|
1098
1098
|
}
|
|
1099
|
-
`;function
|
|
1099
|
+
`;function vt(e){return e==null||e===!1?null:e===!0?"":String(e)}function ft(e,t){let r=e.querySelectorAll("*");for(let n of r){let i=n.getAttribute("data-field");if(i){let o=t[i];n.textContent=o==null?"":String(o)}for(let o of n.getAttributeNames()){if(o==="data-field"||!o.startsWith("data-field-"))continue;let d=o.slice(11);if(!d)continue;let p=n.getAttribute(o);if(!p)continue;let l=vt(t[p]);l===null?n.removeAttribute(d):n.setAttribute(d,l)}}}function he(e,t){let r=e.content.cloneNode(!0);return ft(r,t),r}var me=class{_count=0;_estimateSize=56;_overscan=5;_fixedSize=null;_viewportHeight=0;_scrollTop=0;_sizes=new Map;constructor(e={}){this._count=e.count??0,this._estimateSize=e.estimateSize??56,this._overscan=e.overscan??5,this._fixedSize=e.fixedSize??null}setCount(e){this._count=Math.max(0,e);for(let t of this._sizes.keys())t>=this._count&&this._sizes.delete(t)}setViewportHeight(e){this._viewportHeight=Math.max(0,e)}setScrollTop(e){this._scrollTop=Math.max(0,e)}setEstimateSize(e){this._estimateSize=Math.max(1,e)}setFixedSize(e){this._fixedSize=e&&e>0?e:null}resetMeasurements(){this._sizes.clear()}measure(e,t){if(this._fixedSize!==null||e<0||e>=this._count)return 0;let r=Math.max(1,Math.round(t)),n=this._sizes.get(e);return n===r?0:(this._sizes.set(e,r),this.getOffset(e+1)<=this._scrollTop?r-(n??this._estimateSize):0)}getOffset(e){if(e<=0)return 0;let t=Math.min(e,this._count);if(this._fixedSize!==null)return t*this._fixedSize;let r=0;for(let n=0;n<t;n+=1)r+=this._sizes.get(n)??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 p=Math.max(1,Math.ceil(this._viewportHeight/this._fixedSize)),l=Math.max(0,Math.floor(this._scrollTop/this._fixedSize)-this._overscan),h=Math.min(this._count,l+p+this._overscan*2),m=l*this._fixedSize,c=this._count*this._fixedSize,u=Math.max(0,c-m-(h-l)*this._fixedSize);return{start:l,end:h,paddingTop:m,paddingBottom:u,totalHeight:c}}let e=0,t=0;for(;e<this._count;){let p=this._sizes.get(e)??this._estimateSize;if(t+p>this._scrollTop)break;t+=p,e+=1}e=Math.max(0,e-this._overscan);let r=this.getOffset(e),n=e,i=0;for(;n<this._count&&i<this._viewportHeight;)i+=this._sizes.get(n)??this._estimateSize,n+=1;n=Math.min(this._count,n+this._overscan);let o=this.getTotalHeight(),d=Math.max(0,o-this.getOffset(n));return{start:e,end:n,paddingTop:r,paddingBottom:d,totalHeight:o}}};function _t(e){return e&&typeof e=="object"?e:{value:e}}function xt(e){return e==="center"||e==="right"?e:"left"}var ge=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 xt(this.getAttribute("align"))}connectedCallback(){this.hidden=!0}attributeChangedCallback(){this.dispatchEvent(new CustomEvent("dt-column-change",{bubbles:!0,composed:!0}))}},yt=class extends HTMLElement{_rows=[];_columns=[];_virtualizer=new me({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(e){this._rows=Array.isArray(e)?e:[],this._virtualizer.setCount(this._rows.length),this._render()}get rowHeight(){let e=Number(this.getAttribute("row-height")??"40");return Number.isFinite(e)&&e>0?e:40}set rowHeight(e){this.setAttribute("row-height",String(e))}get sortable(){return this.hasAttribute("sortable")}get emptyText(){return this.getAttribute("empty-text")??"No data"}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=bt,e.appendChild(t),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),e.appendChild(this._root)}connectedCallback(){this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight),this._syncColumns(),this._resizeObserver=new ResizeObserver(e=>{for(let t of e)if(t.target===this._scroll){let r=this._header.offsetHeight;this._virtualizer.setViewportHeight(Math.max(0,t.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(e){e==="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(e=>e instanceof ge).map(e=>({field:e.field,header:e.header,width:e.width,minWidth:e.minWidth,align:e.align,template:Array.from(e.children).find(t=>t instanceof HTMLTemplateElement)??null})).filter(e=>e.field)}_render(){if(!this.isConnected)return;this._emptyState.textContent=this.emptyText;let e=this._columns.length>0?this._columns.map(t=>this._toGridColumn(t)).join(" "):"minmax(0, 1fr)";this._header.style.setProperty("--dt-table-columns",e),this._canvas.style.setProperty("--dt-table-columns",e),this._renderHeader(),this._renderBody()}_renderHeader(){let e=document.createDocumentFragment();for(let t of this._columns){let r=document.createElement("div");r.className="dt-table-header-cell",r.dataset.align=t.align,this.sortable&&(r.classList.add("dt-table-header-cell--sortable"),r.tabIndex=0,r.setAttribute("role","button"),r.setAttribute("aria-label",`Sort by ${t.header}`),r.addEventListener("click",()=>this._requestSort(t.field)),r.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),this._requestSort(t.field))}));let n=document.createElement("span");if(n.className="dt-table-header-label",n.textContent=t.header,this.sortable){let i=document.createElement("span");i.className="dt-table-sort-indicator",this._sortField===t.field?i.textContent=this._sortDirection==="asc"?"▲":"▼":i.textContent="↕",n.appendChild(i)}r.appendChild(n),e.appendChild(r)}this._header.replaceChildren(e)}_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 e=this._virtualizer.getRange();this._body.style.height=`${Math.max(e.totalHeight,this._scroll.clientHeight-this._header.offsetHeight)}px`,this._canvas.style.height=`${e.totalHeight}px`;let t=document.createDocumentFragment();for(let r=e.start;r<e.end;r+=1)t.appendChild(this._renderRow(r));this._canvas.replaceChildren(t)}_renderRow(e){let t=this._rows[e],r=document.createElement("div");r.className="dt-table-row dt-table-row--clickable",r.style.top=`${this._virtualizer.getOffset(e)}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:t,index:e},bubbles:!0,composed:!0}))});let n=_t(t);for(let i of this._columns){let o=document.createElement("div");if(o.className="dt-table-cell",o.dataset.align=i.align,i.template)o.appendChild(he(i.template,n));else{let d=n[i.field];o.textContent=d==null?"":String(d)}r.appendChild(o)}return r}_requestSort(e){this._sortField===e?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortField=e,this._sortDirection="asc"),this._renderHeader(),this.dispatchEvent(new CustomEvent("dt-sort",{detail:{field:e,direction:this._sortDirection},bubbles:!0,composed:!0}))}_toGridColumn(e){let t=/^\d+$/.test(e.minWidth)?`${e.minWidth}px`:e.minWidth;if(e.width==="auto")return`minmax(${t}, 1fr)`;let r=/^\d+$/.test(e.width)?`${e.width}px`:e.width;return`minmax(${t}, ${r})`}},wt=`:host {
|
|
1100
1100
|
display: block;
|
|
1101
1101
|
min-height: 120px;
|
|
1102
1102
|
color: var(--dt-text);
|
|
@@ -1195,7 +1195,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
1195
1195
|
letter-spacing: 0.08em;
|
|
1196
1196
|
font-size: 0.75rem;
|
|
1197
1197
|
}
|
|
1198
|
-
`,ie=56;function
|
|
1198
|
+
`,ie=56;function At(e){return e&&typeof e=="object"?e:{value:e}}var kt=class extends HTMLElement{_items=[];_selectedIndices=new Set;_renderItem=null;_virtualizer=new me({estimateSize:ie,overscan:5});_viewport;_spacer;_itemsLayer;_emptyState;_resizeObserver=null;_itemResizeObserver=null;static get observedAttributes(){return["item-height","dividers","selectable","empty-text"]}get items(){return this._items}set items(e){this._items=Array.isArray(e)?e:[],this._selectedIndices=new Set([...this._selectedIndices].filter(t=>t<this._items.length)),this._virtualizer.setCount(this._items.length),this._syncSizingMode(!0),this._render()}get selectedItems(){return[...this._selectedIndices].sort((e,t)=>e-t).map(e=>this._items[e])}get renderItem(){return this._renderItem}set renderItem(e){this._renderItem=typeof e=="function"?e:null,this._render()}get itemHeight(){let e=this.getAttribute("item-height");if(!e)return null;let t=Number(e);return Number.isFinite(t)&&t>0?t:null}set itemHeight(e){if(e===null||e<=0){this.removeAttribute("item-height");return}this.setAttribute("item-height",String(e))}get selectable(){let e=this.getAttribute("selectable");return e==="single"||e==="multi"?e:"none"}set selectable(e){this.setAttribute("selectable",e)}get emptyText(){return this.getAttribute("empty-text")??"No items"}set emptyText(e){this.setAttribute("empty-text",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=wt,e.appendChild(t),this._viewport=document.createElement("div"),this._viewport.className="dt-list-view",this._viewport.addEventListener("scroll",this._onScroll,{passive:!0}),this._spacer=document.createElement("div"),this._spacer.className="dt-list-spacer",this._itemsLayer=document.createElement("div"),this._itemsLayer.className="dt-list-items",this._emptyState=document.createElement("div"),this._emptyState.className="dt-list-empty",this._spacer.append(this._itemsLayer,this._emptyState),this._viewport.appendChild(this._spacer),e.appendChild(this._viewport)}connectedCallback(){this._resizeObserver=new ResizeObserver(e=>{for(let t of e)t.target===this._viewport&&(this._virtualizer.setViewportHeight(t.contentRect.height),this._render())}),this._resizeObserver.observe(this._viewport),this._itemResizeObserver=new ResizeObserver(e=>{let t=0;for(let r of e){let n=r.target,i=Number(n.dataset.index);Number.isFinite(i)&&(t+=this._virtualizer.measure(i,r.contentRect.height))}t!==0&&(this._viewport.scrollTop+=t),e.length>0&&this._render()}),this._virtualizer.setCount(this._items.length),this._virtualizer.setViewportHeight(this._viewport.clientHeight),this._syncSizingMode(!1),this._render()}disconnectedCallback(){this._viewport.removeEventListener("scroll",this._onScroll),this._resizeObserver?.disconnect(),this._itemResizeObserver?.disconnect(),this._resizeObserver=null,this._itemResizeObserver=null}attributeChangedCallback(e){e==="item-height"&&this._syncSizingMode(!0),e==="selectable"&&this.selectable==="none"&&this._selectedIndices.size>0&&(this._selectedIndices.clear(),this._emitSelectionChange()),this._render()}_onScroll=()=>{this._virtualizer.setScrollTop(this._viewport.scrollTop),this._render()};_syncSizingMode(e){let t=this.itemHeight;this._virtualizer.setFixedSize(t),this._virtualizer.setEstimateSize(t??ie),e&&this._virtualizer.resetMeasurements()}_render(){if(!this.isConnected)return;if(this._emptyState.textContent=this.emptyText,this._emptyState.hidden=this._items.length>0,this._items.length===0){this._itemsLayer.replaceChildren(),this._spacer.style.height="100%";return}this._virtualizer.setScrollTop(this._viewport.scrollTop),this._virtualizer.setViewportHeight(this._viewport.clientHeight),this._virtualizer.setCount(this._items.length);let e=this._virtualizer.getRange();this._spacer.style.height=`${Math.max(e.totalHeight,this._viewport.clientHeight)}px`,this._itemsLayer.style.transform=`translateY(${e.paddingTop}px)`;let t=document.createDocumentFragment();for(let r=e.start;r<e.end;r+=1)t.appendChild(this._renderVisibleItem(r));this._itemsLayer.replaceChildren(t)}_renderVisibleItem(e){let t=this._items[e],r=document.createElement("div");if(r.className="dt-list-item",r.dataset.index=String(e),this.selectable!=="none"&&(r.classList.add("dt-list-item--interactive"),r.setAttribute("role","option"),r.setAttribute("aria-selected",String(this._selectedIndices.has(e))),r.tabIndex=0),this._selectedIndices.has(e)&&r.classList.add("dt-list-item--selected"),this.itemHeight!==null&&(r.style.minHeight=`${this.itemHeight}px`),this._renderItem)this._renderItem(t,r,e);else{let n=this._getTemplate();n?r.appendChild(he(n,At(t))):r.textContent=String(t??"")}return r.addEventListener("click",()=>this._handleItemClick(e)),r.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._handleItemClick(e))}),this.itemHeight===null&&this._itemResizeObserver?.observe(r),r}_handleItemClick(e){let t=this._items[e],r=this.selectable;r==="single"?(this._selectedIndices=new Set([e]),this._emitSelectionChange(),this._render()):r==="multi"&&(this._selectedIndices.has(e)?this._selectedIndices.delete(e):this._selectedIndices.add(e),this._emitSelectionChange(),this._render()),this.dispatchEvent(new CustomEvent("dt-item-click",{detail:{item:t,index:e},bubbles:!0,composed:!0}))}_emitSelectionChange(){this.dispatchEvent(new CustomEvent("dt-selection-change",{detail:{selected:this.selectedItems},bubbles:!0,composed:!0}))}_getTemplate(){for(let e of Array.from(this.children))if(e instanceof HTMLTemplateElement)return e;return null}},Ct=`:host {
|
|
1199
1199
|
display: block;
|
|
1200
1200
|
min-height: 220px;
|
|
1201
1201
|
color: var(--dt-text);
|
|
@@ -1282,7 +1282,7 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
1282
1282
|
.dt-chart__status[hidden] {
|
|
1283
1283
|
display: none;
|
|
1284
1284
|
}
|
|
1285
|
-
`,
|
|
1285
|
+
`,W=null;function Pt(){return window.__DtChart?Promise.resolve(window.__DtChart):W||(W=new Promise((e,t)=>{let r=document.createElement("script");r.src="/api/ui/chart.umd.js",r.async=!0,r.dataset.dtChart="true",r.onload=()=>{if(window.__DtChart){e(window.__DtChart);return}t(new Error("Chart runtime loaded without a __DtChart export."))},r.onerror=()=>t(new Error("Failed to load the Chart.js runtime bundle.")),document.head.appendChild(r)}),W)}function F(e,t,r){return Math.min(r,Math.max(t,e))}function Et(e){return e?e.split(",").map(t=>t.trim()).filter(Boolean):[]}function Z(e){let t=e.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(t){let i=t[1],o=i.length===3?i.split("").map(h=>`${h}${h}`).join(""):i,d=parseInt(o.slice(0,2),16)/255,p=parseInt(o.slice(2,4),16)/255,l=parseInt(o.slice(4,6),16)/255;return oe(d,p,l)}let r=e.trim().match(/^rgba?\((\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)(?:[,/\s]+[\d.]+)?\)$/i);if(r)return oe(Number(r[1])/255,Number(r[2])/255,Number(r[3])/255);let n=e.trim().match(/^hsla?\(([-\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%(?:[,/\s]+[\d.]+)?\)$/i);return n?{h:(Number(n[1])%360+360)%360,s:F(Number(n[2]),0,100),l:F(Number(n[3]),0,100)}:null}function oe(e,t,r){let n=Math.max(e,t,r),i=Math.min(e,t,r),o=n-i,d=0,p=(n+i)/2,l=o===0?0:o/(1-Math.abs(2*p-1));if(o!==0)switch(n){case e:d=60*((t-r)/o%6);break;case t:d=60*((r-e)/o+2);break;default:d=60*((e-t)/o+4);break}return{h:(d+360)%360,s:Math.round(l*100),l:Math.round(p*100)}}function H(e,t=1){return`hsla(${Math.round(e.h)} ${Math.round(e.s)}% ${Math.round(e.l)}% / ${t})`}function zt(e){let t=Z(e)??{h:185,s:88,l:56};return[0,32,68,118,164,212,258,304].map((r,n)=>({h:(t.h+r)%360,s:F(t.s-n*2,55,90),l:F(t.l+(n%2===0?0:6)-n,38,66)}))}function D(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function be(e,t){if(!D(e)||!D(t))return t??e;let r={...e};for(let[n,i]of Object.entries(t)){let o=r[n];r[n]=D(o)&&D(i)?be(o,i):i}return r}function St(e){return e==="top"||e==="bottom"||e==="left"||e==="right"?e:"none"}function It(e){return e==="bar"||e==="line"||e==="area"||e==="pie"||e==="doughnut"||e==="radar"||e==="scatter"||e==="bubble"?e:"bar"}function Mt(e){return e==="bar"||e==="line"||e==="area"||e==="scatter"||e==="bubble"}function Tt(e){return e.map(t=>t.trim()).filter(Boolean)}var Nt=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 It(this.getAttribute("type"))}set type(e){this.setAttribute("type",e)}get legend(){return St(this.getAttribute("legend"))}set legend(e){this.setAttribute("legend",e)}get stacked(){return this.hasAttribute("stacked")}set stacked(e){this.toggleAttribute("stacked",e)}get labels(){return Tt(Et(this.getAttribute("labels")))}set labels(e){this.setAttribute("labels",e.join(","))}get data(){return this._dataInput}set data(e){this._dataInput=e?structuredClone(e):null,this._scheduleSync()}get options(){return this._optionsOverride}set options(e){this._optionsOverride=e?structuredClone(e):null,this._renderChart()}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=Ct,e.appendChild(t);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),e.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=e=>{if(!this._chart)return;let t=this._chart.getElementsAtEventForMode(e,"nearest",{intersect:!0},!0)[0];if(!t)return;let r=Array.isArray(this._chart.data.labels)?this._chart.data.labels[t.index]??null:null,n=this._chart.data.datasets[t.datasetIndex],i=Array.isArray(n?.data)?n.data[t.index]:void 0;this.dispatchEvent(new CustomEvent("dt-chart-click",{bubbles:!0,composed:!0,detail:{label:r,datasetIndex:t.datasetIndex,index:t.index,value:i}}))};_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=Pt().then(e=>(this._runtime=e,e))),this._loadPromise)}async _renderChart(){let e=this._dataInput;if(!e){this._setStatus("Waiting for data");return}let t=await this._ensureRuntime(),r=this._buildConfig(t,e),n=r.type;!this._chart||this._renderedType!==n?(this._chart?.destroy(),this._chart=new t.Chart(this._canvas,r),this._renderedType=n):(this._chart.data=r.data,this._chart.options=r.options,this._chart.update()),this._setStatus(e.datasets.length>0?null:"Waiting for data")}_buildConfig(e,t){let r=getComputedStyle(this),n=r.getPropertyValue("--dt-accent").trim()||"#42d4ff",i=r.getPropertyValue("--dt-text").trim()||"#d6ebff",o=r.getPropertyValue("--dt-text-muted").trim()||"#7b93a6",d=r.getPropertyValue("--dt-border").trim()||"rgba(123, 147, 166, 0.3)",p=r.getPropertyValue("--font-mono").trim()||"'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace",l=zt(n),h=this.type==="area"?"line":this.type,m={labels:t.labels??this.labels,datasets:t.datasets.map((u,x)=>{let A=l[x%l.length],P=u.color??H(A,1),C={label:u.label??"",data:u.data,backgroundColor:h==="line"||h==="radar"||h==="scatter"?H(A,h==="scatter"?.95:.24):P,borderColor:P,pointBackgroundColor:P,pointBorderColor:P,pointHoverBackgroundColor:P,pointRadius:this.type==="line"||this.type==="area"?3:4,pointHoverRadius:this.type==="line"||this.type==="area"?5:6,borderWidth:2,tension:h==="line"||this.type==="area"?.32:void 0,fill:this.type==="area"};return h==="pie"||h==="doughnut"?{...C,backgroundColor:Array.isArray(u.data)?u.data.map((v,g)=>H(l[g%l.length],.86)):P,borderColor:Array.isArray(u.data)?u.data.map((v,g)=>H(l[g%l.length],1)):P,borderWidth:1}:h==="scatter"||h==="bubble"?{...C,showLine:!1,backgroundColor:H(A,.78)}:C})},c={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:i,boxWidth:12,boxHeight:12,padding:14,font:{family:p,size:11}}},tooltip:{backgroundColor:"rgba(10, 18, 24, 0.92)",borderColor:Lt(d,n,.35),borderWidth:1,titleColor:i,bodyColor:i,footerColor:o,titleFont:{family:p,size:11},bodyFont:{family:p,size:11},padding:10}},scales:Mt(this.type)?{x:{stacked:this.stacked,grid:{display:!1,color:d},border:{color:d},ticks:{color:o,font:{family:p,size:11}}},y:{stacked:this.stacked,beginAtZero:!0,grid:{display:!1,color:d},border:{color:d},ticks:{color:o,font:{family:p,size:11}}}}:h==="radar"?{r:{angleLines:{color:d},grid:{color:d},pointLabels:{color:o,font:{family:p,size:11}},ticks:{color:o,backdropColor:"transparent",font:{family:p,size:10}}}}:void 0};return{type:h,data:m,options:be(c,this._optionsOverride??{})}}_setStatus(e){if(!e){this._status.hidden=!0;return}this._status.hidden=!1,this._status.textContent=e}};function Lt(e,t,r){let n=Z(e),i=Z(t);if(!n||!i)return e;let o=F(r,0,1),d=((i.h-n.h)%360+540)%360-180;return H({h:(n.h+d*o+360)%360,s:n.s+(i.s-n.s)*o,l:n.l+(i.l-n.l)*o})}var Ht=`:host {
|
|
1286
1286
|
display: block;
|
|
1287
1287
|
color: var(--dt-text);
|
|
1288
1288
|
font-family: var(--font-sans, 'Inter', sans-serif);
|
|
@@ -1454,13 +1454,13 @@ import{W as be,a as ve,u as L,d as J,A as fe,b as F,_ as Q}from"./index-DCZC2uPI
|
|
|
1454
1454
|
opacity: 0;
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
|
-
`,
|
|
1457
|
+
`,K=null;function $t(){return window.__DtMarked?Promise.resolve(window.__DtMarked):K||(K=new Promise((e,t)=>{let r=document.createElement("script");r.src="/api/ui/marked.js",r.async=!0,r.dataset.dtMarked="true",r.onload=()=>{if(window.__DtMarked){e(window.__DtMarked);return}t(new Error("Marked runtime loaded without a __DtMarked export."))},r.onerror=()=>t(new Error("Failed to load the marked runtime bundle.")),document.head.appendChild(r)}),K)}function ve(e){return e.replaceAll(`\r
|
|
1458
1458
|
`,`
|
|
1459
|
-
`)}function
|
|
1460
|
-
`);for(;t.length>0&&t[0].trim()==="";)t.shift();for(;t.length>0&&t[t.length-1].trim()==="";)t.pop();let r=t.filter(
|
|
1461
|
-
`):t.map(
|
|
1462
|
-
`)}function
|
|
1463
|
-
${r}`}var
|
|
1459
|
+
`)}function Rt(e){let t=ve(e).split(`
|
|
1460
|
+
`);for(;t.length>0&&t[0].trim()==="";)t.shift();for(;t.length>0&&t[t.length-1].trim()==="";)t.pop();let r=t.filter(i=>i.trim()!=="").map(i=>i.match(/^\s*/)?.[0].length??0),n=r.length>0?Math.min(...r):0;return n===0?t.join(`
|
|
1461
|
+
`):t.map(i=>i.slice(n)).join(`
|
|
1462
|
+
`)}function Ft(e){let t=ve(e);if((t.match(/(^|\n)(```|~~~)/g)??[]).length%2===0)return t;let r=t.includes("~~~")&&!t.includes("```")?"~~~":"```";return`${t}
|
|
1463
|
+
${r}`}var Bt=class extends HTMLElement{_body;_caret;_contentOverride=null;_runtime=null;_loadPromise=null;_observer=null;_renderFrame=0;static get observedAttributes(){return["streaming","unsafe-html"]}get content(){return this._contentOverride??this._readInlineMarkdown()}set content(e){this._contentOverride=String(e??""),this._scheduleRender()}get streaming(){return this.hasAttribute("streaming")}set streaming(e){this.toggleAttribute("streaming",e)}get unsafeHtml(){return this.hasAttribute("unsafe-html")}set unsafeHtml(e){this.toggleAttribute("unsafe-html",e)}constructor(){super();let e=this.attachShadow({mode:"open"}),t=document.createElement("style");t.textContent=Ht,e.appendChild(t),this._body=document.createElement("div"),this._body.className="dt-markdown",this._body.addEventListener("click",this._onLinkClick),this._caret=document.createElement("span"),this._caret.className="dt-markdown__caret",this._caret.textContent="▌",this._caret.hidden=!0,e.append(this._body,this._caret)}connectedCallback(){this._observer||(this._observer=new MutationObserver(()=>{this._contentOverride===null&&this._scheduleRender()}),this._observer.observe(this,{childList:!0,characterData:!0,subtree:!0})),this._ensureRuntime(),this._scheduleRender()}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._renderFrame!==0&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=0)}attributeChangedCallback(){this._scheduleRender()}_onLinkClick=e=>{let t=e.composedPath().find(r=>r instanceof HTMLAnchorElement);t&&(e.preventDefault(),this.dispatchEvent(new CustomEvent("dt-link-click",{bubbles:!0,composed:!0,detail:{href:t.getAttribute("href")??"#"}})))};_readInlineMarkdown(){return Rt(this.textContent??"")}_scheduleRender(){this._renderFrame===0&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=0,this._render()}))}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=$t().then(e=>(this._runtime=e,e))),this._loadPromise)}async _render(){let e=await this._ensureRuntime(),t=this.content;this.streaming&&(t=Ft(t)),this._body.innerHTML=e.render(t,{unsafeHtml:this.unsafeHtml}),this._caret.hidden=!this.streaming}},Dt=`:host {
|
|
1464
1464
|
display: block;
|
|
1465
1465
|
min-height: 240px;
|
|
1466
1466
|
color: var(--dt-text);
|
|
@@ -1732,8 +1732,8 @@ ${r}`}var Ht=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1732
1732
|
.milkdown .editor td {
|
|
1733
1733
|
border: 1px solid var(--dt-border);
|
|
1734
1734
|
}
|
|
1735
|
-
`,W=null;function Bt(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):W||(W=new Promise((e,t)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){e(window.__DtMilkdown);return}t(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>t(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),W)}var Rt=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(e){this.setAttribute("placeholder",e)}get readonly(){return this.hasAttribute("readonly")}set readonly(e){this.toggleAttribute("readonly",e)}get value(){return this._editor&&(this._pendingValue=this._editor.getMarkdown()),this._pendingValue}set value(e){let t=String(e??"");this._pendingValue=t,this._editor&&this._runtime&&this._editor.getMarkdown()!==t&&(this._suppressNextChange=!0,this._editor.editor.action(this._runtime.replaceAll(t)))}constructor(){super();let e=this.attachShadow({mode:"open"});this._shadow=e;let t=document.createElement("style");t.textContent=Ft,e.appendChild(t),this._runtimeStyleAnchor=document.createComment("runtime-styles"),e.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),e.appendChild(this._surface)}connectedCallback(){this._initializeEditor()}disconnectedCallback(){this._setupToken+=1,this._clearChangeTimer(),this._destroyEditor()}attributeChangedCallback(e){if(e==="readonly"){this._editor?.setReadonly(this.readonly);return}e==="placeholder"&&this.isConnected&&this._initializeEditor(!0)}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=Bt().then(e=>{this._runtime=e;let t=this._runtimeStyleAnchor;for(let r of e.cssEntries){let i=document.createElement("style");i.dataset.css=r.name,i.textContent=r.css,t.parentNode.insertBefore(i,t.nextSibling)}return e})),this._loadPromise)}async _initializeEditor(e=!1){let t=++this._setupToken;if(this._setStatus("Loading editor"),e)await this._destroyEditor();else if(this._editor){this._setStatus(null);return}try{let r=await this._ensureRuntime();if(!this.isConnected||t!==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((c,d)=>{if(this._pendingValue=d,this._suppressNextChange){this._suppressNextChange=!1;return}this._queueChange(d)}),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||t!==this._setupToken){await n.destroy();return}this._editor=n,this._editor.setReadonly(this.readonly),this._pendingValue=this._editor.getMarkdown(),this._setStatus(null)}catch{t===this._setupToken&&this._setStatus("Failed to load editor")}}async _destroyEditor(){let e=this._editor;if(this._editor=null,!!e)try{await e.destroy()}catch{}}_queueChange(e){this._clearChangeTimer(),this._changeTimer=setTimeout(()=>{this._changeTimer=null,this.dispatchEvent(new CustomEvent("dt-change",{bubbles:!0,composed:!0,detail:{value:e}}))},300)}_clearChangeTimer(){this._changeTimer&&(clearTimeout(this._changeTimer),this._changeTimer=null)}_setStatus(e){if(e){this._status.hidden=!1,this._status.textContent=e;return}this._status.hidden=!0}};customElements.get("dt-tooltip")||customElements.define("dt-tooltip",He),customElements.get("dt-card")||customElements.define("dt-card",Re),customElements.get("dt-select")||customElements.define("dt-select",Ge),customElements.get("dt-grid")||customElements.define("dt-grid",Ze),customElements.get("dt-stack")||customElements.define("dt-stack",et),customElements.get("dt-stat")||customElements.define("dt-stat",it),customElements.get("dt-badge")||customElements.define("dt-badge",at),customElements.get("dt-button")||customElements.define("dt-button",lt),customElements.get("dt-divider")||customElements.define("dt-divider",ut),customElements.get("dt-list-view")||customElements.define("dt-list-view",yt),customElements.get("dt-table-view")||customElements.define("dt-table-view",ft),customElements.get("dt-column")||customElements.define("dt-column",he),customElements.get("dt-chart")||customElements.define("dt-chart",Mt),customElements.get("dt-markdown")||customElements.define("dt-markdown",Ht),customElements.get("dt-markdown-editor")||customElements.define("dt-markdown-editor",Rt);var l={root:"PreferenceApp_root",rootCompact:"PreferenceApp_rootCompact",sidebar:"PreferenceApp_sidebar",sidebarHeader:"PreferenceApp_sidebarHeader",categoryItem:"PreferenceApp_categoryItem",categoryItemActive:"PreferenceApp_categoryItem PreferenceApp_categoryItemActive",categoryIcon:"PreferenceApp_categoryIcon",categoryText:"PreferenceApp_categoryText",settingsPanel:"PreferenceApp_settingsPanel",section:"PreferenceApp_section",sectionTitle:"PreferenceApp_sectionTitle",row:"PreferenceApp_row",rowInfo:"PreferenceApp_rowInfo",rowLabel:"PreferenceApp_rowLabel",rowDescription:"PreferenceApp_rowDescription",rowRestartBadge:"PreferenceApp_rowRestartBadge",rowControl:"PreferenceApp_rowControl",providerGroup:"PreferenceApp_providerGroup",providerGroupHeader:"PreferenceApp_providerGroupHeader",providerList:"PreferenceApp_providerList",providerCard:"PreferenceApp_providerCard",providerCardBody:"PreferenceApp_providerCardBody",providerCardHeader:"PreferenceApp_providerCardHeader",providerCardTitleRow:"PreferenceApp_providerCardTitleRow",providerCardTitle:"PreferenceApp_providerCardTitle",providerDefaultBadge:"PreferenceApp_providerDefaultBadge",providerCardActions:"PreferenceApp_providerCardActions",providerActionButtonWrap:"PreferenceApp_providerActionButtonWrap",providerButtonWrap:"PreferenceApp_providerButtonWrap",providerFieldGrid:"PreferenceApp_providerFieldGrid",providerField:"PreferenceApp_providerField",providerFieldLabel:"PreferenceApp_providerFieldLabel",providerSelectWrap:"PreferenceApp_providerSelectWrap",subscriptionAuth:"PreferenceApp_subscriptionAuth",subscriptionAuthConnected:"PreferenceApp_subscriptionAuth PreferenceApp_subscriptionAuthConnected",subscriptionAuthPending:"PreferenceApp_subscriptionAuth PreferenceApp_subscriptionAuthPending",subscriptionAuthStatus:"PreferenceApp_subscriptionAuthStatus",subscriptionAuthStatusConnected:"PreferenceApp_subscriptionAuthStatusConnected",subscriptionAuthCode:"PreferenceApp_subscriptionAuthCode",subscriptionAuthProgress:"PreferenceApp_subscriptionAuthProgress",selectWrap:"PreferenceApp_selectWrap",textInput:"PreferenceApp_textInput",numberInput:"PreferenceApp_numberInput",textInputSensitive:"PreferenceApp_textInput PreferenceApp_textInputSensitive",colorControl:"PreferenceApp_colorControl",colorInput:"PreferenceApp_colorInput",toggle:"PreferenceApp_toggle",toggleInput:"PreferenceApp_toggleInput",toggleTrack:"PreferenceApp_toggleTrack",toggleKnob:"PreferenceApp_toggleKnob",notification:"PreferenceApp_notification"},R=window.__desktalk_jsx_runtime,s=R.jsx,v=R.jsxs;R.jsxDEV;R.Fragment;var Dt={General:"⚙",Server:"🌐",AI:"🤖",Voice:"🎙"};function Vt({activeCategory:e,onSelect:t,compact:r=!1}){return v("nav",{className:l.sidebar,children:[s("div",{className:l.sidebarHeader,children:"Settings"}),G.map(i=>{const n=v("button",{className:i===e?l.categoryItemActive:l.categoryItem,onClick:()=>t(i),type:"button","aria-label":r?i:void 0,children:[s("span",{className:l.categoryIcon,children:Dt[i]}),!r&&s("span",{className:l.categoryText,children:i})]},i);return r?s("dt-tooltip",{content:i,placement:"bottom",children:n},i):n})]})}function Ot({config:e,onChange:t}){const[r,i]=P([]);y(()=>{let u=!1;return fetch("/api/ai/providers",{credentials:"same-origin"}).then(p=>p.json()).then(p=>{u||i(p.providers??[])}).catch(()=>{u||i([])}),()=>{u=!0}},[]);const n=j(()=>new Map(r.map(u=>[u.id,u])),[r]),o=j(()=>{const u=de(e["ai.enabledProviders"]),p=typeof e["ai.defaultProvider"]=="string"&&e["ai.defaultProvider"]?String(e["ai.defaultProvider"]):N;return u.includes(p)||u.unshift(p),u},[e]),c=f(async u=>{const p=u.length>0?u:[N];await t("ai.enabledProviders",Ae(p)),await t("ai.defaultProvider",p[0])},[t]),d=f(async()=>{const u=M.find(p=>!o.includes(p.id));u&&await c([...o,u.id])},[o,c]),a=f(async(u,p)=>{if(u===p||o.includes(p))return;const x=o.map(C=>C===u?p:C);await c(x)},[o,c]),h=f(async u=>{if(o.length===1)return;const p=o.filter(x=>x!==u);await c(p);for(const x of we(u))await t(x,"")},[o,t,c]),b=f(async u=>{if(o[0]===u)return;const p=[u,...o.filter(x=>x!==u)];await c(p)},[o,c]);return v("div",{className:l.providerGroup,children:[v("div",{className:l.providerGroupHeader,children:[v("div",{children:[s("div",{className:l.rowLabel,children:"Providers"}),s("div",{className:l.rowDescription,children:"Add providers, keep your default at the top, and remove anything you no longer use."})]}),s("div",{className:l.providerActionButtonWrap,children:s(z,{onPress:d,disabled:o.length>=M.length,variant:"secondary",children:"Add provider"})})]}),s("div",{className:l.providerList,children:o.map((u,p)=>{const x=se(u),C=n.get(u);if(!x)return null;const w=M.filter(m=>m.id===u||!o.includes(m.id)),k=String(e[`ai.providers.${u}.model`]??""),g=[{value:"",label:"Select model"},...(C?.models??[]).map(m=>({value:m,label:m}))];return k&&!g.some(m=>m.value===k)&&g.push({value:k,label:`${k} (custom)`}),s("div",{className:l.providerCard,children:s("dt-card",{variant:"outlined",children:v("div",{className:l.providerCardBody,children:[v("div",{className:l.providerCardHeader,children:[v("div",{className:l.providerCardTitleRow,children:[s("div",{className:l.providerCardTitle,children:x.label}),p===0&&s("span",{className:l.providerDefaultBadge,children:"Default"})]}),v("div",{className:l.providerCardActions,children:[s("div",{className:l.providerButtonWrap,children:s(z,{onPress:()=>b(u),disabled:p===0,variant:"secondary",size:"sm",children:"Set as default"})}),s("div",{className:l.providerButtonWrap,children:s(z,{onPress:()=>h(u),disabled:o.length===1,variant:"danger",size:"sm",children:"Delete"})})]})]}),v("div",{className:l.providerFieldGrid,children:[v("div",{className:l.providerField,children:[s("label",{className:l.providerFieldLabel,htmlFor:`ai-provider-${u}`,children:"Provider"}),s(oe,{value:u,options:w.map(m=>({value:m.id,label:m.label})),onChange:m=>a(u,m)})]}),x.authType==="subscription"?s(Wt,{providerId:u}):x.supportsApiKey&&s(K,{id:`ai-provider-key-${u}`,label:"API Key",value:String(e[`ai.providers.${u}.apiKey`]??""),sensitive:!0,onCommit:m=>t(`ai.providers.${u}.apiKey`,m)}),(C?.models?.length??0)>0?v("div",{className:l.providerField,children:[s("label",{className:l.providerFieldLabel,htmlFor:`ai-provider-model-${u}`,children:"Model"}),s(oe,{value:k,options:g,onChange:m=>t(`ai.providers.${u}.model`,m)})]}):s(K,{id:`ai-provider-model-${u}`,label:"Model",value:k,onCommit:m=>t(`ai.providers.${u}.model`,m)}),x.supportsBaseUrl&&s(K,{id:`ai-provider-base-url-${u}`,label:"Base URL",value:String(e[`ai.providers.${u}.baseUrl`]??""),onCommit:m=>t(`ai.providers.${u}.baseUrl`,m)})]})]})})},u)})})]})}function Wt({providerId:e}){const[t,r]=P({phase:"idle"}),i=q(null);y(()=>{let d=!1;return r({phase:"checking"}),fetch(`/api/ai/providers/${e}/auth-status`,{credentials:"same-origin"}).then(a=>a.json()).then(a=>{d||r(a.authenticated?{phase:"authenticated"}:{phase:"idle"})}).catch(()=>{d||r({phase:"idle"})}),()=>{d=!0}},[e]);const n=f(()=>{const d=new AbortController;i.current=d,r({phase:"pending",url:"",instructions:void 0}),fetch(`/api/ai/providers/${e}/login`,{method:"POST",credentials:"same-origin",signal:d.signal}).then(async a=>{const h=a.body?.getReader();if(!h){r({phase:"error",message:"No response stream"});return}const b=new TextDecoder;let u="";for(;;){const{done:p,value:x}=await h.read();if(p)break;u+=b.decode(x,{stream:!0});const C=u.split(`
|
|
1736
|
-
`);u=C.pop()??"";let w="";for(const k of C)if(k.startsWith("event: "))w=k.slice(7);else if(k.startsWith("data: ")&&w){try{const g=JSON.parse(k.slice(6));w==="auth"?r(m=>({phase:"pending",url:String(g.url??""),instructions:g.instructions?String(g.instructions):void 0,progress:m.phase==="pending"?m.progress:void 0})):w==="progress"?r(m=>m.phase==="pending"?{...m,progress:String(g.message??"")}:m):w==="done"?r({phase:"authenticated"}):w==="error"&&r({phase:"error",message:String(g.message??"Login failed")})}catch{}w=""}}}).catch(a=>{if(a?.name==="AbortError")return;const h=a instanceof Error?a.message:String(a);r({phase:"error",message:h})})},[e]),o=f(()=>{i.current?.abort(),i.current=null,fetch(`/api/ai/providers/${e}/logout`,{method:"POST",credentials:"same-origin"}).then(()=>r({phase:"idle"})).catch(()=>r({phase:"idle"}))},[e]),c=f((d,a)=>{a&&navigator.clipboard.writeText(a),window.open(d,"_blank","noopener,noreferrer")},[]);return t.phase==="checking"?s("div",{className:l.subscriptionAuth,children:s("div",{className:l.subscriptionAuthStatus,children:"Checking..."})}):t.phase==="authenticated"?v("div",{className:l.subscriptionAuthConnected,children:[s("div",{className:l.subscriptionAuthStatus,children:s("span",{className:l.subscriptionAuthStatusConnected,children:"Connected"})}),s(z,{onPress:o,variant:"danger",size:"sm",children:"Logout"})]}):t.phase==="pending"?v("div",{className:l.subscriptionAuthPending,children:[v("div",{className:l.subscriptionAuthStatus,children:[t.instructions&&v("div",{children:["Code: ",s("span",{className:l.subscriptionAuthCode,children:t.instructions})]}),t.progress&&s("div",{className:l.subscriptionAuthProgress,children:t.progress}),!t.progress&&!t.instructions&&s("div",{className:l.subscriptionAuthProgress,children:"Starting login..."})]}),v("div",{className:l.providerCardActions,children:[t.url&&s(z,{onPress:()=>c(t.url,t.instructions),variant:"primary",size:"sm",children:"Copy Code & Open"}),s(z,{onPress:o,variant:"secondary",size:"sm",children:"Cancel"})]})]}):t.phase==="error"?v("div",{className:l.subscriptionAuth,children:[v("div",{className:l.subscriptionAuthStatus,children:["Error: ",t.message]}),s(z,{onPress:n,variant:"primary",size:"sm",children:"Retry"})]}):v("div",{className:l.subscriptionAuth,children:[s("div",{className:l.subscriptionAuthStatus,children:"Not connected"}),s(z,{onPress:n,variant:"primary",size:"sm",children:"Login"})]})}function z({children:e,disabled:t=!1,variant:r="primary",size:i="md",onPress:n}){const[o,c]=P(null);return y(()=>{if(!o)return;const d=()=>{n()};return o.addEventListener("click",d),()=>o.removeEventListener("click",d)},[o,n]),s("dt-button",{ref:d=>c(d),disabled:t,variant:r,size:i,children:e})}function oe({value:e,options:t,disabled:r=!1,onChange:i}){const[n,o]=P(null);return y(()=>{n&&(n.options=t)},[t,n]),y(()=>{n&&(n.value=e)},[n,e]),y(()=>{n&&(n.disabled=r)},[r,n]),y(()=>{if(!n)return;const c=d=>{i(d.detail.value)};return n.addEventListener("dt-change",c),()=>n.removeEventListener("dt-change",c)},[i,n]),s("div",{className:l.providerSelectWrap,children:s("dt-select",{ref:c=>o(c)})})}function K({id:e,label:t,value:r,sensitive:i=!1,onCommit:n}){const[o,c]=P(r);y(()=>{c(r)},[r]);const d=f(()=>{o!==r&&n(o)},[o,n,r]);return v("div",{className:l.providerField,children:[s("label",{className:l.providerFieldLabel,htmlFor:e,children:t}),s("input",{id:e,type:i?"password":"text",className:i?l.textInputSensitive:l.textInput,value:o,onChange:a=>c(a.target.value),onBlur:d,onKeyDown:a=>{a.key==="Enter"&&d()}})]})}function Kt({config:e,onChange:t}){const r=j(()=>{const a=ce(e["voice.enabledProviders"]),h=typeof e["voice.defaultProvider"]=="string"&&e["voice.defaultProvider"]?String(e["voice.defaultProvider"]):S;return a.includes(h)||a.unshift(h),a},[e]),i=f(async a=>{const h=a.length>0?a:[S];await t("voice.enabledProviders",Ce(h)),await t("voice.defaultProvider",h[0])},[t]),n=f(async()=>{const a=I.find(h=>!r.includes(h.id));a&&await i([...r,a.id])},[r,i]),o=f(async(a,h)=>{if(a===h||r.includes(h))return;const b=r.map(u=>u===a?h:u);await i(b)},[r,i]),c=f(async a=>{if(r.length===1)return;const h=r.filter(b=>b!==a);await i(h);for(const b of ke(a))await t(b,"")},[r,t,i]),d=f(async a=>{if(r[0]===a)return;const h=[a,...r.filter(b=>b!==a)];await i(h)},[r,i]);return v("div",{className:l.providerGroup,children:[v("div",{className:l.providerGroupHeader,children:[v("div",{children:[s("div",{className:l.rowLabel,children:"Providers"}),s("div",{className:l.rowDescription,children:"Add STT providers, keep your default at the top, and remove unused items."})]}),s("div",{className:l.providerActionButtonWrap,children:s(U,{onPress:n,disabled:r.length>=I.length,variant:"secondary",children:"Add provider"})})]}),s("div",{className:l.providerList,children:r.map((a,h)=>{const b=le(a);if(!b)return null;const u=I.filter(p=>p.id===a||!r.includes(p.id));return s("div",{className:l.providerCard,children:s("dt-card",{variant:"outlined",children:v("div",{className:l.providerCardBody,children:[v("div",{className:l.providerCardHeader,children:[v("div",{className:l.providerCardTitleRow,children:[s("div",{className:l.providerCardTitle,children:b.label}),h===0&&s("span",{className:l.providerDefaultBadge,children:"Default"})]}),v("div",{className:l.providerCardActions,children:[s("div",{className:l.providerButtonWrap,children:s(U,{onPress:()=>d(a),disabled:h===0,variant:"secondary",size:"sm",children:"Set as default"})}),s("div",{className:l.providerButtonWrap,children:s(U,{onPress:()=>c(a),disabled:r.length===1,variant:"danger",size:"sm",children:"Delete"})})]})]}),v("div",{className:l.providerFieldGrid,children:[s(Ut,{label:"Provider",value:a,options:u.map(p=>({value:p.id,label:p.label})),onChange:p=>o(a,p)}),b.supportsApiKey&&s($,{id:`voice-provider-key-${a}`,label:"API Key",value:String(e[`voice.providers.${a}.apiKey`]??""),sensitive:!0,onCommit:p=>t(`voice.providers.${a}.apiKey`,p)}),b.supportsModel&&s($,{id:`voice-provider-model-${a}`,label:"Model",value:String(e[`voice.providers.${a}.model`]??""),onCommit:p=>t(`voice.providers.${a}.model`,p)}),b.supportsBaseUrl&&s($,{id:`voice-provider-base-url-${a}`,label:"Base URL",value:String(e[`voice.providers.${a}.baseUrl`]??""),onCommit:p=>t(`voice.providers.${a}.baseUrl`,p)}),b.supportsAzureDeployment&&s($,{id:`voice-provider-deployment-${a}`,label:"Azure Deployment",value:String(e[`voice.providers.${a}.azureDeployment`]??""),onCommit:p=>t(`voice.providers.${a}.azureDeployment`,p)}),b.supportsAzureApiVersion&&s($,{id:`voice-provider-api-version-${a}`,label:"Azure API Version",value:String(e[`voice.providers.${a}.azureApiVersion`]??""),onCommit:p=>t(`voice.providers.${a}.azureApiVersion`,p)})]})]})})},a)})})]})}function U({children:e,disabled:t=!1,variant:r="primary",size:i="md",onPress:n}){const[o,c]=P(null);return y(()=>{if(!o)return;const d=()=>{n()};return o.addEventListener("click",d),()=>o.removeEventListener("click",d)},[o,n]),s("dt-button",{ref:d=>c(d),disabled:t,variant:r,size:i,children:e})}function Ut({label:e,value:t,options:r,onChange:i}){const[n,o]=P(null);return y(()=>{n&&(n.options=r)},[r,n]),y(()=>{n&&(n.value=t)},[n,t]),y(()=>{if(!n)return;const c=d=>{i(d.detail.value)};return n.addEventListener("dt-change",c),()=>n.removeEventListener("dt-change",c)},[i,n]),v("div",{className:l.providerField,children:[s("label",{className:l.providerFieldLabel,children:e}),s("div",{className:l.providerSelectWrap,children:s("dt-select",{ref:c=>o(c)})})]})}function $({id:e,label:t,value:r,sensitive:i=!1,onCommit:n}){const[o,c]=P(r);y(()=>{c(r)},[r]);const d=f(()=>{o!==r&&n(o)},[o,n,r]);return v("div",{className:l.providerField,children:[s("label",{className:l.providerFieldLabel,htmlFor:e,children:t}),s("input",{id:e,type:i?"password":"text",className:i?l.textInputSensitive:l.textInput,value:o,onChange:a=>c(a.target.value),onBlur:d,onKeyDown:a=>{a.key==="Enter"&&d()}})]})}function jt({title:e,children:t}){return v("section",{className:l.section,children:[s("h3",{className:l.sectionTitle,children:e}),t]})}function qt({schema:e,value:t,onChange:r}){return v("div",{className:l.row,children:[v("div",{className:l.rowInfo,children:[v("div",{className:l.rowLabel,children:[e.label,e.requiresRestart&&s("span",{className:l.rowRestartBadge,children:"restart"})]}),s("div",{className:l.rowDescription,children:e.description})]}),s("div",{className:l.rowControl,children:s(Gt,{schema:e,value:t,onChange:r})})]})}function Gt({schema:e,value:t,onChange:r}){return e.key==="general.accentColor"&&e.type==="string"?s(Yt,{schema:e,value:t,onChange:r}):e.type==="boolean"?s(Zt,{schema:e,value:t,onChange:r}):e.type==="string"&&e.options?s(Jt,{schema:e,value:t,onChange:r}):e.type==="string"?s(er,{schema:e,value:t,onChange:r}):e.type==="number"?s(tr,{schema:e,value:t,onChange:r}):null}function Xt(e){return/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e)}function Yt({schema:e,value:t,onChange:r}){const[i,n]=P(t);y(()=>{n(t)},[t]);const o=f(p=>{const x=(p??i).trim();x!==t&&r(e.key,x)},[i,r,e.key,t]),c=f(p=>{n(p.currentTarget.value)},[]),d=f(p=>{const x=p.target.value;n(x),o(x)},[o]),a=f(p=>{n(p.target.value)},[]),h=f(p=>{p.key==="Enter"&&o()},[o]),b=f(()=>{o()},[o]),u=Xt(i)?i:"#7c6ff7";return v("div",{className:l.colorControl,children:[s("input",{type:"color",className:l.colorInput,value:u,onInput:c,onChange:d,"aria-label":`${e.label} picker`}),s("input",{type:"text",className:l.textInput,value:i,onChange:a,onBlur:b,onKeyDown:h,placeholder:"#7c6ff7"})]})}function Zt({schema:e,value:t,onChange:r}){const i=f(()=>{r(e.key,!t)},[e.key,t,r]);return v("label",{className:l.toggle,children:[s("input",{type:"checkbox",className:l.toggleInput,checked:t,onChange:i}),s("span",{className:l.toggleTrack}),s("span",{className:l.toggleKnob})]})}function Jt({schema:e,value:t,onChange:r}){const i=f(n=>{r(e.key,n)},[e.key,r]);return s(Qt,{value:t,options:(e.options??[]).map(n=>({value:n,label:n})),onChange:i})}function Qt({value:e,options:t,disabled:r=!1,onChange:i}){const[n,o]=P(null);return y(()=>{n&&(n.options=t)},[t,n]),y(()=>{n&&(n.value=e,n.disabled=r)},[r,n,e]),y(()=>{if(!n)return;const c=d=>{i(d.detail.value)};return n.addEventListener("dt-change",c),()=>n.removeEventListener("dt-change",c)},[i,n]),s("div",{className:l.selectWrap,children:s("dt-select",{ref:c=>o(c)})})}function er({schema:e,value:t,onChange:r}){const[i,n]=P(t);y(()=>{n(t)},[t]);const o=f(()=>{i!==t&&r(e.key,i)},[e.key,i,t,r]),c=f(d=>{d.key==="Enter"&&r(e.key,i)},[e.key,i,r]);return s("input",{type:e.sensitive?"password":"text",className:e.sensitive?l.textInputSensitive:l.textInput,value:i,onChange:d=>n(d.target.value),onBlur:o,onKeyDown:c,placeholder:e.sensitive?"Enter API key...":void 0})}function tr({schema:e,value:t,onChange:r}){const[i,n]=P(String(t));y(()=>{n(String(t))},[t]);const o=f(()=>{let d=Number(i);if(Number.isNaN(d)){n(String(t));return}e.min!==void 0&&(d=Math.max(e.min,d)),e.max!==void 0&&(d=Math.min(e.max,d)),n(String(d)),d!==t&&r(e.key,d)},[e.key,e.min,e.max,i,t,r]),c=f(d=>{d.key==="Enter"&&o()},[o]);return s("input",{type:"number",className:l.numberInput,value:i,min:e.min,max:e.max,onChange:d=>n(d.target.value),onBlur:o,onKeyDown:c})}function rr({children:e,onConfigChanged:t}){const r=L("preferences.get"),i=L("preferences.set"),n=L("preferences.reset"),o=L("preferences.resetAll"),c=f(async b=>{const u=b?.key;if(!u)throw new Error("Missing required parameter: key");return await r({key:u})},[r]),d=f(async b=>{const u=b?.key;if(!u)throw new Error("Missing required parameter: key");let p=b?.value;if(p===void 0)throw new Error("Missing required parameter: value");const x=Ie(u);return x&&(x.type==="number"&&typeof p=="string"?p=Number(p):x.type==="boolean"&&typeof p=="string"&&(p=p==="true")),await i({key:u,value:p}),t(),{success:!0}},[i,t]),a=f(async b=>{const u=b?.key;if(!u)throw new Error("Missing required parameter: key");return await n({key:u}),t(),{success:!0}},[n,t]),h=f(async()=>(await o(),t(),{success:!0}),[o,t]);return v(fe,{children:[s(F,{name:"Get Setting",description:"Read the current value of a setting",params:{key:{type:"string",description:"Setting key (e.g. general.theme)",required:!0}},handler:c}),s(F,{name:"Set Setting",description:"Update a setting value",params:{key:{type:"string",description:"Setting key (e.g. general.theme)",required:!0},value:{type:"string",description:"New value for the setting",required:!0}},handler:d}),s(F,{name:"Reset Setting",description:"Reset a setting to its default value",params:{key:{type:"string",description:"Setting key to reset",required:!0}},handler:a}),s(F,{name:"Reset All",description:"Reset all settings to their default values",handler:h}),e]})}var ir=720;function nr(){const[e,t]=P(Me()),[r,i]=P(G[0]),[n,o]=P(null),[c,d]=P(!1),a=q(null),h=q(null),b=L("preferences.getAll"),u=L("preferences.set"),p=f(async()=>{try{const g=await b();t(g)}catch(g){console.error("Failed to load preferences:",g)}},[b]);y(()=>{p()},[p]),y(()=>{if(!h.current)return;const g=A=>{d(A<=ir)};g(h.current.clientWidth);const m=new ResizeObserver(A=>{const Z=A[0];Z&&g(Z.contentRect.width)});return m.observe(h.current),()=>m.disconnect()},[]),J("preferences:changed",g=>{t(m=>({...m,[g.key]:g.value})),g.requiresRestart&&x(Q({scope:"preference",key:"notifications.restartRequired",defaultText:"This change requires a restart to take effect."}))}),J("preferences:resetAll",()=>{p(),x(Q({scope:"preference",key:"notifications.resetAll",defaultText:"All settings have been reset to defaults."}))});const x=f(g=>{o(g),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>o(null),4e3)},[]),C=f(async(g,m)=>{t(A=>({...A,[g]:m}));try{await u({key:g,value:m})}catch(A){console.error(`Failed to update ${g}:`,A),p()}},[u,p]),w=G.filter(g=>g===r),k=f(g=>{const m=Ne(g);return g!=="AI"&&g!=="Voice"?m:m.filter(A=>g==="AI"?!A.key.startsWith("ai.providers.")&&A.key!=="ai.defaultProvider"&&A.key!=="ai.enabledProviders":!A.key.startsWith("voice.providers.")&&A.key!=="voice.defaultProvider"&&A.key!=="voice.enabledProviders")},[]);return s(rr,{onConfigChanged:p,children:v("div",{ref:h,className:`${l.root}${c?` ${l.rootCompact}`:""}`,children:[s(Vt,{activeCategory:r,onSelect:i,compact:c}),s("div",{className:l.settingsPanel,children:w.map(g=>{const m=k(g);return v(jt,{title:g,children:[g==="AI"&&s(Ot,{config:e,onChange:C}),g==="Voice"&&s(Kt,{config:e,onChange:C}),m.map(A=>s(qt,{schema:A,value:e[A.key]??A.default,onChange:C},A.key))]},g)})}),n&&s("div",{className:l.notification,children:n})]})})}function ar(e){const t=_e(e.root);return t.render(s(be,{windowId:e.windowId,children:s(ve,{miniAppId:e.miniAppId,children:s(nr,{})})})),{deactivate(){t.unmount()}}}(()=>{if(typeof document>"u")return;const e="desktalk-style-desktalk-miniapp-preference-xj7a6e";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent=`/* src/styles/PreferenceApp.module.css */
|
|
1735
|
+
`,U=null;function Vt(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):U||(U=new Promise((e,t)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){e(window.__DtMilkdown);return}t(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>t(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),U)}var Ot=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(e){this.setAttribute("placeholder",e)}get readonly(){return this.hasAttribute("readonly")}set readonly(e){this.toggleAttribute("readonly",e)}get value(){return this._editor&&(this._pendingValue=this._editor.getMarkdown()),this._pendingValue}set value(e){let t=String(e??"");this._pendingValue=t,this._editor&&this._runtime&&this._editor.getMarkdown()!==t&&(this._suppressNextChange=!0,this._editor.editor.action(this._runtime.replaceAll(t)))}constructor(){super();let e=this.attachShadow({mode:"open"});this._shadow=e;let t=document.createElement("style");t.textContent=Dt,e.appendChild(t),this._runtimeStyleAnchor=document.createComment("runtime-styles"),e.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),e.appendChild(this._surface)}connectedCallback(){this._initializeEditor()}disconnectedCallback(){this._setupToken+=1,this._clearChangeTimer(),this._destroyEditor()}attributeChangedCallback(e){if(e==="readonly"){this._editor?.setReadonly(this.readonly);return}e==="placeholder"&&this.isConnected&&this._initializeEditor(!0)}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=Vt().then(e=>{this._runtime=e;let t=this._runtimeStyleAnchor;for(let r of e.cssEntries){let n=document.createElement("style");n.dataset.css=r.name,n.textContent=r.css,t.parentNode.insertBefore(n,t.nextSibling)}return e})),this._loadPromise)}async _initializeEditor(e=!1){let t=++this._setupToken;if(this._setStatus("Loading editor"),e)await this._destroyEditor();else if(this._editor){this._setStatus(null);return}try{let r=await this._ensureRuntime();if(!this.isConnected||t!==this._setupToken)return;this._content.replaceChildren();let n=document.createElement("div");n.className="dt-markdown-editor__content",this._content.appendChild(n);let i=new r.Crepe({root:n,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(i.on(o=>{o.markdownUpdated((d,p)=>{if(this._pendingValue=p,this._suppressNextChange){this._suppressNextChange=!1;return}this._queueChange(p)}),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 i.create(),!this.isConnected||t!==this._setupToken){await i.destroy();return}this._editor=i,this._editor.setReadonly(this.readonly),this._pendingValue=this._editor.getMarkdown(),this._setStatus(null)}catch{t===this._setupToken&&this._setStatus("Failed to load editor")}}async _destroyEditor(){let e=this._editor;if(this._editor=null,!!e)try{await e.destroy()}catch{}}_queueChange(e){this._clearChangeTimer(),this._changeTimer=setTimeout(()=>{this._changeTimer=null,this.dispatchEvent(new CustomEvent("dt-change",{bubbles:!0,composed:!0,detail:{value:e}}))},300)}_clearChangeTimer(){this._changeTimer&&(clearTimeout(this._changeTimer),this._changeTimer=null)}_setStatus(e){if(e){this._status.hidden=!1,this._status.textContent=e;return}this._status.hidden=!0}};customElements.get("dt-tooltip")||customElements.define("dt-tooltip",Be),customElements.get("dt-card")||customElements.define("dt-card",Oe),customElements.get("dt-select")||customElements.define("dt-select",Ze),customElements.get("dt-grid")||customElements.define("dt-grid",et),customElements.get("dt-stack")||customElements.define("dt-stack",nt),customElements.get("dt-stat")||customElements.define("dt-stat",at),customElements.get("dt-badge")||customElements.define("dt-badge",lt),customElements.get("dt-button")||customElements.define("dt-button",ut),customElements.get("dt-divider")||customElements.define("dt-divider",gt),customElements.get("dt-list-view")||customElements.define("dt-list-view",kt),customElements.get("dt-table-view")||customElements.define("dt-table-view",yt),customElements.get("dt-column")||customElements.define("dt-column",ge),customElements.get("dt-chart")||customElements.define("dt-chart",Nt),customElements.get("dt-markdown")||customElements.define("dt-markdown",Bt),customElements.get("dt-markdown-editor")||customElements.define("dt-markdown-editor",Ot);var s={root:"PreferenceApp_root",rootCompact:"PreferenceApp_rootCompact",sidebar:"PreferenceApp_sidebar",sidebarHeader:"PreferenceApp_sidebarHeader",categoryItem:"PreferenceApp_categoryItem",categoryItemActive:"PreferenceApp_categoryItem PreferenceApp_categoryItemActive",categoryIcon:"PreferenceApp_categoryIcon",categoryText:"PreferenceApp_categoryText",settingsPanel:"PreferenceApp_settingsPanel",section:"PreferenceApp_section",sectionTitle:"PreferenceApp_sectionTitle",row:"PreferenceApp_row",rowInfo:"PreferenceApp_rowInfo",rowLabel:"PreferenceApp_rowLabel",rowDescription:"PreferenceApp_rowDescription",rowRestartBadge:"PreferenceApp_rowRestartBadge",rowControl:"PreferenceApp_rowControl",providerGroup:"PreferenceApp_providerGroup",providerGroupHeader:"PreferenceApp_providerGroupHeader",providerList:"PreferenceApp_providerList",providerCard:"PreferenceApp_providerCard",providerCardBody:"PreferenceApp_providerCardBody",providerCardHeader:"PreferenceApp_providerCardHeader",providerCardTitleRow:"PreferenceApp_providerCardTitleRow",providerCardTitle:"PreferenceApp_providerCardTitle",providerDefaultBadge:"PreferenceApp_providerDefaultBadge",providerCardActions:"PreferenceApp_providerCardActions",providerActionButtonWrap:"PreferenceApp_providerActionButtonWrap",providerButtonWrap:"PreferenceApp_providerButtonWrap",providerFieldGrid:"PreferenceApp_providerFieldGrid",providerField:"PreferenceApp_providerField",providerFieldLabel:"PreferenceApp_providerFieldLabel",providerSelectWrap:"PreferenceApp_providerSelectWrap",subscriptionAuth:"PreferenceApp_subscriptionAuth",subscriptionAuthConnected:"PreferenceApp_subscriptionAuth PreferenceApp_subscriptionAuthConnected",subscriptionAuthPending:"PreferenceApp_subscriptionAuth PreferenceApp_subscriptionAuthPending",subscriptionAuthStatus:"PreferenceApp_subscriptionAuthStatus",subscriptionAuthStatusConnected:"PreferenceApp_subscriptionAuthStatusConnected",subscriptionAuthCode:"PreferenceApp_subscriptionAuthCode",subscriptionAuthProgress:"PreferenceApp_subscriptionAuthProgress",manualCodeInput:"PreferenceApp_manualCodeInput",manualCodeHint:"PreferenceApp_manualCodeHint",manualCodeRow:"PreferenceApp_manualCodeRow",manualCodeTextInput:"PreferenceApp_manualCodeTextInput",selectWrap:"PreferenceApp_selectWrap",textInput:"PreferenceApp_textInput",numberInput:"PreferenceApp_numberInput",textInputSensitive:"PreferenceApp_textInput PreferenceApp_textInputSensitive",colorControl:"PreferenceApp_colorControl",colorInput:"PreferenceApp_colorInput",toggle:"PreferenceApp_toggle",toggleInput:"PreferenceApp_toggleInput",toggleTrack:"PreferenceApp_toggleTrack",toggleKnob:"PreferenceApp_toggleKnob",notification:"PreferenceApp_notification"},V=window.__desktalk_jsx_runtime,a=V.jsx,b=V.jsxs;V.jsxDEV;V.Fragment;var Wt={General:"⚙",Server:"🌐",AI:"🤖",Voice:"🎙"};function Kt({activeCategory:e,onSelect:t,compact:r=!1}){return b("nav",{className:s.sidebar,children:[a("div",{className:s.sidebarHeader,children:"Settings"}),Y.map(n=>{const i=b("button",{className:n===e?s.categoryItemActive:s.categoryItem,onClick:()=>t(n),type:"button","aria-label":r?n:void 0,children:[a("span",{className:s.categoryIcon,children:Wt[n]}),!r&&a("span",{className:s.categoryText,children:n})]},n);return r?a("dt-tooltip",{content:n,placement:"bottom",children:i},n):i})]})}function Ut({config:e,onChange:t}){const[r,n]=k([]);w(()=>{let c=!1;return fetch("/api/ai/providers",{credentials:"same-origin"}).then(u=>u.json()).then(u=>{c||n(u.providers??[])}).catch(()=>{c||n([])}),()=>{c=!0}},[]);const i=G(()=>new Map(r.map(c=>[c.id,c])),[r]),o=G(()=>{const c=ce(e["ai.enabledProviders"]),u=typeof e["ai.defaultProvider"]=="string"&&e["ai.defaultProvider"]?String(e["ai.defaultProvider"]):L;return c.includes(u)||c.unshift(u),c},[e]),d=f(async c=>{const u=c.length>0?c:[L];await t("ai.enabledProviders",Pe(u)),await t("ai.defaultProvider",u[0])},[t]),p=f(async()=>{const c=T.find(u=>!o.includes(u.id));c&&await d([...o,c.id])},[o,d]),l=f(async(c,u)=>{if(c===u||o.includes(u))return;const x=o.map(A=>A===c?u:A);await d(x)},[o,d]),h=f(async c=>{if(o.length===1)return;const u=o.filter(x=>x!==c);await d(u);for(const x of Ce(c))await t(x,"")},[o,t,d]),m=f(async c=>{if(o[0]===c)return;const u=[c,...o.filter(x=>x!==c)];await d(u)},[o,d]);return b("div",{className:s.providerGroup,children:[b("div",{className:s.providerGroupHeader,children:[b("div",{children:[a("div",{className:s.rowLabel,children:"Providers"}),a("div",{className:s.rowDescription,children:"Add providers, keep your default at the top, and remove anything you no longer use."})]}),a("div",{className:s.providerActionButtonWrap,children:a(S,{onPress:p,disabled:o.length>=T.length,variant:"secondary",children:"Add provider"})})]}),a("div",{className:s.providerList,children:o.map((c,u)=>{const x=le(c),A=i.get(c);if(!x)return null;const P=T.filter(g=>g.id===c||!o.includes(g.id)),C=String(e[`ai.providers.${c}.model`]??""),v=[{value:"",label:"Select model"},...(A?.models??[]).map(g=>({value:g,label:g}))];return C&&!v.some(g=>g.value===C)&&v.push({value:C,label:`${C} (custom)`}),a("div",{className:s.providerCard,children:a("dt-card",{variant:"outlined",children:b("div",{className:s.providerCardBody,children:[b("div",{className:s.providerCardHeader,children:[b("div",{className:s.providerCardTitleRow,children:[a("div",{className:s.providerCardTitle,children:x.label}),u===0&&a("span",{className:s.providerDefaultBadge,children:"Default"})]}),b("div",{className:s.providerCardActions,children:[a("div",{className:s.providerButtonWrap,children:a(S,{onPress:()=>m(c),disabled:u===0,variant:"secondary",size:"sm",children:"Set as default"})}),a("div",{className:s.providerButtonWrap,children:a(S,{onPress:()=>h(c),disabled:o.length===1,variant:"danger",size:"sm",children:"Delete"})})]})]}),b("div",{className:s.providerFieldGrid,children:[b("div",{className:s.providerField,children:[a("label",{className:s.providerFieldLabel,htmlFor:`ai-provider-${c}`,children:"Provider"}),a(ae,{value:c,options:P.map(g=>({value:g.id,label:g.label})),onChange:g=>l(c,g)})]}),x.authType==="subscription"?a(jt,{providerId:c}):x.supportsApiKey&&a(j,{id:`ai-provider-key-${c}`,label:"API Key",value:String(e[`ai.providers.${c}.apiKey`]??""),sensitive:!0,onCommit:g=>t(`ai.providers.${c}.apiKey`,g)}),(A?.models?.length??0)>0?b("div",{className:s.providerField,children:[a("label",{className:s.providerFieldLabel,htmlFor:`ai-provider-model-${c}`,children:"Model"}),a(ae,{value:C,options:v,onChange:g=>t(`ai.providers.${c}.model`,g)})]}):a(j,{id:`ai-provider-model-${c}`,label:"Model",value:C,onCommit:g=>t(`ai.providers.${c}.model`,g)}),x.supportsBaseUrl&&a(j,{id:`ai-provider-base-url-${c}`,label:"Base URL",value:String(e[`ai.providers.${c}.baseUrl`]??""),onCommit:g=>t(`ai.providers.${c}.baseUrl`,g)})]})]})})},c)})})]})}function jt({providerId:e}){const[t,r]=k({phase:"idle"}),[n,i]=k(""),o=X(null);w(()=>{let m=!1;return r({phase:"checking"}),fetch(`/api/ai/providers/${e}/auth-status`,{credentials:"same-origin"}).then(c=>c.json()).then(c=>{m||r(c.authenticated?{phase:"authenticated"}:{phase:"idle"})}).catch(()=>{m||r({phase:"idle"})}),()=>{m=!0}},[e]);const d=f(()=>{const m=new AbortController;o.current=m,r({phase:"pending",url:"",instructions:void 0}),i(""),fetch(`/api/ai/providers/${e}/login`,{method:"POST",credentials:"same-origin",signal:m.signal}).then(async c=>{const u=c.body?.getReader();if(!u){r({phase:"error",message:"No response stream"});return}const x=new TextDecoder;let A="";for(;;){const{done:P,value:C}=await u.read();if(P)break;A+=x.decode(C,{stream:!0});const v=A.split(`
|
|
1736
|
+
`);A=v.pop()??"";let g="";for(const y of v)if(y.startsWith("event: "))g=y.slice(7);else if(y.startsWith("data: ")&&g){try{const E=JSON.parse(y.slice(6));g==="auth"?r(z=>({phase:"pending",url:String(E.url??""),instructions:E.instructions?String(E.instructions):void 0,usesCallbackServer:!!E.usesCallbackServer,progress:z.phase==="pending"?z.progress:void 0,manualCodePrompt:z.phase==="pending"?z.manualCodePrompt:void 0})):g==="prompt"?r(z=>z.phase==="pending"?{...z,manualCodePrompt:{message:String(E.message??""),placeholder:E.placeholder?String(E.placeholder):void 0,allowEmpty:!!E.allowEmpty}}:z):g==="progress"?r(z=>z.phase==="pending"?{...z,progress:String(E.message??"")}:z):g==="done"?r({phase:"authenticated"}):g==="error"&&r({phase:"error",message:String(E.message??"Login failed")})}catch{}g=""}}}).catch(c=>{if(c?.name==="AbortError")return;const u=c instanceof Error?c.message:String(c);r({phase:"error",message:u})})},[e]),p=f(()=>{o.current?.abort(),o.current=null,fetch(`/api/ai/providers/${e}/logout`,{method:"POST",credentials:"same-origin"}).then(()=>r({phase:"idle"})).catch(()=>r({phase:"idle"}))},[e]),l=f((m,c)=>{c&&navigator.clipboard.writeText(c),window.open(m,"_blank","noopener,noreferrer")},[]),h=f(m=>{m.trim()&&fetch(`/api/ai/providers/${e}/login/code`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:m.trim()})}).catch(()=>{})},[e]);return t.phase==="checking"?a("div",{className:s.subscriptionAuth,children:a("div",{className:s.subscriptionAuthStatus,children:"Checking..."})}):t.phase==="authenticated"?b("div",{className:s.subscriptionAuthConnected,children:[a("div",{className:s.subscriptionAuthStatus,children:a("span",{className:s.subscriptionAuthStatusConnected,children:"Connected"})}),a(S,{onPress:p,variant:"danger",size:"sm",children:"Logout"})]}):t.phase==="pending"?b("div",{className:s.subscriptionAuthPending,children:[b("div",{className:s.subscriptionAuthStatus,children:[t.instructions&&b("div",{children:["Code: ",a("span",{className:s.subscriptionAuthCode,children:t.instructions})]}),t.progress&&a("div",{className:s.subscriptionAuthProgress,children:t.progress}),!t.progress&&!t.instructions&&a("div",{className:s.subscriptionAuthProgress,children:"Starting login..."})]}),b("div",{className:s.providerCardActions,children:[t.url&&a(S,{onPress:()=>l(t.url,t.instructions),variant:"primary",size:"sm",children:t.instructions?"Copy Code & Open":"Open in Browser"}),a(S,{onPress:p,variant:"secondary",size:"sm",children:"Cancel"})]}),t.manualCodePrompt&&b("div",{className:s.manualCodeInput,children:[a("div",{className:s.manualCodeHint,children:t.manualCodePrompt.message}),b("div",{className:s.manualCodeRow,children:[a("input",{className:s.manualCodeTextInput,type:"text",placeholder:t.manualCodePrompt.placeholder??"Paste code or URL",value:n,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&h(n)}}),a(S,{onPress:()=>h(n),variant:"primary",size:"sm",disabled:!t.manualCodePrompt.allowEmpty&&!n.trim(),children:"Submit"})]})]})]}):t.phase==="error"?b("div",{className:s.subscriptionAuth,children:[b("div",{className:s.subscriptionAuthStatus,children:["Error: ",t.message]}),a(S,{onPress:d,variant:"primary",size:"sm",children:"Retry"})]}):b("div",{className:s.subscriptionAuth,children:[a("div",{className:s.subscriptionAuthStatus,children:"Not connected"}),a(S,{onPress:d,variant:"primary",size:"sm",children:"Login"})]})}function S({children:e,disabled:t=!1,variant:r="primary",size:n="md",onPress:i}){const[o,d]=k(null);return w(()=>{if(!o)return;const p=()=>{i()};return o.addEventListener("click",p),()=>o.removeEventListener("click",p)},[o,i]),a("dt-button",{ref:p=>d(p),disabled:t,variant:r,size:n,children:e})}function ae({value:e,options:t,disabled:r=!1,onChange:n}){const[i,o]=k(null);return w(()=>{i&&(i.options=t)},[t,i]),w(()=>{i&&(i.value=e)},[i,e]),w(()=>{i&&(i.disabled=r)},[r,i]),w(()=>{if(!i)return;const d=p=>{n(p.detail.value)};return i.addEventListener("dt-change",d),()=>i.removeEventListener("dt-change",d)},[n,i]),a("div",{className:s.providerSelectWrap,children:a("dt-select",{ref:d=>o(d)})})}function j({id:e,label:t,value:r,sensitive:n=!1,onCommit:i}){const[o,d]=k(r);w(()=>{d(r)},[r]);const p=f(()=>{o!==r&&i(o)},[o,i,r]);return b("div",{className:s.providerField,children:[a("label",{className:s.providerFieldLabel,htmlFor:e,children:t}),a("input",{id:e,type:n?"password":"text",className:n?s.textInputSensitive:s.textInput,value:o,onChange:l=>d(l.target.value),onBlur:p,onKeyDown:l=>{l.key==="Enter"&&p()}})]})}function qt({config:e,onChange:t}){const r=G(()=>{const l=ue(e["voice.enabledProviders"]),h=typeof e["voice.defaultProvider"]=="string"&&e["voice.defaultProvider"]?String(e["voice.defaultProvider"]):M;return l.includes(h)||l.unshift(h),l},[e]),n=f(async l=>{const h=l.length>0?l:[M];await t("voice.enabledProviders",ze(h)),await t("voice.defaultProvider",h[0])},[t]),i=f(async()=>{const l=N.find(h=>!r.includes(h.id));l&&await n([...r,l.id])},[r,n]),o=f(async(l,h)=>{if(l===h||r.includes(h))return;const m=r.map(c=>c===l?h:c);await n(m)},[r,n]),d=f(async l=>{if(r.length===1)return;const h=r.filter(m=>m!==l);await n(h);for(const m of Ee(l))await t(m,"")},[r,t,n]),p=f(async l=>{if(r[0]===l)return;const h=[l,...r.filter(m=>m!==l)];await n(h)},[r,n]);return b("div",{className:s.providerGroup,children:[b("div",{className:s.providerGroupHeader,children:[b("div",{children:[a("div",{className:s.rowLabel,children:"Providers"}),a("div",{className:s.rowDescription,children:"Add STT providers, keep your default at the top, and remove unused items."})]}),a("div",{className:s.providerActionButtonWrap,children:a(q,{onPress:i,disabled:r.length>=N.length,variant:"secondary",children:"Add provider"})})]}),a("div",{className:s.providerList,children:r.map((l,h)=>{const m=pe(l);if(!m)return null;const c=N.filter(u=>u.id===l||!r.includes(u.id));return a("div",{className:s.providerCard,children:a("dt-card",{variant:"outlined",children:b("div",{className:s.providerCardBody,children:[b("div",{className:s.providerCardHeader,children:[b("div",{className:s.providerCardTitleRow,children:[a("div",{className:s.providerCardTitle,children:m.label}),h===0&&a("span",{className:s.providerDefaultBadge,children:"Default"})]}),b("div",{className:s.providerCardActions,children:[a("div",{className:s.providerButtonWrap,children:a(q,{onPress:()=>p(l),disabled:h===0,variant:"secondary",size:"sm",children:"Set as default"})}),a("div",{className:s.providerButtonWrap,children:a(q,{onPress:()=>d(l),disabled:r.length===1,variant:"danger",size:"sm",children:"Delete"})})]})]}),b("div",{className:s.providerFieldGrid,children:[a(Gt,{label:"Provider",value:l,options:c.map(u=>({value:u.id,label:u.label})),onChange:u=>o(l,u)}),m.supportsApiKey&&a(R,{id:`voice-provider-key-${l}`,label:"API Key",value:String(e[`voice.providers.${l}.apiKey`]??""),sensitive:!0,onCommit:u=>t(`voice.providers.${l}.apiKey`,u)}),m.supportsModel&&a(R,{id:`voice-provider-model-${l}`,label:"Model",value:String(e[`voice.providers.${l}.model`]??""),onCommit:u=>t(`voice.providers.${l}.model`,u)}),m.supportsBaseUrl&&a(R,{id:`voice-provider-base-url-${l}`,label:"Base URL",value:String(e[`voice.providers.${l}.baseUrl`]??""),onCommit:u=>t(`voice.providers.${l}.baseUrl`,u)}),m.supportsAzureDeployment&&a(R,{id:`voice-provider-deployment-${l}`,label:"Azure Deployment",value:String(e[`voice.providers.${l}.azureDeployment`]??""),onCommit:u=>t(`voice.providers.${l}.azureDeployment`,u)}),m.supportsAzureApiVersion&&a(R,{id:`voice-provider-api-version-${l}`,label:"Azure API Version",value:String(e[`voice.providers.${l}.azureApiVersion`]??""),onCommit:u=>t(`voice.providers.${l}.azureApiVersion`,u)})]})]})})},l)})})]})}function q({children:e,disabled:t=!1,variant:r="primary",size:n="md",onPress:i}){const[o,d]=k(null);return w(()=>{if(!o)return;const p=()=>{i()};return o.addEventListener("click",p),()=>o.removeEventListener("click",p)},[o,i]),a("dt-button",{ref:p=>d(p),disabled:t,variant:r,size:n,children:e})}function Gt({label:e,value:t,options:r,onChange:n}){const[i,o]=k(null);return w(()=>{i&&(i.options=r)},[r,i]),w(()=>{i&&(i.value=t)},[i,t]),w(()=>{if(!i)return;const d=p=>{n(p.detail.value)};return i.addEventListener("dt-change",d),()=>i.removeEventListener("dt-change",d)},[n,i]),b("div",{className:s.providerField,children:[a("label",{className:s.providerFieldLabel,children:e}),a("div",{className:s.providerSelectWrap,children:a("dt-select",{ref:d=>o(d)})})]})}function R({id:e,label:t,value:r,sensitive:n=!1,onCommit:i}){const[o,d]=k(r);w(()=>{d(r)},[r]);const p=f(()=>{o!==r&&i(o)},[o,i,r]);return b("div",{className:s.providerField,children:[a("label",{className:s.providerFieldLabel,htmlFor:e,children:t}),a("input",{id:e,type:n?"password":"text",className:n?s.textInputSensitive:s.textInput,value:o,onChange:l=>d(l.target.value),onBlur:p,onKeyDown:l=>{l.key==="Enter"&&p()}})]})}function Xt({title:e,children:t}){return b("section",{className:s.section,children:[a("h3",{className:s.sectionTitle,children:e}),t]})}function Yt({schema:e,value:t,onChange:r}){return b("div",{className:s.row,children:[b("div",{className:s.rowInfo,children:[b("div",{className:s.rowLabel,children:[e.label,e.requiresRestart&&a("span",{className:s.rowRestartBadge,children:"restart"})]}),a("div",{className:s.rowDescription,children:e.description})]}),a("div",{className:s.rowControl,children:a(Zt,{schema:e,value:t,onChange:r})})]})}function Zt({schema:e,value:t,onChange:r}){return e.key==="general.accentColor"&&e.type==="string"?a(Qt,{schema:e,value:t,onChange:r}):e.type==="boolean"?a(er,{schema:e,value:t,onChange:r}):e.type==="string"&&e.options?a(tr,{schema:e,value:t,onChange:r}):e.type==="string"?a(nr,{schema:e,value:t,onChange:r}):e.type==="number"?a(ir,{schema:e,value:t,onChange:r}):null}function Jt(e){return/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e)}function Qt({schema:e,value:t,onChange:r}){const[n,i]=k(t);w(()=>{i(t)},[t]);const o=f(u=>{const x=(u??n).trim();x!==t&&r(e.key,x)},[n,r,e.key,t]),d=f(u=>{i(u.currentTarget.value)},[]),p=f(u=>{const x=u.target.value;i(x),o(x)},[o]),l=f(u=>{i(u.target.value)},[]),h=f(u=>{u.key==="Enter"&&o()},[o]),m=f(()=>{o()},[o]),c=Jt(n)?n:"#7c6ff7";return b("div",{className:s.colorControl,children:[a("input",{type:"color",className:s.colorInput,value:c,onInput:d,onChange:p,"aria-label":`${e.label} picker`}),a("input",{type:"text",className:s.textInput,value:n,onChange:l,onBlur:m,onKeyDown:h,placeholder:"#7c6ff7"})]})}function er({schema:e,value:t,onChange:r}){const n=f(()=>{r(e.key,!t)},[e.key,t,r]);return b("label",{className:s.toggle,children:[a("input",{type:"checkbox",className:s.toggleInput,checked:t,onChange:n}),a("span",{className:s.toggleTrack}),a("span",{className:s.toggleKnob})]})}function tr({schema:e,value:t,onChange:r}){const n=f(i=>{r(e.key,i)},[e.key,r]);return a(rr,{value:t,options:(e.options??[]).map(i=>({value:i,label:i})),onChange:n})}function rr({value:e,options:t,disabled:r=!1,onChange:n}){const[i,o]=k(null);return w(()=>{i&&(i.options=t)},[t,i]),w(()=>{i&&(i.value=e,i.disabled=r)},[r,i,e]),w(()=>{if(!i)return;const d=p=>{n(p.detail.value)};return i.addEventListener("dt-change",d),()=>i.removeEventListener("dt-change",d)},[n,i]),a("div",{className:s.selectWrap,children:a("dt-select",{ref:d=>o(d)})})}function nr({schema:e,value:t,onChange:r}){const[n,i]=k(t);w(()=>{i(t)},[t]);const o=f(()=>{n!==t&&r(e.key,n)},[e.key,n,t,r]),d=f(p=>{p.key==="Enter"&&r(e.key,n)},[e.key,n,r]);return a("input",{type:e.sensitive?"password":"text",className:e.sensitive?s.textInputSensitive:s.textInput,value:n,onChange:p=>i(p.target.value),onBlur:o,onKeyDown:d,placeholder:e.sensitive?"Enter API key...":void 0})}function ir({schema:e,value:t,onChange:r}){const[n,i]=k(String(t));w(()=>{i(String(t))},[t]);const o=f(()=>{let p=Number(n);if(Number.isNaN(p)){i(String(t));return}e.min!==void 0&&(p=Math.max(e.min,p)),e.max!==void 0&&(p=Math.min(e.max,p)),i(String(p)),p!==t&&r(e.key,p)},[e.key,e.min,e.max,n,t,r]),d=f(p=>{p.key==="Enter"&&o()},[o]);return a("input",{type:"number",className:s.numberInput,value:n,min:e.min,max:e.max,onChange:p=>i(p.target.value),onBlur:o,onKeyDown:d})}function or({children:e,onConfigChanged:t}){const r=$("preferences.get"),n=$("preferences.set"),i=$("preferences.reset"),o=$("preferences.resetAll"),d=f(async m=>{const c=m?.key;if(!c)throw new Error("Missing required parameter: key");return await r({key:c})},[r]),p=f(async m=>{const c=m?.key;if(!c)throw new Error("Missing required parameter: key");let u=m?.value;if(u===void 0)throw new Error("Missing required parameter: value");const x=Le(c);return x&&(x.type==="number"&&typeof u=="string"?u=Number(u):x.type==="boolean"&&typeof u=="string"&&(u=u==="true")),await n({key:c,value:u}),t(),{success:!0}},[n,t]),l=f(async m=>{const c=m?.key;if(!c)throw new Error("Missing required parameter: key");return await i({key:c}),t(),{success:!0}},[i,t]),h=f(async()=>(await o(),t(),{success:!0}),[o,t]);return b(xe,{children:[a(B,{name:"Get Setting",description:"Read the current value of a setting",params:{key:{type:"string",description:"Setting key (e.g. general.theme)",required:!0}},handler:d}),a(B,{name:"Set Setting",description:"Update a setting value",params:{key:{type:"string",description:"Setting key (e.g. general.theme)",required:!0},value:{type:"string",description:"New value for the setting",required:!0}},handler:p}),a(B,{name:"Reset Setting",description:"Reset a setting to its default value",params:{key:{type:"string",description:"Setting key to reset",required:!0}},handler:l}),a(B,{name:"Reset All",description:"Reset all settings to their default values",handler:h}),e]})}var ar=720;function sr(){const[e,t]=k(Ne()),[r,n]=k(Y[0]),[i,o]=k(null),[d,p]=k(!1),l=X(null),h=X(null),m=$("preferences.getAll"),c=$("preferences.set"),u=f(async()=>{try{const v=await m();t(v)}catch(v){console.error("Failed to load preferences:",v)}},[m]);w(()=>{u()},[u]),w(()=>{if(!h.current)return;const v=y=>{p(y<=ar)};v(h.current.clientWidth);const g=new ResizeObserver(y=>{const E=y[0];E&&v(E.contentRect.width)});return g.observe(h.current),()=>g.disconnect()},[]),Q("preferences:changed",v=>{t(g=>({...g,[v.key]:v.value})),v.requiresRestart&&x(ee({scope:"preference",key:"notifications.restartRequired",defaultText:"This change requires a restart to take effect."}))}),Q("preferences:resetAll",()=>{u(),x(ee({scope:"preference",key:"notifications.resetAll",defaultText:"All settings have been reset to defaults."}))});const x=f(v=>{o(v),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>o(null),4e3)},[]),A=f(async(v,g)=>{t(y=>({...y,[v]:g}));try{await c({key:v,value:g})}catch(y){console.error(`Failed to update ${v}:`,y),u()}},[c,u]),P=Y.filter(v=>v===r),C=f(v=>{const g=He(v);return v!=="AI"&&v!=="Voice"?g:g.filter(y=>v==="AI"?!y.key.startsWith("ai.providers.")&&y.key!=="ai.defaultProvider"&&y.key!=="ai.enabledProviders":!y.key.startsWith("voice.providers.")&&y.key!=="voice.defaultProvider"&&y.key!=="voice.enabledProviders")},[]);return a(or,{onConfigChanged:u,children:b("div",{ref:h,className:`${s.root}${d?` ${s.rootCompact}`:""}`,children:[a(Kt,{activeCategory:r,onSelect:n,compact:d}),a("div",{className:s.settingsPanel,children:P.map(v=>{const g=C(v);return b(Xt,{title:v,children:[v==="AI"&&a(Ut,{config:e,onChange:A}),v==="Voice"&&a(qt,{config:e,onChange:A}),g.map(y=>a(Yt,{schema:y,value:e[y.key]??y.default,onChange:A},y.key))]},v)})}),i&&a("div",{className:s.notification,children:i})]})})}function lr(e){const t=ye(e.root);return t.render(a(fe,{windowId:e.windowId,children:a(_e,{miniAppId:e.miniAppId,children:a(sr,{})})})),{deactivate(){t.unmount()}}}(()=>{if(typeof document>"u")return;const e="desktalk-style-desktalk-miniapp-preference-fziypz";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent=`/* src/styles/PreferenceApp.module.css */
|
|
1737
1737
|
.PreferenceApp_root {
|
|
1738
1738
|
display: flex;
|
|
1739
1739
|
height: 100%;
|
|
@@ -1963,7 +1963,8 @@ ${r}`}var Ht=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1963
1963
|
}
|
|
1964
1964
|
.PreferenceApp_subscriptionAuth {
|
|
1965
1965
|
display: flex;
|
|
1966
|
-
|
|
1966
|
+
flex-direction: column;
|
|
1967
|
+
align-items: stretch;
|
|
1967
1968
|
gap: 12px;
|
|
1968
1969
|
padding: 8px 12px;
|
|
1969
1970
|
border: 1px solid var(--dt-border);
|
|
@@ -2004,6 +2005,47 @@ ${r}`}var Ht=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
2004
2005
|
font-size: 12px;
|
|
2005
2006
|
font-style: italic;
|
|
2006
2007
|
}
|
|
2008
|
+
.PreferenceApp_manualCodeInput {
|
|
2009
|
+
display: flex;
|
|
2010
|
+
flex-direction: column;
|
|
2011
|
+
gap: 8px;
|
|
2012
|
+
margin-top: 8px;
|
|
2013
|
+
padding-top: 8px;
|
|
2014
|
+
border-top: 1px dashed var(--dt-border);
|
|
2015
|
+
width: 100%;
|
|
2016
|
+
}
|
|
2017
|
+
.PreferenceApp_manualCodeHint {
|
|
2018
|
+
font-size: 12px;
|
|
2019
|
+
color: var(--dt-text-muted);
|
|
2020
|
+
}
|
|
2021
|
+
.PreferenceApp_manualCodeRow {
|
|
2022
|
+
display: flex;
|
|
2023
|
+
gap: 8px;
|
|
2024
|
+
align-items: center;
|
|
2025
|
+
}
|
|
2026
|
+
.PreferenceApp_manualCodeRow .PreferenceApp_manualCodeTextInput {
|
|
2027
|
+
flex: 1;
|
|
2028
|
+
min-width: 0;
|
|
2029
|
+
padding: 6px 10px;
|
|
2030
|
+
border: 1px solid var(--dt-border);
|
|
2031
|
+
border-radius: 6px;
|
|
2032
|
+
background: var(--dt-surface);
|
|
2033
|
+
color: var(--dt-text);
|
|
2034
|
+
font-family: var(--font-ui, "Work Sans", system-ui, -apple-system, sans-serif);
|
|
2035
|
+
font-size: 13px;
|
|
2036
|
+
outline: none;
|
|
2037
|
+
transition:
|
|
2038
|
+
border-color 0.15s,
|
|
2039
|
+
box-shadow 0.15s,
|
|
2040
|
+
background 0.15s;
|
|
2041
|
+
}
|
|
2042
|
+
.PreferenceApp_manualCodeRow .PreferenceApp_manualCodeTextInput:focus {
|
|
2043
|
+
border-color: var(--dt-accent);
|
|
2044
|
+
box-shadow: 0 0 0 3px var(--dt-accent-ghost);
|
|
2045
|
+
}
|
|
2046
|
+
.PreferenceApp_manualCodeRow .PreferenceApp_manualCodeTextInput::placeholder {
|
|
2047
|
+
color: var(--dt-text-muted);
|
|
2048
|
+
}
|
|
2007
2049
|
.PreferenceApp_selectWrap {
|
|
2008
2050
|
min-width: 120px;
|
|
2009
2051
|
}
|
|
@@ -2218,5 +2260,5 @@ ${r}`}var Ht=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
2218
2260
|
}
|
|
2219
2261
|
}
|
|
2220
2262
|
/*# sourceMappingURL=frontend.css.map */
|
|
2221
|
-
`,document.head.appendChild(t)})();export{
|
|
2222
|
-
//# sourceMappingURL=frontend-
|
|
2263
|
+
`,document.head.appendChild(t)})();export{lr as activate};
|
|
2264
|
+
//# sourceMappingURL=frontend-f1PcGFgm.js.map
|