@co0ontty/wand 4.26.3 → 4.26.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.
@@ -3721,11 +3721,11 @@ Error generating stack: `+l.message+`
3721
3721
  `);s.terminalClickHandler=function(b){zf()||yr(b)},e.addEventListener("click",s.terminalClickHandler),Fa(),tM(),rM(),mM(),vM(),In("mount",{forceReplay:!0}),document.documentElement.classList.contains("is-wand-embed-terminal")&&[120,350,700].forEach(function(b){setTimeout(function(){s.terminal&&In("embed-settle")},b)})}).catch(function(g){s.terminalInitializing=!1,console.error("[wand] wterm init failed:",g)})}}function LM(e,t){if(!(!s.selectedId||!e)){var a=s.selectedId+":"+e;if(s.toolContentCache[a]){t(null,s.toolContentCache[a]);return}fetch("/api/sessions/"+encodeURIComponent(s.selectedId)+"/tool-content/"+encodeURIComponent(e),{credentials:"same-origin"}).then(function(i){return i.json()}).then(function(i){i.error?t(i.error,null):(s.toolContentCache[a]=i,t(null,i))}).catch(function(){t("\u52A0\u8F7D\u5931\u8D25",null)})}}function Pu(e){return!!(s.config&&s.config.cardDefaults&&s.config.cardDefaults[e])}function V0(e,t,a,i){if(!(!e||e.dataset.truncated!=="true"||e.dataset.loaded==="true")){var o=e.dataset.toolUseId;o&&(t&&(t.innerHTML='<div class="tool-content-loading">\u52A0\u8F7D\u4E2D\u2026</div>'),e.dataset.loaded="loading",LM(o,function(c,d){if(c){t&&(t.innerHTML=i||'<div class="tool-content-error">\u52A0\u8F7D\u5931\u8D25\uFF0C\u70B9\u51FB\u91CD\u8BD5</div>'),e.dataset.loaded="";return}e.dataset.truncated="false",e.dataset.loaded="true";var f=typeof d.content=="string"?d.content:JSON.stringify(d.content);a(f,d)}))}}window.__tcToggle=function(e,t){var a=t.closest(".tool-use-card")||t.closest(".inline-diff");if(a){var i=a.classList.contains("collapsed");a.classList.toggle("collapsed");var o=i;t.setAttribute("aria-expanded",o?"true":"false");var c=a.querySelector(".tool-use-body, .diff-body");c&&c.setAttribute("aria-hidden",o?"false":"true");var d=a.dataset.expandKind||"tool-card";if(wo(a,d),i){var f=a.querySelector(".tool-use-result");V0(a,f,function(v){f&&(f.innerHTML='<pre class="tool-use-result-content">'+q(v)+"</pre>")},`<div class="tool-content-error" onclick="__tcToggle(null, this.closest('.tool-use-card,.inline-diff').querySelector('.tool-use-header,.diff-header'))">\u52A0\u8F7D\u5931\u8D25\uFF0C\u70B9\u51FB\u91CD\u8BD5</div>`)}}e&&(e.preventDefault(),e.stopPropagation())},window.__thinkingToggle=function(e){var t=e.classList.contains("collapsed");if(t){e.classList.remove("collapsed"),e.classList.add("expanded"),e.querySelector(".thinking-inline-preview").textContent=e.dataset.thinking||"";var a=e.querySelector(".thinking-inline-action");a&&(a.textContent="\u6536\u8D77")}else{e.classList.remove("expanded"),e.classList.add("collapsed");var i=(e.dataset.thinking||"").slice(0,57)+((e.dataset.thinking||"").length>60?"\u2026":"");e.querySelector(".thinking-inline-preview").textContent=i;var a=e.querySelector(".thinking-inline-action");a&&(a.textContent="\u5C55\u5F00")}wo(e,"thinking")},window.__subagentReplyToggle=function(e,t){e&&(e.preventDefault(),e.stopPropagation());var a=t&&t.closest?t.closest(".subagent-reply"):null;if(a){var i=a.getAttribute("data-expanded")==="true";h5(a,"subagent-reply",!i),wo(a,"subagent-reply")}},window.__subagentPanelToggle=function(e,t){e&&(e.preventDefault(),e.stopPropagation());var a=t&&t.closest?t.closest(".subagent-panel"):null;a&&a.setAttribute("data-expanded","true")};function zM(e){if(e)for(var t=e.querySelectorAll('.subagent-panel[data-follow-tail="true"]'),a=0;a<t.length;a++){var i=t[a].querySelector(".subagent-panel-body");i&&(i.scrollTop=i.scrollHeight)}}window.__openFilePreview=function(e){e&&F0(e)},window.__inlineToolToggle=function(e){var t=e.classList.toggle("inline-tool-open"),a=e.querySelector(".inline-tool-expanded");a&&(a.style.display=t?"block":"none");var i=e.querySelector(".inline-tool-status");i&&(e.dataset.status==="error"?i.textContent="\u2717":e.dataset.status==="done"&&(i.textContent="\u2713")),t&&V0(e,a,function(o){e.dataset.result=o,a&&(a.innerHTML='<div class="inline-tool-result">'+GE(o,"")+"</div>")}),wo(e,"inline-tool")},window.__terminalExpand=function(e){var t=e.closest(".inline-terminal");if(t){var a=t.querySelector(".term-body");if(a){var i=a.style.display==="none";a.style.display=i?"block":"none",t.dataset.expanded=i?"true":"false",e.setAttribute("aria-expanded",i?"true":"false"),a.setAttribute("aria-hidden",i?"false":"true");var o=e.querySelector(".term-toggle-icon");if(o&&(o.textContent=i?"\u25BC":"\u25B6"),wo(t,"terminal"),i){var c=a.querySelector(".term-output");V0(t,c,function(d){if(c){for(var f=d.split(`
3722
3722
  `),v="",g=0;g<f.length;g++)!f[g]&&g===f.length-1||(v+='<div class="term-line">'+q(f[g])+"</div>");c.innerHTML=v}})}}}},window.__askSelect=function(e,t,a,i){var o=s.askUserSelections[e];if(o||(o={submitted:!1},s.askUserSelections[e]=o),!o.submitted){var c=o[t]||[];if(i){var d=c.indexOf(a);d===-1?c.push(a):c.splice(d,1)}else c=c[0]===a?[]:[a];o[t]=c,window.__askRender(e)}},window.__askRender=function(e){var t=document.querySelector('[data-tool-use-id="'+e+'"]');if(t){var a=s.askUserSelections[e]||{};t.querySelectorAll(".ask-user-option").forEach(function(d){var f=parseInt(d.dataset.questionIndex,10),v=parseInt(d.dataset.optionIndex,10),g=(a[f]||[]).indexOf(v)!==-1;d.classList.toggle("selected",g)});var i=t.querySelector(".ask-user-submit");if(i){var o=t.querySelectorAll(".ask-user-question-group"),c=!0;o.forEach(function(d,f){(!a[f]||a[f].length===0)&&(c=!1)}),i.disabled=!c||!!a.submitted,a.submitted&&(i.textContent="\u5DF2\u63D0\u4EA4...",i.classList.add("ask-user-submitted"))}}},window.__askSubmit=function(e){var t=s.askUserSelections[e];if(!(!t||t.submitted||!s.selectedId)){var a=document.querySelector('[data-tool-use-id="'+e+'"]');if(a){var i=a.querySelectorAll(".ask-user-question-group"),o=[],c=!0;if(i.forEach(function(f,v){var g=t[v]||[];if(g.length===0){c=!1;return}var h=[];g.forEach(function(b){var w=f.querySelector('[data-option-index="'+b+'"]');w&&h.push(w.dataset.optionLabel)}),o.push(h.join(", "))}),!!c){t.submitted=!0,window.__askRender(e);var d=o.join(`
3723
3723
  `);fetch("/api/sessions/"+s.selectedId+"/input",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({input:d+`
3724
- `,view:s.currentView})}).catch(function(f){console.error("[wand] Error sending answer:",f),t.submitted=!1,window.__askRender(e)})}}}};var Uu=null;function HM(){if(!s.__globalListenersBound){s.__globalListenersBound=!0,document.addEventListener("click",function(){if(!At()){var t=document.getElementById("sidebar-overflow-menu");t&&t.classList.remove("open")}}),window.addEventListener("resize",function(){if(!At()){var t=document.getElementById("sidebar-overflow-menu");t&&t.classList.remove("open")}});var e=function(){if(!At()){s.topbarMoreOpen=!1;var t=document.getElementById("topbar-more-menu"),a=document.getElementById("topbar-more-button");t&&t.classList.add("hidden"),a&&(a.classList.remove("active"),a.setAttribute("aria-expanded","false"))}};document.addEventListener("click",function(t){if(!At()&&s.topbarMoreOpen){var a=document.getElementById("topbar-more-menu"),i=a&&a.parentElement;i&&!i.contains(t.target)&&e()}}),document.addEventListener("keydown",function(t){At()||t.key==="Escape"&&s.topbarMoreOpen&&e()}),document.addEventListener("click",function(t){if(s.plusPopoverOpen){var a=document.getElementById("composer-plus-popover"),i=document.getElementById("attach-btn");a&&a.contains(t.target)||i&&i.contains(t.target)||tp()}}),document.addEventListener("keydown",function(t){t.key==="Escape"&&s.plusPopoverOpen&&(t.preventDefault(),tp(!0)),t.key==="Escape"&&Mh()}),document.addEventListener("click",function(t){var a=t.target;if(!(!a||typeof a.closest!="function")){var i=a.closest("[data-claude-skills-trigger]");if(i){t.preventDefault(),nR(i);return}var o=a.closest("[data-claude-skill-name]");if(o){t.preventDefault();var c=s.sessions.find(function(f){return f.id===s.selectedId});aR(c,o.getAttribute("data-claude-skill-name"));return}var d=document.getElementById("composer-skills-popover");d&&!d.contains(a)&&Mh()}}),document.addEventListener("click",function(t){var a=t.target;if(!(!a||typeof a.closest!="function")){var i=a.closest("[data-models-refresh]");if(i){t.preventDefault(),i.disabled||fR();return}var o=a.closest("#auto-approve-toggle");o&&(t.preventDefault(),Qj())}}),document.addEventListener("change",function(t){var a=t.target;if(!(!a||a.nodeType!==1)&&!(typeof a.matches!="function"||!a.matches("[data-mode-control]"))){var i=a.getAttribute("data-mode-control"),o=a.value;i==="mode"?mR(o):i==="model"?pR(o):i==="thinking"&&lR(o),a.closest&&a.closest("#composer-plus-popover")&&tp(!0)}})}}function qM(){HM(),Uu&&(Uu.disconnect(),Uu=null);var e=document.getElementById("login-button");if(e){e.addEventListener("click",Fh);var t=document.getElementById("login-form");t&&t.addEventListener("submit",function(me){me.preventDefault(),Fh()});var a=document.getElementById("login-switch-server-button");a&&a.addEventListener("click",Dh);var i=document.getElementById("password"),o=document.getElementById("toggle-password-button");o&&i&&o.addEventListener("click",function(){var me=i.type==="text";i.type=me?"password":"text",o.textContent=me?"\u663E\u793A":"\u9690\u85CF",o.setAttribute("aria-label",me?"\u663E\u793A\u5BC6\u7801":"\u9690\u85CF\u5BC6\u7801"),o.setAttribute("aria-pressed",me?"false":"true"),i.focus()}),i&&(i.addEventListener("keydown",function(me){me.key==="Enter"&&Fh()}),i.addEventListener("input",function(){i.dataset.error="false",i.setAttribute("aria-invalid","false");var me=document.getElementById("login-error");me&&_x(me)}),i.focus());return}var c=At();if(!c){var d=document.getElementById("welcome-input");d&&(d.addEventListener("keydown",function(me){me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),Zx())}),d.focus());var f=document.getElementById("welcome-send-btn");f&&f.addEventListener("click",function(){Zx()});var v=document.getElementById("welcome-tool-claude");v&&v.addEventListener("click",function(){rp()});var g=document.getElementById("welcome-tool-codex");g&&g.addEventListener("click",function(){s.sessionTool="codex",s.preferredCommand="codex",s.modeValue="full-access",rp()});var h=document.getElementById("welcome-tool-opencode");h&&h.addEventListener("click",function(){s.sessionTool="opencode",s.preferredCommand="opencode",s.modeValue="managed",rp()});var b=document.getElementById("welcome-tool-structured");b&&b.addEventListener("click",function(){g2().then(function(){yr(!0)}).catch(function(me){be(me&&me.message||"\u65E0\u6CD5\u542F\u52A8\u7ED3\u6784\u5316\u4F1A\u8BDD\u3002","error")})});var w=document.getElementById("sessions-list");w&&(w.addEventListener("click",wM),w.addEventListener("keydown",yM),w.addEventListener("mouseover",AR),w.addEventListener("mouseout",SR),T_(w)),window.addEventListener("scroll",Wr,!0),window.addEventListener("resize",Wr);var C=document.getElementById("sessions-toggle-button");C&&C.addEventListener("click",w2);var y=document.getElementById("sessions-drawer-backdrop");y&&y.addEventListener("click",cs);var x=document.getElementById("close-drawer-button");x&&x.addEventListener("click",cs);var E=document.getElementById("sidebar-collapse-btn");E&&E.addEventListener("click",Lh);var D=document.getElementById("sidebar-pin-btn");D&&D.addEventListener("click",x2);var A=document.getElementById("sidebar-more-btn"),B=document.getElementById("sidebar-overflow-menu");A&&B&&A.addEventListener("click",function(me){me.stopPropagation();var Te=!B.classList.contains("open");B.classList.toggle("open",Te),Te&&kR(B)});var j=document.getElementById("sidebar-home-btn");j&&j.addEventListener("click",function(){s.selectedId=null,Qt(),Da(),ar(),Hi()});var k=document.getElementById("sidebar-refresh-btn");k&&k.addEventListener("click",function(){window.location.reload()});var O=document.getElementById("logout-button");O&&O.addEventListener("click",Ah);var P=document.getElementById("switch-server-button");P&&P.addEventListener("click",Dh);var U=document.getElementById("back-to-native-button");U&&U.addEventListener("click",$E);var $=document.getElementById("settings-button");$&&$.addEventListener("click",C2);var ne=document.getElementById("topbar-new-session-button");ne&&ne.addEventListener("click",np);var Z=document.getElementById("drawer-new-session-button");Z&&Z.addEventListener("click",np)}var he=document.getElementById("approve-permission-btn");he&&he.addEventListener("click",Kj);var ve=document.getElementById("deny-permission-btn");ve&&ve.addEventListener("click",Wj);var H=document.getElementById("send-input-button");H&&H.addEventListener("click",function(){ar(),MO()});var te=document.getElementById("stop-button");te&&te.addEventListener("click",oh);var L=document.getElementById("input-box");if(L){wE(L),L.addEventListener("keydown",MR),L.addEventListener("paste",qR),L.addEventListener("input",function(){s.terminalComposing||S2(L)||(dh(L),fs(L.value,!0),pc(L))}),L.addEventListener("compositionstart",function(){s.terminalInteractive&&(s.terminalComposing=!0)}),L.addEventListener("compositionend",function(){s.terminalComposing&&(s.terminalComposing=!1,s.terminalInteractive&&S2(L))}),L.addEventListener("focus",function(){ar(),I_({target:L})}),L.addEventListener("blur",L_),dh(L);var Y=L.closest(".composer-input-wrap");if(Y&&typeof ResizeObserver<"u"){var _=-1;Uu=new ResizeObserver(function(me){if(!L.isConnected){Uu?.disconnect(),Uu=null;return}var Te=me[0]?me[0].contentRect.width:Y.getBoundingClientRect().width;Te<=0||Math.abs(Te-_)<.5||(_=Te,dh(L))}),Uu.observe(Y)}}var I=document.getElementById("attach-btn"),ue=document.getElementById("file-upload-input"),fe=document.getElementById("composer-plus-popover"),T=document.getElementById("plus-attach-item");I&&fe&&(I.addEventListener("click",function(me){me.stopPropagation(),ER(me.detail===0)}),fe.addEventListener("keydown",function(me){if(!(me.target instanceof HTMLSelectElement)&&["ArrowDown","ArrowUp","Home","End"].includes(me.key)){var Te=Array.from(fe.querySelectorAll('button:not([disabled]):not(.hidden), select:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(function(re){return re.getClientRects().length>0});if(Te.length){me.preventDefault();var jt=Te.indexOf(document.activeElement),Rt=me.key==="Home"?0:me.key==="End"?Te.length-1:me.key==="ArrowUp"?jt<=0?Te.length-1:jt-1:(jt+1)%Te.length;Te[Rt]?.focus()}}})),T&&ue&&T.addEventListener("click",function(me){tp(me.detail===0),ue.click()}),ue&&ue.addEventListener("change",function(){var me=ue.files;if(me)for(var Te=0;Te<me.length;Te++)qh(me[Te]);ue.value=""});var R=document.getElementById("voice-record-btn");R&&(R.addEventListener("pointerdown",FO),R.addEventListener("pointermove",CO),R.addEventListener("pointerup",Vx),R.addEventListener("pointercancel",DO),R.addEventListener("contextmenu",function(me){me.preventDefault()}));var ae=document.getElementById("prompt-optimize-btn");ae&&(ae.addEventListener("pointerdown",function(me){me.preventDefault()}),ae.addEventListener("click",function(){PR()}));var Q=document.querySelector(".input-composer");Q&&(Q.addEventListener("dragover",function(me){me.preventDefault(),me.stopPropagation(),Q.classList.add("drag-over")}),Q.addEventListener("dragleave",function(me){me.preventDefault(),me.stopPropagation(),Q.classList.remove("drag-over")}),Q.addEventListener("drop",function(me){me.preventDefault(),me.stopPropagation(),Q.classList.remove("drag-over");var Te=me.dataTransfer&&me.dataTransfer.files;if(Te)for(var jt=0;jt<Te.length;jt++)qh(Te[jt])}));var de=["terminal-interactive-toggle-top"];if(de.forEach(function(me){var Te=document.getElementById(me);Te&&Te.addEventListener("click",b_)}),!c){var ee=document.getElementById("file-panel-toggle-btn");ee&&ee.addEventListener("click",jl);var pe=document.getElementById("file-side-panel-close");pe&&pe.addEventListener("click",y0);var xe=document.getElementById("file-panel-backdrop");xe&&xe.addEventListener("click",y0);var Ee=document.getElementById("topbar-file-button");Ee&&Ee.addEventListener("click",jl);var De=document.getElementById("topbar-cwd");De&&(De.addEventListener("click",function(){s.filePanelOpen||jl()}),De.addEventListener("keydown",function(me){(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),s.filePanelOpen||jl())}));var Ne=document.getElementById("topbar-more-button"),at=document.getElementById("topbar-more-menu");Ne&&at&&(Ne.addEventListener("click",function(me){me.stopPropagation(),s.topbarMoreOpen=!s.topbarMoreOpen,at.classList.toggle("hidden",!s.topbarMoreOpen),Ne.classList.toggle("active",s.topbarMoreOpen),Ne.setAttribute("aria-expanded",s.topbarMoreOpen?"true":"false")}),at.addEventListener("click",function(me){var Te=me.target&&me.target.closest?me.target.closest(".topbar-more-item"):null;if(Te){var jt=Te.getAttribute("data-action");switch(s.topbarMoreOpen=!1,at.classList.add("hidden"),Ne.classList.remove("active"),Ne.setAttribute("aria-expanded","false"),jt){case"copy-claude-session-id":var Rt=Ui()&&Ui().provider;es("claudeSessionId",Rt==="codex"?"Codex thread ID \u5DF2\u590D\u5236":Rt==="opencode"?"OpenCode session ID \u5DF2\u590D\u5236":"Claude \u4F1A\u8BDD ID \u5DF2\u590D\u5236");break;case"copy-cwd":es("cwd","\u5DE5\u4F5C\u76EE\u5F55\u5DF2\u590D\u5236");break;case"copy-session-id":es("id","\u4F1A\u8BDD ID \u5DF2\u590D\u5236");break;case"worktree-merge":s.selectedId&&zh(s.selectedId);break;case"worktree-cleanup":s.selectedId&&Hh(s.selectedId);break;case"delete-session":s.selectedId&&(function(re){zi("\u786E\u5B9A\u8981\u5220\u9664\u5F53\u524D\u4F1A\u8BDD\u5417\uFF1F\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500\u3002",{title:"\u5220\u9664\u5F53\u524D\u4F1A\u8BDD"}).then(function(Cr){Cr&&qf(re)})})(s.selectedId);break}}}))}var ct=document.getElementById("terminal-scale-down-top"),je=document.getElementById("terminal-scale-up-top");ct&&ct.addEventListener("click",function(){N6(-.25)}),je&&je.addEventListener("click",function(){N6(.25)});var $e=document.getElementById("page-refresh-btn");$e&&$e.addEventListener("click",function(me){if(me&&me.shiftKey){location.reload();return}qu(),Da({preserveStickState:!0}),mh(!0)});var dt=document.getElementById("terminal-jump-bottom");dt&&dt.addEventListener("click",function(){Ca("force")});var mn=document.getElementById("chat-unread-bubble");if(mn&&mn.addEventListener("click",function(){$7(!0)}),!c){var vt=document.getElementById("file-explorer-refresh");vt&&vt.addEventListener("click",function(){$a()});var mt=document.getElementById("file-explorer-up");mt&&mt.addEventListener("click",q6);var et=document.getElementById("file-explorer-cwd");if(et&&et.tagName==="INPUT"){var Bt=et.value,$n=function(me){var Te=(me||"").trim();return Te?(Te=Te.replace(/\/{2,}/g,"/"),Te.length>1&&(Te=Te.replace(/\/+$/,"")),Te):""};et.addEventListener("focus",function(){Bt=et.value,setTimeout(function(){try{et.select()}catch{}},0)}),et.addEventListener("keydown",function(me){if(me.key==="Enter"){me.preventDefault();var Te=$n(et.value);if(!Te)return;Bt=Te,et.value=Te,$a({cwd:Te}),et.blur()}else me.key==="Escape"&&(me.preventDefault(),et.value=Bt,et.blur())}),et.addEventListener("blur",function(){var me=$n(et.value);if(!me){et.value=Bt;return}if(me===Bt){et.value=me;return}Bt=me,et.value=me,$a({cwd:me})})}var jn=document.getElementById("file-search-input"),Nt=document.getElementById("file-search-clear");jn&&jn.addEventListener("input",function(me){s.fileSearchQuery=me.target.value.trim(),Nt&&Nt.classList.toggle("visible",s.fileSearchQuery.length>0),Ef()}),Nt&&Nt.addEventListener("click",function(){s.fileSearchQuery="",jn&&(jn.value=""),Nt.classList.remove("visible")});var rr=document.getElementById("topbar-git-badge");rr&&rr.addEventListener("click",function(me){me.preventDefault(),D0()})}as(),P_(),eM(),WO(),Ln()}function Da(e){var t=e||{};s.lastRenderedHash=0,s.lastRenderedMsgCount=0,s.lastRenderedEmpty=null,s.renderPending=!1,s.chatRenderedCount=s.chatPageSize,s.askUserSelections={},s.chatScrollElement&&(s.chatScrollHandler&&s.chatScrollElement.removeEventListener("scroll",s.chatScrollHandler),s.chatScrollWheelHandler&&s.chatScrollElement.removeEventListener("wheel",s.chatScrollWheelHandler),s.chatScrollTouchStartHandler&&s.chatScrollElement.removeEventListener("touchstart",s.chatScrollTouchStartHandler),s.chatScrollTouchMoveHandler&&s.chatScrollElement.removeEventListener("touchmove",s.chatScrollTouchMoveHandler)),s.chatScrollElement=null,s.chatScrollHandler=null,s.chatScrollWheelHandler=null,s.chatScrollTouchStartHandler=null,s.chatScrollTouchMoveHandler=null,s.chatIsProgrammaticScroll=!1,t.preserveStickState||(s.chatStickToBottom=!0,s.chatUnreadCount=0,s.chatUnreadStartIndex=-1,s.chatInitialRenderDone=!1)}function Gr(){return s.workingDir||Fu()}window.addEventListener("online",function(){s.isOnline=!0,Mf()}),window.addEventListener("offline",function(){s.isOnline=!1,Mf()});function Mf(){var e=document.getElementById("offline-banner");if(!s.isOnline&&!e){var t=document.createElement("div");t.id="offline-banner",t.className="offline-banner",t.textContent="You are offline - some features may be limited",document.body.appendChild(t)}else s.isOnline&&e&&e.remove()}function PM(){var e=document.getElementById("app");e&&(e.innerHTML='<div class="boot-loading"><div class="boot-loading-card"><div class="boot-loading-spinner"></div><div class="boot-loading-text">\u6B63\u5728\u8FDE\u63A5 Wand\u2026</div></div></div>')}function Pl(e,t){if(s.config&&!document.hidden){var a=t&&t.immediate===!0,i=Date.now();!a&&i-s.lastForegroundSyncAt<1500||(s.lastForegroundSyncAt=i,s.foregroundSyncTimer&&(clearTimeout(s.foregroundSyncTimer),s.foregroundSyncTimer=null),UM(e,a))}}function UM(e,t){return!s.config||document.hidden?Promise.resolve():(sx(),t?_0("resume-force"):(!s.ws||s.ws.readyState!==WebSocket.OPEN&&s.ws.readyState!==WebSocket.CONNECTING)&&Df(),s.claudeHistoryLoaded&&rx(),s.codexHistoryLoaded&&ix(),Er({skipSelectedOutputReload:!0}).catch(function(a){console.error("[wand] foreground sync failed:",e,a)}))}function VM(){window.__wandForegroundSyncBound||(window.__wandForegroundSyncBound=!0,document.addEventListener("visibilitychange",function(){document.hidden?O0():(Pl("visibility"),ql("visibility"))}),window.addEventListener("focus",function(){Pl("focus")}),window.addEventListener("pageshow",function(){Pl("pageshow")}),window.addEventListener("resume",function(){Pl("resume")}),window.addEventListener("wand-android-resume",function(){Pl("android-resume",{immediate:!0}),ql("android-resume")}),window.addEventListener("wand-ime-state",function(e){var t=e&&e.detail&&e.detail.state;if(t==="shown"||t==="hidden")try{In("native-ime-"+t,{forceReplay:!0}),Ca("native-ime")}catch{}}),window.addEventListener("wand-android-network",function(e){var t=e&&e.detail&&e.detail.state;if(t==="lost"){s.isOnline=!1;try{Mf()}catch{}return}if(t==="available"||t==="changed"||t==="validated"){s.isOnline=!0;try{Mf()}catch{}_0("android-network-"+t)}}))}function GM(){fetch("/api/session-check",{credentials:"same-origin"}).then(function(e){return e.ok?e.json():{authed:!1}}).then(function(e){return!e||!e.authed?(s.loginChecked=!0,Hi(),null):fetch("/api/config",{credentials:"same-origin"}).then(function(t){return t.ok?t.json():(s.loginChecked=!0,Hi(),null)})}).then(function(e){e&&(s.config=e,s.loginChecked=!0,requestAnimationFrame(function(){try{Hi({skipShellChrome:!0})}catch{}VM(),ux(),Yi(),dR(),lO(),e.updateAvailable&&e.latestVersion&&Hx(e.currentVersion||"-",e.latestVersion),Lx&&TR(),$0&&jR(),s.claudeHistoryLoaded||setTimeout(function(){s.claudeHistoryLoaded||Nl()},600)}))}).catch(function(){if(s.loginChecked=!0,!navigator.onLine){var e=document.getElementById("app");e&&(e.innerHTML='<div class="boot-loading"><div class="boot-loading-card"><div class="boot-loading-text" style="font-size:1.3em;margin-bottom:12px;display:flex;align-items:center;justify-content:center;gap:8px">'+ot("signal",{size:20,strokeWidth:1.8})+'<span>\u65E0\u6CD5\u8FDE\u63A5\u5230\u670D\u52A1\u5668</span></div><div class="boot-loading-text" style="opacity:0.7;font-size:0.95em">\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u6216\u786E\u8BA4 Wand \u670D\u52A1\u6B63\u5728\u8FD0\u884C\u3002</div><button onclick="location.reload()" style="margin-top:18px;padding:8px 24px;border-radius:8px;border:1px solid rgba(150,118,85,0.3);background:rgba(255,255,255,0.8);cursor:pointer;font-size:0.95em">\u91CD\u8BD5</button></div></div>'),window.addEventListener("online",function(){location.reload()},{once:!0});return}Hi()})}document.addEventListener("click",function(e){if(!fn()&&!s.sidebarPinned&&!s.sidebarCollapsed&&s.sessionsDrawerOpen){var t=e.target;!t||!(t instanceof Element)||t.closest("#sessions-drawer")||t.closest("#sessions-toggle-button")||t.closest(".floating-sidebar-toggle")||t.closest(".sidebar-tile-bubble")||t.closest(".modal-backdrop, .modal-overlay, .modal-container, [role='dialog'], [role='menu'], .topbar-more-menu, .sidebar-header-overflow, .path-suggestions, .permission-prompt-overlay")||yR()}},!0),PM(),GM();function Hi(e){var t=e&&e.skipShellChrome,a=document.getElementById("app");if(a){var i=s.config!==null,o=At(),c=!i||!o&&!!document.getElementById("output");c&&Hl(),!i&&o&&b0(),document.documentElement.classList.add("no-transition"),s.sidebarPinned&&!s.sidebarCollapsed&&!fn()&&(s.sessionsDrawerOpen=!0,_t("wand-sidebar-open",!0));var d="disabled",f=!1;if(i){try{d=uj(a,G0)}catch(g){console.error("[wand] React shell mount failed; using legacy shell",g),b0(),a.innerHTML=G0(),d="disabled"}d==="disabled"?(a.innerHTML=G0(),f=!0):d==="mounted"&&(f=!0)}else a.innerHTML=KM(),f=!0;if(f&&(Da(),qM()),dc(),Sh(),Jf(Ui()),_h(),t||cc(),i&&s.filePanelOpen&&$a(),document.body.offsetHeight,requestAnimationFrame(function(){i&&Qn(document.getElementById("input-box")),document.documentElement.classList.remove("no-transition")}),i&&s.selectedId&&s.gitStatusSessionId!==s.selectedId&&Ff(s.selectedId),i){var v=s.sessions.find(function(g){return g.id===s.selectedId});Yh(v)}vc(document.getElementById("topbar-cwd")),vc(document.getElementById("blank-chat-cwd-path")),hc()}}function YM(){var e=s.sessions.find(function(a){return a.id===s.selectedId}),t=e&&e.approvalStats;return!t||t.total===0?'<span class="approval-stats hidden" id="approval-stats"></span>':'<span class="approval-stats" id="approval-stats"><span class="approval-stats-divider"></span><span class="approval-stats-badge" id="approval-stats-badge" title="\u672C\u6B21\u4F1A\u8BDD\u81EA\u52A8\u6279\u51C6\u7EDF\u8BA1"><svg class="approval-stats-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg><span class="approval-stats-total">'+t.total+'</span></span><span class="approval-stats-popup" id="approval-stats-popup"><span class="approval-stats-popup-title">\u81EA\u52A8\u6279\u51C6\u7EDF\u8BA1</span>'+(t.command>0?'<span class="approval-stats-row"><span class="approval-stats-row-icon">'+ot("terminal",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u547D\u4EE4\u6267\u884C</span><span class="approval-stats-row-count">'+t.command+"</span></span>":"")+(t.file>0?'<span class="approval-stats-row"><span class="approval-stats-row-icon">'+ot("edit",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u6587\u4EF6\u5199\u5165</span><span class="approval-stats-row-count">'+t.file+"</span></span>":"")+(t.tool>0?'<span class="approval-stats-row"><span class="approval-stats-row-icon">'+ot("wrench",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u5176\u4ED6\u5DE5\u5177</span><span class="approval-stats-row-count">'+t.tool+"</span></span>":"")+'<span class="approval-stats-row approval-stats-row-total"><span class="approval-stats-row-icon">'+ot("sigma",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u5408\u8BA1</span><span class="approval-stats-row-count">'+t.total+"</span></span></span></span>"}function KM(){return s.loginChecked?'<div class="login-container"><div class="login-card"><div class="login-header"><div class="login-brand-row"><div class="login-logo"><div class="login-logo-icon">W</div><span class="login-logo-text">Wand</span></div><span class="login-context-badge">\u672C\u5730\u63A7\u5236\u53F0</span></div><h1 class="login-title">\u6B22\u8FCE\u56DE\u6765</h1><div class="login-subtitle">\u8FDE\u63A5\u5230\u672C\u673A\u7EC8\u7AEF\u3001\u4F1A\u8BDD\u548C\u5DE5\u4F5C\u533A\u3002</div></div><form id="login-form" class="login-body" autocomplete="on"><input type="text" name="username" autocomplete="username" value="wand" tabindex="-1" aria-hidden="true" style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0;pointer-events:none" readonly /><p class="login-hint">\u4F7F\u7528\u5F53\u524D Wand \u670D\u52A1\u7684\u8BBF\u95EE\u5BC6\u7801\u7EE7\u7EED\u3002</p><div class="field"><label class="field-label" for="password">\u8BBF\u95EE\u5BC6\u7801</label><div class="password-field"><input id="password" type="password" class="field-input password-input" placeholder="\u8F93\u5165\u8BBF\u95EE\u5BC6\u7801" autocomplete="current-password" data-error="false" aria-describedby="password-hint login-error" aria-invalid="false" /><button id="toggle-password-button" type="button" class="password-toggle" aria-label="\u663E\u793A\u5BC6\u7801" aria-pressed="false">\u663E\u793A</button></div><p id="password-hint" class="hint">\u5BC6\u7801\u7531\u5F53\u524D\u670D\u52A1\u9A8C\u8BC1\uFF0C\u4E0D\u4F1A\u4FDD\u5B58\u5728\u6B64\u9875\u9762\u3002</p><p id="login-error" class="error-message hidden" role="alert"></p></div><div id="login-cert-hint" class="login-cert-hint hidden" role="alert"><div class="login-cert-hint-title">\u8BC1\u4E66\u4E0D\u53D7\u4FE1\u4EFB\uFF0C\u767B\u5F55\u6001\u65E0\u6CD5\u4FDD\u5B58</div><p class="login-cert-hint-body">\u5BC6\u7801\u662F\u5BF9\u7684\uFF0C\u4F46\u5F53\u524D HTTPS \u8BC1\u4E66\u4E0D\u53D7\u6D4F\u89C8\u5668\u4FE1\u4EFB\uFF0C\u6D4F\u89C8\u5668\u56E0\u6B64\u62D2\u7EDD\u4FDD\u5B58\u767B\u5F55 Cookie\uFF0C\u6240\u4EE5\u8FDB\u4E0D\u4E86\u63A7\u5236\u53F0\u3002<br/>\u89E3\u51B3\u529E\u6CD5\uFF08\u4EFB\u9009\u5176\u4E00\uFF09\uFF1A\u6539\u7528 HTTP \u8BBF\u95EE\u672C\u670D\u52A1\uFF1B\u6216\u628A\u672C\u670D\u52A1\u8BC1\u4E66\u8BBE\u4E3A\u300C\u53D7\u4FE1\u4EFB\u300D\uFF08\u63A8\u8350 mkcert\uFF09\uFF1B\u6216\u5728\u672C\u673A\u5C06\u8BE5\u81EA\u7B7E\u8BC1\u4E66\u8BBE\u4E3A\u5B8C\u5168\u4FE1\u4EFB\u540E\u91CD\u8BD5\u3002</p><a id="login-cert-http-link" class="btn btn-ghost btn-block" href="#" rel="noopener">\u6539\u7528 HTTP \u8BBF\u95EE</a></div><button id="login-button" type="submit" class="btn btn-primary btn-block">\u8FDB\u5165\u63A7\u5236\u53F0</button><p class="login-trust-note"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="10" width="14" height="11" rx="2"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/></svg><span>\u51ED\u636E\u53EA\u53D1\u9001\u5230\u5F53\u524D Wand \u670D\u52A1</span></p>'+(Ch()?'<button id="login-switch-server-button" class="btn btn-ghost btn-block login-switch-server" type="button"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="8" rx="2"/><rect x="2" y="13" width="20" height="8" rx="2"/><line x1="6" y1="7" x2="6.01" y2="7"/><line x1="6" y1="17" x2="6.01" y2="17"/></svg><span>\u5207\u6362\u670D\u52A1\u5668</span></button>':"")+"</form></div></div>":'<div class="login-container"><div class="login-card login-card-loading"><div class="login-header"><div class="login-brand-row"><div class="login-logo"><div class="login-logo-icon">W</div><span class="login-logo-text">Wand</span></div><span class="login-context-badge">\u672C\u5730\u63A7\u5236\u53F0</span></div><h1 class="login-title">\u6B63\u5728\u6062\u590D\u4F1A\u8BDD</h1><div class="login-subtitle">\u91CD\u65B0\u8FDE\u63A5\u5230\u8FD9\u53F0\u8BBE\u5907\u4E0A\u7684 Wand \u670D\u52A1\u3002</div></div><div class="login-body"><div class="login-status"><span class="login-spinner" aria-hidden="true"></span><div><p class="login-hint">\u6B63\u5728\u68C0\u67E5\u672C\u5730\u767B\u5F55\u4F1A\u8BDD\uFF0C\u8BF7\u7A0D\u5019\u3002</p><p class="login-muted">\u5982\u679C\u4F60\u521A\u5237\u65B0\u9875\u9762\uFF0C\u8FD9\u662F\u6B63\u5E38\u73B0\u8C61\u3002</p></div></div></div></div></div>'}function G0(){var e="<\/script>",t=s.sessions.find(function(y){return y.id===s.selectedId}),a=t?os(t.command):"\u672A\u9009\u62E9\u4F1A\u8BDD",i=t?t.mode+" | "+t.status:"\u70B9\u51FB\u4E0A\u65B9\u300C\u65B0\u5BF9\u8BDD\u300D\u5F00\u59CB",o=s.selectedId&&s.drafts[s.selectedId]||"",c=s.sessionsDrawerOpen?" open":"",d=_6()?" open":"",f=QN(),v=Qu(f,s.chatMode),g=fn(),h=!!s.sidebarPinned&&!!s.sidebarCollapsed,b=h||!g&&(!!s.sidebarPinned||!!s.sessionsDrawerOpen),w=h?" sidebar-collapsed":"",C=h?" collapsed":"";return'<div class="app-container"><div id="sessions-drawer-backdrop" class="drawer-backdrop'+d+'"></div><div class="main-layout'+(s.sessionsDrawerOpen?" sidebar-open":"")+(b?" sidebar-pinned":"")+w+'"><aside id="sessions-drawer" class="sidebar'+c+(b?" pinned":"")+C+'"><div class="sidebar-header"><div class="sidebar-header-main"><div class="topbar-logo-icon">W</div><span class="sidebar-title">\u4F1A\u8BDD</span><span class="session-count" id="session-count">'+String(s.sessions.filter(function(y){var x=String(y&&y.sessionSource||"").toLowerCase();return x!=="automation"&&x!=="startup"}).length)+'</span></div><div class="sidebar-header-actions"><div class="sidebar-header-more"><button id="sidebar-more-btn" class="btn btn-ghost btn-sm" type="button" title="\u66F4\u591A\u64CD\u4F5C"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="5" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="12" cy="19" r="1.5"/></svg></button><div class="sidebar-header-overflow" id="sidebar-overflow-menu"><button class="overflow-item" id="sidebar-home-btn" type="button"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg><span>\u56DE\u5230\u9996\u9875</span></button><button class="overflow-item" id="sidebar-refresh-btn" type="button"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg><span>\u5237\u65B0\u9875\u9762</span></button></div></div><button id="sidebar-pin-btn" class="btn btn-ghost btn-sm sidebar-pin-toggle'+(s.sidebarPinned?" pinned":"")+'" type="button" title="'+(s.sidebarPinned?"\u5DF2\u56FA\u5B9A\u5E38\u9A7B\uFF08\u70B9\u51FB\u89E3\u9664\u9501\u5B9A\uFF09":"\u56FA\u5B9A\u4FA7\u680F\u5E38\u9A7B")+'" aria-label="'+(s.sidebarPinned?"\u89E3\u9664\u56FA\u5B9A\u5E38\u9A7B":"\u56FA\u5B9A\u4FA7\u680F\u5E38\u9A7B")+'" aria-pressed="'+(s.sidebarPinned?"true":"false")+'"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24z"/></svg></button><button id="sidebar-collapse-btn" class="btn btn-ghost btn-sm sidebar-collapse-toggle'+(h?" collapsed":"")+'" type="button" title="'+(h?"\u5C55\u5F00\u4E3A\u5168\u5C3A\u5BF8":"\u6536\u8D77\u4E3A\u7A84\u6761")+'" aria-label="'+(h?"\u5C55\u5F00\u4E3A\u5168\u5C3A\u5BF8":"\u6536\u8D77\u4E3A\u7A84\u6761")+'">'+(h?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="10 6 16 12 10 18"/><line x1="20" y1="5" x2="20" y2="19"/></svg>':'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="14 6 8 12 14 18"/><line x1="4" y1="5" x2="4" y2="19"/></svg>')+'</button><button id="close-drawer-button" class="btn btn-ghost btn-icon sidebar-close drawer-close-btn" type="button" aria-label="\u5173\u95ED\u83DC\u5355"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg></button></div></div><div class="sidebar-body"><div id="sessions-panel"><div class="sessions-list" id="sessions-list">'+k0()+'</div></div></div><div class="sidebar-footer"><button id="drawer-new-session-button" class="btn btn-primary btn-block"><span>+</span> \u65B0\u4F1A\u8BDD</button><div class="sidebar-footer-actions"><button id="file-panel-toggle-btn" class="btn btn-ghost btn-sm'+(s.filePanelOpen?" active":"")+'" type="button" title="\u67E5\u770B\u6587\u4EF6"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg><span>\u6587\u4EF6</span></button><button id="settings-button" class="btn btn-ghost btn-sm" type="button" title="\u8BBE\u7F6E"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg><span>\u8BBE\u7F6E</span></button>'+(WN()?'<button id="back-to-native-button" class="btn btn-ghost btn-sm sidebar-back-to-native" type="button" title="\u8FD4\u56DE App \u539F\u751F\u754C\u9762"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="10" y="3" width="11" height="18" rx="2"/><line x1="14" y1="17" x2="17" y2="17"/><polyline points="7 8 3 12 7 16"/></svg><span>\u8FD4\u56DEApp</span></button>':"")+(Ch()?'<button id="switch-server-button" class="btn btn-ghost btn-sm sidebar-switch-server" type="button" title="\u5207\u6362\u670D\u52A1\u5668"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="8" rx="2"/><rect x="2" y="13" width="20" height="8" rx="2"/><line x1="6" y1="7" x2="6.01" y2="7"/><line x1="6" y1="17" x2="6.01" y2="17"/></svg><span>\u5207\u6362</span></button>':"")+'<button id="logout-button" class="btn btn-ghost btn-sm sidebar-logout" type="button" title="\u9000\u51FA\u767B\u5F55"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg><span>\u9000\u51FA</span></button></div></div></aside><main class="main-content"><div class="main-header-row"><div class="topbar-left"><button id="sessions-toggle-button" class="floating-sidebar-toggle'+(s.sessionsDrawerOpen?" active":"")+'" aria-label="\u5207\u6362\u4F1A\u8BDD\u4FA7\u680F" type="button"><span class="hamburger-icon"><span></span><span></span><span></span></span></button><span class="topbar-brand" aria-hidden="true">W</span></div><div class="topbar-center">'+(t?'<span class="topbar-session-title'+(t.titleGenerating?" title-generating":"")+'"'+(t.titleGenerating?' aria-busy="true"':"")+' title="'+q(t.description||t.command||"")+'">'+q(t.title||os(t.command))+'</span><span class="session-status-pill '+K6(t)+'" title="'+q(Ml(t))+'"><span class="session-status-dot"></span><span class="session-status-text">'+q(Ml(t))+'</span></span><span class="current-task hidden" id="current-task"></span>'+(t.cwd?up(t.cwd,"topbar-cwd",' id="topbar-cwd" role="button" tabindex="0"'):""):'<span class="topbar-tagline">Wand \u63A7\u5236\u53F0</span><span class="current-task hidden" id="current-task"></span>')+'</div><div class="topbar-right"><button id="topbar-file-button" class="topbar-btn square'+(s.filePanelOpen?" active":"")+'" type="button" aria-label="\u6587\u4EF6" title="\u67E5\u770B\u6587\u4EF6\uFF08\u53EF\u4FEE\u6539\u8DEF\u5F84\uFF09"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg></button><span id="topbar-git-slot" class="topbar-git-slot">'+V6()+"</span>"+(t?Fj(t):"")+'</div></div><div id="file-panel-backdrop" class="file-panel-backdrop'+(s.filePanelOpen?" open":"")+'"></div><div id="file-side-panel" class="file-side-panel'+(s.filePanelOpen?" open":"")+'"><div class="file-side-panel-header"><div class="file-side-panel-title-group"><span class="file-side-panel-icon">'+Qo("folder-open",{size:16})+'</span><span class="file-side-panel-title">\u6587\u4EF6</span></div><div class="file-side-panel-header-actions"><button class="file-side-panel-iconbtn" id="file-explorer-refresh" type="button" title="\u5237\u65B0" aria-label="\u5237\u65B0\u6587\u4EF6\u5217\u8868">'+Qo("refresh",{size:15})+'</button><button id="file-side-panel-close" class="file-side-panel-iconbtn close" type="button" aria-label="\u5173\u95ED\u6587\u4EF6\u9762\u677F" title="\u5173\u95ED">'+Qo("x",{size:16})+'</button></div></div><div class="file-side-panel-body"><div class="file-explorer-header"><button class="file-explorer-up" id="file-explorer-up" type="button" title="\u8FD4\u56DE\u4E0A\u7EA7\u76EE\u5F55" aria-label="\u8FD4\u56DE\u4E0A\u7EA7\u76EE\u5F55">'+Qo("arrow-up",{size:15})+'</button><input type="text" class="file-explorer-path" id="file-explorer-cwd" value="'+q(t&&t.cwd?t.cwd:Fu())+'" title="'+q(t&&t.cwd?t.cwd:Fu())+'" placeholder="\u8F93\u5165\u8DEF\u5F84\u5E76\u56DE\u8F66..." spellcheck="false" autocomplete="off" autocapitalize="off" autocorrect="off" aria-label="\u5F53\u524D\u8DEF\u5F84\uFF0C\u53EF\u76F4\u63A5\u4FEE\u6539\u540E\u56DE\u8F66" /></div><div class="file-search-box"><span class="file-search-icon">'+Qo("search",{size:14})+'</span><input type="text" id="file-search-input" class="file-search-input" placeholder="\u641C\u7D22\u5F53\u524D\u76EE\u5F55\u2026" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><button class="file-search-clear" id="file-search-clear" type="button" aria-label="\u6E05\u9664\u641C\u7D22" title="\u6E05\u9664">'+Qo("x",{size:13})+'</button></div><div class="file-explorer" id="file-explorer">'+gj(t&&t.cwd?t.cwd:Fu())+'</div></div></div><div id="output" class="terminal-container'+(s.selectedId?"":" hidden")+' active"><div class="terminal-scale-overlay" aria-label="\u7EC8\u7AEF\u7F29\u653E\u63A7\u4EF6"><button id="terminal-scale-down-top" class="terminal-scale-overlay-btn terminal-scale-btn" type="button" title="\u7F29\u5C0F">\u2212</button><span class="terminal-scale-overlay-label terminal-scale-label" id="terminal-scale-label-top">'+Math.round(s.terminalScale*100)+'%</span><button id="terminal-scale-up-top" class="terminal-scale-overlay-btn terminal-scale-btn" type="button" title="\u653E\u5927">+</button><span class="terminal-scale-overlay-divider"></span><button id="page-refresh-btn" class="terminal-scale-overlay-btn" type="button" title="\u5237\u65B0\u9875\u9762">\u21BB</button></div><button id="terminal-jump-bottom" class="terminal-jump-bottom'+(s.showTerminalJumpToBottom?" visible":"")+'" type="button" title="\u56DE\u5230\u5E95\u90E8" aria-label="\u56DE\u5230\u5E95\u90E8"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8l4.5 4.5L12.5 8"/></svg></button></div><div id="chat-output" class="chat-container hidden"><div id="chat-fold-bar" class="chat-fold-bar hidden" aria-live="polite"></div><button id="chat-unread-bubble" class="chat-unread-bubble" type="button" title="\u56DE\u5230\u6700\u65B0\u6D88\u606F" aria-label="\u56DE\u5230\u6700\u65B0\u6D88\u606F"><span class="chat-unread-bubble-icon"><svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8l4.5 4.5L12.5 8"/></svg></span><span class="chat-unread-bubble-count" aria-hidden="true"></span></button></div><div id="blank-chat" class="blank-chat'+(s.selectedId?" hidden":"")+'"><div class="blank-chat-inner"><div class="blank-chat-logo">W</div><h2 class="blank-chat-title">Wand</h2><p class="blank-chat-subtitle">\u652F\u6301\u7EC8\u7AEF PTY \u4F1A\u8BDD\u4E0E\u7ED3\u6784\u5316 chat \u4F1A\u8BDD\uFF0C\u4E24\u79CD\u6A21\u5F0F\u53EF\u5E76\u5B58\u3002</p><div class="blank-chat-tools"><button class="blank-chat-tool-btn" id="welcome-tool-claude" type="button"><span class="tool-icon">'+Yv("claude")+'</span>\u65B0\u5EFA\u7EC8\u7AEF\u4F1A\u8BDD</button><button class="blank-chat-tool-btn" id="welcome-tool-codex" type="button"><span class="tool-icon">'+Yv("codex")+'</span>\u65B0\u5EFA Codex \u4F1A\u8BDD</button><button class="blank-chat-tool-btn" id="welcome-tool-opencode" type="button"><span class="tool-icon">'+Yv("opencode")+'</span>\u65B0\u5EFA OpenCode \u4F1A\u8BDD</button><button class="blank-chat-tool-btn" id="welcome-tool-structured" type="button"><span class="tool-icon">'+ot("chat",{size:16,strokeWidth:1.8})+'</span>\u65B0\u5EFA\u7ED3\u6784\u5316\u4F1A\u8BDD</button></div><div class="blank-chat-cwd-wrap"><div class="blank-chat-cwd" id="blank-chat-cwd" role="button" tabindex="0" aria-haspopup="dialog" aria-expanded="false" title="\u70B9\u51FB\u5207\u6362\u5DE5\u4F5C\u76EE\u5F55"><span class="blank-chat-cwd-icon">'+ot("folder",{size:13,strokeWidth:1.8})+"</span>"+up(Gr(),"blank-chat-cwd-path",' id="blank-chat-cwd-path"')+'<span class="blank-chat-cwd-arrow">'+ot("chevronDown",{size:11,strokeWidth:2})+'</span></div></div></div><div id="cross-session-queue-host"></div></div><div class="input-panel'+(s.selectedId?"":" hidden")+'"><div class="composer-top-row"><div id="todo-progress" class="todo-progress hidden"><button class="todo-progress-header" id="todo-progress-toggle" type="button" aria-expanded="false" aria-controls="todo-progress-body" aria-label="\u5C55\u5F00\u5F85\u529E\u5217\u8868"><div class="todo-progress-fill" id="todo-progress-fill" aria-hidden="true" style="--progress:0"></div><div class="todo-progress-left"><span class="todo-progress-ring" id="todo-progress-ring" aria-hidden="true" style="--progress:0"><svg width="16" height="16" viewBox="0 0 36 36"><circle class="todo-ring-track" cx="18" cy="18" r="15.5" fill="none" stroke-width="4"/><circle class="todo-ring-fill" cx="18" cy="18" r="15.5" fill="none" stroke-width="4" stroke-linecap="round"/></svg></span><span class="todo-progress-counter" id="todo-progress-counter"></span></div><div class="todo-progress-task-wrap"><span class="todo-progress-task" id="todo-progress-task"></span></div>'+ot("chevronDown",{size:14,strokeWidth:2})+'</button></div><div class="todo-progress-body hidden" id="todo-progress-body"><ul class="todo-progress-list" id="todo-progress-list"></ul></div></div><div id="queue-bar-host" class="queue-bar-host" hidden></div><div class="input-composer-row"><div class="input-composer'+(String(o||"").trim()?" has-text":"")+'"><div class="composer-status-row" id="composer-status-row">'+cR(t)+'<span class="permission-actions hidden" id="permission-actions"><span class="permission-actions-label" id="permission-actions-label">\u7B49\u5F85\u6388\u6743</span><button id="approve-permission-btn" class="btn btn-permission btn-permission-approve" type="button">\u6279\u51C6</button><button id="deny-permission-btn" class="btn btn-permission btn-permission-deny" type="button">\u62D2\u7EDD</button></span>'+YM()+'</div><div class="composer-main-row"><div class="composer-actions-left"><button id="attach-btn" class="btn-circle btn-circle-action" type="button" title="\u66F4\u591A" aria-label="\u66F4\u591A\u64CD\u4F5C" aria-haspopup="dialog" aria-controls="composer-plus-popover" aria-expanded="false">'+ot("plus",{size:18,strokeWidth:2.2})+'</button><input type="file" id="file-upload-input" multiple tabindex="-1" style="position:absolute;width:1px;height:1px;opacity:0;overflow:hidden;clip:rect(0,0,0,0);pointer-events:none"></div><div class="composer-inline-config">'+s2(t)+'</div><div class="composer-input-wrap"><textarea id="input-box" class="input-textarea" aria-label="\u6D88\u606F\u8F93\u5165" placeholder="'+JE(t,s.terminalInteractive)+'" rows="1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" enterkeyhint="send">'+q(o)+'</textarea><button class="prompt-optimize-btn" id="prompt-optimize-btn" type="button" title="\u4F18\u5316\u63D0\u793A\u8BCD" aria-label="\u4F18\u5316\u63D0\u793A\u8BCD">'+ot("edit",{size:13,strokeWidth:1.9,cls:"prompt-optimize-icon"})+'<span class="prompt-optimize-label">\u4F18\u5316</span><span class="prompt-optimize-spinner" aria-hidden="true"></span></button></div><div class="composer-actions-right"><button id="stop-button" class="btn-circle btn-circle-stop hidden" type="button" title="\u505C\u6B62" aria-label="\u505C\u6B62\u751F\u6210"><svg width="12" height="12" viewBox="0 0 16 16" fill="currentColor"><rect x="3" y="3" width="10" height="10" rx="2"/></svg></button><button id="voice-record-btn" class="btn-circle btn-circle-action btn-circle-voice" type="button" title="\u6309\u4F4F\u8BED\u97F3\u8F93\u5165" aria-label="\u6309\u4F4F\u8BED\u97F3\u8F93\u5165" aria-pressed="false"'+(s.terminalInteractive?" disabled":"")+">"+ot("mic",{size:19,strokeWidth:2})+'</button><button id="send-input-button" class="btn-circle btn-circle-send" type="button" title="\u53D1\u9001" aria-label="\u53D1\u9001\u6D88\u606F"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5"/><path d="m6 11 6-6 6 6"/></svg></button></div></div><div id="attachment-preview" class="attachment-preview hidden"></div></div></div><div class="composer-plus-popover hidden" id="composer-plus-popover" role="dialog" aria-modal="false" aria-label="\u66F4\u591A\u64CD\u4F5C" aria-hidden="true"><button class="plus-popover-item" id="plus-attach-item" type="button">'+ot("paperclip",{size:14,strokeWidth:1.8,cls:"plus-popover-icon"})+'<span class="plus-popover-label">\u4E0A\u4F20\u9644\u4EF6</span></button><button class="plus-popover-item'+(s.terminalInteractive?" is-on":"")+'" id="terminal-interactive-toggle-top" type="button" aria-pressed="'+(s.terminalInteractive?"true":"false")+'">'+ot("keyboard",{size:14,strokeWidth:1.8,cls:"plus-popover-icon"})+'<span class="plus-popover-label">\u7EC8\u7AEF\u4EA4\u4E92</span><span class="plus-popover-toggle-state">'+(s.terminalInteractive?"\u5F00":"\u5173")+'</span></button><div class="plus-popover-sep" aria-hidden="true"></div><div class="plus-popover-trio-wrap">'+s2(t)+"</div></div>"+u2(t)+'<div class="voice-transcript-bubble hidden" id="voice-transcript-bubble" aria-live="polite"><div class="voice-transcript-text" id="voice-transcript-text"></div><div class="voice-transcript-hint" id="voice-transcript-hint"><span class="voice-wave" aria-hidden="true"><i></i><i></i><i></i><i></i></span><span class="voice-transcript-status" id="voice-transcript-status">\u6B63\u5728\u8046\u542C\u2026\u4E0A\u6ED1\u53D6\u6D88</span></div><span class="voice-bubble-arrow" aria-hidden="true"></span></div><p id="action-error" class="error-message hidden"></p></div></main></div></div>'}var Vu=0,Y0=null,Ul=!1;function Mx(){const e=window.__wandReactUi;return!e||typeof e.dialog!="function"||typeof e.toast!="function"?null:e}function WM(e){switch(e){case"warning":case"danger":case"success":case"question":return e;case"error":return"danger";default:return"info"}}function QM(e){switch(e){case"success":case"warning":case"error":return e;default:return"info"}}function Ox(e){switch(e){case"primary":case"outline":case"ghost":case"danger":return e;default:return"secondary"}}function XM(e){return Array.isArray(e.buttons)&&e.buttons.length>0?e.buttons:[{label:"\u597D",value:!0,kind:"primary",autofocus:!0}]}function $M(e){return e.cancelValue!==void 0?e.cancelValue:e.input?null:!1}function ZM(){if(typeof document>"u")return null;const e=document.activeElement;return e&&typeof e.focus=="function"?e:null}function JM(){if(Ul)return;Ul=!0,(typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):t=>setTimeout(()=>t(Date.now()),0))(()=>{if(Ul=!1,Vu>0)return;const t=Y0;if(Y0=null,!(!t||!t.isConnected||typeof document>"u"||!document.contains(t)))try{t.focus()}catch{}})}function eO(){Vu=Math.max(0,Vu-1),Vu===0&&JM()}function tO(e){const t=Mx();if(!t)return null;const a=Vu===0&&!Ul?ZM():null,i=XM(e),o=WM(e.type),c=!!e.input,d={title:e.title?String(e.title):o==="danger"?"\u786E\u8BA4\u64CD\u4F5C":"\u63D0\u793A",description:e.message?String(e.message):void 0,tone:o,icon:e.icon==null?void 0:String(e.icon),actions:i.map(v=>({label:v.label==null?"":String(v.label),value:{button:v},kind:Ox(v.kind),autoFocus:v.autofocus===!0||v.autoFocus===!0})),input:c?{value:e.inputValue==null?"":String(e.inputValue),placeholder:e.inputPlaceholder==null?void 0:String(e.inputPlaceholder),label:e.inputLabel==null?e.title==null?"\u8F93\u5165\u5185\u5BB9":String(e.title):String(e.inputLabel)}:void 0,dismissable:e.dismissable!==!1};let f;try{f=t.dialog(d)}catch{return null}return Vu===0&&!Ul&&(Y0=a),Vu+=1,f.then(v=>{if(v.dismissed===!0)return $M(e);const g=v.action.button;return c&&Ox(g.kind)==="primary"?v.inputValue??"":g.value}).finally(eO)}function nO(e,t,a){const i=Mx();if(!i)return!1;const o={tone:QM(t),duration:a};try{return i.toast(e,o),!0}catch{return!1}}function Ja(e,t){if(e){e.textContent=t,e.classList.remove("hidden");for(var a=e.previousElementSibling;a;){if(a.tagName==="INPUT"){a.setAttribute("data-error","true");break}a=a.previousElementSibling}}}function _x(e){if(e){e.textContent="",e.classList.add("hidden");for(var t=e.previousElementSibling;t;){if(t.tagName==="INPUT"){t.setAttribute("data-error","false");break}t=t.previousElementSibling}}}function be(e,t){var a=t==="error"?4e3:2200;nO(e,t,a)||W0({title:e,type:t==="error"?"warning":"info",duration:a})}function Vl(e){e=e||{};var t=tO(e);return t||aO(e)}function aO(e){var t=e.title==null?"":String(e.title),a=e.message==null?"":String(e.message),i=t&&a?t+`
3724
+ `,view:s.currentView})}).catch(function(f){console.error("[wand] Error sending answer:",f),t.submitted=!1,window.__askRender(e)})}}}};var Uu=null;function HM(){if(!s.__globalListenersBound){s.__globalListenersBound=!0,document.addEventListener("click",function(){if(!At()){var t=document.getElementById("sidebar-overflow-menu");t&&t.classList.remove("open")}}),window.addEventListener("resize",function(){if(!At()){var t=document.getElementById("sidebar-overflow-menu");t&&t.classList.remove("open")}});var e=function(){if(!At()){s.topbarMoreOpen=!1;var t=document.getElementById("topbar-more-menu"),a=document.getElementById("topbar-more-button");t&&t.classList.add("hidden"),a&&(a.classList.remove("active"),a.setAttribute("aria-expanded","false"))}};document.addEventListener("click",function(t){if(!At()&&s.topbarMoreOpen){var a=document.getElementById("topbar-more-menu"),i=a&&a.parentElement;i&&!i.contains(t.target)&&e()}}),document.addEventListener("keydown",function(t){At()||t.key==="Escape"&&s.topbarMoreOpen&&e()}),document.addEventListener("click",function(t){if(s.plusPopoverOpen){var a=document.getElementById("composer-plus-popover"),i=document.getElementById("attach-btn");a&&a.contains(t.target)||i&&i.contains(t.target)||tp()}}),document.addEventListener("keydown",function(t){t.key==="Escape"&&s.plusPopoverOpen&&(t.preventDefault(),tp(!0)),t.key==="Escape"&&Mh()}),document.addEventListener("click",function(t){var a=t.target;if(!(!a||typeof a.closest!="function")){var i=a.closest("[data-claude-skills-trigger]");if(i){t.preventDefault(),nR(i);return}var o=a.closest("[data-claude-skill-name]");if(o){t.preventDefault();var c=s.sessions.find(function(f){return f.id===s.selectedId});aR(c,o.getAttribute("data-claude-skill-name"));return}var d=document.getElementById("composer-skills-popover");d&&!d.contains(a)&&Mh()}}),document.addEventListener("click",function(t){var a=t.target;if(!(!a||typeof a.closest!="function")){var i=a.closest("[data-models-refresh]");if(i){t.preventDefault(),i.disabled||fR();return}var o=a.closest("#auto-approve-toggle");o&&(t.preventDefault(),Qj())}}),document.addEventListener("change",function(t){var a=t.target;if(!(!a||a.nodeType!==1)&&!(typeof a.matches!="function"||!a.matches("[data-mode-control]"))){var i=a.getAttribute("data-mode-control"),o=a.value;i==="mode"?mR(o):i==="model"?pR(o):i==="thinking"&&lR(o),a.closest&&a.closest("#composer-plus-popover")&&tp(!0)}})}}function qM(){HM(),Uu&&(Uu.disconnect(),Uu=null);var e=document.getElementById("login-button");if(e){e.addEventListener("click",Fh);var t=document.getElementById("login-form");t&&t.addEventListener("submit",function(me){me.preventDefault(),Fh()});var a=document.getElementById("login-switch-server-button");a&&a.addEventListener("click",Dh);var i=document.getElementById("password"),o=document.getElementById("toggle-password-button");o&&i&&o.addEventListener("click",function(){var me=i.type==="text";i.type=me?"password":"text",o.textContent=me?"\u663E\u793A":"\u9690\u85CF",o.setAttribute("aria-label",me?"\u663E\u793A\u5BC6\u7801":"\u9690\u85CF\u5BC6\u7801"),o.setAttribute("aria-pressed",me?"false":"true"),i.focus()}),i&&(i.addEventListener("keydown",function(me){me.key==="Enter"&&Fh()}),i.addEventListener("input",function(){i.dataset.error="false",i.setAttribute("aria-invalid","false");var me=document.getElementById("login-error");me&&_x(me)}),i.focus());return}var c=At();if(!c){var d=document.getElementById("welcome-input");d&&(d.addEventListener("keydown",function(me){me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),Zx())}),d.focus());var f=document.getElementById("welcome-send-btn");f&&f.addEventListener("click",function(){Zx()});var v=document.getElementById("welcome-tool-claude");v&&v.addEventListener("click",function(){rp()});var g=document.getElementById("welcome-tool-codex");g&&g.addEventListener("click",function(){s.sessionTool="codex",s.preferredCommand="codex",s.modeValue="full-access",rp()});var h=document.getElementById("welcome-tool-opencode");h&&h.addEventListener("click",function(){s.sessionTool="opencode",s.preferredCommand="opencode",s.modeValue="managed",rp()});var b=document.getElementById("welcome-tool-structured");b&&b.addEventListener("click",function(){g2().then(function(){yr(!0)}).catch(function(me){be(me&&me.message||"\u65E0\u6CD5\u542F\u52A8\u7ED3\u6784\u5316\u4F1A\u8BDD\u3002","error")})});var w=document.getElementById("sessions-list");w&&(w.addEventListener("click",wM),w.addEventListener("keydown",yM),w.addEventListener("mouseover",AR),w.addEventListener("mouseout",SR),T_(w)),window.addEventListener("scroll",Wr,!0),window.addEventListener("resize",Wr);var C=document.getElementById("sessions-toggle-button");C&&C.addEventListener("click",w2);var y=document.getElementById("sessions-drawer-backdrop");y&&y.addEventListener("click",cs);var x=document.getElementById("close-drawer-button");x&&x.addEventListener("click",cs);var E=document.getElementById("sidebar-collapse-btn");E&&E.addEventListener("click",Lh);var D=document.getElementById("sidebar-pin-btn");D&&D.addEventListener("click",x2);var A=document.getElementById("sidebar-more-btn"),B=document.getElementById("sidebar-overflow-menu");A&&B&&A.addEventListener("click",function(me){me.stopPropagation();var Te=!B.classList.contains("open");B.classList.toggle("open",Te),Te&&kR(B)});var j=document.getElementById("sidebar-home-btn");j&&j.addEventListener("click",function(){s.selectedId=null,Qt(),Da(),ar(),Hi()});var k=document.getElementById("sidebar-refresh-btn");k&&k.addEventListener("click",function(){window.location.reload()});var O=document.getElementById("logout-button");O&&O.addEventListener("click",Ah);var P=document.getElementById("switch-server-button");P&&P.addEventListener("click",Dh);var U=document.getElementById("back-to-native-button");U&&U.addEventListener("click",$E);var $=document.getElementById("settings-button");$&&$.addEventListener("click",C2);var ne=document.getElementById("topbar-new-session-button");ne&&ne.addEventListener("click",np);var Z=document.getElementById("drawer-new-session-button");Z&&Z.addEventListener("click",np)}var he=document.getElementById("approve-permission-btn");he&&he.addEventListener("click",Kj);var ve=document.getElementById("deny-permission-btn");ve&&ve.addEventListener("click",Wj);var H=document.getElementById("send-input-button");H&&H.addEventListener("click",function(){ar(),MO()});var te=document.getElementById("stop-button");te&&te.addEventListener("click",oh);var L=document.getElementById("input-box");if(L){wE(L),L.addEventListener("keydown",MR),L.addEventListener("paste",qR),L.addEventListener("input",function(){s.terminalComposing||S2(L)||(dh(L),fs(L.value,!0),pc(L))}),L.addEventListener("compositionstart",function(){s.terminalInteractive&&(s.terminalComposing=!0)}),L.addEventListener("compositionend",function(){s.terminalComposing&&(s.terminalComposing=!1,s.terminalInteractive&&S2(L))}),L.addEventListener("focus",function(){ar(),I_({target:L})}),L.addEventListener("blur",L_),dh(L);var Y=L.closest(".composer-input-wrap");if(Y&&typeof ResizeObserver<"u"){var _=-1;Uu=new ResizeObserver(function(me){if(!L.isConnected){Uu?.disconnect(),Uu=null;return}var Te=me[0]?me[0].contentRect.width:Y.getBoundingClientRect().width;Te<=0||Math.abs(Te-_)<.5||(_=Te,dh(L))}),Uu.observe(Y)}}var I=document.getElementById("attach-btn"),ue=document.getElementById("file-upload-input"),fe=document.getElementById("composer-plus-popover"),T=document.getElementById("plus-attach-item");I&&fe&&(I.addEventListener("click",function(me){me.stopPropagation(),ER(me.detail===0)}),fe.addEventListener("keydown",function(me){if(!(me.target instanceof HTMLSelectElement)&&["ArrowDown","ArrowUp","Home","End"].includes(me.key)){var Te=Array.from(fe.querySelectorAll('button:not([disabled]):not(.hidden), select:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(function(re){return re.getClientRects().length>0});if(Te.length){me.preventDefault();var jt=Te.indexOf(document.activeElement),Rt=me.key==="Home"?0:me.key==="End"?Te.length-1:me.key==="ArrowUp"?jt<=0?Te.length-1:jt-1:(jt+1)%Te.length;Te[Rt]?.focus()}}})),T&&ue&&T.addEventListener("click",function(me){tp(me.detail===0),ue.click()}),ue&&ue.addEventListener("change",function(){var me=ue.files;if(me)for(var Te=0;Te<me.length;Te++)qh(me[Te]);ue.value=""});var R=document.getElementById("voice-record-btn");R&&(R.addEventListener("pointerdown",FO),R.addEventListener("pointermove",CO),R.addEventListener("pointerup",Vx),R.addEventListener("pointercancel",DO),R.addEventListener("contextmenu",function(me){me.preventDefault()}));var ae=document.getElementById("prompt-optimize-btn");ae&&(ae.addEventListener("pointerdown",function(me){me.preventDefault()}),ae.addEventListener("click",function(){PR()}));var Q=document.querySelector(".input-composer");Q&&(Q.addEventListener("dragover",function(me){me.preventDefault(),me.stopPropagation(),Q.classList.add("drag-over")}),Q.addEventListener("dragleave",function(me){me.preventDefault(),me.stopPropagation(),Q.classList.remove("drag-over")}),Q.addEventListener("drop",function(me){me.preventDefault(),me.stopPropagation(),Q.classList.remove("drag-over");var Te=me.dataTransfer&&me.dataTransfer.files;if(Te)for(var jt=0;jt<Te.length;jt++)qh(Te[jt])}));var de=["terminal-interactive-toggle-top"];if(de.forEach(function(me){var Te=document.getElementById(me);Te&&Te.addEventListener("click",b_)}),!c){var ee=document.getElementById("file-panel-toggle-btn");ee&&ee.addEventListener("click",jl);var pe=document.getElementById("file-side-panel-close");pe&&pe.addEventListener("click",y0);var xe=document.getElementById("file-panel-backdrop");xe&&xe.addEventListener("click",y0);var Ee=document.getElementById("topbar-file-button");Ee&&Ee.addEventListener("click",jl);var De=document.getElementById("topbar-cwd");De&&(De.addEventListener("click",function(){s.filePanelOpen||jl()}),De.addEventListener("keydown",function(me){(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),s.filePanelOpen||jl())}));var Ne=document.getElementById("topbar-more-button"),at=document.getElementById("topbar-more-menu");Ne&&at&&(Ne.addEventListener("click",function(me){me.stopPropagation(),s.topbarMoreOpen=!s.topbarMoreOpen,at.classList.toggle("hidden",!s.topbarMoreOpen),Ne.classList.toggle("active",s.topbarMoreOpen),Ne.setAttribute("aria-expanded",s.topbarMoreOpen?"true":"false")}),at.addEventListener("click",function(me){var Te=me.target&&me.target.closest?me.target.closest(".topbar-more-item"):null;if(Te){var jt=Te.getAttribute("data-action");switch(s.topbarMoreOpen=!1,at.classList.add("hidden"),Ne.classList.remove("active"),Ne.setAttribute("aria-expanded","false"),jt){case"copy-claude-session-id":var Rt=Ui()&&Ui().provider;es("claudeSessionId",Rt==="codex"?"Codex thread ID \u5DF2\u590D\u5236":Rt==="opencode"?"OpenCode session ID \u5DF2\u590D\u5236":"Claude \u4F1A\u8BDD ID \u5DF2\u590D\u5236");break;case"copy-cwd":es("cwd","\u5DE5\u4F5C\u76EE\u5F55\u5DF2\u590D\u5236");break;case"copy-session-id":es("id","\u4F1A\u8BDD ID \u5DF2\u590D\u5236");break;case"worktree-merge":s.selectedId&&zh(s.selectedId);break;case"worktree-cleanup":s.selectedId&&Hh(s.selectedId);break;case"delete-session":s.selectedId&&(function(re){zi("\u786E\u5B9A\u8981\u5220\u9664\u5F53\u524D\u4F1A\u8BDD\u5417\uFF1F\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500\u3002",{title:"\u5220\u9664\u5F53\u524D\u4F1A\u8BDD"}).then(function(Cr){Cr&&qf(re)})})(s.selectedId);break}}}))}var ct=document.getElementById("terminal-scale-down-top"),je=document.getElementById("terminal-scale-up-top");ct&&ct.addEventListener("click",function(){N6(-.25)}),je&&je.addEventListener("click",function(){N6(.25)});var $e=document.getElementById("page-refresh-btn");$e&&$e.addEventListener("click",function(me){if(me&&me.shiftKey){location.reload();return}qu(),Da({preserveStickState:!0}),mh(!0)});var dt=document.getElementById("terminal-jump-bottom");dt&&dt.addEventListener("click",function(){Ca("force")});var mn=document.getElementById("chat-unread-bubble");if(mn&&mn.addEventListener("click",function(){$7(!0)}),!c){var vt=document.getElementById("file-explorer-refresh");vt&&vt.addEventListener("click",function(){$a()});var mt=document.getElementById("file-explorer-up");mt&&mt.addEventListener("click",q6);var et=document.getElementById("file-explorer-cwd");if(et&&et.tagName==="INPUT"){var Bt=et.value,$n=function(me){var Te=(me||"").trim();return Te?(Te=Te.replace(/\/{2,}/g,"/"),Te.length>1&&(Te=Te.replace(/\/+$/,"")),Te):""};et.addEventListener("focus",function(){Bt=et.value,setTimeout(function(){try{et.select()}catch{}},0)}),et.addEventListener("keydown",function(me){if(me.key==="Enter"){me.preventDefault();var Te=$n(et.value);if(!Te)return;Bt=Te,et.value=Te,$a({cwd:Te}),et.blur()}else me.key==="Escape"&&(me.preventDefault(),et.value=Bt,et.blur())}),et.addEventListener("blur",function(){var me=$n(et.value);if(!me){et.value=Bt;return}if(me===Bt){et.value=me;return}Bt=me,et.value=me,$a({cwd:me})})}var jn=document.getElementById("file-search-input"),Nt=document.getElementById("file-search-clear");jn&&jn.addEventListener("input",function(me){s.fileSearchQuery=me.target.value.trim(),Nt&&Nt.classList.toggle("visible",s.fileSearchQuery.length>0),Ef()}),Nt&&Nt.addEventListener("click",function(){s.fileSearchQuery="",jn&&(jn.value=""),Nt.classList.remove("visible")});var rr=document.getElementById("topbar-git-badge");rr&&rr.addEventListener("click",function(me){me.preventDefault(),D0()})}as(),P_(),eM(),WO(),Ln()}function Da(e){var t=e||{};s.lastRenderedHash=0,s.lastRenderedMsgCount=0,s.lastRenderedEmpty=null,s.renderPending=!1,s.chatRenderedCount=s.chatPageSize,s.askUserSelections={},s.chatScrollElement&&(s.chatScrollHandler&&s.chatScrollElement.removeEventListener("scroll",s.chatScrollHandler),s.chatScrollWheelHandler&&s.chatScrollElement.removeEventListener("wheel",s.chatScrollWheelHandler),s.chatScrollTouchStartHandler&&s.chatScrollElement.removeEventListener("touchstart",s.chatScrollTouchStartHandler),s.chatScrollTouchMoveHandler&&s.chatScrollElement.removeEventListener("touchmove",s.chatScrollTouchMoveHandler)),s.chatScrollElement=null,s.chatScrollHandler=null,s.chatScrollWheelHandler=null,s.chatScrollTouchStartHandler=null,s.chatScrollTouchMoveHandler=null,s.chatIsProgrammaticScroll=!1,t.preserveStickState||(s.chatStickToBottom=!0,s.chatUnreadCount=0,s.chatUnreadStartIndex=-1,s.chatInitialRenderDone=!1)}function Gr(){return s.workingDir||Fu()}window.addEventListener("online",function(){s.isOnline=!0,Mf()}),window.addEventListener("offline",function(){s.isOnline=!1,Mf()});function Mf(){var e=document.getElementById("offline-banner");if(!s.isOnline&&!e){var t=document.createElement("div");t.id="offline-banner",t.className="offline-banner",t.textContent="You are offline - some features may be limited",document.body.appendChild(t)}else s.isOnline&&e&&e.remove()}function PM(){var e=document.getElementById("app");e&&(e.innerHTML='<div class="boot-loading"><div class="boot-loading-card"><div class="boot-loading-spinner"></div><div class="boot-loading-text">\u6B63\u5728\u8FDE\u63A5 Wand\u2026</div></div></div>')}function Pl(e,t){if(s.config&&!document.hidden){var a=t&&t.immediate===!0,i=Date.now();!a&&i-s.lastForegroundSyncAt<1500||(s.lastForegroundSyncAt=i,s.foregroundSyncTimer&&(clearTimeout(s.foregroundSyncTimer),s.foregroundSyncTimer=null),UM(e,a))}}function UM(e,t){return!s.config||document.hidden?Promise.resolve():(sx(),t?_0("resume-force"):(!s.ws||s.ws.readyState!==WebSocket.OPEN&&s.ws.readyState!==WebSocket.CONNECTING)&&Df(),s.claudeHistoryLoaded&&rx(),s.codexHistoryLoaded&&ix(),Er({skipSelectedOutputReload:!0}).catch(function(a){console.error("[wand] foreground sync failed:",e,a)}))}function VM(){window.__wandForegroundSyncBound||(window.__wandForegroundSyncBound=!0,document.addEventListener("visibilitychange",function(){document.hidden?O0():(Pl("visibility"),ql("visibility"))}),window.addEventListener("focus",function(){Pl("focus")}),window.addEventListener("pageshow",function(){Pl("pageshow")}),window.addEventListener("resume",function(){Pl("resume")}),window.addEventListener("wand-android-resume",function(){Pl("android-resume",{immediate:!0}),ql("android-resume")}),window.addEventListener("wand-ime-state",function(e){var t=e&&e.detail&&e.detail.state;if(t==="shown"||t==="hidden")try{In("native-ime-"+t,{forceReplay:!0}),Ca("native-ime")}catch{}}),window.addEventListener("wand-android-network",function(e){var t=e&&e.detail&&e.detail.state;if(t==="lost"){s.isOnline=!1;try{Mf()}catch{}return}if(t==="available"||t==="changed"||t==="validated"){s.isOnline=!0;try{Mf()}catch{}_0("android-network-"+t)}}))}function GM(){fetch("/api/session-check",{credentials:"same-origin"}).then(function(e){return e.ok?e.json():{authed:!1}}).then(function(e){return!e||!e.authed?(s.loginChecked=!0,Hi(),null):fetch("/api/config",{credentials:"same-origin"}).then(function(t){return t.ok?t.json():(s.loginChecked=!0,Hi(),null)})}).then(function(e){e&&(s.config=e,s.loginChecked=!0,requestAnimationFrame(function(){try{Hi({skipShellChrome:!0})}catch{}VM(),ux(),Yi(),dR(),lO(),e.updateAvailable&&e.latestVersion&&Hx(e.currentVersion||"-",e.latestVersion),Lx&&TR(),$0&&jR(),s.claudeHistoryLoaded||setTimeout(function(){s.claudeHistoryLoaded||Nl()},600)}))}).catch(function(){if(s.loginChecked=!0,!navigator.onLine){var e=document.getElementById("app");e&&(e.innerHTML='<div class="boot-loading"><div class="boot-loading-card"><div class="boot-loading-text" style="font-size:1.3em;margin-bottom:12px;display:flex;align-items:center;justify-content:center;gap:8px">'+ot("signal",{size:20,strokeWidth:1.8})+'<span>\u65E0\u6CD5\u8FDE\u63A5\u5230\u670D\u52A1\u5668</span></div><div class="boot-loading-text" style="opacity:0.7;font-size:0.95em">\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u6216\u786E\u8BA4 Wand \u670D\u52A1\u6B63\u5728\u8FD0\u884C\u3002</div><button onclick="location.reload()" style="margin-top:18px;padding:8px 24px;border-radius:8px;border:1px solid rgba(150,118,85,0.3);background:rgba(255,255,255,0.8);cursor:pointer;font-size:0.95em">\u91CD\u8BD5</button></div></div>'),window.addEventListener("online",function(){location.reload()},{once:!0});return}Hi()})}document.addEventListener("click",function(e){if(!fn()&&!s.sidebarPinned&&!s.sidebarCollapsed&&s.sessionsDrawerOpen){var t=e.target;!t||!(t instanceof Element)||t.closest("#sessions-drawer")||t.closest("#sessions-toggle-button")||t.closest(".floating-sidebar-toggle")||t.closest(".sidebar-tile-bubble")||t.closest(".modal-backdrop, .modal-overlay, .modal-container, [role='dialog'], [role='menu'], .topbar-more-menu, .sidebar-header-overflow, .path-suggestions, .permission-prompt-overlay")||yR()}},!0),PM(),GM();function Hi(e){var t=e&&e.skipShellChrome,a=document.getElementById("app");if(a){var i=s.config!==null,o=At(),c=!i||!o&&!!document.getElementById("output");c&&Hl(),!i&&o&&b0(),document.documentElement.classList.add("no-transition"),s.sidebarPinned&&!s.sidebarCollapsed&&!fn()&&(s.sessionsDrawerOpen=!0,_t("wand-sidebar-open",!0));var d="disabled",f=!1;if(i){try{d=uj(a,G0)}catch(g){console.error("[wand] React shell mount failed; using legacy shell",g),b0(),a.innerHTML=G0(),d="disabled"}d==="disabled"?(a.innerHTML=G0(),f=!0):d==="mounted"&&(f=!0)}else a.innerHTML=KM(),f=!0;if(f&&(Da(),qM()),dc(),Sh(),Jf(Ui()),_h(),t||cc(),i&&s.filePanelOpen&&$a(),document.body.offsetHeight,requestAnimationFrame(function(){i&&Qn(document.getElementById("input-box")),document.documentElement.classList.remove("no-transition")}),i&&s.selectedId&&s.gitStatusSessionId!==s.selectedId&&Ff(s.selectedId),i){var v=s.sessions.find(function(g){return g.id===s.selectedId});Yh(v)}vc(document.getElementById("topbar-cwd")),vc(document.getElementById("blank-chat-cwd-path")),hc()}}function YM(){var e=s.sessions.find(function(a){return a.id===s.selectedId}),t=e&&e.approvalStats;return!t||t.total===0?'<span class="approval-stats hidden" id="approval-stats"></span>':'<span class="approval-stats" id="approval-stats"><span class="approval-stats-divider"></span><span class="approval-stats-badge" id="approval-stats-badge" title="\u672C\u6B21\u4F1A\u8BDD\u81EA\u52A8\u6279\u51C6\u7EDF\u8BA1"><svg class="approval-stats-icon" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg><span class="approval-stats-total">'+t.total+'</span></span><span class="approval-stats-popup" id="approval-stats-popup"><span class="approval-stats-popup-title">\u81EA\u52A8\u6279\u51C6\u7EDF\u8BA1</span>'+(t.command>0?'<span class="approval-stats-row"><span class="approval-stats-row-icon">'+ot("terminal",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u547D\u4EE4\u6267\u884C</span><span class="approval-stats-row-count">'+t.command+"</span></span>":"")+(t.file>0?'<span class="approval-stats-row"><span class="approval-stats-row-icon">'+ot("edit",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u6587\u4EF6\u5199\u5165</span><span class="approval-stats-row-count">'+t.file+"</span></span>":"")+(t.tool>0?'<span class="approval-stats-row"><span class="approval-stats-row-icon">'+ot("wrench",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u5176\u4ED6\u5DE5\u5177</span><span class="approval-stats-row-count">'+t.tool+"</span></span>":"")+'<span class="approval-stats-row approval-stats-row-total"><span class="approval-stats-row-icon">'+ot("sigma",{size:12,strokeWidth:1.8})+'</span><span class="approval-stats-row-label">\u5408\u8BA1</span><span class="approval-stats-row-count">'+t.total+"</span></span></span></span>"}function KM(){return s.loginChecked?'<div class="login-container"><div class="login-card"><div class="login-header"><div class="login-brand-row"><div class="login-logo"><div class="login-logo-icon">W</div><span class="login-logo-text">Wand</span></div><span class="login-context-badge">\u672C\u5730\u63A7\u5236\u53F0</span></div><h1 class="login-title">\u6B22\u8FCE\u56DE\u6765</h1><div class="login-subtitle">\u8FDE\u63A5\u5230\u672C\u673A\u7EC8\u7AEF\u3001\u4F1A\u8BDD\u548C\u5DE5\u4F5C\u533A\u3002</div></div><form id="login-form" class="login-body" autocomplete="on"><input type="text" name="username" autocomplete="username" value="wand" tabindex="-1" aria-hidden="true" style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0;pointer-events:none" readonly /><p class="login-hint">\u4F7F\u7528\u5F53\u524D Wand \u670D\u52A1\u7684\u8BBF\u95EE\u5BC6\u7801\u7EE7\u7EED\u3002</p><div class="field"><label class="field-label" for="password">\u8BBF\u95EE\u5BC6\u7801</label><div class="password-field"><input id="password" type="password" class="field-input password-input" placeholder="\u8F93\u5165\u8BBF\u95EE\u5BC6\u7801" autocomplete="current-password" data-error="false" aria-describedby="password-hint login-error" aria-invalid="false" /><button id="toggle-password-button" type="button" class="password-toggle" aria-label="\u663E\u793A\u5BC6\u7801" aria-pressed="false">\u663E\u793A</button></div><p id="password-hint" class="hint">\u5BC6\u7801\u7531\u5F53\u524D\u670D\u52A1\u9A8C\u8BC1\uFF0C\u4E0D\u4F1A\u4FDD\u5B58\u5728\u6B64\u9875\u9762\u3002</p><p id="login-error" class="error-message hidden" role="alert"></p></div><div id="login-cert-hint" class="login-cert-hint hidden" role="alert"><div class="login-cert-hint-title">\u8BC1\u4E66\u4E0D\u53D7\u4FE1\u4EFB\uFF0C\u767B\u5F55\u6001\u65E0\u6CD5\u4FDD\u5B58</div><p class="login-cert-hint-body">\u5BC6\u7801\u662F\u5BF9\u7684\uFF0C\u4F46\u5F53\u524D HTTPS \u8BC1\u4E66\u4E0D\u53D7\u6D4F\u89C8\u5668\u4FE1\u4EFB\uFF0C\u6D4F\u89C8\u5668\u56E0\u6B64\u62D2\u7EDD\u4FDD\u5B58\u767B\u5F55 Cookie\uFF0C\u6240\u4EE5\u8FDB\u4E0D\u4E86\u63A7\u5236\u53F0\u3002<br/>\u89E3\u51B3\u529E\u6CD5\uFF08\u4EFB\u9009\u5176\u4E00\uFF09\uFF1A\u6539\u7528 HTTP \u8BBF\u95EE\u672C\u670D\u52A1\uFF1B\u6216\u628A\u672C\u670D\u52A1\u8BC1\u4E66\u8BBE\u4E3A\u300C\u53D7\u4FE1\u4EFB\u300D\uFF08\u63A8\u8350 mkcert\uFF09\uFF1B\u6216\u5728\u672C\u673A\u5C06\u8BE5\u81EA\u7B7E\u8BC1\u4E66\u8BBE\u4E3A\u5B8C\u5168\u4FE1\u4EFB\u540E\u91CD\u8BD5\u3002</p><a id="login-cert-http-link" class="btn btn-ghost btn-block" href="#" rel="noopener">\u6539\u7528 HTTP \u8BBF\u95EE</a></div><button id="login-button" type="submit" class="btn btn-primary btn-block">\u8FDB\u5165\u63A7\u5236\u53F0</button><p class="login-trust-note"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="10" width="14" height="11" rx="2"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/></svg><span>\u51ED\u636E\u53EA\u53D1\u9001\u5230\u5F53\u524D Wand \u670D\u52A1</span></p>'+(Ch()?'<button id="login-switch-server-button" class="btn btn-ghost btn-block login-switch-server" type="button"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="8" rx="2"/><rect x="2" y="13" width="20" height="8" rx="2"/><line x1="6" y1="7" x2="6.01" y2="7"/><line x1="6" y1="17" x2="6.01" y2="17"/></svg><span>\u5207\u6362\u670D\u52A1\u5668</span></button>':"")+"</form></div></div>":'<div class="login-container"><div class="login-card login-card-loading"><div class="login-header"><div class="login-brand-row"><div class="login-logo"><div class="login-logo-icon">W</div><span class="login-logo-text">Wand</span></div><span class="login-context-badge">\u672C\u5730\u63A7\u5236\u53F0</span></div><h1 class="login-title">\u6B63\u5728\u6062\u590D\u4F1A\u8BDD</h1><div class="login-subtitle">\u91CD\u65B0\u8FDE\u63A5\u5230\u8FD9\u53F0\u8BBE\u5907\u4E0A\u7684 Wand \u670D\u52A1\u3002</div></div><div class="login-body"><div class="login-status"><span class="login-spinner" aria-hidden="true"></span><div><p class="login-hint">\u6B63\u5728\u68C0\u67E5\u672C\u5730\u767B\u5F55\u4F1A\u8BDD\uFF0C\u8BF7\u7A0D\u5019\u3002</p><p class="login-muted">\u5982\u679C\u4F60\u521A\u5237\u65B0\u9875\u9762\uFF0C\u8FD9\u662F\u6B63\u5E38\u73B0\u8C61\u3002</p></div></div></div></div></div>'}function G0(){var e="<\/script>",t=s.sessions.find(function(y){return y.id===s.selectedId}),a=t?os(t.command):"\u672A\u9009\u62E9\u4F1A\u8BDD",i=t?t.mode+" | "+t.status:"\u70B9\u51FB\u4E0A\u65B9\u300C\u65B0\u5BF9\u8BDD\u300D\u5F00\u59CB",o=s.selectedId&&s.drafts[s.selectedId]||"",c=s.sessionsDrawerOpen?" open":"",d=_6()?" open":"",f=QN(),v=Qu(f,s.chatMode),g=fn(),h=!!s.sidebarPinned&&!!s.sidebarCollapsed,b=h||!g&&(!!s.sidebarPinned||!!s.sessionsDrawerOpen),w=h?" sidebar-collapsed":"",C=h?" collapsed":"";return'<div class="app-container"><div id="sessions-drawer-backdrop" class="drawer-backdrop'+d+'"></div><div class="main-layout'+(s.sessionsDrawerOpen?" sidebar-open":"")+(b?" sidebar-pinned":"")+w+'"><aside id="sessions-drawer" class="sidebar'+c+(b?" pinned":"")+C+'"><div class="sidebar-header"><div class="sidebar-header-main"><div class="topbar-logo-icon">W</div><span class="sidebar-title">\u4F1A\u8BDD</span><span class="session-count" id="session-count">'+String(s.sessions.filter(function(y){var x=String(y&&y.sessionSource||"").toLowerCase();return x!=="automation"&&x!=="startup"}).length)+'</span></div><div class="sidebar-header-actions"><div class="sidebar-header-more"><button id="sidebar-more-btn" class="btn btn-ghost btn-sm" type="button" title="\u66F4\u591A\u64CD\u4F5C"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="5" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="12" cy="19" r="1.5"/></svg></button><div class="sidebar-header-overflow" id="sidebar-overflow-menu"><button class="overflow-item" id="sidebar-home-btn" type="button"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg><span>\u56DE\u5230\u9996\u9875</span></button><button class="overflow-item" id="sidebar-refresh-btn" type="button"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg><span>\u5237\u65B0\u9875\u9762</span></button></div></div><button id="sidebar-pin-btn" class="btn btn-ghost btn-sm sidebar-pin-toggle'+(s.sidebarPinned?" pinned":"")+'" type="button" title="'+(s.sidebarPinned?"\u5DF2\u56FA\u5B9A\u5E38\u9A7B\uFF08\u70B9\u51FB\u89E3\u9664\u9501\u5B9A\uFF09":"\u56FA\u5B9A\u4FA7\u680F\u5E38\u9A7B")+'" aria-label="'+(s.sidebarPinned?"\u89E3\u9664\u56FA\u5B9A\u5E38\u9A7B":"\u56FA\u5B9A\u4FA7\u680F\u5E38\u9A7B")+'" aria-pressed="'+(s.sidebarPinned?"true":"false")+'"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24z"/></svg></button><button id="sidebar-collapse-btn" class="btn btn-ghost btn-sm sidebar-collapse-toggle'+(h?" collapsed":"")+'" type="button" title="'+(h?"\u5C55\u5F00\u4E3A\u5168\u5C3A\u5BF8":"\u6536\u8D77\u4E3A\u7A84\u6761")+'" aria-label="'+(h?"\u5C55\u5F00\u4E3A\u5168\u5C3A\u5BF8":"\u6536\u8D77\u4E3A\u7A84\u6761")+'">'+(h?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="10 6 16 12 10 18"/><line x1="20" y1="5" x2="20" y2="19"/></svg>':'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="14 6 8 12 14 18"/><line x1="4" y1="5" x2="4" y2="19"/></svg>')+'</button><button id="close-drawer-button" class="btn btn-ghost btn-icon sidebar-close drawer-close-btn" type="button" aria-label="\u5173\u95ED\u83DC\u5355"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/></svg></button></div></div><div class="sidebar-body"><div id="sessions-panel"><div class="sessions-list" id="sessions-list">'+k0()+'</div></div></div><div class="sidebar-footer"><button id="drawer-new-session-button" class="btn btn-primary btn-block"><span>+</span> \u65B0\u4F1A\u8BDD</button><div class="sidebar-footer-actions"><button id="file-panel-toggle-btn" class="btn btn-ghost btn-sm'+(s.filePanelOpen?" active":"")+'" type="button" title="\u67E5\u770B\u6587\u4EF6"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg><span>\u6587\u4EF6</span></button><button id="settings-button" class="btn btn-ghost btn-sm" type="button" title="\u8BBE\u7F6E"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg><span>\u8BBE\u7F6E</span></button>'+(WN()?'<button id="back-to-native-button" class="btn btn-ghost btn-sm sidebar-back-to-native" type="button" title="\u8FD4\u56DE App \u539F\u751F\u754C\u9762"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="10" y="3" width="11" height="18" rx="2"/><line x1="14" y1="17" x2="17" y2="17"/><polyline points="7 8 3 12 7 16"/></svg><span>\u8FD4\u56DEApp</span></button>':"")+(Ch()?'<button id="switch-server-button" class="btn btn-ghost btn-sm sidebar-switch-server" type="button" title="\u5207\u6362\u670D\u52A1\u5668"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="8" rx="2"/><rect x="2" y="13" width="20" height="8" rx="2"/><line x1="6" y1="7" x2="6.01" y2="7"/><line x1="6" y1="17" x2="6.01" y2="17"/></svg><span>\u5207\u6362</span></button>':"")+'<button id="logout-button" class="btn btn-ghost btn-sm sidebar-logout" type="button" title="\u9000\u51FA\u767B\u5F55"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg><span>\u9000\u51FA</span></button></div></div></aside><main class="main-content"><div class="main-header-row"><div class="topbar-left"><button id="sessions-toggle-button" class="floating-sidebar-toggle'+(s.sessionsDrawerOpen?" active":"")+'" aria-label="\u5207\u6362\u4F1A\u8BDD\u4FA7\u680F" type="button"><span class="hamburger-icon"><span></span><span></span><span></span></span></button><span class="topbar-brand" aria-hidden="true">W</span></div><div class="topbar-center">'+(t?'<span class="topbar-session-title'+(t.titleGenerating?" title-generating":"")+'"'+(t.titleGenerating?' aria-busy="true"':"")+' title="'+q(t.description||t.command||"")+'">'+q(t.title||os(t.command))+'</span><span class="session-status-pill '+K6(t)+'" title="'+q(Ml(t))+'"><span class="session-status-dot"></span><span class="session-status-text">'+q(Ml(t))+'</span></span><span class="current-task hidden" id="current-task"></span>'+(t.cwd?up(t.cwd,"topbar-cwd",' id="topbar-cwd" role="button" tabindex="0"'):""):'<span class="topbar-tagline">Wand \u63A7\u5236\u53F0</span><span class="current-task hidden" id="current-task"></span>')+'</div><div class="topbar-right"><button id="topbar-file-button" class="topbar-btn square'+(s.filePanelOpen?" active":"")+'" type="button" aria-label="\u6587\u4EF6" title="\u67E5\u770B\u6587\u4EF6\uFF08\u53EF\u4FEE\u6539\u8DEF\u5F84\uFF09"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg></button><span id="topbar-git-slot" class="topbar-git-slot">'+V6()+"</span>"+(t?Fj(t):"")+'</div></div><div id="file-panel-backdrop" class="file-panel-backdrop'+(s.filePanelOpen?" open":"")+'"></div><div id="file-side-panel" class="file-side-panel'+(s.filePanelOpen?" open":"")+'"><div class="file-side-panel-header"><div class="file-side-panel-title-group"><span class="file-side-panel-icon">'+Qo("folder-open",{size:16})+'</span><span class="file-side-panel-title">\u6587\u4EF6</span></div><div class="file-side-panel-header-actions"><button class="file-side-panel-iconbtn" id="file-explorer-refresh" type="button" title="\u5237\u65B0" aria-label="\u5237\u65B0\u6587\u4EF6\u5217\u8868">'+Qo("refresh",{size:15})+'</button><button id="file-side-panel-close" class="file-side-panel-iconbtn close" type="button" aria-label="\u5173\u95ED\u6587\u4EF6\u9762\u677F" title="\u5173\u95ED">'+Qo("x",{size:16})+'</button></div></div><div class="file-side-panel-body"><div class="file-explorer-header"><button class="file-explorer-up" id="file-explorer-up" type="button" title="\u8FD4\u56DE\u4E0A\u7EA7\u76EE\u5F55" aria-label="\u8FD4\u56DE\u4E0A\u7EA7\u76EE\u5F55">'+Qo("arrow-up",{size:15})+'</button><input type="text" class="file-explorer-path" id="file-explorer-cwd" value="'+q(t&&t.cwd?t.cwd:Fu())+'" title="'+q(t&&t.cwd?t.cwd:Fu())+'" placeholder="\u8F93\u5165\u8DEF\u5F84\u5E76\u56DE\u8F66..." spellcheck="false" autocomplete="off" autocapitalize="off" autocorrect="off" aria-label="\u5F53\u524D\u8DEF\u5F84\uFF0C\u53EF\u76F4\u63A5\u4FEE\u6539\u540E\u56DE\u8F66" /></div><div class="file-search-box"><span class="file-search-icon">'+Qo("search",{size:14})+'</span><input type="text" id="file-search-input" class="file-search-input" placeholder="\u641C\u7D22\u5F53\u524D\u76EE\u5F55\u2026" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><button class="file-search-clear" id="file-search-clear" type="button" aria-label="\u6E05\u9664\u641C\u7D22" title="\u6E05\u9664">'+Qo("x",{size:13})+'</button></div><div class="file-explorer" id="file-explorer">'+gj(t&&t.cwd?t.cwd:Fu())+'</div></div></div><div id="output" class="terminal-container'+(s.selectedId?"":" hidden")+' active"><div class="terminal-scale-overlay" aria-label="\u7EC8\u7AEF\u7F29\u653E\u63A7\u4EF6"><button id="terminal-scale-down-top" class="terminal-scale-overlay-btn terminal-scale-btn" type="button" title="\u7F29\u5C0F">\u2212</button><span class="terminal-scale-overlay-label terminal-scale-label" id="terminal-scale-label-top">'+Math.round(s.terminalScale*100)+'%</span><button id="terminal-scale-up-top" class="terminal-scale-overlay-btn terminal-scale-btn" type="button" title="\u653E\u5927">+</button><span class="terminal-scale-overlay-divider"></span><button id="page-refresh-btn" class="terminal-scale-overlay-btn" type="button" title="\u5237\u65B0\u9875\u9762">\u21BB</button></div><button id="terminal-jump-bottom" class="terminal-jump-bottom'+(s.showTerminalJumpToBottom?" visible":"")+'" type="button" title="\u56DE\u5230\u5E95\u90E8" aria-label="\u56DE\u5230\u5E95\u90E8"><svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8l4.5 4.5L12.5 8"/></svg></button></div><div id="chat-output" class="chat-container hidden"><div id="chat-fold-bar" class="chat-fold-bar hidden" aria-live="polite"></div><button id="chat-unread-bubble" class="chat-unread-bubble" type="button" title="\u56DE\u5230\u6700\u65B0\u6D88\u606F" aria-label="\u56DE\u5230\u6700\u65B0\u6D88\u606F"><span class="chat-unread-bubble-icon"><svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3.5v9M3.5 8l4.5 4.5L12.5 8"/></svg></span><span class="chat-unread-bubble-count" aria-hidden="true"></span></button></div><div id="blank-chat" class="blank-chat'+(s.selectedId?" hidden":"")+'"><div class="blank-chat-inner"><div class="blank-chat-logo">W</div><h2 class="blank-chat-title">Wand</h2><p class="blank-chat-subtitle">\u652F\u6301\u7EC8\u7AEF PTY \u4F1A\u8BDD\u4E0E\u7ED3\u6784\u5316 chat \u4F1A\u8BDD\uFF0C\u4E24\u79CD\u6A21\u5F0F\u53EF\u5E76\u5B58\u3002</p><div class="blank-chat-tools"><button class="blank-chat-tool-btn" id="welcome-tool-claude" type="button"><span class="tool-icon">'+Yv("claude")+'</span>\u65B0\u5EFA\u7EC8\u7AEF\u4F1A\u8BDD</button><button class="blank-chat-tool-btn" id="welcome-tool-codex" type="button"><span class="tool-icon">'+Yv("codex")+'</span>\u65B0\u5EFA Codex \u4F1A\u8BDD</button><button class="blank-chat-tool-btn" id="welcome-tool-opencode" type="button"><span class="tool-icon">'+Yv("opencode")+'</span>\u65B0\u5EFA OpenCode \u4F1A\u8BDD</button><button class="blank-chat-tool-btn" id="welcome-tool-structured" type="button"><span class="tool-icon">'+ot("chat",{size:16,strokeWidth:1.8})+'</span>\u65B0\u5EFA\u7ED3\u6784\u5316\u4F1A\u8BDD</button></div><div class="blank-chat-cwd-wrap"><div class="blank-chat-cwd" id="blank-chat-cwd" role="button" tabindex="0" aria-haspopup="dialog" aria-expanded="false" title="\u70B9\u51FB\u5207\u6362\u5DE5\u4F5C\u76EE\u5F55"><span class="blank-chat-cwd-icon">'+ot("folder",{size:13,strokeWidth:1.8})+"</span>"+up(Gr(),"blank-chat-cwd-path",' id="blank-chat-cwd-path"')+'<span class="blank-chat-cwd-arrow">'+ot("chevronDown",{size:11,strokeWidth:2})+'</span></div></div></div><div id="cross-session-queue-host"></div></div><div class="input-panel'+(s.selectedId?"":" hidden")+'"><div class="composer-top-row"><div id="todo-progress" class="todo-progress hidden"><button class="todo-progress-header" id="todo-progress-toggle" type="button" aria-expanded="false" aria-controls="todo-progress-body" aria-label="\u5C55\u5F00\u5F85\u529E\u5217\u8868"><div class="todo-progress-fill" id="todo-progress-fill" aria-hidden="true" style="--progress:0"></div><div class="todo-progress-left"><span class="todo-progress-ring" id="todo-progress-ring" aria-hidden="true" style="--progress:0"><svg width="16" height="16" viewBox="0 0 36 36"><circle class="todo-ring-track" cx="18" cy="18" r="15.5" fill="none" stroke-width="4"/><circle class="todo-ring-fill" cx="18" cy="18" r="15.5" fill="none" stroke-width="4" stroke-linecap="round"/></svg></span><span class="todo-progress-counter" id="todo-progress-counter"></span></div><div class="todo-progress-task-wrap"><span class="todo-progress-task" id="todo-progress-task"></span></div>'+ot("chevronDown",{size:14,strokeWidth:2})+'</button></div><div class="todo-progress-body hidden" id="todo-progress-body"><ul class="todo-progress-list" id="todo-progress-list"></ul></div></div><div id="queue-bar-host" class="queue-bar-host" hidden></div><div class="input-composer-row"><div class="input-composer'+(String(o||"").trim()?" has-text":"")+'"><div class="composer-status-row" id="composer-status-row">'+cR(t)+'<span class="permission-actions hidden" id="permission-actions"><span class="permission-actions-label" id="permission-actions-label">\u7B49\u5F85\u6388\u6743</span><button id="approve-permission-btn" class="btn btn-permission btn-permission-approve" type="button">\u6279\u51C6</button><button id="deny-permission-btn" class="btn btn-permission btn-permission-deny" type="button">\u62D2\u7EDD</button></span>'+YM()+'</div><div class="composer-main-row"><div class="composer-actions-left"><button id="attach-btn" class="btn-circle btn-circle-action" type="button" title="\u66F4\u591A" aria-label="\u66F4\u591A\u64CD\u4F5C" aria-haspopup="dialog" aria-controls="composer-plus-popover" aria-expanded="false">'+ot("plus",{size:18,strokeWidth:2.2})+'</button><input type="file" id="file-upload-input" multiple tabindex="-1" style="position:absolute;width:1px;height:1px;opacity:0;overflow:hidden;clip:rect(0,0,0,0);pointer-events:none"></div><div class="composer-inline-config">'+s2(t)+'</div><div class="composer-input-wrap"><textarea id="input-box" class="input-textarea" aria-label="\u6D88\u606F\u8F93\u5165" placeholder="'+JE(t,s.terminalInteractive)+'" rows="1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" enterkeyhint="send">'+q(o)+'</textarea></div><div class="composer-actions-right"><button class="prompt-optimize-btn" id="prompt-optimize-btn" type="button" title="\u4F18\u5316\u63D0\u793A\u8BCD" aria-label="\u4F18\u5316\u63D0\u793A\u8BCD">'+ot("edit",{size:15,strokeWidth:1.9,cls:"prompt-optimize-icon"})+'<span class="prompt-optimize-label">\u4F18\u5316</span><span class="prompt-optimize-spinner" aria-hidden="true"></span></button><button id="stop-button" class="btn-circle btn-circle-stop hidden" type="button" title="\u505C\u6B62" aria-label="\u505C\u6B62\u751F\u6210"><svg width="12" height="12" viewBox="0 0 16 16" fill="currentColor"><rect x="3" y="3" width="10" height="10" rx="2"/></svg></button><button id="voice-record-btn" class="btn-circle btn-circle-action btn-circle-voice" type="button" title="\u6309\u4F4F\u8BED\u97F3\u8F93\u5165" aria-label="\u6309\u4F4F\u8BED\u97F3\u8F93\u5165" aria-pressed="false"'+(s.terminalInteractive?" disabled":"")+">"+ot("mic",{size:19,strokeWidth:2})+'</button><button id="send-input-button" class="btn-circle btn-circle-send" type="button" title="\u53D1\u9001" aria-label="\u53D1\u9001\u6D88\u606F"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5"/><path d="m6 11 6-6 6 6"/></svg></button></div></div><div id="attachment-preview" class="attachment-preview hidden"></div></div></div><div class="composer-plus-popover hidden" id="composer-plus-popover" role="dialog" aria-modal="false" aria-label="\u66F4\u591A\u64CD\u4F5C" aria-hidden="true"><button class="plus-popover-item" id="plus-attach-item" type="button">'+ot("paperclip",{size:14,strokeWidth:1.8,cls:"plus-popover-icon"})+'<span class="plus-popover-label">\u4E0A\u4F20\u9644\u4EF6</span></button><button class="plus-popover-item'+(s.terminalInteractive?" is-on":"")+'" id="terminal-interactive-toggle-top" type="button" aria-pressed="'+(s.terminalInteractive?"true":"false")+'">'+ot("keyboard",{size:14,strokeWidth:1.8,cls:"plus-popover-icon"})+'<span class="plus-popover-label">\u7EC8\u7AEF\u4EA4\u4E92</span><span class="plus-popover-toggle-state">'+(s.terminalInteractive?"\u5F00":"\u5173")+'</span></button><div class="plus-popover-sep" aria-hidden="true"></div><div class="plus-popover-trio-wrap">'+s2(t)+"</div></div>"+u2(t)+'<div class="voice-transcript-bubble hidden" id="voice-transcript-bubble" aria-live="polite"><div class="voice-transcript-text" id="voice-transcript-text"></div><div class="voice-transcript-hint" id="voice-transcript-hint"><span class="voice-wave" aria-hidden="true"><i></i><i></i><i></i><i></i></span><span class="voice-transcript-status" id="voice-transcript-status">\u6B63\u5728\u8046\u542C\u2026\u4E0A\u6ED1\u53D6\u6D88</span></div><span class="voice-bubble-arrow" aria-hidden="true"></span></div><p id="action-error" class="error-message hidden"></p></div></main></div></div>'}var Vu=0,Y0=null,Ul=!1;function Mx(){const e=window.__wandReactUi;return!e||typeof e.dialog!="function"||typeof e.toast!="function"?null:e}function WM(e){switch(e){case"warning":case"danger":case"success":case"question":return e;case"error":return"danger";default:return"info"}}function QM(e){switch(e){case"success":case"warning":case"error":return e;default:return"info"}}function Ox(e){switch(e){case"primary":case"outline":case"ghost":case"danger":return e;default:return"secondary"}}function XM(e){return Array.isArray(e.buttons)&&e.buttons.length>0?e.buttons:[{label:"\u597D",value:!0,kind:"primary",autofocus:!0}]}function $M(e){return e.cancelValue!==void 0?e.cancelValue:e.input?null:!1}function ZM(){if(typeof document>"u")return null;const e=document.activeElement;return e&&typeof e.focus=="function"?e:null}function JM(){if(Ul)return;Ul=!0,(typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame.bind(window):t=>setTimeout(()=>t(Date.now()),0))(()=>{if(Ul=!1,Vu>0)return;const t=Y0;if(Y0=null,!(!t||!t.isConnected||typeof document>"u"||!document.contains(t)))try{t.focus()}catch{}})}function eO(){Vu=Math.max(0,Vu-1),Vu===0&&JM()}function tO(e){const t=Mx();if(!t)return null;const a=Vu===0&&!Ul?ZM():null,i=XM(e),o=WM(e.type),c=!!e.input,d={title:e.title?String(e.title):o==="danger"?"\u786E\u8BA4\u64CD\u4F5C":"\u63D0\u793A",description:e.message?String(e.message):void 0,tone:o,icon:e.icon==null?void 0:String(e.icon),actions:i.map(v=>({label:v.label==null?"":String(v.label),value:{button:v},kind:Ox(v.kind),autoFocus:v.autofocus===!0||v.autoFocus===!0})),input:c?{value:e.inputValue==null?"":String(e.inputValue),placeholder:e.inputPlaceholder==null?void 0:String(e.inputPlaceholder),label:e.inputLabel==null?e.title==null?"\u8F93\u5165\u5185\u5BB9":String(e.title):String(e.inputLabel)}:void 0,dismissable:e.dismissable!==!1};let f;try{f=t.dialog(d)}catch{return null}return Vu===0&&!Ul&&(Y0=a),Vu+=1,f.then(v=>{if(v.dismissed===!0)return $M(e);const g=v.action.button;return c&&Ox(g.kind)==="primary"?v.inputValue??"":g.value}).finally(eO)}function nO(e,t,a){const i=Mx();if(!i)return!1;const o={tone:QM(t),duration:a};try{return i.toast(e,o),!0}catch{return!1}}function Ja(e,t){if(e){e.textContent=t,e.classList.remove("hidden");for(var a=e.previousElementSibling;a;){if(a.tagName==="INPUT"){a.setAttribute("data-error","true");break}a=a.previousElementSibling}}}function _x(e){if(e){e.textContent="",e.classList.add("hidden");for(var t=e.previousElementSibling;t;){if(t.tagName==="INPUT"){t.setAttribute("data-error","false");break}t=t.previousElementSibling}}}function be(e,t){var a=t==="error"?4e3:2200;nO(e,t,a)||W0({title:e,type:t==="error"?"warning":"info",duration:a})}function Vl(e){e=e||{};var t=tO(e);return t||aO(e)}function aO(e){var t=e.title==null?"":String(e.title),a=e.message==null?"":String(e.message),i=t&&a?t+`
3725
3725
 
3726
3726
  `+a:t||a,o=Array.isArray(e.buttons)&&e.buttons.length?e.buttons:[{label:"\u597D",value:!0,kind:"primary"}];if(e.input)return Promise.resolve(window.prompt(i,e.inputValue==null?"":String(e.inputValue)));if(o.length<=1)return window.alert(i),Promise.resolve(o[0]?.value);var c=window.confirm(i);if(!c)return Promise.resolve(e.cancelValue!==void 0?e.cancelValue:!1);var d=o.find(function(f){return f.kind==="primary"||f.kind==="danger"})||o[o.length-1];return Promise.resolve(d.value)}function rO(e,t){return t=t||{},Vl({title:t.title||"\u63D0\u793A",message:typeof e=="string"?e:String(e??""),type:t.type||"info",dismissable:t.dismissable,buttons:[{label:t.okLabel||"\u597D",value:void 0,kind:"primary",autofocus:!0}]})}function K0(e,t){t=t||{};var a=!!t.danger||t.type==="danger";return Vl({title:t.title||(a?"\u786E\u8BA4\u64CD\u4F5C":"\u8BF7\u786E\u8BA4"),message:typeof e=="string"?e:String(e??""),type:t.type||(a?"danger":"question"),cancelValue:!1,dismissable:t.dismissable,buttons:[{label:t.cancelLabel||"\u53D6\u6D88",value:!1,kind:"secondary"},{label:t.okLabel||(a?"\u5220\u9664":"\u786E\u5B9A"),value:!0,kind:a?"danger":"primary",autofocus:!a}]}).then(function(i){return i===!0})}function iO(e,t,a){return a=a||{},Vl({title:a.title||"\u8BF7\u8F93\u5165",message:typeof e=="string"?e:String(e??""),type:a.type||"question",input:!0,inputValue:t==null?"":String(t),inputPlaceholder:a.placeholder||"",cancelValue:null,dismissable:a.dismissable,buttons:[{label:a.cancelLabel||"\u53D6\u6D88",value:null,kind:"secondary"},{label:a.okLabel||"\u786E\u5B9A",value:void 0,kind:"primary"}]})}window.wandAlert=rO,window.wandConfirm=K0,window.wandPrompt=iO,window.openWandDialog=Vl,window.showToast=be;var Yr=[],Nx=0,uO=6,oO=16;function W0(e){if((e.actionLabel||e.playSound)&&Ux(),!s.notifBubble)return{dismiss:function(){}};var t=++Nx,a=e.type||"info",i=e.icon||(a==="warning"?"!":a==="success"?"\u2713":"i"),o=e.duration!==void 0?e.duration:8e3,c=document.createElement("div");c.className="notification-bubble",c.setAttribute("data-nid",String(t));var d='<div class="notification-bubble-header"><span class="notification-bubble-icon '+a+'">'+i+'</span><span class="notification-bubble-title">'+q(e.title)+'</span><button class="notification-bubble-close" title="\u5173\u95ED">\xD7</button></div>',f=e.body?'<div class="notification-bubble-body">'+q(e.body).replace(/\n/g,"<br>")+"</div>":"",v=e.actionLabel?'<div class="notification-bubble-actions"><button class="primary">'+q(e.actionLabel)+"</button></div>":"";c.innerHTML=d+f+v,document.body.appendChild(c);var g={id:t,el:c};Yr.push(g),Q0();var h=c.querySelector(".notification-bubble-close");if(h&&(h.onclick=function(){Gl(t)}),e.actionLabel&&e.action){var b=c.querySelector(".notification-bubble-actions button");b&&(b.onclick=function(){e.action(),Gl(t)})}var w=null;return o>0&&(w=setTimeout(function(){Gl(t)},o)),{dismiss:function(){Gl(t)}}}function Gl(e){for(var t=-1,a=0;a<Yr.length;a++)if(Yr[a].id===e){t=a;break}if(t!==-1){var i=Yr[t];i.el.classList.add("slide-out"),Yr.splice(t,1),Q0(),setTimeout(function(){i.el.parentNode&&i.el.parentNode.removeChild(i.el)},300)}}function Q0(){for(var e=oO,t=0;t<Yr.length;t++)Yr[t].el.style.top=e+"px",e+=Yr[t].el.offsetHeight+uO}try{Rx=navigator.userAgent.match(/WandPlatform\/macOS/),X0=window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.wandNative||null,Rx&&X0&&typeof window.WandNative>"u"&&(window.WandNative={downloadUpdate:function(e,t,a){try{X0.postMessage({type:"downloadUpdate",url:String(e||""),fileName:String(t||"wand-update.dmg"),source:String(a||"local")})}catch{}}})}catch{}var Rx,X0,qi=typeof WandNative<"u"&&typeof WandNative.sendNotification=="function",Yl=navigator.userAgent.match(/WandApp\/([^\s]+)/),Ix=/WandPlatform\/macOS/.test(navigator.userAgent),sO=!!Yl&&!Ix,Lx=Yl&&sO?Yl[1]:null,$0=Yl&&Ix?Yl[1]:null;function Kl(e){if(!(!qi||typeof WandNative.vibrate!="function"))try{WandNative.vibrate(e||"light")}catch{}}function Z0(){if(qi){var e=s.sessions.some(function(t){return!t.archived&&(t.status==="running"||t.status==="thinking"||t.status==="initializing")});if(typeof WandNative.setKeepScreenOn=="function")try{WandNative.setKeepScreenOn(e)}catch{}if(e){if(typeof WandNative.startKeepAlive=="function")try{WandNative.startKeepAlive()}catch{}}else if(typeof WandNative.stopKeepAlive=="function")try{WandNative.stopKeepAlive()}catch{}}}function zx(){if(qi&&typeof WandNative.getPermission=="function")try{return WandNative.getPermission()}catch{}return null}function lO(){if(qi){var e=zx();if(e==="default"||e==="denied")try{WandNative.requestPermission()}catch{}return}typeof Notification<"u"&&Notification.permission==="default"&&Notification.requestPermission()}function cO(e){var t=e||{};return!(t.onlyWhenHidden&&!document.hidden||t.skipWhenSelectedSessionId&&t.skipWhenSelectedSessionId===s.selectedId&&!document.hidden)}function dO(e,t){if(!e||!t||t<=0)return!1;var a=s.notificationHistory[e]||0,i=Date.now();return i-a<t?!0:(s.notificationHistory[e]=i,!1)}function Of(e,t,a){var i=a||{},o=i.tag||"";if(cO(i)&&!dO(o,i.minIntervalMs||0)){if(qi){var c=zx();if(c!=="granted")return;try{var d=o;i.kind&&(d=i.kind+(o?":"+o:"")),WandNative.sendNotification(e||"Wand",t||"",d||"")}catch{}return}if(!(typeof Notification>"u"||Notification.permission!=="granted")&&document.hidden)try{var f=new Notification(e,{body:t||"",icon:i.icon||"/favicon.ico",tag:o||void 0});f.onclick=function(){window.focus(),f.close(),i.onClick&&i.onClick()},setTimeout(function(){f.close()},1e4)}catch{}}}function fO(e,t){if(!(!t||!t.title)){var a=s.sessions.find(function(o){return o.id===e});if(a){var i=a.summary||a.command||e;Of("\u4EFB\u52A1\u8FDB\u884C\u4E2D",i+`
3727
3727
  `+t.title,{kind:"task",tag:"wand-task-"+e+"-"+t.title,minIntervalMs:9e4,onlyWhenHidden:!0,skipWhenSelectedSessionId:e,onClick:function(){e!==s.selectedId&&nr(e)}})}}}function Hx(e,t){bO(e||"-",t||"-"),Of("Wand \u53D1\u73B0\u65B0\u7248\u672C","\u5F53\u524D "+(e||"-")+" \u2192 \u6700\u65B0 "+(t||"-"),{kind:"update",tag:"wand-update",minIntervalMs:3e5})}function pO(e,t){Of("\u9700\u8981\u4F60\u7684\u6388\u6743",t,{kind:"permission",tag:"wand-perm-"+e,minIntervalMs:6e4,onlyWhenHidden:!0,skipWhenSelectedSessionId:e,onClick:function(){e!==s.selectedId&&nr(e)}})}function mO(e,t,a){Of(t,a,{kind:"task-ended",tag:"wand-ended-"+e,minIntervalMs:1e4,onClick:function(){e!==s.selectedId&&nr(e)}})}var Gu={},vO=30;function qx(e){if(!e)return"";var t=String(e).replace(/^#+\s+/gm,"").replace(/\*\*/g,"").replace(/`/g,"").trim(),a=t.split(`
3728
- `)[0].trim();return a.length>100&&(a=a.slice(0,100)+"\u2026"),a}function J0(e){!qi||typeof WandNative.updateSessionProgress!="function"||e&&(Gu[e]&&clearTimeout(Gu[e]),Gu[e]=setTimeout(function(){delete Gu[e],hO(e)},vO))}function hO(e){var t=s.sessions.find(function(k){return k.id===e});if(t){var a=t.summary||t.command||e,i=t.status||"running";if(i==="idle"||i==="archived"||i==="exited"){Px(e);return}for(var o=null,c="",d="",f=[],v=t.messages||[],g=v.length-1;g>=0;g--){var h=v[g];if(!(!h.content||!Array.isArray(h.content))){if(!d&&h.role==="assistant")for(var b=h.content.length-1;b>=0;b--){var w=h.content[b];if(w&&w.type==="text"&&w.text&&w.text.trim()){d=qx(w.text);break}}if(h.role==="user"){var C=h.content.some(function(k){return k&&k.__queued});if(!C)for(var y=0;y<h.content.length;y++){var x=h.content[y];if(x&&x.type==="text"&&x.text&&x.text.trim()){var E=qx(x.text);c||(c=E),f.length<4&&f.push(E);break}}}if(!o)for(var D=h.content.length-1;D>=0;D--){var A=h.content[D];if(A&&A.type==="tool_use"&&A.name==="TodoWrite"&&A.input&&A.input.todos){o=A.input.todos;break}}if(o&&f.length>=4&&d)break}}f.reverse();var B="";e===s.selectedId&&s.currentTask&&s.currentTask.title&&(B=s.currentTask.title);var j={sessionLabel:a,status:i,currentTask:B,latestUserText:c,latestAssistantText:d,todos:o||[],recentUserTexts:f};try{WandNative.updateSessionProgress(e,JSON.stringify(j))}catch{}}}function Px(e){if(!(!qi||typeof WandNative.clearSessionProgress!="function")){Gu[e]&&(clearTimeout(Gu[e]),delete Gu[e]);try{WandNative.clearSessionProgress(e)}catch{}}}window.handleNativeBack=function(){if(Hu.isOpen())return!0;var e=window.__wandReactUi;if(e&&typeof e.closeTopmost=="function")try{if(e.closeTopmost())return!0}catch{}var t=window.__wandReactFilePreview;if(t&&typeof t.closeTopmost=="function")try{if(t.closeTopmost())return!0}catch{}var a=window.__wandReactQuickCommit;if(a&&typeof a.closeTopmost=="function")try{if(a.closeTopmost())return!0}catch{}var i=window.__wandReactNewSession;if(i&&typeof i.closeTopmost=="function")try{if(i.closeTopmost())return!0}catch{}var o=window.__wandReactFolderPicker;if(o&&typeof o.closeTopmost=="function")try{if(o.closeTopmost())return!0}catch{}var c=window.__wandReactWorktreeMerge;if(c&&typeof c.closeTopmost=="function")try{if(c.closeTopmost())return!0}catch{}var d=window.__wandReactSettings;if(d&&typeof d.closeTopmost=="function")try{if(d.closeTopmost())return!0}catch{}return s.filePanelOpen&&fn()?(w0(!1),!0):s.sessionsDrawerOpen&&fn()?(cs(),!0):fn()&&s.selectedId?(s.selectedId=null,Qt(),s.sessionsDrawerOpen=!0,_t("wand-sidebar-open",!0),Hi(),!0):!1};function Ux(){s.notifSound&&gO()}function gO(){try{let o=function(c,d,f){var v=a.createOscillator(),g=a.createGain();v.type="sine",v.frequency.value=c,g.gain.setValueAtTime(0,a.currentTime+d),g.gain.linearRampToValueAtTime(.5*i,a.currentTime+d+.04),g.gain.exponentialRampToValueAtTime(.001,a.currentTime+d+f),v.connect(g),g.connect(a.destination),v.start(a.currentTime+d),v.stop(a.currentTime+d+f)};var e=o,t=window.AudioContext||window.webkitAudioContext;if(!t)return!1;var a=new t;a.state==="suspended"&&a.resume();var i=(s.notifVolume||0)/100;return o(523,0,.25),o(659,.12,.3),setTimeout(function(){a.close()},600),!0}catch{return!1}}function bO(e,t){if(s._updateBubbleShown)return;s._updateBubbleShown=!0,Ux();var a=++Nx,i=document.createElement("div");i.className="notification-bubble update-card",i.setAttribute("data-nid",String(a)),i.innerHTML='<div class="update-card-shine" aria-hidden="true"></div><div class="update-card-header"><div class="update-card-icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5"/><path d="M5 12l7-7 7 7"/></svg></div><div class="update-card-heading"><div class="update-card-title">\u53D1\u73B0\u65B0\u7248\u672C</div><div class="update-card-subtitle" id="update-card-subtitle">\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u4E00\u952E\u66F4\u65B0</div></div><button class="update-card-close" title="\u7A0D\u540E\u63D0\u9192" aria-label="\u5173\u95ED"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg></button></div><div class="update-card-version"><span class="update-card-version-chip update-card-version-current">v'+q(String(e).replace(/^v/,""))+'</span><svg class="update-card-version-arrow" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 5l7 7-7 7"/></svg><span class="update-card-version-chip update-card-version-latest">v'+q(String(t).replace(/^v/,""))+'</span></div><div class="update-card-progress" id="update-card-progress" aria-hidden="true"><div class="update-card-progress-track"><div class="update-card-progress-fill"></div></div></div><div class="update-card-status hidden" id="update-card-status"></div><div class="update-card-actions"><button class="update-card-action update-card-action-primary" id="update-bubble-action" type="button"><span class="update-card-action-label">\u7ACB\u5373\u66F4\u65B0</span></button></div>',document.body.appendChild(i);var o={id:a,el:i};Yr.push(o),Q0();var c=i.querySelector(".update-card-close");c&&(c.onclick=function(){Gl(a),s._updateBubbleShown=!1});var d=i.querySelector("#update-bubble-action"),f=i.querySelector(".update-card-action-label"),v=i.querySelector("#update-card-subtitle"),g=i.querySelector("#update-card-status"),h=i.querySelector("#update-card-progress");function b(y,x){if(g){if(g.textContent=y||"",g.classList.remove("hidden","error","success"),!y){g.classList.add("hidden");return}x&&g.classList.add(x)}}function w(y){v&&(v.textContent=y||"")}function C(y){h&&h.classList.toggle("active",!!y)}d&&(d.onclick=function(){d.disabled=!0,i.classList.add("is-busy"),f&&(f.textContent="\u66F4\u65B0\u4E2D\u2026"),w("\u6B63\u5728\u4E0B\u8F7D\u5E76\u5B89\u88C5\u65B0\u7248\u672C\u2026"),C(!0),b(""),fetch("/api/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin"}).then(function(y){return y.json()}).then(function(y){if(y.error){C(!1),i.classList.remove("is-busy"),w("\u66F4\u65B0\u672A\u5B8C\u6210"),b(y.error,"error"),d.disabled=!1,f&&(f.textContent="\u91CD\u8BD5");return}if(i.classList.add("is-success"),w((y.message||"\u66F4\u65B0\u5B8C\u6210")+"\uFF0C\u6B63\u5728\u91CD\u542F\u670D\u52A1\u2026"),b(""),f&&(f.textContent="\u6B63\u5728\u91CD\u542F\u2026"),y.detachedUpdate){Wl();return}if(y.restartRequired===!1){C(!1),i.classList.remove("is-busy"),d.disabled=!1,f&&(f.textContent="\u5DF2\u5B8C\u6210");return}wO(d,f,v,g,h)}).catch(function(){C(!1),i.classList.remove("is-busy"),w("\u66F4\u65B0\u672A\u5B8C\u6210"),b("\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u540E\u91CD\u8BD5","error"),d.disabled=!1,f&&(f.textContent="\u91CD\u8BD5")})})}function wO(e,t,a,i,o){fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin"}).then(function(c){return c.json()}).then(function(){Wl()}).catch(function(){Wl()})}function Wl(e,t){yk(e,t)}function yO(e,t,a){xk(e,t,a)}var zt={recording:!1,canceling:!1,transcript:"",startY:0},xO=60;function EO(e){zt.transcript=e||"";var t=document.getElementById("voice-transcript-text");t&&(t.textContent=zt.transcript);var a=document.getElementById("voice-transcript-bubble");a&&a.classList.toggle("has-text",!!zt.transcript)}function FO(e){if(!(s.terminalInteractive||zt.recording||s.promptOptimizeRequest&&s.promptOptimizeRequest.sessionId===s.selectedId)){if(e){e.preventDefault(),zt.startY=typeof e.clientY=="number"?e.clientY:0;try{e.pointerId!==void 0&&e.currentTarget&&e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId)}catch{}}zt.recording=!0,zt.canceling=!1,zt.transcript="";var t=document.getElementById("voice-record-btn");if(t){t.classList.add("is-recording"),t.setAttribute("aria-pressed","true"),t.setAttribute("title","\u677E\u5F00\u7ED3\u675F \xB7 \u4E0A\u6ED1\u53D6\u6D88");var a=t.querySelector(".voice-record-label");a&&(a.textContent="\u677E\u5F00 \u53D1\u9001")}var i=document.getElementById("voice-transcript-bubble");i&&i.classList.remove("hidden","is-canceling","has-text"),EO("");var o=document.getElementById("voice-transcript-status");o&&(o.textContent="\u7F51\u9875\u7AEF\u6682\u4E0D\u652F\u6301\u8BED\u97F3\u8F93\u5165\uFF0C\u8BF7\u4F7F\u7528 App")}}function CO(e){if(!(!zt.recording||!e)){var t=zt.startY-(typeof e.clientY=="number"?e.clientY:zt.startY),a=t>xO;if(a!==zt.canceling){zt.canceling=a;var i=document.getElementById("voice-transcript-bubble");i&&i.classList.toggle("is-canceling",a);var o=document.getElementById("voice-record-btn"),c=o&&o.querySelector(".voice-record-label");c&&(c.textContent=a?"\u677E\u5F00 \u53D6\u6D88":"\u677E\u5F00 \u53D1\u9001");var d=document.getElementById("voice-transcript-status");d&&(d.textContent=a?"\u677E\u5F00\u624B\u6307 \u53D6\u6D88":"\u6B63\u5728\u8046\u542C\u2026\u4E0A\u6ED1\u53D6\u6D88")}}}function Vx(e){if(zt.recording){e&&e.preventDefault(),zt.recording=!1;var t=!zt.canceling&&!!zt.transcript.trim(),a=zt.transcript;Gx(),t&&AO(a)}}function DO(e){zt.recording&&(zt.canceling=!0,Vx(e))}function Gx(){zt.canceling=!1;var e=document.getElementById("voice-record-btn");if(e){e.classList.remove("is-recording"),e.setAttribute("aria-pressed","false"),e.setAttribute("title","\u6309\u4F4F\u8BED\u97F3\u8F93\u5165");var t=e.querySelector(".voice-record-label");t&&(t.textContent="\u6309\u4F4F \u8BF4\u8BDD")}var a=document.getElementById("voice-transcript-bubble");a&&a.classList.add("hidden")}function AO(e){if(!(s.promptOptimizeRequest&&s.promptOptimizeRequest.sessionId===s.selectedId)){var t=(e||"").trim();if(t){var a=document.getElementById("input-box");if(a){var i=a.value||"",o=i?i.replace(/\s+$/,"")+" "+t:t;a.value=o,fs(o,!0),Qn(a);try{a.setSelectionRange(o.length,o.length)}catch{}}}}}function Qn(e){if(e){var t=40,a=parseFloat(window.getComputedStyle(e).maxHeight||""),i=Number.isFinite(a)?Math.max(t,a):120,o=is();if(!e.value||e.value.trim()===""){e.style.height=t+"px",e.style.minHeight=t+"px",e.style.overflowY=o?"auto":"hidden",e.scrollTop=0,e.classList.remove("has-multiline-draft","has-clipped-draft"),e.closest(".input-composer")?.classList.remove("is-expanded"),pc(e);return}var c=e.scrollTop,d=e.selectionStart===e.value.length&&e.selectionEnd===e.value.length;e.style.overflowY="hidden",e.style.height=t+"px";var f=e.scrollHeight,v=Math.max(t,Math.min(f,i)),g=f>i,h=f>t+1;if(e.style.height=v+"px",e.style.minHeight=t+"px",e.style.overflowY=g||o?"auto":"hidden",e.classList.toggle("has-multiline-draft",h),e.classList.toggle("has-clipped-draft",g),e.closest(".input-composer")?.classList.toggle("is-expanded",h),g)if(d)Gf(e);else{var b=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop=Math.min(c,b)}else e.scrollTop=0;pc(e)}}var Ql=!1;function Yx(e){return!e||e.archived?!1:it(e)?!!(e.structuredState&&e.structuredState.inFlight):e.status==="running"}function eh(){return s.sessions.some(Yx)}function SO(){var e=s.sessions.filter(Yx);if(e.length===0)return null;if(s.selectedId){var t=e.find(function(a){return a.id===s.selectedId});if(t)return t}return e.sort(function(a,i){return(Date.parse(i.startedAt)||0)-(Date.parse(a.startedAt)||0)}),e[0]}function Kx(e){if(!e)return"";for(var t=Array.isArray(e.queuedMessages)?e.queuedMessages:[],a=t.length-1;a>=0;a--){var i=typeof t[a]=="string"?t[a].trim():"";if(i)return i}for(var o=Array.isArray(e.messages)?e.messages:[],c=o.length-1;c>=0;c--){var d=o[c];if(!(!d||d.role!=="user"||!Array.isArray(d.content))){var f=d.content.filter(function(h){return h&&h.type==="text"&&typeof h.text=="string"}).map(function(h){return h.text});if(f.length)return f.join(`
3728
+ `)[0].trim();return a.length>100&&(a=a.slice(0,100)+"\u2026"),a}function J0(e){!qi||typeof WandNative.updateSessionProgress!="function"||e&&(Gu[e]&&clearTimeout(Gu[e]),Gu[e]=setTimeout(function(){delete Gu[e],hO(e)},vO))}function hO(e){var t=s.sessions.find(function(k){return k.id===e});if(t){var a=t.summary||t.command||e,i=t.status||"running";if(i==="idle"||i==="archived"||i==="exited"){Px(e);return}for(var o=null,c="",d="",f=[],v=t.messages||[],g=v.length-1;g>=0;g--){var h=v[g];if(!(!h.content||!Array.isArray(h.content))){if(!d&&h.role==="assistant")for(var b=h.content.length-1;b>=0;b--){var w=h.content[b];if(w&&w.type==="text"&&w.text&&w.text.trim()){d=qx(w.text);break}}if(h.role==="user"){var C=h.content.some(function(k){return k&&k.__queued});if(!C)for(var y=0;y<h.content.length;y++){var x=h.content[y];if(x&&x.type==="text"&&x.text&&x.text.trim()){var E=qx(x.text);c||(c=E),f.length<4&&f.push(E);break}}}if(!o)for(var D=h.content.length-1;D>=0;D--){var A=h.content[D];if(A&&A.type==="tool_use"&&A.name==="TodoWrite"&&A.input&&A.input.todos){o=A.input.todos;break}}if(o&&f.length>=4&&d)break}}f.reverse();var B="";e===s.selectedId&&s.currentTask&&s.currentTask.title&&(B=s.currentTask.title);var j={sessionLabel:a,status:i,currentTask:B,latestUserText:c,latestAssistantText:d,todos:o||[],recentUserTexts:f};try{WandNative.updateSessionProgress(e,JSON.stringify(j))}catch{}}}function Px(e){if(!(!qi||typeof WandNative.clearSessionProgress!="function")){Gu[e]&&(clearTimeout(Gu[e]),delete Gu[e]);try{WandNative.clearSessionProgress(e)}catch{}}}window.handleNativeBack=function(){if(Hu.isOpen())return!0;var e=window.__wandReactUi;if(e&&typeof e.closeTopmost=="function")try{if(e.closeTopmost())return!0}catch{}var t=window.__wandReactFilePreview;if(t&&typeof t.closeTopmost=="function")try{if(t.closeTopmost())return!0}catch{}var a=window.__wandReactQuickCommit;if(a&&typeof a.closeTopmost=="function")try{if(a.closeTopmost())return!0}catch{}var i=window.__wandReactNewSession;if(i&&typeof i.closeTopmost=="function")try{if(i.closeTopmost())return!0}catch{}var o=window.__wandReactFolderPicker;if(o&&typeof o.closeTopmost=="function")try{if(o.closeTopmost())return!0}catch{}var c=window.__wandReactWorktreeMerge;if(c&&typeof c.closeTopmost=="function")try{if(c.closeTopmost())return!0}catch{}var d=window.__wandReactSettings;if(d&&typeof d.closeTopmost=="function")try{if(d.closeTopmost())return!0}catch{}return s.filePanelOpen&&fn()?(w0(!1),!0):s.sessionsDrawerOpen&&fn()?(cs(),!0):fn()&&s.selectedId?(s.selectedId=null,Qt(),s.sessionsDrawerOpen=!0,_t("wand-sidebar-open",!0),Hi(),!0):!1};function Ux(){s.notifSound&&gO()}function gO(){try{let o=function(c,d,f){var v=a.createOscillator(),g=a.createGain();v.type="sine",v.frequency.value=c,g.gain.setValueAtTime(0,a.currentTime+d),g.gain.linearRampToValueAtTime(.5*i,a.currentTime+d+.04),g.gain.exponentialRampToValueAtTime(.001,a.currentTime+d+f),v.connect(g),g.connect(a.destination),v.start(a.currentTime+d),v.stop(a.currentTime+d+f)};var e=o,t=window.AudioContext||window.webkitAudioContext;if(!t)return!1;var a=new t;a.state==="suspended"&&a.resume();var i=(s.notifVolume||0)/100;return o(523,0,.25),o(659,.12,.3),setTimeout(function(){a.close()},600),!0}catch{return!1}}function bO(e,t){if(s._updateBubbleShown)return;s._updateBubbleShown=!0,Ux();var a=++Nx,i=document.createElement("div");i.className="notification-bubble update-card",i.setAttribute("data-nid",String(a)),i.innerHTML='<div class="update-card-shine" aria-hidden="true"></div><div class="update-card-header"><div class="update-card-icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5"/><path d="M5 12l7-7 7 7"/></svg></div><div class="update-card-heading"><div class="update-card-title">\u53D1\u73B0\u65B0\u7248\u672C</div><div class="update-card-subtitle" id="update-card-subtitle">\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u4E00\u952E\u66F4\u65B0</div></div><button class="update-card-close" title="\u7A0D\u540E\u63D0\u9192" aria-label="\u5173\u95ED"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg></button></div><div class="update-card-version"><span class="update-card-version-chip update-card-version-current">v'+q(String(e).replace(/^v/,""))+'</span><svg class="update-card-version-arrow" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 5l7 7-7 7"/></svg><span class="update-card-version-chip update-card-version-latest">v'+q(String(t).replace(/^v/,""))+'</span></div><div class="update-card-progress" id="update-card-progress" aria-hidden="true"><div class="update-card-progress-track"><div class="update-card-progress-fill"></div></div></div><div class="update-card-status hidden" id="update-card-status"></div><div class="update-card-actions"><button class="update-card-action update-card-action-primary" id="update-bubble-action" type="button"><span class="update-card-action-label">\u7ACB\u5373\u66F4\u65B0</span></button></div>',document.body.appendChild(i);var o={id:a,el:i};Yr.push(o),Q0();var c=i.querySelector(".update-card-close");c&&(c.onclick=function(){Gl(a),s._updateBubbleShown=!1});var d=i.querySelector("#update-bubble-action"),f=i.querySelector(".update-card-action-label"),v=i.querySelector("#update-card-subtitle"),g=i.querySelector("#update-card-status"),h=i.querySelector("#update-card-progress");function b(y,x){if(g){if(g.textContent=y||"",g.classList.remove("hidden","error","success"),!y){g.classList.add("hidden");return}x&&g.classList.add(x)}}function w(y){v&&(v.textContent=y||"")}function C(y){h&&h.classList.toggle("active",!!y)}d&&(d.onclick=function(){d.disabled=!0,i.classList.add("is-busy"),f&&(f.textContent="\u66F4\u65B0\u4E2D\u2026"),w("\u6B63\u5728\u4E0B\u8F7D\u5E76\u5B89\u88C5\u65B0\u7248\u672C\u2026"),C(!0),b(""),fetch("/api/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin"}).then(function(y){return y.json()}).then(function(y){if(y.error){C(!1),i.classList.remove("is-busy"),w("\u66F4\u65B0\u672A\u5B8C\u6210"),b(y.error,"error"),d.disabled=!1,f&&(f.textContent="\u91CD\u8BD5");return}if(i.classList.add("is-success"),w((y.message||"\u66F4\u65B0\u5B8C\u6210")+"\uFF0C\u6B63\u5728\u91CD\u542F\u670D\u52A1\u2026"),b(""),f&&(f.textContent="\u6B63\u5728\u91CD\u542F\u2026"),y.detachedUpdate){Wl();return}if(y.restartRequired===!1){C(!1),i.classList.remove("is-busy"),d.disabled=!1,f&&(f.textContent="\u5DF2\u5B8C\u6210");return}wO(d,f,v,g,h)}).catch(function(){C(!1),i.classList.remove("is-busy"),w("\u66F4\u65B0\u672A\u5B8C\u6210"),b("\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u540E\u91CD\u8BD5","error"),d.disabled=!1,f&&(f.textContent="\u91CD\u8BD5")})})}function wO(e,t,a,i,o){fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin"}).then(function(c){return c.json()}).then(function(){Wl()}).catch(function(){Wl()})}function Wl(e,t){yk(e,t)}function yO(e,t,a){xk(e,t,a)}var zt={recording:!1,canceling:!1,transcript:"",startY:0},xO=60;function EO(e){zt.transcript=e||"";var t=document.getElementById("voice-transcript-text");t&&(t.textContent=zt.transcript);var a=document.getElementById("voice-transcript-bubble");a&&a.classList.toggle("has-text",!!zt.transcript)}function FO(e){if(!(s.terminalInteractive||zt.recording||s.promptOptimizeRequest&&s.promptOptimizeRequest.sessionId===s.selectedId)){if(e){e.preventDefault(),zt.startY=typeof e.clientY=="number"?e.clientY:0;try{e.pointerId!==void 0&&e.currentTarget&&e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId)}catch{}}zt.recording=!0,zt.canceling=!1,zt.transcript="";var t=document.getElementById("voice-record-btn");if(t){t.classList.add("is-recording"),t.setAttribute("aria-pressed","true"),t.setAttribute("title","\u677E\u5F00\u7ED3\u675F \xB7 \u4E0A\u6ED1\u53D6\u6D88");var a=t.querySelector(".voice-record-label");a&&(a.textContent="\u677E\u5F00 \u53D1\u9001")}var i=document.getElementById("voice-transcript-bubble");i&&i.classList.remove("hidden","is-canceling","has-text"),EO("");var o=document.getElementById("voice-transcript-status");o&&(o.textContent="\u7F51\u9875\u7AEF\u6682\u4E0D\u652F\u6301\u8BED\u97F3\u8F93\u5165\uFF0C\u8BF7\u4F7F\u7528 App")}}function CO(e){if(!(!zt.recording||!e)){var t=zt.startY-(typeof e.clientY=="number"?e.clientY:zt.startY),a=t>xO;if(a!==zt.canceling){zt.canceling=a;var i=document.getElementById("voice-transcript-bubble");i&&i.classList.toggle("is-canceling",a);var o=document.getElementById("voice-record-btn"),c=o&&o.querySelector(".voice-record-label");c&&(c.textContent=a?"\u677E\u5F00 \u53D6\u6D88":"\u677E\u5F00 \u53D1\u9001");var d=document.getElementById("voice-transcript-status");d&&(d.textContent=a?"\u677E\u5F00\u624B\u6307 \u53D6\u6D88":"\u6B63\u5728\u8046\u542C\u2026\u4E0A\u6ED1\u53D6\u6D88")}}}function Vx(e){if(zt.recording){e&&e.preventDefault(),zt.recording=!1;var t=!zt.canceling&&!!zt.transcript.trim(),a=zt.transcript;Gx(),t&&AO(a)}}function DO(e){zt.recording&&(zt.canceling=!0,Vx(e))}function Gx(){zt.canceling=!1;var e=document.getElementById("voice-record-btn");if(e){e.classList.remove("is-recording"),e.setAttribute("aria-pressed","false"),e.setAttribute("title","\u6309\u4F4F\u8BED\u97F3\u8F93\u5165");var t=e.querySelector(".voice-record-label");t&&(t.textContent="\u6309\u4F4F \u8BF4\u8BDD")}var a=document.getElementById("voice-transcript-bubble");a&&a.classList.add("hidden")}function AO(e){if(!(s.promptOptimizeRequest&&s.promptOptimizeRequest.sessionId===s.selectedId)){var t=(e||"").trim();if(t){var a=document.getElementById("input-box");if(a){var i=a.value||"",o=i?i.replace(/\s+$/,"")+" "+t:t;a.value=o,fs(o,!0),Qn(a);try{a.setSelectionRange(o.length,o.length)}catch{}}}}}function Qn(e){if(e){e.style.minHeight="";var t=window.getComputedStyle(e),a=parseFloat(t.minHeight||""),i=Number.isFinite(a)?a:40,o=parseFloat(t.maxHeight||""),c=Number.isFinite(o)?Math.max(i,o):120,d=is();if(!e.value||e.value.trim()===""){e.style.height=i+"px",e.style.minHeight=i+"px",e.style.overflowY=d?"auto":"hidden",e.scrollTop=0,e.classList.remove("has-multiline-draft","has-clipped-draft"),e.closest(".input-composer")?.classList.remove("is-expanded"),pc(e);return}var f=e.scrollTop,v=e.selectionStart===e.value.length&&e.selectionEnd===e.value.length;e.style.overflowY="hidden",e.style.height=i+"px";var g=e.scrollHeight,h=Math.max(i,Math.min(g,c)),b=g>c,w=g>i+1;if(e.style.height=h+"px",e.style.minHeight=i+"px",e.style.overflowY=b||d?"auto":"hidden",e.classList.toggle("has-multiline-draft",w),e.classList.toggle("has-clipped-draft",b),e.closest(".input-composer")?.classList.toggle("is-expanded",w),b)if(v)Gf(e);else{var C=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop=Math.min(f,C)}else e.scrollTop=0;pc(e)}}var Ql=!1;function Yx(e){return!e||e.archived?!1:it(e)?!!(e.structuredState&&e.structuredState.inFlight):e.status==="running"}function eh(){return s.sessions.some(Yx)}function SO(){var e=s.sessions.filter(Yx);if(e.length===0)return null;if(s.selectedId){var t=e.find(function(a){return a.id===s.selectedId});if(t)return t}return e.sort(function(a,i){return(Date.parse(i.startedAt)||0)-(Date.parse(a.startedAt)||0)}),e[0]}function Kx(e){if(!e)return"";for(var t=Array.isArray(e.queuedMessages)?e.queuedMessages:[],a=t.length-1;a>=0;a--){var i=typeof t[a]=="string"?t[a].trim():"";if(i)return i}for(var o=Array.isArray(e.messages)?e.messages:[],c=o.length-1;c>=0;c--){var d=o[c];if(!(!d||d.role!=="user"||!Array.isArray(d.content))){var f=d.content.filter(function(h){return h&&h.type==="text"&&typeof h.text=="string"}).map(function(h){return h.text});if(f.length)return f.join(`
3729
3729
  `).trim();for(var v=0;v<d.content.length;v++){var g=d.content[v];if(g&&g.type==="tool_result"&&typeof g.content=="string")return g.content.trim()}return""}}return""}var Wx={};function _f(e){return e&&Wx[e]||0}function Kr(e){if(!e)return 0;var t=_f(e)+1;return Wx[e]=t,t}function Qx(e,t,a){var i=s.sessions.find(function(d){return d.id===e}),o=i&&Array.isArray(i.queuedMessages)?i.queuedMessages.slice():[],c=typeof a=="number"&&o[a]===t?a:o.lastIndexOf(t);return c>=0&&o.splice(c,1),o}function th(e,t,a,i){return!e||!e.queuedMessages||(_f(t)!==a||s.queueEpoch>i)&&delete e.queuedMessages,e}function BO(e,t){var a=typeof t=="string"?t.trim():"";if(a&&Kx(e)===a)return be("\u4E0E\u4E0A\u4E00\u6761\u6D88\u606F\u76F8\u540C\uFF0C\u5DF2\u5FFD\u7565\uFF0C\u4E0D\u4F1A\u52A0\u5165\u6392\u961F\u3002","warning"),Promise.resolve();var i=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,10),o=Array.isArray(e.queuedMessages)?e.queuedMessages.slice():[],c=o.slice();c.push(t);var d=Kr(e.id),f=s.queueEpoch;ut({id:e.id,queuedMessages:c}),e.id===s.selectedId&&Ln();var v=e.title||os(e.command)||"\u5F53\u524D\u4F1A\u8BDD";return be("\u5DF2\u52A0\u5165\u300C"+v+"\u300D\u7684\u6392\u961F\uFF0C\u56DE\u590D\u7ED3\u675F\u540E\u81EA\u52A8\u53D1\u9001\uFF08\u542B\u4E0A\u4E0B\u6587\uFF09\u3002","info"),fetch("/api/structured-sessions/"+e.id+"/messages",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({input:t,idempotencyKey:i,...xr(e)?{skills:rc(e)}:{}})}).then(function(g){return g.ok?g.json():g.json().catch(function(){return{error:"\u8BF7\u6C42\u5931\u8D25"}}).then(function(h){throw new Error(h&&h.error||"\u65E0\u6CD5\u6392\u961F\u6D88\u606F\u3002")})}).then(function(g){g&&g.id&&(th(g,e.id,d,f),ut(g),g.id===s.selectedId&&Ln())}).catch(function(g){var h=Qx(e.id,t,o.length);Kr(e.id),ut({id:e.id,queuedMessages:h}),e.id===s.selectedId&&Ln(),be(g&&g.message||"\u6392\u961F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002","error")})}function Xx(e){var t=SO();if(t&&it(t)){BO(t,e);return}if(s.crossSessionQueue.length>=10){be("\u6392\u961F\u6D88\u606F\u5DF2\u6EE1\uFF08\u6700\u591A 10 \u6761\uFF09\uFF0C\u8BF7\u7B49\u5F85\u5F53\u524D\u4F1A\u8BDD\u5B8C\u6210\u3002","warning");return}var a="csq-"+Date.now()+"-"+Math.random().toString(36).slice(2,8);s.crossSessionQueue.push({id:a,text:e,cwd:Gr(),mode:s.chatMode||"managed",tool:tr(),queuedAt:Date.now()}),kr(),er(),be("\u5DF2\u6392\u961F\uFF0C\u5C06\u5728\u7A7A\u95F2\u540E\u81EA\u52A8\u5F00\u59CB\u65B0\u4F1A\u8BDD\u3002","info")}function kO(e){Ql||(Ql=!0,fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(Qi({command:e.tool,cwd:e.cwd,mode:e.mode,initialInput:e.text}))}).then(function(t){return t.json()}).then(function(t){return Ql=!1,t.error?(be(t.error,"error"),s.crossSessionQueue.unshift(e),kr(),er(),null):Pf(t)}).catch(function(t){Ql=!1,be(t&&t.message||"\u65E0\u6CD5\u542F\u52A8\u6392\u961F\u4F1A\u8BDD\u3002","error"),s.crossSessionQueue.unshift(e),kr(),er()}))}function TO(e){var t=s.crossSessionQueue.findIndex(function(i){return i.id===e});if(!(t<0)){var a=s.crossSessionQueue.splice(t,1)[0];kr(),er(),fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(Qi({command:a.tool,cwd:a.cwd,mode:a.mode,initialInput:a.text}))}).then(function(i){return i.json()}).then(function(i){return i.error?(be(i.error,"error"),s.crossSessionQueue.splice(t,0,a),kr(),er(),null):Pf(i)}).catch(function(i){be(i&&i.message||"\u65E0\u6CD5\u542F\u52A8\u6392\u961F\u4F1A\u8BDD\u3002","error"),s.crossSessionQueue.splice(t,0,a),kr(),er()})}}function jO(e){var t=s.crossSessionQueue.findIndex(function(a){return a.id===e});t<0||(s.crossSessionQueue.splice(t,1),kr(),er(),s.crossSessionQueue.length===0&&be("\u6392\u961F\u5DF2\u6E05\u7A7A\u3002","info"))}function Nf(){if(s.crossSessionQueue.length!==0&&!eh()&&!Ql){var e=s.crossSessionQueue.shift();er(),kO(e)}}function $x(e){var t=Math.floor((Date.now()-e)/1e3);if(t<60)return t+"s";var a=Math.floor(t/60);return a<60?a+"m":Math.floor(a/60)+"h"}function er(){var e=document.querySelector(".cross-session-queue"),t=document.querySelector(".input-panel"),a=document.querySelector(".structured-status-bar"),i=document.querySelector(".input-composer"),o=document.getElementById("cross-session-queue-host");if(s.crossSessionQueue.length===0){e&&e.remove(),kr();return}var c=t&&!t.classList.contains("hidden"),d=c?t:o,f=c?a||i:null;if(d){e&&e.parentNode!==d&&(e.remove(),e=null),e?c&&f&&e.nextSibling!==f&&d.insertBefore(e,f):(e=document.createElement("div"),e.className="cross-session-queue",f?d.insertBefore(e,f):d.appendChild(e));var v=s.crossSessionQueue.length,g=s.crossSessionQueue.map(function(b,w){var C=b.text.length>60?b.text.slice(0,60)+"\u2026":b.text,y=$x(b.queuedAt);return'<div class="queue-item" data-queue-id="'+q(b.id)+'"><span class="queue-item-dot"></span><span class="queue-item-text" title="'+q(b.text)+'">'+q(C)+'</span><span class="queue-item-age">'+y+'</span><button class="queue-item-send-now" data-queue-id="'+q(b.id)+'" title="\u7ACB\u5373\u53D1\u9001" type="button">\u53D1\u9001</button><button class="queue-item-cancel" data-queue-id="'+q(b.id)+'" title="\u53D6\u6D88" type="button">\xD7</button></div>'}).join(""),h=v>1?'<div class="queue-header"><span class="queue-header-label">\u6392\u961F '+v+' \u6761</span><button class="queue-header-clear" id="queue-clear-all" type="button" title="\u6E05\u7A7A\u6392\u961F">\u6E05\u7A7A</button></div>':"";e.innerHTML=h+g}}setInterval(function(){if(s.crossSessionQueue.length>0){var e=document.querySelectorAll(".queue-item-age");s.crossSessionQueue.forEach(function(t,a){e[a]&&(e[a].textContent=$x(t.queuedAt))}),Nf()}},5e3),document.addEventListener("click",function(e){var t=e.target;if(t.closest("#queue-clear-all")){e.preventDefault(),s.crossSessionQueue=[],kr(),er(),be("\u6392\u961F\u5DF2\u6E05\u7A7A\u3002","info");return}var a=t.closest(".queue-item-send-now");if(a){e.preventDefault(),TO(a.dataset.queueId);return}var i=t.closest(".queue-item-cancel");if(i){e.preventDefault(),jO(i.dataset.queueId);return}});function Zx(){var e=document.getElementById("welcome-input"),t=e?e.value.trim():"";if(t){if(eh()){e.value="",Xx(t);return}var a=document.getElementById("todo-progress");a&&a.classList.add("hidden"),e.value="",e.placeholder="\u6B63\u5728\u542F\u52A8\u2026",e.disabled=!0;var i=s.chatMode||"managed",o=Gr(),c=tr();fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(Qi({command:c,provider:c,cwd:o,mode:i,initialInput:t}))}).then(function(d){return d.json()}).then(function(d){if(d.error){be(d.error,"error"),e.placeholder="\u8F93\u5165\u6D88\u606F",e.disabled=!1;return}s.selectedId=d.id,Qt(),s.drafts[d.id]="",Da(),ut(d),St(),Xl(d.id),$u(d.id),Wi(d.id).then(function(){e.placeholder="\u8F93\u5165\u6D88\u606F",e.disabled=!1,yr(!0)})}).catch(function(d){be(d&&d.message||(c==="codex"?"\u65E0\u6CD5\u542F\u52A8 Codex \u4F1A\u8BDD\u3002":"\u65E0\u6CD5\u542F\u52A8 Claude \u4F1A\u8BDD\u3002"),"error"),e.placeholder="\u8F93\u5165\u6D88\u606F",e.disabled=!1})}}function MO(e){e=e||{};var t=document.getElementById("welcome-input"),a=document.getElementById("input-box"),i=t?t.value.trim():"",o=a?a.value:"",c=i||o.trim();if(s.selectedId){Vh(o,s.selectedId)&&eE(e);return}if(c&&eh()){a&&(a.value=""),t&&(t.value=""),pc(a),Xx(c);return}var d=s.chatMode||"managed",f=Gr(),v=tr();fetch("/api/commands",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(Qi({command:v,provider:v,cwd:f,mode:d,initialInput:c||void 0}))}).then(function(g){return g.json()}).then(function(g){return g.error?(be(g.error,"error"),null):(s.selectedId=g.id,Qt(),s.drafts[g.id]="",Da(),a&&(a.value=""),t&&(t.value=""),ut(g),St(),Xl(g.id),$u(g.id),Wi(g.id))}).catch(function(g){be(g&&g.message||(v==="codex"?"\u65E0\u6CD5\u542F\u52A8 Codex \u4F1A\u8BDD\u3002":"\u65E0\u6CD5\u542F\u52A8 Claude \u4F1A\u8BDD\u3002"),"error")})}function Xl(e){var t=At(),a=s.sessions.find(function(C){return C.id===e}),i=document.getElementById("blank-chat"),o=document.getElementById("output"),c=document.getElementById("chat-output"),d=document.getElementById("stop-button"),f=document.getElementById("terminal-title"),v=document.getElementById("terminal-info"),g=document.querySelector(".session-summary-value"),h=it(a);!t&&i&&i.classList.add("hidden"),!t&&o&&o.classList.toggle("hidden",h),!t&&c&&c.classList.remove("hidden"),h?s.currentView="chat":s.currentView="terminal";var b=a?os(a.command):"Wand",w=a?Ml(a):"\u5F00\u59CB\u5BF9\u8BDD";f&&(f.textContent=b),v&&(v.textContent=w),g&&(g.textContent=b),h||s.terminal||as(),_h(),B2(e),yr(!0),h||In("view-switch",{forceReplay:!0}),Ea("session:view")}function Jx(e,t){var a=(t||[]).map(function(i){return[i.name||"",i.size||0,i.file&&i.file.lastModified||0].join(":")}).join("|");return String(e||"").trim()+"\0"+a}function OO(e,t,a){var i=Ph(e),o=t;if(i&&i!==t&&(o=t?t+`
3730
3730
  `+i:i),Xi(e,o,!0),LR(e,a),e===s.selectedId){var c=document.getElementById("input-box");if(c){c.value=o,Qn(c);try{c.setSelectionRange(o.length,o.length)}catch{}}}Aa()}function _O(e,t){if(!(!e||!is())){var a=function(){if(!(s.selectedId!==t||!e.isConnected||e.disabled))try{e.focus({preventScroll:!0})}catch{e.focus()}};a(),requestAnimationFrame(a)}}function eE(e){e=e||{};var t=!!e.interrupt,a=document.documentElement.classList.contains("is-wand-embed-terminal");if(s.terminalInteractive&&!a)return be("\u7EC8\u7AEF\u4EA4\u4E92\u6A21\u5F0F\u5F00\u542F\u65F6\uFF0C\u8BF7\u76F4\u63A5\u5728\u7EC8\u7AEF\u4E2D\u8F93\u5165\u3002","info"),Promise.resolve();var i=document.getElementById("input-box"),o=Ui(),c=o&&o.id||s.selectedId,d=s.currentView,f=i?i.value:Ph(c),v=Qr(c);if(s.promptOptimizeRequest&&s.promptOptimizeRequest.sessionId===c||!c||!Vh(f,c))return Promise.resolve();var g=Jx(f,v),h=s.composerSubmissionsBySession[c];h||(h={},s.composerSubmissionsBySession[c]=h);var b=h[g];if(b)return b.promise||Promise.resolve();var w=IR(c);Xi(c,"",!0),i&&s.selectedId===c&&(i.value="",Qn(i)),Aa(),_O(i,c);var C={fingerprint:g,promise:null};h[g]=C;var y=Promise.resolve().then(function(){return w.length?zR(c,w).catch(function(x){be("\u9644\u4EF6\u4E0A\u4F20\u5931\u8D25: "+(x&&x.message||x),"error");var E=x instanceof Error?x:new Error(String(x));throw E.__wandToasted=!0,E}):[]}).then(function(x){var E=HR(x),D=!!f.trim(),A=E+(D?f:x.length?"\u8BF7\u67E5\u770B\u9644\u4EF6\u3002":""),B=document.getElementById("todo-progress");if(B&&c===s.selectedId&&B.classList.add("hidden"),it(o))return NO(A,i,o,{interrupt:t,composerCaptured:!0});var j=ZO(o,A);if(s.selectedId!==c)throw new Error("\u53D1\u9001\u524D\u4F1A\u8BDD\u5DF2\u5207\u6362\uFF0C\u539F\u8349\u7A3F\u5DF2\u6062\u590D\u3002");if(!s.wsConnected)throw new Error("\u7F51\u7EDC\u5DF2\u65AD\u5F00\uFF0C\u6D88\u606F\u672A\u53D1\u9001\uFF0C\u539F\u8349\u7A3F\u5DF2\u6062\u590D\u3002");return $O(o).then(function(k){if(!k){var O=new Error("\u4F1A\u8BDD\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u6D88\u606F\u672A\u53D1\u9001\u3002");throw O.__wandToasted=!0,O}if(s.selectedId!==c)throw new Error("\u53D1\u9001\u524D\u4F1A\u8BDD\u5DF2\u5207\u6362\uFF0C\u539F\u8349\u7A3F\u5DF2\u6062\u590D\u3002");return l5(),JO(j,"enter_text",30,d,k.id||c)})}).then(function(x){return A2(w),x}).catch(function(x){OO(c,f,w),x&&(x.__wandToasted||x.__wandHandled)||be(QO(x),"error")}).finally(function(){h[g]===C&&delete h[g],Object.keys(h).length===0&&s.composerSubmissionsBySession[c]===h&&delete s.composerSubmissionsBySession[c],Aa()});return C.promise=y,y}var Rf={},tE=350;function NO(e,t,a,i){i=i||{};var o=!!i.interrupt;if(!e)return Promise.resolve();if(!a){be("\u4F1A\u8BDD\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6216\u65B0\u5EFA\u4F1A\u8BDD\u3002","error");var c=new Error("\u4F1A\u8BDD\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6216\u65B0\u5EFA\u4F1A\u8BDD\u3002");return c.__wandToasted=!0,Promise.reject(c)}var d=!!(a.structuredState&&a.structuredState.inFlight&&a.status==="running");if(d&&!o&&Kx(a)===e.trim())return i.composerCaptured||(t&&a.id===s.selectedId&&(t.value="",Qn(t)),Xi(a.id,"",!0)),be("\u4E0E\u4E0A\u4E00\u6761\u6D88\u606F\u76F8\u540C\uFF0C\u5DF2\u5FFD\u7565\uFF0C\u4E0D\u4F1A\u52A0\u5165\u6392\u961F\u3002","warning"),a.id===s.selectedId&&Yu("Enter \u53D1\u9001 \xB7 Shift+Enter \u6362\u884C"),Promise.resolve();var f=Date.now(),v=!i.composerCaptured,g=Rf[a.id],h=typeof g=="number"?g:g&&g.at||0,b=typeof g=="number"?e:g&&g.input;if(v&&b===e&&f-h<tE)return console.log("[wand] postStructuredInput: duplicate submit (within "+tE+"ms) ignored for session",a.id),Promise.resolve();var w=v?{at:f,input:e}:null;w&&(Rf[a.id]=w);var C=d&&o,y=d&&!o,x=_f(a.id),E=-1,D=rl(Array.isArray(a.messages)?a.messages.slice():[]),A;if(y){var B=Array.isArray(a.queuedMessages)?a.queuedMessages.slice():[];if(E=B.length,B.push(e),x=Kr(a.id),A={id:a.id,queuedMessages:B},ut(A),a.id===s.selectedId){var j=s.sessions.find(function($){return $.id===a.id})||a;s.currentMessages=Tn(j,Xn(j,j.output,!1)),Yu("\u5DF2\u52A0\u5165\u6392\u961F\u2026"),pn(!0),Pi()}be(B.length>1?"\u5DF2\u52A0\u5165\u6392\u961F\uFF08\u5171 "+B.length+" \u6761\u7B49\u5F85\uFF09":"\u5DF2\u52A0\u5165\u6392\u961F\uFF0C\u7B49\u5F53\u524D\u56DE\u590D\u5B8C\u6210\u4F1A\u81EA\u52A8\u53D1\u9001\u3002","info")}else{var k={role:"user",content:[{type:"text",text:e}]};D.push(k);var O=Object.assign({},a.structuredState||{},{inFlight:!0});ut({id:a.id,status:"running",messages:D,structuredState:O}),a.id===s.selectedId&&(s.currentMessages=Tn(Object.assign({},a,{status:"running",messages:D,structuredState:O}),D),Yu(C?"\u5DF2\u4E2D\u65AD\uFF0C\u6B63\u5728\u5904\u7406\u65B0\u6D88\u606F\u2026":"\u601D\u8003\u4E2D\u2026"),l5(),pn(!0)),C&&be("\u5DF2\u4E2D\u65AD\u4E0A\u4E00\u6761\u56DE\u590D\uFF0C\u6B63\u5728\u5904\u7406\u65B0\u6D88\u606F\u2026","info")}i.composerCaptured||(t&&a.id===s.selectedId&&(t.value="",Qn(t)),Xi(a.id,"",!0));var P=s.queueEpoch,U=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,10);return fetch("/api/structured-sessions/"+a.id+"/messages",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({input:e,interrupt:C||void 0,idempotencyKey:U,...xr(a)?{skills:rc(a)}:{}})}).then(function($){return $.ok?$.json():$.json().catch(function(){return{error:"\u8BF7\u6C42\u5931\u8D25"}}).then(function(ne){var Z=new Error(ne&&ne.error||"\u65E0\u6CD5\u53D1\u9001\u7ED3\u6784\u5316\u6D88\u606F\u3002");throw Z.errorCode=ne&&ne.errorCode,Z.httpStatus=$.status,Z})}).then(function($){if($&&$.error)throw new Error($.error);if($&&$.id&&(th($,a.id,x,P),ut($),$.id===s.selectedId)){var ne=s.sessions.find(function(Z){return Z.id===$.id})||$;s.currentMessages=Tn(ne,Xn(ne,$.output,!1)),pn(!0),Pi()}}).catch(function($){if($&&$.errorCode==="duplicate_idempotency_key"){be($.message||"\u68C0\u6D4B\u5230\u91CD\u590D\u53D1\u9001\uFF0C\u5DF2\u62E6\u622A\u3002","warning"),a.id===s.selectedId&&Yu("Enter \u53D1\u9001 \xB7 Shift+Enter \u6362\u884C");return}if(w&&Rf[a.id]===w&&delete Rf[a.id],y){var ne=Qx(a.id,e,E);if(Kr(a.id),ut({id:a.id,queuedMessages:ne}),a.id===s.selectedId){var Z=s.sessions.find(function(te){return te.id===a.id})||a;s.currentMessages=Tn(Z,Xn(Z,Z.output,!1)),pn(!0),Pi()}}else{var he=D.slice(0,-1);ut({id:a.id,status:a.status,messages:he,structuredState:Object.assign({},a.structuredState||{},{inFlight:!1})}),a.id===s.selectedId&&(s.currentMessages=Tn(Object.assign({},a,{messages:he,structuredState:Object.assign({},a.structuredState||{},{inFlight:!1})}),he),pn(!0))}var ve=$&&$.message||"",H=ve==="Failed to fetch"||ve==="NetworkError when attempting to fetch resource."||ve==="Load failed"||/aborted|aborterror|networkerror|failed to fetch/i.test(ve);throw H||(be($&&$.message||"\u65E0\u6CD5\u53D1\u9001\u7ED3\u6784\u5316\u6D88\u606F\u3002","error"),$.__wandToasted=!0),$.__wandHandled=!0,a.id===s.selectedId&&Yu("Enter \u53D1\u9001 \xB7 Shift+Enter \u6362\u884C"),$})}function Yu(e){var t=document.querySelector(".input-hint");t&&(t.textContent=e)}function Pi(){Ln()}var RO=10,nE=26;function IO(e){if(typeof e!="string")return"";var t=e.replace(/\s+/g," ").trim();return t.length<=nE?t:t.slice(0,nE)+"\u2026"}function LO(){return!!s.queueBarExpanded}function zO(e){if(!!s.queueBarExpanded!=!!e){s.queueBarExpanded=!!e;var t=document.querySelector(".queue-bar");t&&t.classList.toggle("expanded",!!e)}}function HO(e,t,a){var i=e.length,o="queue-bar";a&&(o+=" queue-bar-capacity"),t&&(o+=" queue-bar-inflight");for(var c=t?"\u4E2D\u65AD\u5F53\u524D\u56DE\u590D\uFF0C\u7ACB\u5373\u53D1\u9001\u8FD9\u6761":"\u7ACB\u5373\u53D1\u9001\u8FD9\u6761",d="",f=0;f<i;f++){var v=e[f]==null?"":String(e[f]),g=IO(v),h=v+"\uFF08\u6309\u4F4F\u53EF\u62D6\u52A8\u8C03\u5E8F\uFF09";d+='<li class="queue-bar-item" data-index="'+f+'" data-action="drag" title="'+q(h)+'"><span class="queue-bar-item-index" aria-hidden="true">'+(f+1)+'</span><span class="queue-bar-item-text">'+q(g)+'</span><button type="button" class="queue-bar-item-promote" data-action="promote-item" title="'+q(c)+'" aria-label="\u7ACB\u5373\u53D1\u9001\u7B2C '+(f+1)+' \u6761"><svg width="11" height="11" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M13 2 L4 14 L11 14 L10 22 L20 9 L13 9 Z"/></svg></button><button type="button" class="queue-bar-item-delete" data-action="delete" aria-label="\u5220\u9664\u7B2C '+(f+1)+' \u6761\u6392\u961F\u6D88\u606F" title="\u5220\u9664"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="6" y1="6" x2="18" y2="18"/><line x1="6" y1="18" x2="18" y2="6"/></svg></button></li>'}var b="";return i>=2&&(b='<div class="queue-bar-head"><span class="queue-bar-head-count">'+i+' \u6761\u6392\u961F</span><button type="button" class="queue-bar-clear-all" data-action="clear-all" title="\u6E05\u7A7A\u5168\u90E8\u6392\u961F" aria-label="\u6E05\u7A7A\u5168\u90E8 '+i+' \u6761\u6392\u961F\u6D88\u606F">\u6E05\u7A7A</button></div>'),'<div class="'+o+'" data-queue-bar="1" title="\u6392\u961F '+i+' \u6761\uFF08\u6309\u4F4F\u6C14\u6CE1\u53EF\u8C03\u5E8F\uFF09">'+b+'<ol class="queue-bar-list" data-queue-list="1">'+d+"</ol></div>"}function Ln(){var e=document.getElementById("queue-bar-host");if(e){var t=s.sessions.find(function(d){return d.id===s.selectedId}),a=t&&t.sessionKind==="structured",i=a?Bm(t):[];if(i=Array.isArray(i)?i:[],!a||i.length===0){e.hidden=!0,e.innerHTML="",s.queueBarExpanded=!1;return}if(!s.queueBarDrag){e.hidden=!1;var o=!!(t.structuredState&&t.structuredState.inFlight&&t.status==="running"),c=i.length>=RO;e.innerHTML=HO(i,o,c)}}}function If(e,t,a){if(typeof a=="number"&&_f(e.id)!==a){Ln();return}Kr(e.id),ut({id:e.id,queuedMessages:t});var i=s.sessions.find(function(o){return o.id===e.id})||e;s.currentMessages=Tn(i,Xn(i,i.output,!1)),pn(!0),Ln()}function qO(e){var t=s.sessions.find(function(f){return f.id===s.selectedId});if(t){var a=Array.isArray(t.queuedMessages)?t.queuedMessages.slice():[];if(!(e<0||e>=a.length)){var i=a.slice(),o=a.slice(0,e).concat(a.slice(e+1)),c=Kr(t.id);ut({id:t.id,queuedMessages:o});var d=s.sessions.find(function(f){return f.id===t.id})||t;s.currentMessages=Tn(d,Xn(d,d.output,!1)),pn(!0),Ln(),fetch("/api/structured-sessions/"+t.id+"/queued/"+e,{method:"DELETE",credentials:"same-origin"}).then(function(f){if(!f.ok)return f.json().catch(function(){return{}}).then(function(v){throw new Error(v&&v.error||"\u5220\u9664\u5931\u8D25")})}).catch(function(f){If(t,i,c),be(f&&f.message||"\u5220\u9664\u6392\u961F\u6D88\u606F\u5931\u8D25\u3002","error")})}}}function PO(){var e=s.sessions.find(function(o){return o.id===s.selectedId});if(e){var t=Array.isArray(e.queuedMessages)?e.queuedMessages.slice():[];if(t.length!==0){s.queueBarExpanded=!1;var a=Kr(e.id);ut({id:e.id,queuedMessages:[]});var i=s.sessions.find(function(o){return o.id===e.id})||e;s.currentMessages=Tn(i,Xn(i,i.output,!1)),pn(!0),Ln(),fetch("/api/structured-sessions/"+e.id+"/queued",{method:"DELETE",credentials:"same-origin"}).then(function(o){if(!o.ok)return o.json().catch(function(){return{}}).then(function(c){throw new Error(c&&c.error||"\u6E05\u7A7A\u5931\u8D25")});be("\u5DF2\u6E05\u7A7A "+t.length+" \u6761\u6392\u961F\u6D88\u606F\u3002","info")}).catch(function(o){If(e,t,a),be(o&&o.message||"\u6E05\u7A7A\u6392\u961F\u6D88\u606F\u5931\u8D25\u3002","error")})}}}function UO(e){if(!s.queueBarPromoting){var t=s.sessions.find(function(h){return h.id===s.selectedId});if(t){var a=Array.isArray(t.queuedMessages)?t.queuedMessages.slice():[];if(!(e<0||e>=a.length)){var i=a[e],o=a.slice(0,e).concat(a.slice(e+1)),c=a.slice(),d=!!(t.structuredState&&t.structuredState.inFlight&&t.status==="running");s.queueBarPromoting=!0,o.length===0&&(s.queueBarExpanded=!1);var f=Kr(t.id),v=s.queueEpoch;ut({id:t.id,queuedMessages:o});var g=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+"-"+Math.random().toString(36).slice(2,10);be(d?"\u5DF2\u8BF7\u6C42\u4E2D\u65AD\u5F53\u524D\u56DE\u590D\uFF0C\u7ACB\u5373\u53D1\u9001\u8FD9\u6761\u3002":"\u5DF2\u7ACB\u5373\u53D1\u9001\u8FD9\u6761\u6D88\u606F\u3002","info"),fetch("/api/structured-sessions/"+t.id+"/queued/"+e+"/promote",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({expectedText:i,idempotencyKey:g})}).then(function(h){return h.ok?h.json():h.json().catch(function(){return{}}).then(function(b){throw new Error(b&&b.error||"\u7ACB\u5373\u53D1\u9001\u5931\u8D25")})}).then(function(h){if(h&&h.id&&(th(h,t.id,f,v),ut(h),h.id===s.selectedId)){var b=s.sessions.find(function(w){return w.id===h.id})||h;s.currentMessages=Tn(b,Xn(b,h.output,!1)),pn(!0),Ln()}s.queueBarPromoting=!1}).catch(function(h){s.queueBarPromoting=!1,If(t,c,f),be(h&&h.message||"\u7ACB\u5373\u53D1\u9001\u5931\u8D25\u3002","error")})}}}}function VO(e,t){var a=s.sessions.find(function(b){return b.id===s.selectedId});if(a){var i=Array.isArray(a.queuedMessages)?a.queuedMessages.slice():[];if(!(i.length<=1)&&t){var o=t.parentElement;if(o){var c=Number(t.getAttribute("data-index")),d=Array.prototype.slice.call(o.children),f=d.map(function(b){return b.getBoundingClientRect()}),v=3;f.length>=2&&(v=Math.max(0,f[1].top-f[0].top-f[0].height)),e.preventDefault();try{t.setPointerCapture(e.pointerId)}catch{}if(navigator&&navigator.vibrate)try{navigator.vibrate(8)}catch{}s.queueBarDrag={pointerId:e.pointerId,handleEl:t,itemEl:t,listEl:o,siblings:d,rects:f,origIndex:c,targetIndex:c,startY:e.clientY,gap:v,queueSnapshot:i},t.classList.add("dragging"),d.forEach(function(b){b!==t&&b.classList.add("queue-bar-item-sliding")});var g=function(b){YO(b)},h=function(b){KO(b)};s.queueBarDrag.moveHandler=g,s.queueBarDrag.upHandler=h,t.addEventListener("pointermove",g),t.addEventListener("pointerup",h),t.addEventListener("pointercancel",h)}}}}function GO(e,t,a,i){for(var o=a.length,c=[],d=0;d<o;d++)c.push(d);c.splice(e,1),c.splice(t,0,e);for(var f=a[0].top,v=a[0].top,g=1;g<o;g++)a[g].top<v&&(v=a[g].top);for(var h={},b=v,w=0;w<o;w++){var C=c[w];h[C]=b,b+=a[C].height+i}return h}function YO(e){var t=s.queueBarDrag;if(!(!t||e.pointerId!==t.pointerId)){e.preventDefault();var a=e.clientY-t.startY;t.itemEl.style.transform="translateY("+a+"px)";for(var i=t.rects[t.origIndex].top+t.rects[t.origIndex].height/2+a,o=t.origIndex,c=0;c<t.rects.length;c++)if(c!==t.origIndex){var d=t.rects[c].top+t.rects[c].height/2;c<t.origIndex&&i<d?o=Math.min(o,c):c>t.origIndex&&i>d&&(o=Math.max(o,c))}if(o!==t.targetIndex){t.targetIndex=o;var f=GO(t.origIndex,o,t.rects,t.gap);t.siblings.forEach(function(v,g){if(g!==t.origIndex){var h=f[g]-t.rects[g].top;v.style.transform=h?"translateY("+h+"px)":""}})}}}function KO(e){var t=s.queueBarDrag;if(!(!t||e&&e.pointerId!==t.pointerId)){try{t.handleEl.releasePointerCapture(t.pointerId)}catch{}t.handleEl.removeEventListener("pointermove",t.moveHandler),t.handleEl.removeEventListener("pointerup",t.upHandler),t.handleEl.removeEventListener("pointercancel",t.upHandler);var a=t.origIndex,i=t.targetIndex,o=t.queueSnapshot;if(t.siblings.forEach(function(h){h.style.transform="",h.classList.remove("queue-bar-item-sliding")}),t.itemEl.classList.remove("dragging"),s.queueBarDrag=null,a===i){Ln();return}for(var c=[],d=0;d<o.length;d++)c.push(d);c.splice(a,1),c.splice(i,0,a);var f=c.map(function(h){return o[h]}),v=s.sessions.find(function(h){return h.id===s.selectedId});if(!v){Ln();return}var g=Kr(v.id);ut({id:v.id,queuedMessages:f}),Ln(),fetch("/api/structured-sessions/"+v.id+"/queued",{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({order:c})}).then(function(h){if(!h.ok)return h.json().catch(function(){return{}}).then(function(b){throw new Error(b&&b.error||"\u6392\u5E8F\u5931\u8D25")})}).catch(function(h){If(v,o,g),be(h&&h.message||"\u8C03\u6574\u6392\u961F\u987A\u5E8F\u5931\u8D25\u3002","error")})}}function WO(){var e=document.getElementById("queue-bar-host");!e||e.__queueDelegated||(e.__queueDelegated=!0,e.addEventListener("click",function(t){var a=t.target,i=a&&a.closest?a.closest("[data-action]"):null;if(i&&e.contains(i)){var o=i.getAttribute("data-action");if(o==="drag")return;if(t.preventDefault(),t.stopPropagation(),o==="promote-item"){var c=i.closest(".queue-bar-item");c&&UO(Number(c.getAttribute("data-index")))}else if(o==="delete"){var d=i.closest(".queue-bar-item");d&&qO(Number(d.getAttribute("data-index")))}else o==="clear-all"&&PO();return}}),e.addEventListener("pointerdown",function(t){if(!(t.button!==void 0&&t.button!==0)){var a=t.target;if(!(a&&a.closest&&a.closest('[data-action="delete"], [data-action="promote-item"], [data-action="clear-all"], [data-action="expand"]'))){var i=a&&a.closest?a.closest(".queue-bar-item"):null;i&&VO(t,i)}}}),e.addEventListener("keydown",function(t){t.key==="Escape"&&LO()&&(t.stopPropagation(),zO(!1))}))}function Tn(e,t){var a=Array.isArray(t)?rl(t):[],i=Array.isArray(a)?a.slice():[];if(!e||e.sessionKind!=="structured")return i;if(e.structuredState&&e.structuredState.inFlight){var o=i[i.length-1];(!o||o.role!=="assistant")&&i.push({role:"assistant",content:[{type:"text",text:"",__processing:!0}]})}return i}function aE(){var e=s.sessions.find(function(t){return t.id===s.selectedId});pd(e),Pi()}function QO(e){var t=Ui(),a=t&&t.provider==="codex";return e&&(e.errorCode==="SESSION_NOT_RUNNING"||e.errorCode==="SESSION_NO_PTY")?a?"Codex \u4F1A\u8BDD\u5DF2\u7ED3\u675F\uFF1B\u82E5\u5B58\u5728 Codex \u5386\u53F2\u4F1A\u8BDD\uFF0C\u5C06\u5728\u4F60\u4E0B\u6B21\u53D1\u9001\u6D88\u606F\u65F6\u81EA\u52A8\u6062\u590D\u3002":"\u4F1A\u8BDD\u5DF2\u7ED3\u675F\uFF1B\u82E5\u5B58\u5728 Claude \u5386\u53F2\u4F1A\u8BDD\uFF0C\u5C06\u5728\u4F60\u4E0B\u6B21\u53D1\u9001\u6D88\u606F\u65F6\u81EA\u52A8\u6062\u590D\u3002":e&&e.errorCode==="SESSION_NOT_FOUND"?"\u4F1A\u8BDD\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6216\u65B0\u5EFA\u4F1A\u8BDD\u3002":e&&e.message||(a?"Codex \u4F1A\u8BDD\u6682\u4E0D\u53EF\u7528\uFF1B\u82E5\u5B58\u5728 Codex \u5386\u53F2\u4F1A\u8BDD\uFF0C\u5C06\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D\u3002":"\u4F1A\u8BDD\u6682\u4E0D\u53EF\u7528\uFF1B\u82E5\u5B58\u5728 Claude \u5386\u53F2\u4F1A\u8BDD\uFF0C\u5C06\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D\u3002")}function rE(e){var t=new Error(e&&e.error||"\u4F1A\u8BDD\u5DF2\u7ED3\u675F\u3002");return e&&typeof e=="object"&&(t.errorCode=e.errorCode||null,t.sessionId=e.sessionId||s.selectedId||null,t.sessionStatus=Object.prototype.hasOwnProperty.call(e,"sessionStatus")?e.sessionStatus:null),t}function iE(e){return e&&(e.errorCode==="SESSION_NOT_RUNNING"||e.errorCode==="SESSION_NO_PTY"||e.errorCode==="SESSION_NOT_FOUND")}function XO(e,t){e&&ut({id:e,status:t||"exited"})}function nh(e){return!!(e&&!it(e)&&["claude","codex","opencode","grok","qoder"].indexOf(e.provider)!==-1&&e.status!=="running"&&e.claudeSessionId)}function $O(e,t){if(!e)return be("\u4F1A\u8BDD\u4E0D\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6216\u65B0\u5EFA\u4F1A\u8BDD\u3002","error"),Promise.resolve(null);if(e.status==="running")return Promise.resolve(e);if(!nh(e)){var a={claude:"Claude",codex:"Codex",opencode:"OpenCode",grok:"Grok",qoder:"Qoder"},i=e&&a[e.provider]||"Provider";return be("\u8BE5\u4F1A\u8BDD\u6CA1\u6709\u53EF\u6062\u590D\u7684 "+i+" \u5386\u53F2\u4E0A\u4E0B\u6587\uFF0C\u8BF7\u65B0\u5EFA\u4F1A\u8BDD\u3002","error"),Promise.resolve(null)}return hE(e.id,t).then(function(o){return o?(ut(o),St(),$u(o.id),Wi(o.id).then(function(){return yr(!0),o})):null})}function ZO(e,t){return[t,"\r"]}function JO(e,t,a,i,o){var c=Array.isArray(e)?e.filter(function(f){return!!f}):[];if(c.length===0)return Promise.resolve();var d=typeof a=="number"?a:0;return c.reduce(function(f,v,g){return f.then(function(){return g>0&&d>0?new Promise(function(h){setTimeout(h,d)}).then(function(){return wr(v,g===c.length-1?t:void 0,i,o)}):wr(v,g===c.length-1?t:void 0,i,o)})},Promise.resolve())}var e_=5e3,t_=100;function uE(e){e&&(s.pendingMessages.length>=t_&&s.pendingMessages.shift(),s.pendingMessages.push({input:e,at:Date.now()}))}function n_(e){if(!(typeof e!="string"||!e)){var t=e.replace(/\x1b\[200~/g,"").replace(/\x1b\[201~/g,"");/(?:^|\n)\s*\/clear\s*(?:\r|\n|$)/.test(t)&&typeof s<"u"&&s&&(s.terminalOutputMarker=(s.terminalOutput&&s.terminalOutput.length)|0)}}function wr(e,t,a,i){var o=i||s.selectedId;return!e||!o?Promise.resolve():(n_(e),s.messageQueue.push(e),s.inputQueue=s.inputQueue.then(function(){return a_(e,t,a,o,!!i).finally(function(){var c=s.messageQueue.indexOf(e);c>-1&&s.messageQueue.splice(c,1)})}),s.inputQueue)}function a_(e,t,a,i,o){var c=i||s.selectedId;if(!c)return Promise.resolve();var d=a||s.currentView,f=s.sessions.find(function(h){return h.id===c}),v=!!f&&!it(f)&&f.status==="running";if(!v){if(o){var g=new Error("\u76EE\u6807\u4F1A\u8BDD\u5DF2\u505C\u6B62\uFF0C\u6D88\u606F\u672A\u53D1\u9001\u3002");throw g.errorCode=f?"SESSION_NOT_RUNNING":"SESSION_NOT_FOUND",g}return s.wsConnected?(console.warn("[wand] postInput: session not running, skipping send",{sessionId:c}),be("\u4F1A\u8BDD\u672A\u8FD0\u884C\uFF0C\u6B63\u5728\u7B49\u5F85\u81EA\u52A8\u6062\u590D\u540E\u91CD\u8BD5\u3002","info"),Promise.resolve()):(uE(e),console.log("[wand] postInput: session not running, queued for reconnect",{sessionId:c,inputLength:e.length}),Promise.resolve())}if(!s.wsConnected){if(o)throw new Error("\u7F51\u7EDC\u5DF2\u65AD\u5F00\uFF0C\u6D88\u606F\u672A\u53D1\u9001\u3002");return uE(e),console.log("[wand] postInput: WebSocket disconnected, queued message",{sessionId:c,inputLength:e.length}),Promise.resolve()}return fetch("/api/sessions/"+c+"/input",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({input:e,view:d,shortcutKey:t||void 0})}).then(function(h){return h.ok?h.json():h.json().catch(function(){return{error:"\u8BF7\u6C42\u5931\u8D25"}}).then(function(b){var w=rE(b);throw w.httpStatus=h.status,console.error("[wand] postInput: request failed",{status:h.status,errorCode:w.errorCode,message:w.message,sessionId:c}),iE(w)&&XO(c,w.sessionStatus||"exited"),w})}).then(function(h){return h&&h.id&&(ut(h),h.id===s.selectedId&&(h.messages&&h.messages.length>0&&(s.currentMessages=h.messages),pn(!0))),h})}function Ui(){return s.sessions.find(function(e){return e.id===s.selectedId})||null}function ah(){return!!s.selectedId&&s.currentView==="terminal"}function r_(e){return!(!s.terminal||!e||e!==s.selectedId||s.terminalSessionId&&s.terminalSessionId!==e)}function oE(e){if(!s.terminalInteractive||!ah()||e.defaultPrevented||e.isComposing)return!1;var t=e.target;return t?!(document.documentElement.classList.contains("is-wand-embed-terminal")&&t.closest&&t.closest("#input-box")||t.closest&&t.closest("#mini-keyboard")||d_(t)):!0}var i_={Esc:"escape",ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",Enter:"enter",Tab:"tab",Backspace:"backspace",Home:"home",End:"end",PageUp:"pageup",PageDown:"pagedown",Delete:"delete",Insert:"insert"," ":"space"},u_={space:" ",tab:" ",shift_tab:"\x1B[Z",backspace:"\x7F",home:"\x1B[H",end:"\x1B[F",pageup:"\x1B[5~",pagedown:"\x1B[6~",delete:"\x1B[3~",insert:"\x1B[2~"},sE={" ":0,"[":27,"\\":28,"]":29,"^":30,_:31},o_=400,s_=10,l_=8,Lf=54,Vi=8,rh=[{key:"enter",label:"Enter"},{key:"ctrl_c",label:"Ctrl+C"},{key:"escape",label:"Esc"},{key:"shift_tab",label:"Shift+Tab"}],c_=new Set(["mini-keyboard-fab","mini-keyboard-toggle","terminal-interactive-toggle"]);function d_(e){return e?c_.has(e.id)?!0:!!(e.closest&&e.closest('[role="dialog"], [role="alertdialog"]')):!1}var f_=new Set(["ctrl","alt","shift"]);function lE(e){return f_.has(e)}function p_(e){return u_[e]||""}function m_(e){var t=e.toLowerCase();return t>="a"&&t<="z"?String.fromCharCode(t.charCodeAt(0)-96):Object.prototype.hasOwnProperty.call(sE,t)?String.fromCharCode(sE[t]):""}function v_(e){return i_[e.key]||e.key}function h_(e,t){return{ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey&&(t.length===1||t==="tab"),meta:e.metaKey}}function cE(e,t){e&&wr(e,t).catch(function(){})}function g_(){FE()}function ih(e){s.keyboardPopupOpen=!1,e!==!1&&Hf(),y_()}function b_(){ah()&&rs(!s.terminalInteractive)}function rs(e){var t=!!e&&ah();s.terminalInteractive!==t&&(s.terminalInteractive=t,t?(E_(),ih(!1),g_(),be("\u7EC8\u7AEF\u4EA4\u4E92\u6A21\u5F0F\u5DF2\u5F00\u542F","info")):(F_(),Hf()),Aa())}function dE(){var e=s.sessions.find(function(a){return a.id===s.selectedId}),t=!e||e.status!=="running"||s.currentView!=="terminal";if(t&&s.terminalInteractive){rs(!1);return}(!e||s.currentView!=="terminal")&&s.keyboardPopupOpen&&(s.keyboardPopupOpen=!1),Aa()}function Aa(){var e=s.sessions.find(function(he){return he.id===s.selectedId}),t=it(e),a=e&&e.provider==="codex",i=t?!!(e&&e.structuredState&&e.structuredState.inFlight):!!e&&e.status==="running",o=document.getElementById("input-box"),c=document.querySelector(".input-composer"),d=s.promptOptimizeRequest,f=!!(d&&d.sessionId===s.selectedId),v=!!d,g=["terminal-interactive-toggle-top"];g.forEach(function(he){var ve=document.getElementById(he);if(ve){ve.classList.toggle("active",s.terminalInteractive),ve.classList.toggle("is-on",s.terminalInteractive),ve.classList.toggle("hidden",t||s.currentView!=="terminal"||!e),ve.setAttribute("aria-pressed",s.terminalInteractive?"true":"false");var H=ve.querySelector(".plus-popover-toggle-state");H&&(H.textContent=s.terminalInteractive?"\u5F00":"\u5173")}});var h=document.querySelector(".input-hint");h&&(h.classList.toggle("hidden",t?!0:s.currentView==="terminal"),!t&&e&&(h.textContent=a?"Enter \u53D1\u9001 \xB7 chat \u4E3A\u89E3\u6790\u89C6\u56FE\uFF0Cterminal \u4E3A\u539F\u59CB\u8F93\u51FA":"Enter \u53D1\u9001 \xB7 Shift+Enter \u6362\u884C"));var b=!t&&!i&&nh(e);o&&(o.placeholder=JE(e,s.terminalInteractive),o.disabled=!t&&!!e&&!i&&!b,o.setAttribute("aria-disabled",o.disabled?"true":"false"),o.readOnly=f,o.setAttribute("aria-readonly",o.readOnly?"true":"false"),o.setAttribute("aria-busy",f?"true":"false"),o.classList.toggle("is-terminal-passthrough",!!s.terminalInteractive&&!document.documentElement.classList.contains("is-wand-embed-terminal"))),c&&c.classList.toggle("is-optimizing",f);var w=document.getElementById("prompt-optimize-btn");if(w){w.disabled=v,w.classList.toggle("is-loading",f),w.setAttribute("aria-busy",f?"true":"false"),w.setAttribute("aria-label",f?"\u6B63\u5728\u4F18\u5316\u63D0\u793A\u8BCD":v?"\u5176\u4ED6\u4F1A\u8BDD\u6B63\u5728\u4F18\u5316\u63D0\u793A\u8BCD":"\u4F18\u5316\u63D0\u793A\u8BCD"),w.setAttribute("title",f?"\u6B63\u5728\u4F18\u5316\u2026":v?"\u5176\u4ED6\u4F1A\u8BDD\u6B63\u5728\u4F18\u5316\u2026":"\u4F18\u5316\u63D0\u793A\u8BCD");var C=w.querySelector(".prompt-optimize-label");C&&(C.textContent=f?"\u4F18\u5316\u4E2D":"\u4F18\u5316")}var y=document.getElementById("voice-record-btn");y&&(y.disabled=s.terminalInteractive||f,y.setAttribute("aria-disabled",y.disabled?"true":"false")),(s.terminalInteractive||f)&&zt.recording&&(zt.recording=!1,Gx());var x=document.getElementById("send-input-button"),E=t&&i;if(x){var D=!t&&!!e&&!i&&!b,A=o?o.value:"",B=Qr(s.selectedId),j=Vh(A,s.selectedId),k=s.selectedId&&s.composerSubmissionsBySession[s.selectedId],O=!!(j&&k&&k[Jx(A,B)]);x.disabled=f||!j||O||D,x.setAttribute("aria-disabled",x.disabled?"true":"false"),x.setAttribute("title",f?"\u6B63\u5728\u4F18\u5316\u63D0\u793A\u8BCD":t?E?"\u6392\u961F\u53D1\u9001\uFF08\u5F53\u524D\u56DE\u590D\u7ED3\u675F\u540E\u5904\u7406\uFF09":"\u53D1\u9001":a?i?"\u53D1\u9001\u7ED9 Codex":"Codex \u4F1A\u8BDD\u5DF2\u7ED3\u675F":!e||i||b?"\u53D1\u9001":"\u4F1A\u8BDD\u5DF2\u7ED3\u675F"),x.classList.toggle("queue-mode",E)}var P=document.getElementById("stop-button");if(P){var U=Gh(e);P.classList.toggle("hidden",!U.active)}var $=document.getElementById("stop-button");if($){var ne=Gh(e);$.classList.toggle("hidden",!ne.active)}var Z=document.getElementById("output");Z&&Z.classList.toggle("interactive",!t&&s.terminalInteractive),Ex()}function zf(){var e=window.getSelection&&window.getSelection();if(!e||e.isCollapsed)return!1;var t=document.getElementById("output");if(!t)return!1;var a=e.anchorNode;return a&&a.nodeType===3&&(a=a.parentNode),!!(a&&t.contains(a))}function uh(e){if(oE(e)&&!e.metaKey){var t=v_(e);if(t){var a=h_(e,t);if(!lE(t)&&!(a.ctrl&&t.length===1&&t.toLowerCase()==="c"&&zf())){var i=fE(t,a);i&&(e.preventDefault(),cE(i,t))}}}}function w_(){s.terminal&&_M(500)}function y_(){zl()}function x_(){s.keyboardPopupOpen=!1,Aa()}function E_(){document.addEventListener("keydown",uh,!0)}function F_(){document.removeEventListener("keydown",uh,!0)}function fE(e,t){var a=t||{ctrl:!1,alt:!1,shift:!1};if(lE(e))return"";if(e==="tab"&&a.shift)return"\x1B[Z";var i=p_(e);if(i)return i;if(e.indexOf("ctrl_")===0)return String.fromCharCode(e.charCodeAt(e.length-1)-96);var o=$l(e);if(o)return o;if(!e)return"";var c=e.length===1?e:"";return c?(a.shift&&(c=c.toUpperCase()),a.ctrl?m_(c):a.alt?"\x1B"+c:c):""}function Hf(){s.modifiers.ctrl=!1,s.modifiers.alt=!1,s.modifiers.shift=!1,C_()}function C_(){var e=document.getElementById("mini-keyboard");e&&["ctrl","alt","shift"].forEach(function(t){var a=e.querySelector('[data-key="'+t+'"]');a&&a.classList.toggle("active",!!s.modifiers[t])})}function $l(e){switch(e){case"yes":return"y\r";case"no":return"n\r";case"up":return"\x1B[A";case"down":return"\x1B[B";case"left":return"\x1B[D";case"right":return"\x1B[C";case"enter":return"\r";case"ctrl_c":return"";case"ctrl_d":return"";case"ctrl_l":return"\f";case"ctrl_u":return"";case"ctrl_k":return"\v";case"ctrl_w":return"";case"ctrl_z":return"";case"escape":return"\x1B";default:return""}}function D_(){if(s.pendingMessages.length!==0){var e=Ui();if(it(e)){s.pendingMessages=[];return}var t=Date.now(),a=[],i=0;s.pendingMessages.forEach(function(c){if(typeof c=="string"){a.push(c);return}if(!(!c||typeof c.input!="string")){if(t-(c.at||0)>e_){i++;return}a.push(c.input)}}),s.pendingMessages=[],i>0&&console.log("[wand] flushPendingMessages: dropped "+i+" stale input(s)");var o=Promise.resolve();a.forEach(function(c){o=o.then(function(){return A_(c).catch(function(){})})})}}function A_(e){if(!e||!s.selectedId)return Promise.resolve();var t=s.selectedId;return fetch("/api/sessions/"+t+"/input",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({input:e,view:s.currentView})}).then(function(a){return a.ok?a.json():a.json().catch(function(){return{error:"\u8BF7\u6C42\u5931\u8D25"}}).then(function(i){var o=rE(i);if(o.httpStatus=a.status,iE(o))return console.log("[wand] sendInputDirect: session unavailable, dropping",{sessionId:t,errorCode:o.errorCode}),null;throw o})}).then(function(a){return a&&a.id&&(ut(a),a.id===s.selectedId&&(a.messages&&a.messages.length>0&&(s.currentMessages=a.messages),pn(!0))),a})}function oh(){if(s.selectedId){var e=s.selectedId;K0(_n("stop.confirm.message"),{title:_n("stop.confirm.title"),danger:!0,okLabel:_n("stop.confirm.ok"),cancelLabel:_n("stop.confirm.cancel")}).then(function(t){t&&s.selectedId===e&&fetch("/api/sessions/"+e+"/stop",{method:"POST",credentials:"same-origin"}).then(Yi)})}}function qf(e){var t=At()?null:document.querySelector('.session-item[data-session-id="'+e+'"]'),a=s.sessions.find(function(o){return o.id===e}),i=a&&a.claudeSessionId;t&&t.classList.add("deleting"),setTimeout(function(){fetch("/api/sessions/"+e,{method:"DELETE",credentials:"same-origin"}).then(function(o){return o.json()}).then(function(o){if(o&&o.error)throw new Error(o.error);return s.selectedId===e&&(s.selectedId=null,Qt()),i&&(s.claudeHistory=s.claudeHistory.filter(function(c){return c.claudeSessionId!==i}),s.codexHistory=s.codexHistory.filter(function(c){return c.claudeSessionId!==i})),Yi()}).catch(function(){t&&t.classList.remove("deleting");var o=document.getElementById("action-error");Ja(o,"\u65E0\u6CD5\u5220\u9664\u4F1A\u8BDD\u3002")})},250)}function pE(e,t){t&&t.classList.add("deleting"),setTimeout(function(){fetch("/api/claude-history/"+encodeURIComponent(e),{method:"DELETE",credentials:"same-origin"}).then(function(a){return a.json()}).then(function(a){if(a&&a.error)throw new Error(a.error);s.claudeHistory=s.claudeHistory.filter(function(i){return i.claudeSessionId!==e}),delete s.selectedClaudeHistoryIds[e],St()}).catch(function(){t&&t.classList.remove("deleting");var a=document.getElementById("action-error");Ja(a,"\u65E0\u6CD5\u5220\u9664\u4F1A\u8BDD\u3002")})},250)}function S_(e,t){pE(e,t)}function B_(e,t,a){e&&fetch("/api/claude-history?cwd="+encodeURIComponent(e),{method:"DELETE",credentials:"same-origin"}).then(function(i){return i.json()}).then(function(i){if(i&&i.error)throw new Error(i.error);s.claudeHistory=s.claudeHistory.filter(function(o){return o.cwd!==e}),St()}).catch(function(){mE(a,!1);var i=document.getElementById("action-error");Ja(i,"\u65E0\u6CD5\u6E05\u7406\u8BE5\u76EE\u5F55\u7684\u5386\u53F2\u4F1A\u8BDD\u3002")})}function mE(e,t){e.forEach(function(a){a.classList.toggle("deleting",t)})}function k_(e){return Array.prototype.slice.call(document.querySelectorAll('.claude-history-item[data-cwd="'+window.CSS.escape(String(e))+'"]'))}var vE=null,Zl=null;function Jl(){if(Zl){Zl.classList.remove("swiped");var e=Zl.querySelector(".session-item-content");e&&(e.style.transform=""),Zl=null}}function T_(e){vE=null,Zl=null}var sh=!1;function hE(e,t){return!e||sh?Promise.resolve(null):(sh=!0,fetch("/api/sessions/"+encodeURIComponent(e)+"/resume",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(Qi({mode:s.chatMode||s.config.defaultMode||"default"}))}).then(function(a){return a.json()}).then(function(a){return a.error?(t?Ja(t,a.error):be(a.error,"error"),null):(s.selectedId=a.id,Qt(),s.drafts[a.id]="",a)}).catch(function(a){var i=a&&a.message||"\u65E0\u6CD5\u6062\u590D\u4F1A\u8BDD\u3002";return t?Ja(t,i):be(i,"error"),null}).finally(function(){sh=!1}))}function Pf(e){return!e||!e.id?Promise.resolve():(s.selectedId=e.id,Qt(),s.currentMessages=[],Hl(),Da(),Xl(e.id),ut(e),St(),$u(e.id),Wi(e.id).then(function(){yr(!0)}))}function lh(e){return hE(e).then(function(t){return t?(t.claudeSessionId&&(t.provider==="codex"?s.codexHistory=s.codexHistory.filter(function(a){return a.claudeSessionId!==t.claudeSessionId}):s.claudeHistory=s.claudeHistory.filter(function(a){return a.claudeSessionId!==t.claudeSessionId})),Pf(t).then(function(){return t})):null})}function j_(e){e.disabled=!0,lh(e.dataset.sessionId).finally(function(){e.disabled=!1})}function M_(e){var t=e.dataset.claudeSessionId,a=e.dataset.cwd;t&&(e.disabled=!0,ch("codex",t,a).finally(function(){e.disabled=!1}))}function Uf(e,t){return fetch("/api/codex-sessions/"+encodeURIComponent(e)+"/resume",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(Qi({mode:s.chatMode||s.config&&s.config.defaultMode||"default",cwd:t}))}).then(function(a){return a.json()}).then(function(a){return a.error?(be(a.error,"error"),null):a}).catch(function(a){return be(a&&a.message||"\u65E0\u6CD5\u6062\u590D\u4F1A\u8BDD\u3002","error"),null})}function O_(e){var t=e.dataset.claudeSessionId;t&&zi("\u786E\u8BA4\u5220\u9664\u8FD9\u6761 Codex \u4F1A\u8BDD\u5417\uFF1F",{title:"\u5220\u9664\u4F1A\u8BDD"}).then(function(a){if(a){var i=e.closest(".session-item");i&&(i.style.opacity="0.5"),gE(t).catch(function(){i&&(i.style.opacity="1")})}})}function __(e){var t=e.dataset.claudeSessionId,a=e.dataset.cwd;t&&(e.disabled=!0,ch("claude",t,a).finally(function(){e.disabled=!1}))}function Vf(e,t){return fetch("/api/claude-sessions/"+encodeURIComponent(e)+"/resume",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(Qi({mode:s.chatMode||s.config&&s.config.defaultMode||"default",cwd:t}))}).then(function(a){return a.json()}).then(function(a){return a.error?(be(a.error,"error"),null):a}).catch(function(a){return be(a&&a.message||"\u65E0\u6CD5\u6062\u590D\u4F1A\u8BDD\u3002","error"),null})}function ch(e,t,a){var i=e==="codex"?Uf(t,a):Vf(t,a);return i.then(function(o){return!o||!o.id?null:(e==="codex"?s.codexHistory=s.codexHistory.filter(function(c){return c.claudeSessionId!==t}):s.claudeHistory=s.claudeHistory.filter(function(c){return c.claudeSessionId!==t}),s.selectedId=o.id,Qt(),s.drafts[o.id]="",Pf(o).then(function(){return ar(),o}))})}function gE(e){return fetch("/api/codex-history/"+encodeURIComponent(e),{method:"DELETE",credentials:"same-origin"}).then(function(t){return t.json()}).then(function(t){if(!t||t.ok!==!0)throw new Error(t&&t.error||"\u65E0\u6CD5\u5220\u9664\u4F1A\u8BDD\u3002");return s.codexHistory=s.codexHistory.filter(function(a){return a.claudeSessionId!==e}),St(),t})}function is(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function yr(e){if(!s.terminalInteractive){var t=document.getElementById("input-box");!t||!s.selectedId||document.activeElement!==t&&(e&&is()||xE(t))}}function N_(){var e=document.querySelector(".input-panel");e&&e.style.removeProperty("--keyboard-offset")}function R_(){var e=document.querySelector(".input-panel");e&&e.style.removeProperty("--keyboard-offset")}function bE(e){if(e){var t=e.selectionStart,a=e.selectionEnd;Gf(e),typeof t=="number"&&typeof a=="number"&&e.setSelectionRange(t,a)}}function wE(e){!e||e.dataset.touchScrollBound==="true"||(e.dataset.touchScrollBound="true",e.addEventListener("touchstart",function(){e.scrollHeight<=e.clientHeight+1||(e.scrollTop<=0?e.scrollTop=1:e.scrollTop+e.clientHeight>=e.scrollHeight&&(e.scrollTop=Math.max(1,e.scrollHeight-e.clientHeight-1)))},{passive:!0}))}function yE(e){e&&(Qn(e),bE(e))}function I_(e){var t=e&&e.target?e.target:document.getElementById("input-box");t&&(N_(),yE(t))}function L_(e){var t=e&&e.target?e.target:document.getElementById("input-box");R_(),t&&Qn(t),vx(2200,t);var a=[80,200,380,620,900];a.forEach(function(i,o){setTimeout(function(){Jo(!1),t&&t.value&&Qn(t),o===1&&is()&&(In("keyboard-blur",{forceReplay:!0}),Ca("keyboard"))},i)})}function z_(e){e&&(e.setSelectionRange(e.value.length,e.value.length),bE(e))}function xE(e){e&&(e.focus({preventScroll:!0}),z_(e))}function H_(e){wE(e),yE(e)}function dh(e){H_(e)}function q_(e,t){if(!e||!t||document.activeElement!==t)return!1;var a=window.innerHeight-e.height-e.offsetTop;if(a<=50)return!1;var i=t.getBoundingClientRect();return i.bottom>e.offsetTop+e.height-12}function Gf(e){if(e){var t=e.scrollHeight>e.clientHeight+1;if(!t){e.scrollTop=0;return}e.scrollTop=e.scrollHeight}}function EE(){if(s.terminalInteractive){FE();return}if(!is()){var e=document.getElementById("input-box");!e||!s.selectedId||document.activeElement===e||xE(e)}}function FE(){var e=document.getElementById("output");e&&(e.setAttribute("tabindex","0"),e.focus(),s.terminal&&s.terminal.focus&&s.terminal.focus())}function P_(){var e=document.querySelector(".input-panel"),t=document.querySelector(".chat-messages");if("virtualKeyboard"in navigator){var a=navigator.virtualKeyboard;a.addEventListener("geometrychange",function(){e&&e.style.removeProperty("padding-bottom")})}var i=document.getElementById("output");i&&i.addEventListener("click",function(){EE()}),t&&t.addEventListener("click",function(o){var c=o.target;c.tagName!=="A"&&c.tagName!=="BUTTON"&&!c.closest("button")&&!c.closest("[data-tool-toggle]")&&EE()}),document.addEventListener("click",function(o){if(is()){var c=document.getElementById("input-box");if(!(!c||document.activeElement!==c)){var d=o.target;!d||typeof d.closest!="function"||d.closest(".input-panel")||d.closest("#mini-keyboard")||d.closest("#mini-keyboard-fab")||d.closest("#mini-keyboard-toggle")||d.closest("#terminal-interactive-toggle")||d.closest(".wand-joystick-root")||c.blur()}}},!0)}function fh(){try{window.scrollTo(0,0)}catch{}document.scrollingElement&&(document.scrollingElement.scrollTop=0),document.documentElement&&(document.documentElement.scrollTop=0),document.body&&(document.body.scrollTop=0)}var U_=new Set(["claude-sdk","claude-cli-print","codex-cli-exec","opencode-cli-run","grok-cli-headless","qoder-cli-print"]);function V_(e){return!e||e.sessionKind==="structured"?!1:typeof e.runner!="string"||!U_.has(e.runner)}var CE={read:"\u8BFB\u53D6\u6587\u4EF6",write:"\u5199\u5165\u6587\u4EF6",edit:"\u7F16\u8F91\u6587\u4EF6",multiedit:"\u591A\u5904\u7F16\u8F91",apply_patch:"\u5E94\u7528\u8865\u4E01",bash:"\u6267\u884C\u547D\u4EE4",exec_command:"\u6267\u884C\u547D\u4EE4",write_stdin:"\u7EC8\u7AEF\u8F93\u5165",grep:"\u641C\u7D22\u5185\u5BB9",glob:"\u67E5\u627E\u6587\u4EF6",webfetch:"\u83B7\u53D6\u7F51\u9875",websearch:"\u641C\u7D22\u7F51\u9875",task:"\u4EFB\u52A1",todowrite:"\u66F4\u65B0\u5F85\u529E",todoread:"\u8BFB\u53D6\u5F85\u529E",update_plan:"\u66F4\u65B0\u8BA1\u5212",notebookedit:"\u7F16\u8F91\u7B14\u8BB0\u672C",agent:"\u5B50\u4EE3\u7406",spawn_agent:"\u542F\u52A8\u5B50\u4EE3\u7406",askuserquestion:"\u63D0\u95EE",request_user_input:"\u8BF7\u6C42\u8F93\u5165",exit:"\u9000\u51FA"};function ph(e){const t=typeof e=="string"?e.trim():"";if(!t)return"\u5DE5\u5177";const a=t.toLowerCase(),i=a.split(/__|\/|:/).filter(Boolean),o=i[i.length-1]??a;return CE[a]??CE[o]??t}function G_(e){const t=typeof e=="string"?e.trim().toLowerCase():"",a=t.split(/__|\/|:/).filter(Boolean),i=a[a.length-1]??t;return/ask|question|request_user_input|prompt_user/.test(i)?"question":/todo|checklist|update_plan/.test(i)?"todo":/image|screenshot|photo|vision|camera/.test(i)?"image":/github|(^|[_/])git|commit|pull_request|merge_request|branch/.test(i)?"git":/browser|(^|[_/])web|fetch|http|url|navigate|page_|click_link/.test(i)?"web":/grep|glob|search|find|query|lookup/.test(i)?"search":/bash|exec|command|terminal|shell|stdin|repl|run_code|javascript|(^|_)js($|_)/.test(i)?"terminal":/apply_patch|patch|edit|(^|_)write($|_)|write_file|create_file|save_file|replace|format_file/.test(i)?"edit":/agent|task|subagent|spawn|collaborat|followup|interrupt|delegate|send_input/.test(i)?"agent":/read|open|load|list|get_|inspect|view/.test(i)?"read":/think|reason/.test(i)?"thinking":/wait|time|sleep|poll|monitor/.test(i)?"wait":/exit|stop|kill|cancel|terminate/.test(i)?"exit":"generic"}var Y_={agent:'<circle cx="9" cy="8" r="3"/><path d="M3.5 19c.6-3.2 2.4-5 5.5-5s4.9 1.8 5.5 5"/><circle cx="17" cy="9" r="2"/><path d="M15.5 14.5c2.8-.7 4.7.6 5 3.5"/>',edit:'<path d="M4 20h4l11-11a2.8 2.8 0 0 0-4-4L4 16v4Z"/><path d="m13.5 6.5 4 4M4 20l4-1"/>',exit:'<path d="M15 7l5 5-5 5M20 12H9"/><path d="M11 4H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h6"/>',generic:'<path d="M14.7 6.3a4 4 0 0 0-5 5L4 17l3 3 5.7-5.7a4 4 0 0 0 5-5l-2.4 2.4-3-3 2.4-2.4Z"/>',git:'<circle cx="6" cy="5" r="2"/><circle cx="18" cy="7" r="2"/><circle cx="6" cy="19" r="2"/><path d="M6 7v10M8 7c4 0 4 0 8 0M8 17c4 0 4-8 8-8"/>',image:'<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m4 17 5-5 4 4 2-2 5 5"/>',question:'<circle cx="12" cy="12" r="9"/><path d="M9.8 9a2.5 2.5 0 1 1 3.5 2.3c-.9.4-1.3 1-1.3 2.2M12 17h.01"/>',read:'<path d="M5 3h10l4 4v14H5V3Z"/><path d="M15 3v5h4M8 12h8M8 16h6"/>',search:'<circle cx="10.5" cy="10.5" r="6.5"/><path d="m15.5 15.5 5 5"/>',terminal:'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="m7 9 3 3-3 3M12 16h5"/>',thinking:'<path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/><circle cx="12" cy="12" r="3"/>',todo:'<rect x="3" y="3" width="18" height="18" rx="3"/><path d="m7.5 12 3 3 6-7"/>',wait:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',web:'<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c2.4 2.5 3.7 5.5 3.7 9s-1.3 6.5-3.7 9c-2.4-2.5-3.7-5.5-3.7-9S9.6 5.5 12 3Z"/>'};function DE(e){const t=G_(e);return'<svg class="tool-use-icon-svg" data-tool-icon="'+t+'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">'+Y_[t]+"</svg>"}function pn(e){s.renderPending&&!e||(s.renderPending=!0,e?(Yf(!0),s.renderPending=!1):requestAnimationFrame(function(){Yf(!1),s.renderPending=!1}))}s.chatRenderTimer=null;function mh(e){if(!(s.chatRenderTimer&&!e)){if(s.chatRenderTimer&&clearTimeout(s.chatRenderTimer),e){s.chatRenderTimer=null,pn();return}try{window.__scheduleChatRender=function(){mh(!0)}}catch{}var t=s.sessions.find(function(o){return o.id===s.selectedId}),a=t&&t.status==="running"&&t.sessionKind!=="structured",i=a?Bx:kx;s.chatRenderTimer=setTimeout(function(){s.chatRenderTimer=null;var o=s.sessions.find(function(c){return c.id===s.selectedId});o&&(s.currentMessages=Tn(o,Xn(o,o.output,!0))),pn()},i)}}function K_(e,t){if(!e||!t||t.length===0)return[];function a(D){return D.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g,"")}for(var i=a(e),o=[],c=[],d=0;d<t.length;d++)if(t[d].role==="user"){var f="",v=t[d].content;if(typeof v=="string")f=v;else if(Array.isArray(v)){for(var g=0;g<v.length;g++)if(v[g].type==="text"){f=v[g].text;break}}f&&c.push({text:f,index:d})}for(var h=0,d=0;d<c.length;d++){var b=c[d],w=i.indexOf("\u276F "+b.text,h);if(w===-1&&(w=i.indexOf(`
3731
3731
  \u276F `+b.text,h),w!==-1&&(w+=1)),w>h){for(var C=i.substring(h,w),y=C.split(`