@wudao-org/web 0.4.21 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index-BmKJMIZE.css +1 -0
- package/dist/assets/index-Tahki_14.js +339 -0
- package/dist/assets/pet-4XdpdZBF.css +1 -0
- package/dist/assets/pet-CHP5UESQ.js +3 -0
- package/dist/assets/tokens-w4ILWEys.js +64 -0
- package/dist/index.html +3 -3
- package/dist/pet/skin-power.png +0 -0
- package/dist/pet.html +3 -3
- package/package.json +1 -1
- package/dist/assets/index-DILA5KBt.css +0 -1
- package/dist/assets/index-Dy-Ll1qR.js +0 -339
- package/dist/assets/pet-CmLZS41k.js +0 -3
- package/dist/assets/pet-GasEBuc7.css +0 -1
- package/dist/assets/tokens-D-f0h-_m.js +0 -64
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--pet-accent: 14 159 110;--pet-accent-ink: 20 21 25}.pet-root{position:fixed;left:50%;bottom:12px;transform:translate(-50%);width:96px;height:96px;user-select:none;-webkit-user-select:none;cursor:grab;touch-action:none}.pet-root[data-pet-state=drag]{cursor:grabbing}.pet-figure{position:relative;width:100%;height:100%}.pet-sprite-img{position:absolute;bottom:0;left:0;display:block;width:96px;aspect-ratio:390 / 238;background-size:200% 100%;background-repeat:no-repeat;background-position:0 0;pointer-events:none;user-select:none;-webkit-user-select:none;will-change:transform,background-position;transform-origin:50% 100%}[data-skin=power] .pet-sprite-img{aspect-ratio:1 / 1;width:88px;left:4px}@keyframes pet-blink{0%,23.5%{background-position:0% 0}24%,25.6%{background-position:100% 0}26.1%,47.5%{background-position:0% 0}48%,49.6%{background-position:100% 0}50.1%,71.5%{background-position:0% 0}72%,73.6%{background-position:100% 0}74.1%,91%{background-position:0% 0}91.5%,93.1%{background-position:100% 0}93.6%,94.4%{background-position:0% 0}94.9%,96.5%{background-position:100% 0}97%,to{background-position:0% 0}}@keyframes pet-idle{0%{transform:scale(1.06,.92)}9%{transform:scale(.95,1.07)}18%{transform:scale(1.06,.92)}27%{transform:scale(.95,1.07)}36%{transform:scale(1.06,.92)}42%,48%{transform:scale(1.06,.92) rotate(-4deg)}54%{transform:scale(1.06,.92)}60%{transform:scale(.95,1.07)}66%{transform:scale(1.06,.92)}71%{transform:translateY(0) scale(1.05,.95)}74%{transform:translateY(-5px) scale(.97,1.05)}77%{transform:translateY(0) scale(1.04,.96)}80%{transform:translateY(-2px) scale(1)}90%{transform:scale(.95,1.07)}to{transform:scale(1.06,.92)}}@keyframes pet-thinking{0%,to{transform:rotate(-3deg)}25%,75%{transform:rotate(1deg)}50%{transform:rotate(3deg)}}@keyframes pet-working{0%,to{transform:translateY(0) scale(1)}35%{transform:translateY(0) scale(1.04,.94)}70%{transform:translateY(-7px) scale(.97,1.03)}}@keyframes pet-answering{0%{transform:scale(1)}30%{transform:scale(1.09,.93)}60%{transform:scale(.96,1.05)}to{transform:scale(1)}}@keyframes pet-waiting{0%,to{transform:rotate(0)}20%{transform:rotate(-6deg)}40%{transform:rotate(6deg)}60%{transform:rotate(-4deg)}80%{transform:rotate(4deg)}}@keyframes pet-done{0%{transform:translateY(-10px) scale(.98,1.02)}40%{transform:translateY(0) scale(1.06,.92)}70%{transform:translateY(-2px) scale(.98,1.02)}to{transform:translateY(0) scale(1)}}@keyframes pet-drag{0%{transform:scale(1)}to{transform:scale(1.05)}}@keyframes pet-squash{0%{transform:scale(1)}35%{transform:scale(1.22,.78)}65%{transform:scale(.92,1.08)}to{transform:scale(1)}}@keyframes pet-release{0%{transform:scale(1.05)}40%{transform:scale(.94,1.06)}70%{transform:scale(1.02,.98)}to{transform:scale(1)}}@keyframes pet-sway{0%,to{transform:rotate(0)}25%{transform:rotate(-2.5deg)}50%{transform:rotate(0)}75%{transform:rotate(2.5deg)}}[data-pet-state=idle] .pet-sprite-img{animation:pet-idle 12s ease-in-out infinite,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=thinking] .pet-sprite-img{animation:pet-thinking 2.2s ease-in-out infinite,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=working] .pet-sprite-img{animation:pet-working .6s ease-in-out infinite,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=answering] .pet-sprite-img{animation:pet-answering 1s ease-in-out infinite,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=waiting-user] .pet-sprite-img{animation:pet-waiting 1.6s ease-in-out infinite,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=done] .pet-sprite-img{animation:pet-done .7s ease-out 1,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=drag] .pet-sprite-img{animation:pet-drag .16s ease-out 1 forwards,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=release] .pet-sprite-img{animation:pet-release .45s cubic-bezier(.2,.8,.3,1.15) 1,pet-blink 9.6s steps(1,end) infinite}[data-pet-state=idle] .pet-figure{animation:pet-sway 4.8s ease-in-out infinite;transform-origin:50% 100%}.pet-poke-layer{width:100%;height:100%}.pet-poke-layer[data-poked]{animation:pet-squash .6s cubic-bezier(.3,1.2,.4,1) 1;transform-origin:50% 100%}[data-paused] *{animation-play-state:paused!important}@media (prefers-reduced-motion: reduce){[data-pet-state=idle] .pet-sprite-img,[data-pet-state=thinking] .pet-sprite-img,[data-pet-state=working] .pet-sprite-img,[data-pet-state=answering] .pet-sprite-img,[data-pet-state=waiting-user] .pet-sprite-img{animation-iteration-count:0,infinite!important}[data-pet-state=done] .pet-sprite-img,[data-pet-state=drag] .pet-sprite-img{animation-iteration-count:1,infinite!important}[data-pet-state=idle] .pet-figure{animation-iteration-count:0!important}.pet-bubble{transition:none!important}.pet-bubble-thinking,.pet-bubble-hint[data-bubble-thinking]{animation:none}}.pet-bubble{position:fixed;left:50%;bottom:79px;transform:translate(-50%);width:min(204px,calc(100vw - 16px));max-height:min(176px,calc(100vh - 96px));box-sizing:border-box;padding:8px 10px;border-radius:var(--radius-lg);background:var(--surface);color:var(--text-1);box-shadow:var(--elev-2);font:12px/1.55 var(--font);overflow:hidden;opacity:1;transition:opacity .25s ease}.pet-bubble[data-bubble-fading]{opacity:0}.pet-bubble[data-bubble-state=stream]{width:min(396px,calc(100vw - 16px));max-height:min(452px,calc(100vh - 104px));padding:12px 14px;font-size:13px;line-height:1.65}.pet-bubble[data-bubble-state=stream] .pet-bubble-stream[data-stream-expanded]{justify-content:flex-start;overflow-y:auto}.pet-bubble[data-bubble-state=stream] .pet-bubble-stream{max-height:396px;padding-right:22px;border-left:3px solid rgb(var(--pet-accent) / .5);padding-left:10px}.pet-bubble-close{position:absolute;top:4px;right:4px;width:18px;height:18px;border:none;border-radius:var(--radius-sm);padding:0;background:transparent;color:var(--text-3);font:inherit;line-height:18px;cursor:pointer}.pet-bubble-close:hover{color:var(--text-1)}.pet-bubble[data-bubble-state=input]{width:min(396px,calc(100vw - 16px));max-height:max(176px,min(452px,calc(100vh - 104px)));padding:12px 14px;font-size:13px;line-height:1.65;display:flex;flex-direction:column}.pet-bubble-chat{display:flex;flex-direction:column;gap:8px;flex:1 1 auto;min-height:0}.pet-bubble-transcript{flex:1 1 auto;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding-right:4px}.pet-bubble-transcript::-webkit-scrollbar,.pet-bubble-stream[data-stream-expanded]::-webkit-scrollbar{width:8px}.pet-bubble-transcript::-webkit-scrollbar-thumb,.pet-bubble-stream[data-stream-expanded]::-webkit-scrollbar-thumb{background:var(--hair-3);border-radius:50%}.pet-bubble-transcript::-webkit-scrollbar-track,.pet-bubble-stream[data-stream-expanded]::-webkit-scrollbar-track{background:transparent}.pet-turn{display:flex;flex-direction:column;gap:6px}.pet-msg-user{display:flex;flex-direction:column;align-items:flex-end}.pet-row-pet{display:flex;align-items:flex-start;gap:6px}.pet-avatar{flex:0 0 auto;width:34px;height:34px;background-size:200% auto;background-position:0 center;background-repeat:no-repeat}.pet-bubble-q{max-width:85%;box-sizing:border-box;padding:5px 10px;border-radius:var(--radius-md);background:var(--bubble-user-bg);color:var(--bubble-user-ink);display:flex;flex-direction:column;align-items:flex-end;gap:2px}.pet-bubble-body{white-space:pre-wrap;word-break:break-word}.pet-bubble-a{box-sizing:border-box;padding:2px 0;border-radius:var(--radius-md);background:transparent;display:flex;flex-direction:column;align-items:stretch;gap:2px}.pet-row-pet>.pet-bubble-a,.pet-row-pet>.pet-bubble-thinking{flex:0 1 auto;max-width:calc(100% - 40px)}.pet-bubble-a[data-folded] .pet-bubble-body,.pet-bubble-q[data-folded] .pet-bubble-body{max-height:calc(3 * 1.65em);overflow:hidden;-webkit-mask-image:linear-gradient(180deg,var(--shade) calc(100% - 1.4em),transparent);mask-image:linear-gradient(180deg,var(--shade) calc(100% - 1.4em),transparent)}.pet-bubble-fold{align-self:flex-start;border:none;border-radius:var(--radius-sm);padding:3px 10px;background:transparent;color:var(--text-2);font:inherit;font-size:12px;cursor:pointer;margin-top:2px}.pet-bubble-q .pet-bubble-fold{align-self:flex-end}.pet-bubble-fold:hover{color:var(--text-1);background:var(--hover)}@keyframes pet-thinking-breath{0%,to{opacity:1}50%{opacity:.55}}.pet-bubble-thinking{color:var(--warn);animation:pet-thinking-breath 1.2s ease-in-out infinite;padding:2px 0;border-radius:var(--radius-md);background:transparent}.pet-bubble-hint[data-bubble-thinking]{animation:pet-thinking-breath 1.2s ease-in-out infinite}.pet-bubble-input{display:flex;flex-direction:column;gap:6px;border-top:1px solid var(--hair-1);padding-top:8px}.pet-bubble-input textarea{box-sizing:border-box;width:100%;resize:none;border:none;border-radius:var(--radius-sm);padding:6px 8px;background:var(--surface-2);color:var(--text-1);font:inherit;outline:none}.pet-bubble-input textarea:focus{background:var(--surface-2);box-shadow:0 0 0 1.5px rgb(var(--pet-accent))}.pet-bubble-send{align-self:flex-end;border:none;border-radius:var(--radius-md);padding:4px 12px;background:rgb(var(--pet-accent));color:rgb(var(--pet-accent-ink));font:inherit;cursor:pointer}.pet-bubble-input-row{display:flex;justify-content:flex-end;gap:14px}.pet-bubble-cancel{border:none;border-radius:var(--radius-sm);padding:4px 8px;background:transparent;color:var(--text-3);font:inherit;font-size:12px;cursor:pointer}.pet-bubble-cancel:hover{color:var(--text-1)}.pet-bubble-stream{display:flex;flex-direction:column;justify-content:flex-end;max-height:160px;overflow:hidden;white-space:pre-wrap;word-break:break-word}.pet-bubble-hint{color:var(--warn)}.pet-bubble-ask{display:flex;flex-direction:column;gap:6px;box-sizing:border-box;padding:6px 8px;border-radius:var(--radius-md);background:var(--surface-2);color:var(--text-1)}.pet-bubble-ask-tool{align-self:flex-start;padding:0 6px;border-radius:var(--radius-sm);background:var(--bubble-user-bg);color:var(--text-2);font-size:11px;line-height:18px}.pet-bubble-ask-summary{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pet-bubble-ask-actions{display:flex;flex-wrap:wrap;gap:6px}.pet-bubble-ask-actions button{flex:1 1 auto;border:none;border-radius:var(--radius-md);padding:4px 10px;background:rgb(var(--pet-accent));color:rgb(var(--pet-accent-ink));font:inherit;cursor:pointer}.pet-bubble-ask-actions button[data-ask-always]{background:transparent;border:1px solid rgb(var(--pet-accent));color:var(--text-1)}.pet-bubble-ask-actions button[data-ask-deny]{background:transparent;border:1px solid var(--hair-2);color:var(--text-1)}.pet-bubble-ask-actions button[disabled]{opacity:.5;cursor:default}.pet-bubble-selection{display:flex;flex-direction:column;gap:6px;box-sizing:border-box;padding:6px 8px;border-radius:var(--radius-md);background:var(--surface-2);color:var(--text-1)}.pet-bubble-selection-text{max-height:64px;overflow:hidden;white-space:pre-wrap;word-break:break-word;border-radius:var(--radius-sm);padding:4px 6px;background:var(--bg);color:var(--text-2)}.pet-bubble-selection-actions{display:flex;flex-wrap:wrap;gap:6px}.pet-bubble-selection button{border:none;border-radius:var(--radius-md);padding:4px 10px;background:rgb(var(--pet-accent));color:rgb(var(--pet-accent-ink));font:inherit;cursor:pointer}.pet-bubble-selection button[data-selection-explain]{background:transparent;border:1px solid rgb(var(--pet-accent));color:var(--text-1)}.pet-bubble-selection button[data-selection-cancel]{background:transparent;border:1px solid var(--hair-2);color:var(--text-1)}.pet-bubble-selection button[disabled]{opacity:.5;cursor:default}.pet-bubble-selection-row{display:flex;gap:6px;align-items:center}.pet-bubble-selection-row input{flex:1 1 auto;min-width:0;box-sizing:border-box;border:1px solid var(--hair-2);border-radius:var(--radius-md);padding:4px 8px;background:var(--bg);color:var(--text-1);font:inherit;outline:none}.pet-bubble-selection-row input:focus{border-color:rgb(var(--pet-accent))}.pet-md{display:flex;flex-direction:column;gap:6px}.pet-md-heading{font-weight:700}.pet-md-heading[data-level="1"],.pet-md-heading[data-level="2"]{font-size:14px}.pet-md-pre{box-sizing:border-box;max-width:100%;overflow-x:auto;border-radius:var(--radius-md);padding:6px 8px;background:var(--bg);border:1px solid var(--hair-1);font:11px/1.5 var(--mono);white-space:pre}.pet-md-quote{border-left:2px solid var(--hair-1);padding:2px 0 2px 8px;color:var(--text-2)}.pet-md-list{padding-left:2px}.pet-md-table{display:block;max-width:100%;overflow-x:auto;border-collapse:collapse}.pet-md-table th,.pet-md-table td{padding:2px 6px;border:1px solid var(--hair-1);text-align:left}.pet-md-table th{background:var(--surface-2);color:var(--text-1)}.pet-md-bold{font-weight:700}.pet-md-code{padding:0 4px;border-radius:var(--radius-sm);border:1px solid var(--hair-1);background:var(--surface-2);font-family:var(--mono);font-size:.92em;color:var(--tok-str)}.pet-toast{position:fixed;top:8px;left:50%;transform:translate(-50%);width:min(204px,calc(100vw - 16px));box-sizing:border-box;padding:8px 10px;border-radius:var(--radius-lg);background:var(--surface);color:var(--text-1);box-shadow:var(--elev-2);font:12px/1.55 var(--font);text-align:center;z-index:var(--z-modal)}.pet-expr{position:fixed;bottom:83px;left:50%;transform:translate(-50%);box-sizing:border-box;padding:4px 10px;border-radius:var(--radius-md);background:var(--surface);color:var(--text-1);box-shadow:var(--elev-2);font:12px/1.45 var(--font);text-align:center;white-space:nowrap;z-index:var(--z-modal)}.pet-expr:after{content:"";position:absolute;bottom:-5px;left:50%;transform:translate(-50%);border:5px solid transparent;border-top-color:var(--surface);border-bottom:none}.pet-toolbar{display:flex;align-items:center;gap:4px;margin-bottom:6px;min-width:0}.pet-toolbar-new{flex:none;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:none;border-radius:var(--radius-sm);background:transparent;color:var(--text-3);cursor:pointer}.pet-toolbar-new:hover{background:var(--surface-2);color:var(--text-1)}.pet-pop{position:relative;flex:none}.pet-chip{display:inline-flex;align-items:center;gap:3px;max-width:84px;height:20px;padding:0 6px;border:1px solid var(--hair-1);border-radius:var(--radius-sm);background:var(--surface-2);color:var(--text-2);font-size:11px;line-height:1;cursor:pointer}.pet-chip:hover{color:var(--text-1);border-color:var(--hair-2)}.pet-chip .pet-chip-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pet-caret{flex:none;color:var(--text-3);font-size:9px}.pet-menu{position:absolute;top:calc(100% + 4px);left:0;z-index:var(--z-modal);display:flex;flex-direction:column;gap:4px;box-sizing:border-box;min-width:168px;max-width:calc(100vw - 24px);padding:6px;border-radius:var(--radius-md);background:var(--surface);box-shadow:var(--elev-2);font:11px/1.5 var(--font);color:var(--text-1)}.pet-menu input{box-sizing:border-box;width:100%;padding:3px 6px;border:1px solid var(--hair-1);border-radius:var(--radius-sm);background:var(--bg);color:var(--text-1);font:11px/1.5 var(--font)}.pet-menu input::placeholder{color:var(--text-3)}.pet-menu input:focus{outline:none;border-color:var(--hair-2)}.pet-menu-send{padding:3px 6px;border:1px solid var(--hair-1);border-radius:var(--radius-sm);background:var(--surface-2);color:var(--text-1);font-size:11px;cursor:pointer}.pet-menu-send:hover{border-color:var(--hair-2)}.pet-mi{padding:3px 6px;border:none;border-radius:var(--radius-sm);background:transparent;color:var(--text-2);font-size:11px;text-align:left;cursor:pointer}.pet-mi:hover{color:var(--text-1)}.pet-mi.on{background:var(--surface-2);color:var(--text-1)}.pet-mi.pet-mi-browse{width:100%;color:var(--text-1);border-bottom:1px solid var(--hair-1);border-radius:var(--radius-sm);margin-bottom:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pet-bubble[data-bubble-state=stream] .pet-toolbar{padding-right:22px}@media (max-width: 260px){.pet-chip{max-width:60px;padding:0 4px}.pet-chip .pet-caret,.pet-chip[data-toolbar-effort] .pet-chip-label,.pet-chip[data-toolbar-workspace] .pet-chip-label{display:none}}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as n,al as $,R as Oe,m as Ge,p as Je,r as o,I as Ze,b as Q,c as G,v as et,M as tt,N as nt,am as st,an as rt,ao as lt,ap as at,u as be,t as H,aq as ot,i as de,a4 as it,a3 as ut,a6 as ct,ar as dt,as as ft,a9 as mt,T as B,at as bt,au as pt,av as ht,aw as vt,ah as Ce,ak as kt,ax as yt,ad as xt,ay as wt,a8 as Et,W as gt,af as Nt,a7 as jt,az as St,a2 as Tt,aA as Pt,aj as _t}from"./tokens-w4ILWEys.js";const Ct=1500;function Dt(){return{display:"idle",busy:!1,doneAt:null}}function At(e){return e.pendingPermission!=null?"waiting-user":e.live.busyTools.length>0?"working":e.live.reasoning!==""?"thinking":e.live.answer!==""?"answering":"idle"}function Rt(e,t,r){const l=At(t);let a,i=e.doneAt;return t.busy||l==="waiting-user"?a=l:e.busy&&!t.busy?(a="done",i=r):e.display==="done"&&e.doneAt!==null&&r-e.doneAt<Ct?a="done":a=l,a!=="done"&&(i=null),{display:a,busy:t.busy,doneAt:i}}function X(e){return function(r){return n.jsx("div",{className:"pet-figure",children:n.jsx("div",{className:"pet-sprite-img",style:{backgroundImage:`url(${e})`}})})}}const Lt=X("/pet/skin-default.png");function Mt({display:e,skinId:t="default",figure:r=Lt,paused:l=!1,pokeEpoch:a,poked:i,onPointerDown:u}){return n.jsx("div",{className:"pet-root","data-pet-root":"","data-skin":t,"data-pet-state":e,"data-paused":l?"":void 0,title:"wudao pet",onPointerDown:u,children:n.jsx("div",{className:"pet-poke-layer","data-poked":i?"":void 0,children:n.jsx(r,{display:e})},a??0)})}const J=["idle","thinking","working","answering","waiting-user","done","drag"],It=X($.sakura),Ot=X($.lake),Ft=X($.honey),Kt=X($.power),Wt={default:{component:X($.default),states:J},sakura:{component:It,states:J},lake:{component:Ot,states:J},honey:{component:Ft,states:J},power:{component:Kt,states:J}},De={turns:[]};function fe(e){const t=Array.from(e);return t.length<=24?e:`${t.slice(0,24).join("")}…`}function qt(e,t){return{turns:[...e.turns.map(l=>l.live?{...l,live:!1}:l),{q:t,a:"",live:!0}]}}function Ut(e,t){const r=e.turns.length>0?e.turns[e.turns.length-1]:void 0;if(r===void 0)return t.answerTail===""?e:{turns:[{q:"",a:t.answerTail,live:!0}]};if(r.live){if(t.answerTail!==""){if(r.a===t.answerTail)return e;const l=e.turns.slice();return l[l.length-1]={...r,a:t.answerTail},{turns:l}}if(!t.busy){const l=e.turns.slice();return l[l.length-1]={...r,live:!1},{turns:l}}return e}return t.answerTail!==""?{turns:[...e.turns,{q:"",a:t.answerTail,live:!0}]}:e}function Bt(e,t){const r=e.map(u=>({q:u.q,a:u.a,live:!1})),l=[];let a=t.turns.length-1,i=r.length-1;for(;a>=0||i>=0;){const u=a>=0?t.turns[a]:void 0,d=i>=0?r[i]:void 0;u!==void 0&&d!==void 0&&u.q!==""&&u.q===fe(d.q)?(l.push({q:d.q,a:d.a,live:u.live}),a-=1,i-=1):u!==void 0?(l.push(u),a-=1):(l.push(d),i-=1)}return{turns:l.reverse()}}function Z({s:e}){return n.jsx(n.Fragment,{children:Je(e).map((t,r)=>t.code?n.jsx("code",{className:"pet-md-code",children:t.text},r):t.bold?n.jsx("span",{className:"pet-md-bold",children:t.text},r):n.jsx("span",{children:t.text},r))})}function Vt(e){return e.map((t,r)=>t.kind==="code"?n.jsx("div",{className:"pet-md-pre",children:n.jsx("code",{children:t.lines.join(`
|
|
2
|
+
`)})},r):t.kind==="heading"?n.jsx("div",{className:"pet-md-heading","data-level":t.level,children:n.jsx(Z,{s:t.text})},r):t.kind==="list"?n.jsx("div",{className:"pet-md-list",children:t.items.map((l,a)=>n.jsxs("div",{children:["• ",n.jsx(Z,{s:l})]},a))},r):t.kind==="quote"?n.jsx("div",{className:"pet-md-quote",children:t.lines.map((l,a)=>n.jsx("div",{children:`| ${l}`},a))},r):t.kind==="table"?n.jsxs("table",{className:"pet-md-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:t.header.map((l,a)=>n.jsx("th",{children:n.jsx(Z,{s:l})},a))})}),n.jsx("tbody",{children:t.rows.map((l,a)=>n.jsx("tr",{children:l.map((i,u)=>n.jsx("td",{children:n.jsx(Z,{s:i})},u))},a))})]},r):n.jsx("div",{className:"pet-md-para",children:t.lines.map((l,a)=>n.jsxs(Oe.Fragment,{children:[a>0?`
|
|
3
|
+
`:null,n.jsx(Z,{s:l})]},a))},r))}const Fe=Oe.memo(function({source:t}){return n.jsx("div",{className:"pet-md",children:Vt(Ge(t))})}),Ae=2500,Ht=250,$t=3e4,Xt=600,Re=100;function Yt(e,t){const r=e.ask??null;if(r!==null)return{kind:"ask",ask:r};const l=e.selection??null;if(l!==null)return{kind:"selection",selection:l};if(e.inputOpen)return{kind:"input"};if(e.waitingUser)return{kind:"hint"};const a=e.busyNarration??null;return a!==null&&a!==""?{kind:"narration",text:a}:e.livePending?{kind:"thinking"}:e.answerTail!==""&&e.answerTail!==t?{kind:"stream",text:e.answerTail}:e.delivery!==null?{kind:"delivery",delivery:e.delivery}:null}function zt(e,t){return e!==null&&e.kind==="stream"&&e.text===t}function Qt(e,t,r,l){const a=u=>u!==null&&!zt(u,l)?u:null,i=a(t)??a(r);return i===null?"compact":i.kind==="stream"||i.kind==="thinking"||i.kind==="input"||e==="answer"?"answer":"bubble"}function Gt(e){const[t,r]=o.useState(!0),[l,a]=o.useState(!0),i=e.turn.q.length>Re,u=!e.turn.live&&e.turn.a.length>Re;return n.jsxs("div",{className:"pet-turn",children:[e.turn.q!==""&&n.jsx("div",{className:"pet-msg pet-msg-user",children:n.jsxs("div",{className:"pet-bubble-q","data-folded":i&&t?"":void 0,children:[n.jsx("div",{className:"pet-bubble-body",children:e.turn.q}),i&&n.jsx("button",{type:"button",className:"pet-bubble-fold","data-bubble-fold":"",onClick:()=>r(d=>!d),children:t?"查看全文":"收起"})]})}),(e.thinking||e.turn.a!=="")&&n.jsxs("div",{className:"pet-row pet-row-pet","data-pet-msg":"",children:[n.jsx("div",{className:"pet-avatar","data-pet-avatar":"",style:{backgroundImage:`url(${e.avatarSheet})`}}),e.thinking&&n.jsx("div",{className:"pet-bubble-thinking",children:"思考中…"}),!e.thinking&&e.turn.a!==""&&n.jsxs("div",{className:"pet-bubble-a","data-folded":u&&l?"":void 0,children:[n.jsx("div",{className:"pet-bubble-body",children:n.jsx(Fe,{source:e.turn.a})}),u&&n.jsx("button",{type:"button",className:"pet-bubble-fold","data-bubble-fold":"",onClick:()=>a(d=>!d),children:l?"查看全文":"收起"})]})]})]})}function Jt(e){return e.split("/").filter(t=>t!=="").slice(-1)[0]??e}function Zt(e){const{inputOpen:t,answerTail:r,waitingUser:l,onInputClose:a,delivery:i}=e,[u,d]=o.useState(""),[T,j]=o.useState(""),[I,D]=o.useState(!1),p=Yt(e,T);o.useEffect(()=>{r===""&&(j(""),D(!1))},[r]);const k=o.useRef(null);p===null||(p.kind==="input"||p.kind==="delivery"||p.kind==="ask"||p.kind==="selection"?k.current=null:k.current=p);const[P,x]=o.useState(p!==null),[w,y]=o.useState(!1),E=p!==null;o.useEffect(()=>{if(E){x(!0),y(!1);return}if(!P)return;const s=k.current?.kind;if(s===void 0||s==="stream")return;const f=setTimeout(()=>y(!0),Ae),_e=setTimeout(()=>x(!1),Ae+Ht);return()=>{clearTimeout(f),clearTimeout(_e)}},[E,P]);const _=o.useRef("compact"),Y=o.useRef(e.onLayoutMode);Y.current=e.onLayoutMode;const v=o.useRef(e.onDeliveryClose);v.current=e.onDeliveryClose,o.useEffect(()=>{if(i===null)return;const s=setTimeout(()=>v.current(),$t);return()=>clearTimeout(s)},[i]),o.useEffect(()=>{if(i===null||t||(e.ask??null)!==null||(e.selection??null)!==null)return;const s=f=>{f.key==="Escape"&&(f.preventDefault(),v.current())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[i,t,e.ask,e.selection]);const m=o.useRef(e.onSelectionClose);m.current=e.onSelectionClose,o.useEffect(()=>{if((e.selection??null)===null||(e.ask??null)!==null)return;const s=f=>{f.key==="Escape"&&(f.preventDefault(),m.current())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e.selection,e.ask]);const[h,C]=o.useState(!1),S=e.ask??null,V=S===null?"":`${S.toolName} ${S.summary} ${String(S.canAlways)}`;o.useEffect(()=>{C(!1)},[V]);const O=(s,f)=>{C(!0),H(it,f===void 0?{allow:s}:{allow:s,scope:f})},A=e.selection??null,z=A===null?"":`${A.granted}|${A.truncated}|${A.text}`,[L,ee]=o.useState(!1),[F,K]=o.useState(""),W=o.useRef({composing:!1,endedAt:0}),b=o.useRef({composing:!1,endedAt:0});o.useEffect(()=>{ee(!1),K("")},[z]);const g=s=>{L||(ee(!0),H(ct,{text:s}),e.onPetTurn(fe(s)),m.current())},pe=()=>{if(A===null)return;const s=F.trim();g(s===""?dt(A.text):ft(A.text,s))},Ke=s=>{de(s.nativeEvent,b.current,Date.now())||s.key==="Enter"&&(s.preventDefault(),pe())},he=()=>{const s=u.trim();s!==""&&(d(""),e.onPetTurn(fe(s)),H(ut,{text:s}))},We=s=>{if(!de(s.nativeEvent,W.current,Date.now())){if(s.key==="Escape"){s.preventDefault(),a();return}s.key==="Enter"&&(s.preventDefault(),he())}},c=p??k.current,qe=()=>{c===null||c.kind!=="stream"||(j(c.text),k.current=null)},te=Qt(_.current,p,P?c:null,T);o.useEffect(()=>{te!==_.current&&(_.current=te,Y.current?.(te))},[te]);const ve=o.useRef(null);o.useEffect(()=>{const s=ve.current;s!==null&&(s.scrollTop=s.scrollHeight)},[e.transcript,e.answerTail,e.livePending]);const Ue=$[e.skinId??"default"],ke=e.model??null,re=e.effort??null,Be=e.workspaceName??null,le=e.modelChoices??null,ye=le!==null&&le.length>0?le:null,ae=e.recentWorkspaces??null,xe=ae!==null&&ae.length>0?ae:null,[M,R]=o.useState(null),[we,Ee]=o.useState(""),[ge,Ne]=o.useState(""),[je,Se]=o.useState(""),N=o.useRef({composing:!1,endedAt:0}),oe=o.useRef(null),Te=o.useRef(e.onNewSession);Te.current=e.onNewSession,o.useEffect(()=>{if(M===null)return;const s=f=>{oe.current!==null&&!oe.current.contains(f.target)&&R(null)};return document.addEventListener("pointerdown",s),()=>document.removeEventListener("pointerdown",s)},[M]);const ie=s=>{R(f=>f===s?null:s),s==="model"&&(Ee(""),Ne(ke??"")),s==="workspace"&&Se("")},q=s=>{H(mt,s)},Ve=()=>{q({kind:"new-session"}),Te.current?.()},He=s=>{q({kind:"set-effort",effort:s}),R(null)},$e=(s,f)=>{q({kind:"set-model",provider:s,model:f}),R(null)},Xe=s=>{q({kind:"set-workspace",path:s}),R(null)},Ye=()=>{q({kind:"pick-workspace"}),R(null)},ue=()=>{const s=we.trim();if(s==="")return;const f=ge.trim();q(f===""?{kind:"set-model",provider:s}:{kind:"set-model",provider:s,model:f}),R(null)},Pe=()=>{const s=je.trim();s!==""&&(q({kind:"set-workspace",path:s}),R(null))},ce=(s,f)=>{if(!de(s.nativeEvent,N.current,Date.now())){if(s.key==="Enter"){s.preventDefault(),f();return}s.key==="Escape"&&(s.preventDefault(),R(null))}};if(!P||c===null)return null;const ze=()=>{v.current(),H(ot,null)};return n.jsxs("div",{className:"pet-bubble","data-bubble":"","data-bubble-state":c.kind,"data-bubble-fading":w&&p===null?"":void 0,"data-bubble-held":p===null&&c.kind==="stream"?"":void 0,onClick:c.kind==="delivery"?ze:void 0,style:c.kind==="delivery"?{cursor:"pointer"}:void 0,children:[n.jsxs("div",{className:"pet-toolbar","data-pet-toolbar":"",ref:oe,children:[n.jsx("button",{type:"button",className:"pet-toolbar-new","data-toolbar-new":"",title:"新会话","aria-label":"新会话",onClick:Ve,children:n.jsx(Ze,{size:12})}),n.jsxs("div",{className:"pet-pop",children:[n.jsxs("button",{type:"button",className:"pet-chip","data-toolbar-model":"",title:"模型","aria-haspopup":"menu","aria-expanded":M==="model",onClick:()=>ie("model"),children:[n.jsx("span",{className:"pet-chip-label",children:ke??"模型"}),n.jsx("span",{className:"pet-caret","aria-hidden":!0,children:"▾"})]}),M==="model"&&n.jsx("div",{className:"pet-menu",role:"menu","aria-label":"模型","data-toolbar-model-menu":"",children:ye!==null?ye.map(s=>n.jsxs("button",{type:"button",role:"menuitem",className:"pet-mi","data-toolbar-model-item":"",title:`${s.provider} · ${s.model}`,onClick:()=>$e(s.provider,s.model),children:[s.provider," · ",s.model]},`${s.provider}/${s.model}`)):n.jsxs(n.Fragment,{children:[n.jsx("input",{"data-toolbar-provider":"",placeholder:"供应商 id(如 glm)",value:we,onChange:s=>Ee(s.target.value),onCompositionStart:()=>{N.current=G(N.current)},onCompositionEnd:()=>{N.current=Q(N.current,Date.now())},onKeyDown:s=>ce(s,ue)}),n.jsx("input",{"data-toolbar-model-input":"",placeholder:"模型 id(留空=只换供应商)",value:ge,onChange:s=>Ne(s.target.value),onCompositionStart:()=>{N.current=G(N.current)},onCompositionEnd:()=>{N.current=Q(N.current,Date.now())},onKeyDown:s=>ce(s,ue)}),n.jsx("button",{type:"button",className:"pet-menu-send","data-toolbar-model-send":"",onClick:ue,children:"发送"})]})})]}),n.jsxs("div",{className:"pet-pop",children:[n.jsxs("button",{type:"button",className:"pet-chip","data-toolbar-effort":"",title:"思考深度","aria-haspopup":"menu","aria-expanded":M==="effort",onClick:()=>ie("effort"),children:[n.jsx(et,{size:12}),n.jsx("span",{className:"pet-chip-label",children:re??"思考"}),n.jsx("span",{className:"pet-caret","aria-hidden":!0,children:"▾"})]}),M==="effort"&&n.jsx("div",{className:"pet-menu",role:"menu","aria-label":"思考深度","data-toolbar-effort-menu":"",children:tt.map(s=>n.jsx("button",{type:"button",role:"menuitemradio","aria-checked":s===re,className:`pet-mi${s===re?" on":""}`,"data-toolbar-effort-item":s,onClick:()=>He(s),children:s},s))})]}),n.jsxs("div",{className:"pet-pop",children:[n.jsxs("button",{type:"button",className:"pet-chip","data-toolbar-workspace":"",title:"工作区","aria-haspopup":"menu","aria-expanded":M==="workspace",onClick:()=>ie("workspace"),children:[n.jsx(nt,{size:12}),n.jsx("span",{className:"pet-chip-label",children:Be??"工作区"}),n.jsx("span",{className:"pet-caret","aria-hidden":!0,children:"▾"})]}),M==="workspace"&&n.jsxs("div",{className:"pet-menu",role:"menu","aria-label":"工作区","data-toolbar-workspace-menu":"",children:[n.jsx("button",{type:"button",role:"menuitem",className:"pet-mi pet-mi-browse","data-toolbar-workspace-browse":"",onClick:Ye,children:"浏览文件夹…"}),xe!==null?xe.map(s=>n.jsx("button",{type:"button",role:"menuitem",className:"pet-mi","data-toolbar-workspace-item":"",title:s,onClick:()=>Xe(s),children:Jt(s)},s)):n.jsxs(n.Fragment,{children:[n.jsx("input",{"data-toolbar-path":"",placeholder:"工作区绝对路径",value:je,onChange:s=>Se(s.target.value),onCompositionStart:()=>{N.current=G(N.current)},onCompositionEnd:()=>{N.current=Q(N.current,Date.now())},onKeyDown:s=>ce(s,Pe)}),n.jsx("button",{type:"button",className:"pet-menu-send","data-toolbar-workspace-send":"",onClick:Pe,children:"发送"})]})]})]})]}),c.kind==="ask"&&n.jsxs("div",{className:"pet-bubble-ask","data-ask-card":"",children:[n.jsx("div",{className:"pet-bubble-ask-tool","data-ask-tool":"",children:c.ask.toolName}),n.jsx("div",{className:"pet-bubble-ask-summary","data-ask-summary":"",children:c.ask.summary}),n.jsxs("div",{className:"pet-bubble-ask-actions","data-ask-actions":"",children:[n.jsx("button",{type:"button","data-ask-allow":"",disabled:h,onClick:()=>O(!0),children:"允许"}),c.ask.canAlways&&n.jsx("button",{type:"button","data-ask-always":"",disabled:h,onClick:()=>O(!0,"always"),children:"总是允许"}),n.jsx("button",{type:"button","data-ask-deny":"",disabled:h,onClick:()=>O(!1),children:"拒绝"})]})]}),c.kind==="input"&&n.jsxs("div",{className:"pet-bubble-chat",children:[n.jsx("div",{className:"pet-bubble-transcript","data-bubble-transcript":"",ref:ve,children:e.transcript.map((s,f)=>{const Qe=f===e.transcript.length-1&&s.live&&s.a==="";return n.jsx(Gt,{turn:s,thinking:Qe,avatarSheet:Ue},f)})}),n.jsxs("div",{className:"pet-bubble-input",children:[n.jsx("textarea",{"data-bubble-input":"",placeholder:"问点什么…",rows:1,autoFocus:!0,value:u,onChange:s=>d(s.target.value),onCompositionStart:()=>{W.current=G(W.current)},onCompositionEnd:()=>{W.current=Q(W.current,Date.now())},onKeyDown:We}),n.jsxs("div",{className:"pet-bubble-input-row","data-bubble-actions":"",children:[n.jsx("button",{type:"button","data-bubble-cancel":"",className:"pet-bubble-cancel",onClick:a,children:"取消"}),n.jsx("button",{type:"button","data-bubble-send":"",className:"pet-bubble-send",onClick:he,children:"发送"})]})]})]}),c.kind==="selection"&&c.selection.granted&&c.selection.text!==""&&n.jsxs("div",{className:"pet-bubble-selection","data-selection-card":"",children:[n.jsx("div",{className:"pet-bubble-selection-text","data-selection-text":"",children:c.selection.text}),n.jsxs("div",{className:"pet-bubble-selection-actions","data-selection-actions":"",children:[n.jsx("button",{type:"button","data-selection-translate":"",disabled:L,onClick:()=>g(st(c.selection.text)),children:"翻译"}),n.jsx("button",{type:"button","data-selection-explain":"",disabled:L,onClick:()=>g(rt(c.selection.text)),children:"解释"}),lt(c.selection.text)&&n.jsx("button",{type:"button","data-selection-url":"",disabled:L,onClick:()=>g(at(c.selection.text)),children:"读这个网页"})]}),n.jsxs("div",{className:"pet-bubble-selection-row","data-selection-row":"",children:[n.jsx("input",{"data-selection-question":"",placeholder:"想问它什么?",value:F,onChange:s=>K(s.target.value),onCompositionStart:()=>{b.current=G(b.current)},onCompositionEnd:()=>{b.current=Q(b.current,Date.now())},onKeyDown:Ke}),n.jsx("button",{type:"button","data-selection-send":"",disabled:L,onClick:pe,children:"发送"}),n.jsx("button",{type:"button","data-selection-cancel":"",onClick:()=>m.current(),children:"取消"})]})]}),c.kind==="selection"&&c.selection.granted&&c.selection.text===""&&n.jsxs("div",{className:"pet-bubble-selection","data-selection-empty":"",children:[n.jsx("div",{className:"pet-bubble-selection-text",children:"没划到文字"}),n.jsx("div",{className:"pet-bubble-selection-actions",children:n.jsx("button",{type:"button","data-selection-cancel":"",onClick:()=>m.current(),children:"取消"})})]}),c.kind==="selection"&&!c.selection.granted&&n.jsxs("div",{className:"pet-bubble-selection","data-selection-guide":"",children:[n.jsx("div",{className:"pet-bubble-selection-text",children:"需要辅助功能权限"}),n.jsxs("div",{className:"pet-bubble-selection-actions",children:[n.jsx("button",{type:"button","data-selection-open-settings":"",onClick:()=>void be("open_accessibility_settings",{}),children:"去系统设置打开"}),n.jsx("button",{type:"button","data-selection-cancel":"",onClick:()=>m.current(),children:"取消"})]})]}),c.kind==="hint"&&n.jsx("div",{className:"pet-bubble-hint",children:"在等你确认操作"}),c.kind==="narration"&&n.jsx("div",{className:"pet-bubble-hint","data-bubble-narration":"","data-work-kind":e.workKind??void 0,children:c.text}),c.kind==="thinking"&&n.jsx("div",{className:"pet-bubble-hint","data-bubble-thinking":"",children:"思考中…"}),c.kind==="stream"&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"pet-bubble-close","data-bubble-close":"","aria-label":"关闭回答",onClick:qe,children:"✕"}),n.jsx("div",{className:"pet-bubble-stream","data-stream-expanded":I?"":void 0,children:n.jsx(Fe,{source:c.text})}),c.text.length>Xt&&n.jsx("button",{type:"button",className:"pet-bubble-fold","data-stream-toggle":"",onClick:()=>D(s=>!s),children:I?"收起":"展开全文"})]}),c.kind==="delivery"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"pet-bubble-hint",children:"定时任务送达"}),n.jsx("div",{className:"pet-bubble-stream","data-delivery-prompt":"",children:c.delivery.promptDigest}),c.delivery.answerDigest!==""&&n.jsx("div",{className:"pet-bubble-stream","data-delivery-answer":"",children:c.delivery.answerDigest})]})]})}const en=4e3,me=Symbol("bad-ask");function tn(e){if(e==null)return null;if(typeof e!="object")return me;const t=e;return typeof t.toolName!="string"||typeof t.summary!="string"||typeof t.canAlways!="boolean"?me:{toolName:t.toolName,summary:t.summary,canAlways:t.canAlways}}const U=Symbol("bad-list");function nn(e){if(e==null)return null;if(!Array.isArray(e))return U;const t=[];for(const r of e){if(typeof r!="object"||r===null)return U;const l=r;if(typeof l.provider!="string"||typeof l.model!="string")return U;t.push({provider:l.provider,model:l.model})}return t}function sn(e){if(e==null)return null;if(!Array.isArray(e))return U;const t=[];for(const r of e){if(typeof r!="string")return U;t.push(r)}return t}function rn(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.busy!="boolean"||typeof t.pendingPermission!="boolean"||typeof t.reasoningActive!="boolean"||typeof t.answerTail!="string"||typeof t.busyToolCount!="number"||t.busyNarration!==void 0&&t.busyNarration!==null&&typeof t.busyNarration!="string"||t.workKind!==void 0&&t.workKind!==null&&typeof t.workKind!="string"||t.model!==void 0&&t.model!==null&&typeof t.model!="string"||t.effort!==void 0&&t.effort!==null&&typeof t.effort!="string"||t.workspaceName!==void 0&&t.workspaceName!==null&&typeof t.workspaceName!="string"||t.workspacePath!==void 0&&t.workspacePath!==null&&typeof t.workspacePath!="string")return null;const r=nn(t.modelChoices);if(r===U)return null;const l=sn(t.recentWorkspaces);if(l===U)return null;const a=tn(t.ask);return a===me?null:{busy:t.busy,pendingPermission:t.pendingPermission,reasoningActive:t.reasoningActive,answerTail:t.answerTail,busyToolCount:t.busyToolCount,busyNarration:typeof t.busyNarration=="string"?t.busyNarration:null,workKind:typeof t.workKind=="string"?t.workKind:null,ask:a,model:typeof t.model=="string"?t.model:null,effort:typeof t.effort=="string"?t.effort:null,workspaceName:typeof t.workspaceName=="string"?t.workspaceName:null,workspacePath:typeof t.workspacePath=="string"?t.workspacePath:null,modelChoices:r,recentWorkspaces:l}}function ln(e,t){o.useEffect(()=>{be("set_pet_layout",{mode:e})},[e,t])}function an(){const[e,t]=o.useState(null);return o.useEffect(()=>{let r=null,l=!1;return B(pt,a=>{const i=bt(a);i!==null&&t(i)}).then(a=>{l?a?.():r=a}),()=>{l=!0,r?.()}},[]),{delivery:e,clearDelivery:()=>t(null)}}function on(){const[e,t]=o.useState(null);return o.useEffect(()=>{let r=null,l=!1;return B(vt,a=>{const i=ht(a);i!==null&&t(i)}).then(a=>{l?a?.():r=a}),()=>{l=!0,r?.()}},[]),{selection:e,clearSelection:()=>t(null)}}function un(){const[e,t]=o.useState("default");return o.useEffect(()=>{let r=!1;return be("get_pet_skin",{}).then(l=>{r||t(Ce(l))}),()=>{r=!0}},[]),o.useEffect(()=>{let r=null,l=!1;return B(kt,a=>{if(typeof a!="object"||a===null)return;const i=a.skin;if(typeof i!="string")return;const u=Ce(i);u===i&&t(u)}).then(a=>{l?a?.():r=a}),()=>{l=!0,r?.()}},[]),e}function cn(e){const[t,r]=o.useState(null);return o.useEffect(()=>{let l=null,a=!1,i=null;return B(xt,u=>{const d=yt(u);d!==null&&(r(d.text),e(d.text),i!==null&&clearTimeout(i),i=setTimeout(()=>r(null),en))}).then(u=>{a?u?.():l=u}),()=>{a=!0,l?.(),i!==null&&clearTimeout(i)}},[]),t}function dn(){const[e,t]=o.useState(null);o.useEffect(()=>{let l=null,a=!1;return B(Et,i=>{const u=wt(i);u!==null&&t(u.turns)}).then(i=>{a?i?.():l=i}),()=>{a=!0,l?.()}},[]);const r=()=>{H(jt,{}).catch(()=>{})};return o.useEffect(()=>{r()},[]),{history:e,requestHistory:r,clearHistory:()=>t(null)}}function fn(){o.useEffect(()=>{let e=null,t=!1;return B(gt,r=>{if(typeof r!="object"||r===null)return;const l=r.theme;l!=="light"&&l!=="dark"||(document.documentElement.dataset.theme=l)}).then(r=>{t?r?.():e=r}),()=>{t=!0,e?.()}},[])}function mn(e){o.useEffect(()=>{let t=null,r=!1;return B(Nt,l=>{const a=rn(l);a!==null&&e(a)}).then(l=>{r?l?.():t=l}),()=>{r=!0,t?.()}},[])}const bn=650,pn=2200,hn=600,ne=["呀!","在呢在呢~","嘿嘿,别捏啦","痒痒的!","元气满满!","有什么吩咐?"];function vn(e,t){const r=ne.length,l=e===null?-1:ne.indexOf(e),a=l>=0?r-1:r,i=t(),u=i>=0&&i<1?i:0,d=Math.min(Math.floor(u*a),a-1),T=l>=0&&d>=l?d+1:d,j=ne[T];return j!==void 0?j:ne[0]}const se=5;function kn(e,t){if(e===null||t.type==="pointercancel"||e.x===void 0||e.y===void 0||t.clientX===void 0||t.clientY===void 0)return!1;const r=t.clientX-e.x,l=t.clientY-e.y;return r*r+l*l>=se*se}function yn(e,t){if(e===null||!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;const r=t.x-e.x,l=t.y-e.y;return r*r+l*l>=se*se}const Le=5,xn=600,Me=4;function wn(e){const[t,r]=o.useState(0),l=o.useRef(document.hidden);return o.useEffect(()=>{const a=()=>{l.current&&!document.hidden&&(r(i=>i+1),e()),l.current=document.hidden};return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[]),t}function En(e){const{inputOpen:t,setInputOpen:r}=e,[l,a]=o.useState(!1),[i,u]=o.useState(0),[d,T]=o.useState(!1),[j,I]=o.useState(null),[D,p]=o.useState(!1),k=o.useRef(null),P=o.useRef(!1),x=o.useRef(null),w=o.useRef(null),y=o.useRef(null),E=o.useRef(null),_=o.useRef(null);return o.useEffect(()=>{if(!l)return;const v=m=>{x.current!==null&&(clearTimeout(x.current),x.current=null),a(!1);const h=k.current;if(k.current=null,kn(h,m)&&(p(!0),y.current!==null&&clearTimeout(y.current),y.current=setTimeout(()=>{y.current=null,p(!1)},450)),h===null||m.type==="pointercancel"||h.x===void 0||h.y===void 0||m.clientX===void 0||m.clientY===void 0)return;const C=m.clientX-h.x,S=m.clientY-h.y,V=Date.now()-h.t;C*C+S*S<Le*Le&&V<xn&&(r(O=>!O),t||St())};return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[l,t]),o.useEffect(()=>{if(!l){P.current=!1;return}const v=m=>{const h=k.current;if(P.current){m.buttons===0&&(P.current=!1,k.current=null,a(!1),p(!0),y.current!==null&&clearTimeout(y.current),y.current=setTimeout(()=>{y.current=null,p(!1)},450));return}if(h===null||h.x===void 0||h.y===void 0)return;const C=m.clientX-h.x,S=m.clientY-h.y;C*C+S*S>=Me*Me&&(P.current=!0,Tt())};return window.addEventListener("pointermove",v),()=>{window.removeEventListener("pointermove",v)}},[l]),o.useEffect(()=>()=>{x.current!==null&&clearTimeout(x.current),w.current!==null&&clearTimeout(w.current),y.current!==null&&clearTimeout(y.current),E.current!==null&&clearTimeout(E.current)},[]),{dragging:l,releaseFlash:D,pokeEpoch:i,pokeFlash:d,pokeExpr:j,onPointerDown:v=>{k.current={x:v.clientX,y:v.clientY,sx:window.screenX,sy:window.screenY,t:Date.now()},a(!0),x.current!==null&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,!yn(k.current!==null?{x:k.current.sx,y:k.current.sy}:null,{x:window.screenX,y:window.screenY})&&(_.current=vn(_.current,Math.random),u(m=>m+1),T(!0),E.current!==null&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,T(!1)},hn),I(_.current),w.current!==null&&clearTimeout(w.current),w.current=setTimeout(()=>{w.current=null,I(null)},pn))},bn)}}}function gn(){const[e,t]=o.useState(Dt),[r,l]=o.useState(null),[a,i]=o.useState(!1),[u,d]=o.useState("compact"),[T,j]=o.useState(De),[I,D]=o.useState(!1),{delivery:p,clearDelivery:k}=an(),{selection:P,clearSelection:x}=on(),w=un();ln(u,w);const y=cn(()=>{D(!1),j(b=>{const g=b.turns.length>0?b.turns[b.turns.length-1]:void 0;return g===void 0||!g.live?b:{turns:b.turns.slice(0,-1)}})}),{history:E,requestHistory:_,clearHistory:Y}=dn();fn(),mn(b=>{l(b),t(g=>Rt(g,Pt(b),Date.now())),j(g=>Ut(g,b)),D(!1)});const v=wn(_),{dragging:m,releaseFlash:h,pokeEpoch:C,pokeFlash:S,pokeExpr:V,onPointerDown:O}=En({inputOpen:a,setInputOpen:i}),A=Wt[w].component;o.useEffect(()=>{if(!a)return;const b=()=>i(!1);return window.addEventListener("blur",b),()=>window.removeEventListener("blur",b)},[a]),o.useEffect(()=>{a&&_()},[a]);const z=r?.busy??!1,L=o.useRef(!1);o.useEffect(()=>{L.current&&!z&&_(),L.current=z},[z]);const ee=b=>{j(g=>qt(g,b)),D(!0)},F=o.useMemo(()=>E===null?T.turns:Bt(E,T).turns,[E,T]),K=F.length>0?F[F.length-1]:void 0,W=I||K!==void 0&&K.live&&K.q!==""&&K.a===""&&(r?.busy??!1)===!0;return n.jsxs(n.Fragment,{children:[n.jsx(Zt,{inputOpen:a,answerTail:r?.answerTail??"",waitingUser:e.display==="waiting-user",busyNarration:r?.busyNarration??null,workKind:r?.workKind??null,onInputClose:()=>i(!1),delivery:p,onDeliveryClose:k,ask:r?.ask??null,selection:P,onSelectionClose:x,onLayoutMode:d,transcript:F,onPetTurn:ee,livePending:W,skinId:w,model:r?.model??null,effort:r?.effort??null,workspaceName:r?.workspaceName??null,workspacePath:r?.workspacePath??null,modelChoices:r?.modelChoices??null,recentWorkspaces:r?.recentWorkspaces??null,onNewSession:()=>{j(De),D(!1),Y()}}),n.jsx(Mt,{display:m?"drag":h?"release":e.display,skinId:w,figure:A,pokeEpoch:C,poked:S,onPointerDown:O},v),y!==null&&n.jsx("div",{className:"pet-toast","data-pet-toast":"",role:"status",children:y}),V!==null&&n.jsx("div",{className:"pet-expr","data-pet-expr":"",role:"status",children:V})]})}const Ie=new URLSearchParams(window.location.search).get("view");Ie!==null&&(document.documentElement.dataset.view=Ie);try{document.documentElement.dataset.theme=localStorage.getItem("wudao.ui.theme")==="light"?"light":"dark"}catch{document.documentElement.dataset.theme="dark"}const Nn=document.getElementById("pet-root")??document.body;_t.createRoot(Nn).render(n.jsx(o.StrictMode,{children:n.jsx(gn,{})}));
|