pisper 0.5.50 → 0.5.51
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/package.json +7 -7
- package/web/.vite/manifest.json +162 -159
- package/web/assets/{AppOverlays-DrS2NA9w.js → AppOverlays-DlB6SVT6.js} +1 -1
- package/web/assets/{AppSelect-CRjRgr38.js → AppSelect-kDqZkETY.js} +1 -1
- package/web/assets/{AssetsPage-C2GY8596.js → AssetsPage-mZkZgR9g.js} +1 -1
- package/web/assets/{ChannelsPage-FPSrQa1G.js → ChannelsPage-Dau7vaaV.js} +1 -1
- package/web/assets/{ChatDockView-BJGa8Bm8.js → ChatDockView-Cq7J6Xmn.js} +1 -1
- package/web/assets/{ChatHistoryPage-BBmrFY5U.js → ChatHistoryPage-BpoHAiYo.js} +1 -1
- package/web/assets/{ChatPage-DfQGtuLo.js → ChatPage-CCMsSvJV.js} +3 -3
- package/web/assets/{ConfigPage-D27UB6Ni.js → ConfigPage-BGZoCXnB.js} +1 -1
- package/web/assets/{MarkdownMessage-BQ_6o9-O.js → MarkdownMessage-Dbgb5XkJ.js} +1 -1
- package/web/assets/{MemoryPage-D46RKJLE.js → MemoryPage-BiAbcHbL.js} +1 -1
- package/web/assets/{PageHeader-DH1jtT2l.js → PageHeader-9ctH9v28.js} +1 -1
- package/web/assets/PluginsPage-D-D22LWb.js +1 -0
- package/web/assets/{PreviewPages-BBwzd5LJ.js → PreviewPages-DUZgwvOb.js} +1 -1
- package/web/assets/{SchedulesPage-AyePMsz_.js → SchedulesPage-C3sS9Ej3.js} +1 -1
- package/web/assets/{SkillsPage-Cb3i7xyX.js → SkillsPage-BeeTZyfc.js} +1 -1
- package/web/assets/{TerminalPanel-B06cwdRZ.js → TerminalPanel-a4jiIuSs.js} +1 -1
- package/web/assets/{WelcomeEffects-CsxWSguh.js → WelcomeEffects-Xo1Z1Nf4.js} +1 -1
- package/web/assets/{WorkflowsPage-Byq1cQot.js → WorkflowsPage-BCdz4ise.js} +1 -1
- package/web/assets/{WorkspacePicker-BNVaK0c9.js → WorkspacePicker-Ctf1A8lp.js} +1 -1
- package/web/assets/client-store-ohgbeJNh.js +1 -0
- package/web/assets/{collapsible-C4owDMcF.js → collapsible-U8Wh2f7S.js} +1 -1
- package/web/assets/{config-search-CsGhOXIG.js → config-search-CdRsMMUS.js} +1 -1
- package/web/assets/{dist-VQXpFPjV.js → dist-Dq4VqZgU.js} +1 -1
- package/web/assets/{dist-CyztUDRL.js → dist-cR3ayBwn.js} +1 -1
- package/web/assets/{es2015-BpePoPbM.js → es2015-DycjrqX-.js} +1 -1
- package/web/assets/{field-BAyGDYW_.js → field-t72VAR-1.js} +1 -1
- package/web/assets/index-Bd5A8V1V.js +40 -0
- package/web/assets/index-DUhopGVK.css +2 -0
- package/web/assets/{progress-BqaId9J2.js → progress-DQDjWjzV.js} +1 -1
- package/web/assets/{scroll-area-DkxdCF8r.js → scroll-area-C1DpxpHg.js} +1 -1
- package/web/assets/{separator-0_agp17Z.js → separator-Br2F2Mir.js} +1 -1
- package/web/assets/tool-labels-v0OysnpI.js +1 -0
- package/web/assets/{tooltip-D9uQM6ab.js → tooltip-DfGEs0yi.js} +1 -1
- package/web/assets/use-i18n-jYw5s_Yn.js +1 -0
- package/web/assets/{use-mobile-A2egKMjY.js → use-mobile-C1OVAMOm.js} +1 -1
- package/web/assets/web-preview-panel-uBOnhY4Z.js +556 -0
- package/web/assets/{welcome-brand-CYtVVlIL.js → welcome-brand-R7Xflzvb.js} +1 -1
- package/web/index.html +10 -10
- package/web/assets/PluginsPage-B4cG171E.js +0 -1
- package/web/assets/client-store-BSV7t02b.js +0 -1
- package/web/assets/index-CAWCOpxG.js +0 -40
- package/web/assets/index-DT-gaDrM.css +0 -2
- package/web/assets/tool-labels-BJhLig5u.js +0 -1
- package/web/assets/use-i18n-yjKc6F2w.js +0 -1
- package/web/assets/web-preview-panel-BOmJGqhe.js +0 -556
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{o as r,t as i}from"./chat-api-Cy0t78Jm.js";import{t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{o as r,t as i}from"./chat-api-Cy0t78Jm.js";import{t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-jYw5s_Yn.js";import{t as s}from"./loader-circle-72TYCcVQ.js";import{t as c}from"./tag-Csd134FL.js";import{t as l}from"./x-bw26XDZM.js";import{t as u}from"./input-D1QFzNMx.js";import{A as d,B as f,Ht as p,P as m,j as h,k as g,n as _,vt as v,wt as y,xt as b}from"./index-Bd5A8V1V.js";import{t as x}from"./field-t72VAR-1.js";var S=e(t(),1),C=n();function w({navigation:e,onClose:t,onNavigate:n,onOpenSession:a,onNewChat:l}){let{t:u,language:_}=o(),[x,w]=(0,S.useState)(``),{data:T}=p(r(`sessions`)),E=(0,S.useMemo)(()=>T?.sessions||[],[T]),[D,O]=(0,S.useState)([]),[k,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)(0),[N,P]=(0,S.useState)(``);(0,S.useEffect)(()=>{let e=x.trim();if(!e){O([]),A(!1);return}let t=!0;A(!0);let n=window.setTimeout(()=>{i.searchSessionTreeLabels(e,12).then(e=>{t&&(O(e.labels||[]),A(!1))}).catch(()=>{t&&(O([]),A(!1))})},140);return()=>{t=!1,window.clearTimeout(n)}},[x]);let F=(0,S.useMemo)(()=>{let t=x.trim().toLocaleLowerCase(_),r=(...e)=>!t||e.some(e=>String(e||``).toLocaleLowerCase(_).includes(t)),i=[],o=u(`navigation:appOverlays.newChat`);r(o,u(`navigation:appOverlays.actions`))&&i.push({id:`action:new-chat`,Icon:b,label:o,hint:u(`navigation:appOverlays.actions`),run:l});for(let[t,a]of e)for(let[e,o,s]of a)r(o,t,e)&&i.push({id:`page:${e}`,Icon:s,label:o,hint:t,run:()=>n(e)});let s=e=>{let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(_,{dateStyle:`medium`,timeStyle:`short`}).format(t):u(`navigation:appOverlays.unknownTime`)};for(let e of D){let t=s(e.sessionCreated||e.sessionModified),n=s(e.nodeTimestamp);i.push({id:`label:${e.sessionId}:${e.entryId}`,Icon:c,label:e.label,hint:e.sessionName||u(`navigation:appOverlays.untitledChat`),meta:u(`navigation:appOverlays.labelResultTimes`,{sessionTime:t,nodeTime:n}),title:e.summary||e.label,run:()=>a(e.sessionId,e.entryId,e.active)})}for(let e of[...E].sort((e,t)=>Date.parse(t.modified)-Date.parse(e.modified)))if(r(e.name,e.firstMessage)&&(i.push({id:`session:${e.id}`,Icon:y,label:e.name||u(`navigation:appOverlays.untitledChat`),hint:f(e.modified,_),run:()=>a(e.id)}),i.filter(e=>e.id.startsWith(`session:`)).length>=8))break;return i},[D,_,e,n,l,a,x,E,u]);(0,S.useEffect)(()=>{M(0)},[x]);let I=Math.min(j,Math.max(0,F.length-1)),L=async e=>{if(!(!e||N)){if(!e.id.startsWith(`label:`)){t(),e.run();return}P(e.id);try{await e.run(),t()}catch{P(``)}}};return(0,C.jsx)(g,{open:!0,onOpenChange:e=>!e&&!N&&t(),children:(0,C.jsxs)(d,{showCloseButton:!1,"aria-busy":!!N,className:`command-palette max-[650px]:w-full w-[min(560px,calc(100vw_-_40px))] overflow-hidden [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] shadow-[0_28px_80px_-24px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] top-[16vh]! max-w-[calc(100vw-40px)]! translate-y-0! gap-0 p-0 ring-0 max-sm:top-[8vh]! sm:max-w-[560px]!`,children:[(0,C.jsx)(m,{className:`sr-only`,children:u(`navigation:appOverlays.commandPalette`)}),(0,C.jsx)(h,{className:`sr-only`,children:u(`navigation:appOverlays.searchPagesChatsOrActions`)}),(0,C.jsxs)(`label`,{className:`palette-input [&_input]:w-full [&_input]:min-w-0 [&_input]:border-0 [&_input]:[outline:0] [&_input]:bg-transparent [&_input]:text-[var(--text)] [&_input]:text-[14px] [&_kbd]:flex-none [&_kbd]:[border:1px_solid_var(--stroke)] [&_kbd]:rounded-[5px] [&_kbd]:bg-[var(--surface-subtle)] [&_kbd]:p-[1px_5px] [&_kbd]:text-[var(--text-muted)] [&_kbd]:font-[inherit] [&_kbd]:text-[10px] flex h-[46px] items-center gap-[9px] [border-bottom:1px_solid_var(--stroke-soft)] [padding:0_14px] text-[var(--text-muted)]`,children:[(0,C.jsx)(v,{size:16}),(0,C.jsx)(`input`,{autoFocus:!0,value:x,disabled:!!N,onChange:e=>w(e.target.value),onKeyDown:e=>{if(N){e.preventDefault();return}e.key===`ArrowDown`?(e.preventDefault(),M(e=>F.length?(e+1)%F.length:0)):e.key===`ArrowUp`?(e.preventDefault(),M(e=>F.length?(e-1+F.length)%F.length:0)):e.key===`Enter`?(e.preventDefault(),L(F[I])):e.key===`Escape`&&(e.preventDefault(),t())},placeholder:u(`navigation:appOverlays.searchPagesChatsOrActions`)}),N?(0,C.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs`,role:`status`,"aria-live":`polite`,children:[(0,C.jsx)(s,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}),u(`navigation:appOverlays.locatingLabel`)]}):(0,C.jsx)(`kbd`,{children:`Esc`})]}),(0,C.jsxs)(`div`,{className:`max-h-[min(380px,50vh)] overflow-y-auto [padding:6px]`,role:`listbox`,"aria-label":u(`navigation:appOverlays.commandPalette`),children:[F.map((e,t)=>(0,C.jsxs)(`button`,{type:`button`,className:`palette-item [&_>_svg]:flex-none [&_>_svg]:text-[var(--text-muted)] [&.active]:bg-[var(--star-soft)] [&.active]:text-[var(--text)] [&.active_>_svg]:text-[var(--star-strong)] flex w-full items-center gap-[10px] border-0 rounded-[var(--r-sm)] bg-transparent [padding:9px_10px] text-[var(--text-secondary)] text-[13px] text-left cursor-pointer ${e.meta?`has-meta`:``} ${t===I?`active`:``}`,title:e.title,role:`option`,"aria-selected":t===I,disabled:!!N,"aria-busy":N===e.id,onMouseEnter:()=>!N&&M(t),onClick:()=>void L(e),children:[N===e.id?(0,C.jsx)(s,{className:`size-[15px] animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(e.Icon,{size:15}),(0,C.jsxs)(`span`,{className:`palette-item-copy [&_>_small]:overflow-hidden [&_>_small]:text-[var(--text-muted)] [&_>_small]:text-[10px] [&_>_small]:text-ellipsis [&_>_small]:whitespace-nowrap flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,C.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:e.label}),e.meta&&(0,C.jsx)(`small`,{children:e.meta})]}),(0,C.jsx)(`span`,{className:`palette-item-hint max-[650px]:max-w-[34vw] max-w-[180px] flex-none overflow-hidden text-[var(--text-muted)] text-[11px] text-ellipsis whitespace-nowrap`,children:N===e.id?u(`navigation:appOverlays.locatingLabel`):e.hint})]},e.id)),!F.length&&(0,C.jsx)(`div`,{className:`palette-empty [padding:20px] text-[var(--text-muted)] text-[12px] text-center`,children:u(k?`navigation:appOverlays.searchingLabels`:`navigation:appOverlays.noMatchingResults`)}),F.length>0&&k&&(0,C.jsx)(`div`,{"aria-live":`polite`,className:`palette-empty [padding:20px] text-[var(--text-muted)] text-[12px] text-center palette-searching [.palette-empty&]:p-[8px_12px]`,children:u(`navigation:appOverlays.searchingLabels`)})]})]})})}function T({type:e,close:t,notify:n}){let{t:r}=o(),i={chat:r(`navigation:appOverlays.newChat2`),assets:r(`navigation:appOverlays.exportAsset`),channels:r(`navigation:appOverlays.connectChannel`),schedules:r(`navigation:appOverlays.newScheduledTask`),config:r(`navigation:appOverlays.addProvider`),plugins:r(`navigation:appOverlays.savePluginPolicy`),memory:r(`navigation:appOverlays.addMemory`),mcp:r(`navigation:appOverlays.addMCPService`),skills:r(`navigation:appOverlays.installSkill`)}[e]||r(`navigation:appOverlays.newProject`),s=[r(`navigation:appOverlays.default`),r(`navigation:appOverlays.custom`),r(`navigation:appOverlays.createFromTemplate`)];return(0,C.jsx)(g,{open:!0,onOpenChange:e=>!e&&t(),children:(0,C.jsx)(d,{showCloseButton:!1,className:`modal !w-[min(430px,100%)] max-h-[calc(100dvh_-_40px)] overflow-y-auto [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)] max-w-[430px]! gap-0 rounded-dialog border-surface-highlight shadow-dialog ring-0`,children:(0,C.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n(r(`navigation:appOverlays.actionSucceeded`,{action:i})),t()},children:[(0,C.jsxs)(_,{children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(m,{children:i}),(0,C.jsx)(h,{children:r(`navigation:appOverlays.enterTheBasicDetailsToContinue`)})]}),(0,C.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":r(`navigation:appOverlays.closeDialog`),title:r(`navigation:appOverlays.closeDialog`),onClick:t,children:(0,C.jsx)(l,{className:`size-[17px]`})})]}),(0,C.jsxs)(x,{variant:`control`,className:`items-start`,children:[r(`navigation:appOverlays.name`),(0,C.jsx)(u,{name:`name`,placeholder:r(`navigation:appOverlays.enterAName`)})]}),(0,C.jsxs)(x,{variant:`control`,className:`items-start`,children:[r(`navigation:appOverlays.description`),(0,C.jsx)(u,{name:`description`,placeholder:r(`navigation:appOverlays.addAShortDescription`)})]}),(0,C.jsx)(x,{variant:`control`,className:`items-start`,htmlFor:`quick-create-type`,children:r(`navigation:appOverlays.type`)}),(0,C.jsx)(`select`,{id:`quick-create-type`,name:`type`,defaultValue:s[0],className:`mt-1 w-full bg-surface-subtle`,children:s.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))}),(0,C.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,C.jsx)(a,{type:`button`,variant:`secondary`,onClick:t,children:r(`navigation:appOverlays.cancel`)}),(0,C.jsxs)(a,{type:`submit`,children:[(0,C.jsx)(b,{className:`size-3.5`}),r(`navigation:appOverlays.create`)]})]})]})})})}export{w as CommandPalette,T as QuickCreate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n,t as r}from"./vendor-react-CHuvPdJE.js";import{i,n as a,o}from"./button-XhIEgIsg.js";import{d as s,f as c,h as l,m as u,p as d}from"./use-i18n-yjKc6F2w.js";import{c as f,i as p,o as m,s as h,t as g,u as _}from"./use-mobile-A2egKMjY.js";import{a as v,i as y,n as b,r as x,s as S,t as C,u as w}from"./es2015-BpePoPbM.js";import{n as T,t as E}from"./dist-CyztUDRL.js";import{t as D}from"./utils-C8uzG5AZ.js";import{t as O}from"./check-jIXqkGKr.js";import{t as k}from"./chevron-down-DT6AXwTP.js";import{Bt as A,Vt as j}from"./index-CAWCOpxG.js";var M=e(n(),1),N=e(t(),1),ee=Object.defineProperty,P=(e,t)=>ee(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}P(F,`usePrevious`);var I=Object.defineProperty,te=(e,t)=>I(e,`name`,{value:t,configurable:!0});function L(e,[t,n]){return Math.min(n,Math.max(t,e))}te(L,`clamp`);var R=r(),z=Object.defineProperty,B=(e,t)=>z(e,`name`,{value:t,configurable:!0}),V=[` `,`Enter`,`ArrowUp`,`ArrowDown`],H=[` `,`Enter`],U=`Select`,[W,G,ne]=j(U),[K,re]=u(U,[ne,f]),q=f(),[ie,J]=K(U),[ae,oe]=K(U);function se(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:g,internal_do_not_use_render:_}=e,v=q(t),[y,b]=N.useState(null),[x,S]=N.useState(null),[C,w]=N.useState(!1),E=A(u),[D,O]=s({prop:r,defaultProp:i??!1,onChange:a,caller:U}),[k,j]=s({prop:o,defaultProp:c,onChange:l,caller:U}),M=N.useRef(null),ee=N.useRef(k);N.useEffect(()=>{let e=g?y?.ownerDocument.getElementById(g):y?.form;if(e instanceof HTMLFormElement){let t=B(()=>j(ee.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[g,y,j]);let P=!y||!!g||!!y.closest(`form`),[F,I]=N.useState(new Set),te=T(),L=Array.from(F).map(e=>e.props.value).join(`;`),z=N.useCallback(e=>{I(t=>new Set(t).add(e))},[]),V=N.useCallback(e=>{I(t=>{let n=new Set(t);return n.delete(e),n})},[]),H={required:m,trigger:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:te,value:k,onValueChange:j,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:p,name:d,autoComplete:f,form:g,nativeOptions:F,nativeSelectKey:L,isFormControl:P};return(0,R.jsx)(h,{...v,children:(0,R.jsx)(ie,{scope:t,...H,children:(0,R.jsx)(W.Provider,{scope:t,children:(0,R.jsx)(ae,{scope:t,onNativeOptionAdd:z,onNativeOptionRemove:V,children:We(_)?_(H):n})})})})}B(se,`SelectProvider`);var ce=B(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,R.jsx)(se,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,R.jsxs)(R.Fragment,{children:[n,e?(0,R.jsx)(Ue,{__scopeSelect:t}):null]})})},`Select`),le=`SelectTrigger`,ue=N.forwardRef(B(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=q(n),s=J(le,n),c=s.disabled||r,u=o(t,s.onTriggerChange),f=G(n),m=N.useRef(`touch`),[h,g,_]=Ge(e=>{let t=f().filter(e=>!e.disabled),n=Ke(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onValueChange(n.value)}),v=B(e=>{c||(s.onOpenChange(!0),_()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,R.jsx)(p,{asChild:!0,...a,children:(0,R.jsx)(l.button,{type:`button`,role:`combobox`,"aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":$(s.value)?``:void 0,...i,ref:u,onClick:d(i.onClick,e=>{e.currentTarget.focus(),m.current!==`mouse`&&v(e)}),onPointerDown:d(i.onPointerDown,e=>{m.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(v(e),e.preventDefault())}),onKeyDown:d(i.onKeyDown,e=>{let t=h.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&g(e.key),!(t&&e.key===` `)&&V.includes(e.key)&&(v(),e.preventDefault())})})})},`SelectTrigger`)),de=`SelectValue`,fe=N.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:s=``,...u}=e,d=J(de,n),{onValueNodeHasChildrenChange:f}=d,p=a!==void 0,m=o(t,d.onValueNodeChange);c(()=>{f(p)},[f,p]);let h=$(d.value);return(0,R.jsx)(l.span,{...u,asChild:!h&&u.asChild,ref:m,style:{pointerEvents:`none`},children:(0,R.jsx)(N.Fragment,{children:h?s:a},h?`placeholder`:`value`)})},`SelectValue`)),pe=N.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,R.jsx)(l.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[me,he]=K(`SelectPortal`,{forceMount:void 0}),ge=B(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,R.jsx)(me,{scope:e.__scopeSelect,forceMount:n,children:(0,R.jsx)(y,{asChild:!0,...r})})},`SelectPortal`),Y=`SelectContent`,_e=N.forwardRef(B(function(e,t){let n=he(Y,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=J(Y,e.__scopeSelect),[o,s]=N.useState();return c(()=>{s(new DocumentFragment)},[]),(0,R.jsx)(w,{present:r||a.open,children:({present:e})=>e?(0,R.jsx)(xe,{...i,ref:t}):(0,R.jsx)(ve,{...i,fragment:o})})},`SelectContent`)),ve=N.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,R.jsx)(ye,{scope:n,children:(0,R.jsx)(W.Slot,{scope:n,children:(0,R.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),X=10,[ye,Z]=K(Y),be=i(`SelectContent.RemoveScroll`),xe=N.forwardRef(B(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:_,avoidCollisions:y,...w}=e,T=J(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=o(t,D),[j,M]=N.useState(null),[ee,P]=N.useState(null),F=G(n),[I,te]=N.useState(!1),L=N.useRef(!1);N.useEffect(()=>{if(E)return C(E)},[E]),x();let z=N.useCallback(e=>{let[t,...n]=F().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[F,O]),V=N.useCallback(()=>z([j,E]),[z,j,E]);N.useEffect(()=>{I&&V()},[I,V]);let{onOpenChange:H,triggerPointerDownPosRef:U}=T;N.useEffect(()=>{if(E){let e={x:0,y:0},t=B(t=>{e={x:Math.abs(Math.round(t.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(U.current?.y??0))}},`handlePointerMove`),n=B(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||H(!1),document.removeEventListener(`pointermove`,t),U.current=null},`handlePointerUp`);return U.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,H,U]),N.useEffect(()=>{let e=B(()=>H(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[H]);let[W,ne]=Ge(e=>{let t=F().filter(e=>!e.disabled),n=Ke(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),K=N.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&(M(e),r&&(L.current=!0))},[T.value]),re=N.useCallback(()=>E?.focus(),[E]),q=N.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&P(e)},[T.value]),ie=r===`popper`?Ce:Se,ae=ie===Ce?{side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:_,avoidCollisions:y}:{};return(0,R.jsx)(ye,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:K,selectedItem:j,onItemLeave:re,itemTextRefCallback:q,focusSelectedItem:V,selectedItemText:ee,position:r,isPositioned:I,searchRef:W,children:(0,R.jsx)(b,{as:be,allowPinchZoom:!0,children:(0,R.jsx)(v,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:d(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,R.jsx)(S,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,R.jsx)(ie,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ae,onPlaced:()=>te(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:d(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>z(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Se=N.forwardRef(B(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=J(Y,n),s=Z(Y,n),[u,d]=N.useState(null),[f,p]=N.useState(null),m=o(t,p),h=G(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=s,S=N.useCallback(()=>{if(a.trigger&&a.valueNode&&u&&f&&v&&y&&b){let e=a.trigger.getBoundingClientRect(),t=f.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-X,d=L(a,[X,Math.max(X,l-c)]);u.style.minWidth=s+`px`,u.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-X,d=L(a,[X,Math.max(X,l-c)]);u.style.minWidth=s+`px`,u.style.right=d+`px`}let o=h(),s=window.innerHeight-X*2,c=v.scrollHeight,l=window.getComputedStyle(f),d=parseInt(l.borderTopWidth,10),p=parseInt(l.paddingTop,10),m=parseInt(l.borderBottomWidth,10),_=parseInt(l.paddingBottom,10),x=d+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-X,D=s-E,O=y.offsetHeight/2,k=y.offsetTop+O,A=d+p+k,j=x-A;if(A<=E){let e=o.length>0&&y===o[o.length-1].ref.current;u.style.bottom=`0px`;let t=f.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+m);u.style.height=n+`px`}else{let e=o.length>0&&y===o[0].ref.current;u.style.top=`0px`;let t=Math.max(E,d+v.offsetTop+(e?w:0)+O)+j;u.style.height=t+`px`,v.scrollTop=A-E+v.offsetTop}u.style.margin=`${X}px 0`,u.style.minHeight=S+`px`,u.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,u,f,v,y,b,a.dir,r]);c(()=>S(),[S]);let[C,w]=N.useState();c(()=>{f&&w(window.getComputedStyle(f).zIndex)},[f]);let T=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,R.jsx)(we,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,R.jsx)(`div`,{ref:d,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,R.jsx)(l.div,{...i,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Ce=N.forwardRef(B(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=X,...a}=e,o=q(n);return(0,R.jsx)(m,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[we,Te]=K(Y,{}),Ee=`SelectViewport`,De=N.forwardRef(B(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Z(Ee,n),s=Te(Ee,n),c=o(t,a.onViewportChange),u=N.useRef(0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,R.jsx)(W.Slot,{scope:n,children:(0,R.jsx)(l.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:d(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(u.current-t.scrollTop);if(e>0){let r=window.innerHeight-X*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}u.current=t.scrollTop})})})]})},`SelectViewport`)),[Oe,ke]=K(`SelectGroup`),Ae=`SelectItem`,[je,Me]=K(Ae),Ne=N.forwardRef(B(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...s}=e,c=J(Ae,n),u=Z(Ae,n),f=c.value===r,[p,m]=N.useState(a??``),[h,g]=N.useState(!1),_=E(e=>u.itemRefCallback?.(e,r,i)),v=o(t,_),y=T(),b=N.useRef(`touch`),x=B(()=>{i||(c.onValueChange(r),c.onOpenChange(!1))},`handleSelect`);return(0,R.jsx)(je,{scope:n,value:r,disabled:i,textId:y,isSelected:f,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,R.jsx)(W.ItemSlot,{scope:n,value:r,disabled:i,textValue:p,children:(0,R.jsx)(l.div,{role:`option`,"aria-labelledby":y,"data-highlighted":h?``:void 0,"aria-selected":f&&h,"data-state":f?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...s,ref:v,onFocus:d(s.onFocus,()=>g(!0)),onBlur:d(s.onBlur,()=>g(!1)),onClick:d(s.onClick,()=>{b.current!==`mouse`&&x()}),onPointerUp:d(s.onPointerUp,()=>{b.current===`mouse`&&x()}),onPointerDown:d(s.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:d(s.onPointerMove,e=>{b.current=e.pointerType,i?u.onItemLeave?.():b.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:d(s.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:d(s.onKeyDown,e=>{i||e.target!==e.currentTarget||(u.searchRef?.current===``||e.key!==` `)&&(H.includes(e.key)&&x(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,Pe=N.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,s=J(Q,n),u=Z(Q,n),d=Me(Q,n),f=oe(Q,n),[p,m]=N.useState(null),h=E(e=>u.itemTextRefCallback?.(e,d.value,d.disabled)),g=o(t,m,d.onItemTextChange,h),_=p?.textContent,v=N.useMemo(()=>(0,R.jsx)(`option`,{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:y,onNativeOptionRemove:b}=f;return c(()=>(y(v),()=>b(v)),[y,b,v]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l.span,{id:d.textId,...a,ref:g}),d.isSelected&&s.valueNode&&!s.valueNodeHasChildren&&!$(s.value)?M.createPortal(a.children,s.valueNode):null]})},`SelectItemText`)),Fe=`SelectItemIndicator`,Ie=N.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e;return Me(Fe,n).isSelected?(0,R.jsx)(l.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Le=`SelectScrollUpButton`,Re=N.forwardRef(B(function(e,t){let n=Z(Le,e.__scopeSelect),r=Te(Le,e.__scopeSelect),[i,a]=N.useState(!1),s=o(t,r.onScrollButtonChange);return c(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(Ve,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),ze=`SelectScrollDownButton`,Be=N.forwardRef(B(function(e,t){let n=Z(ze,e.__scopeSelect),r=Te(ze,e.__scopeSelect),[i,a]=N.useState(!1),s=o(t,r.onScrollButtonChange);return c(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(Ve,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Ve=N.forwardRef(B(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Z(`SelectScrollButton`,n),o=N.useRef(null),s=G(n),u=N.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return N.useEffect(()=>()=>u(),[u]),c(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,R.jsx)(l.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:d(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:d(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:d(i.onPointerLeave,()=>{u()})})},`SelectScrollButtonImpl`)),He=`SelectBubbleInput`,Ue=N.forwardRef(B(function({__scopeSelect:e,...t},n){let r=J(He,e),{value:i,onValueChange:a,required:s,disabled:c,name:u,autoComplete:d,form:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,h=N.useRef(null),g=o(n,h),v=i??``,y=F(v),b=Array.from(p).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=h.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,R.jsxs)(l.select,{"aria-hidden":!0,required:s,tabIndex:-1,name:u,autoComplete:d,disabled:c,form:f,onChange:e=>a(e.target.value),...t,style:{..._,...t.style},ref:g,defaultValue:v,children:[$(i)&&!b?(0,R.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function We(e){return typeof e==`function`}B(We,`isFunction`);function $(e){return e===``||e===void 0}B($,`shouldShowPlaceholder`);function Ge(e){let t=E(e),n=N.useRef(``),r=N.useRef(0),i=N.useCallback(e=>{let i=n.current+e;t(i),B((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=N.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}B(Ge,`useTypeaheadSearch`);function Ke(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=qe(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}B(Ke,`findNextItem`);function qe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}B(qe,`wrapArray`);var Je=a(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]);function Ye({...e}){return(0,R.jsx)(ce,{"data-slot":`select`,...e})}function Xe({...e}){return(0,R.jsx)(fe,{"data-slot":`select-value`,...e})}function Ze({className:e,size:t=`default`,children:n,...r}){return(0,R.jsxs)(ue,{"data-slot":`select-trigger`,"data-size":t,className:D(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,R.jsx)(pe,{asChild:!0,children:(0,R.jsx)(k,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Qe({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,R.jsx)(ge,{children:(0,R.jsxs)(_e,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:D(`relative z-[200] max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,R.jsx)(et,{}),(0,R.jsx)(De,{"data-position":n,className:D(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,R.jsx)(tt,{})]})})}function $e({className:e,children:t,...n}){return(0,R.jsxs)(Ne,{"data-slot":`select-item`,className:D(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,R.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,R.jsx)(Ie,{children:(0,R.jsx)(O,{className:`pointer-events-none`})})}),(0,R.jsx)(Pe,{children:t})]})}function et({className:e,...t}){return(0,R.jsx)(Re,{"data-slot":`select-scroll-up-button`,className:D(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,R.jsx)(Je,{})})}function tt({className:e,...t}){return(0,R.jsx)(Be,{"data-slot":`select-scroll-down-button`,className:D(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,R.jsx)(k,{})})}var nt=`__pisper_empty_value__`;function rt({children:e,className:t,disabled:n,onChange:r,value:i,...a}){let o=N.Children.toArray(e).filter(N.isValidElement).map(e=>{let t=e.props.value??e.props.children??``;return{disabled:e.props.disabled,label:e.props.children,value:String(t)||nt}}),s=String(i??``)||nt;return g()?(0,R.jsxs)(`select`,{"data-slot":`select-trigger`,className:D(`h-[31px] min-h-0 w-full rounded-[var(--r-xs)] border border-[var(--stroke)] bg-[var(--surface-subtle)] px-2.5 py-0 text-[12px] font-normal text-[var(--text)] shadow-none focus-visible:border-[var(--focus)] focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] dark:bg-[var(--solid)]`,t),value:s,disabled:n,onChange:r,...a,children:[!o.some(e=>e.value===s)&&(0,R.jsx)(`option`,{value:s,hidden:!0}),o.map(e=>(0,R.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]}):(0,R.jsxs)(Ye,{value:s,disabled:n,onValueChange:e=>{r?.({target:{value:e===nt?``:e}})},children:[(0,R.jsx)(Ze,{className:D(`h-[31px] min-h-0 w-full rounded-[var(--r-xs)] border border-[var(--stroke)] bg-[var(--surface-subtle)] px-2.5 py-0 text-[12px] font-normal text-[var(--text)] shadow-none focus-visible:border-[var(--focus)] focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] dark:bg-[var(--solid)] [&>svg]:size-[13px] [&>svg]:text-[var(--text-muted)]`,t),...a,children:(0,R.jsx)(Xe,{})}),(0,R.jsx)(Qe,{position:`popper`,align:`start`,className:`min-w-[var(--radix-select-trigger-width)]`,children:o.map(e=>(0,R.jsx)($e,{value:e.value,disabled:e.disabled,className:`text-[12px]`,children:e.label},e.value))})]})}export{L as n,F as r,rt as t};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n,t as r}from"./vendor-react-CHuvPdJE.js";import{i,n as a,o}from"./button-XhIEgIsg.js";import{d as s,f as c,h as l,m as u,p as d}from"./use-i18n-jYw5s_Yn.js";import{c as f,i as p,o as m,s as h,t as g,u as _}from"./use-mobile-C1OVAMOm.js";import{a as v,i as y,n as b,r as x,s as S,t as C,u as w}from"./es2015-DycjrqX-.js";import{n as T,t as E}from"./dist-cR3ayBwn.js";import{t as D}from"./utils-C8uzG5AZ.js";import{t as O}from"./check-jIXqkGKr.js";import{t as k}from"./chevron-down-DT6AXwTP.js";import{Bt as A,Vt as j}from"./index-Bd5A8V1V.js";var M=e(n(),1),N=e(t(),1),ee=Object.defineProperty,P=(e,t)=>ee(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}P(F,`usePrevious`);var I=Object.defineProperty,te=(e,t)=>I(e,`name`,{value:t,configurable:!0});function L(e,[t,n]){return Math.min(n,Math.max(t,e))}te(L,`clamp`);var R=r(),z=Object.defineProperty,B=(e,t)=>z(e,`name`,{value:t,configurable:!0}),V=[` `,`Enter`,`ArrowUp`,`ArrowDown`],H=[` `,`Enter`],U=`Select`,[W,G,ne]=j(U),[K,re]=u(U,[ne,f]),q=f(),[ie,J]=K(U),[ae,oe]=K(U);function se(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:g,internal_do_not_use_render:_}=e,v=q(t),[y,b]=N.useState(null),[x,S]=N.useState(null),[C,w]=N.useState(!1),E=A(u),[D,O]=s({prop:r,defaultProp:i??!1,onChange:a,caller:U}),[k,j]=s({prop:o,defaultProp:c,onChange:l,caller:U}),M=N.useRef(null),ee=N.useRef(k);N.useEffect(()=>{let e=g?y?.ownerDocument.getElementById(g):y?.form;if(e instanceof HTMLFormElement){let t=B(()=>j(ee.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[g,y,j]);let P=!y||!!g||!!y.closest(`form`),[F,I]=N.useState(new Set),te=T(),L=Array.from(F).map(e=>e.props.value).join(`;`),z=N.useCallback(e=>{I(t=>new Set(t).add(e))},[]),V=N.useCallback(e=>{I(t=>{let n=new Set(t);return n.delete(e),n})},[]),H={required:m,trigger:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:te,value:k,onValueChange:j,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:p,name:d,autoComplete:f,form:g,nativeOptions:F,nativeSelectKey:L,isFormControl:P};return(0,R.jsx)(h,{...v,children:(0,R.jsx)(ie,{scope:t,...H,children:(0,R.jsx)(W.Provider,{scope:t,children:(0,R.jsx)(ae,{scope:t,onNativeOptionAdd:z,onNativeOptionRemove:V,children:We(_)?_(H):n})})})})}B(se,`SelectProvider`);var ce=B(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,R.jsx)(se,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,R.jsxs)(R.Fragment,{children:[n,e?(0,R.jsx)(Ue,{__scopeSelect:t}):null]})})},`Select`),le=`SelectTrigger`,ue=N.forwardRef(B(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=q(n),s=J(le,n),c=s.disabled||r,u=o(t,s.onTriggerChange),f=G(n),m=N.useRef(`touch`),[h,g,_]=Ge(e=>{let t=f().filter(e=>!e.disabled),n=Ke(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onValueChange(n.value)}),v=B(e=>{c||(s.onOpenChange(!0),_()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,R.jsx)(p,{asChild:!0,...a,children:(0,R.jsx)(l.button,{type:`button`,role:`combobox`,"aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":$(s.value)?``:void 0,...i,ref:u,onClick:d(i.onClick,e=>{e.currentTarget.focus(),m.current!==`mouse`&&v(e)}),onPointerDown:d(i.onPointerDown,e=>{m.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(v(e),e.preventDefault())}),onKeyDown:d(i.onKeyDown,e=>{let t=h.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&g(e.key),!(t&&e.key===` `)&&V.includes(e.key)&&(v(),e.preventDefault())})})})},`SelectTrigger`)),de=`SelectValue`,fe=N.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:s=``,...u}=e,d=J(de,n),{onValueNodeHasChildrenChange:f}=d,p=a!==void 0,m=o(t,d.onValueNodeChange);c(()=>{f(p)},[f,p]);let h=$(d.value);return(0,R.jsx)(l.span,{...u,asChild:!h&&u.asChild,ref:m,style:{pointerEvents:`none`},children:(0,R.jsx)(N.Fragment,{children:h?s:a},h?`placeholder`:`value`)})},`SelectValue`)),pe=N.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,R.jsx)(l.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[me,he]=K(`SelectPortal`,{forceMount:void 0}),ge=B(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,R.jsx)(me,{scope:e.__scopeSelect,forceMount:n,children:(0,R.jsx)(y,{asChild:!0,...r})})},`SelectPortal`),Y=`SelectContent`,_e=N.forwardRef(B(function(e,t){let n=he(Y,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=J(Y,e.__scopeSelect),[o,s]=N.useState();return c(()=>{s(new DocumentFragment)},[]),(0,R.jsx)(w,{present:r||a.open,children:({present:e})=>e?(0,R.jsx)(xe,{...i,ref:t}):(0,R.jsx)(ve,{...i,fragment:o})})},`SelectContent`)),ve=N.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,R.jsx)(ye,{scope:n,children:(0,R.jsx)(W.Slot,{scope:n,children:(0,R.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),X=10,[ye,Z]=K(Y),be=i(`SelectContent.RemoveScroll`),xe=N.forwardRef(B(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:_,avoidCollisions:y,...w}=e,T=J(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=o(t,D),[j,M]=N.useState(null),[ee,P]=N.useState(null),F=G(n),[I,te]=N.useState(!1),L=N.useRef(!1);N.useEffect(()=>{if(E)return C(E)},[E]),x();let z=N.useCallback(e=>{let[t,...n]=F().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[F,O]),V=N.useCallback(()=>z([j,E]),[z,j,E]);N.useEffect(()=>{I&&V()},[I,V]);let{onOpenChange:H,triggerPointerDownPosRef:U}=T;N.useEffect(()=>{if(E){let e={x:0,y:0},t=B(t=>{e={x:Math.abs(Math.round(t.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(U.current?.y??0))}},`handlePointerMove`),n=B(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||H(!1),document.removeEventListener(`pointermove`,t),U.current=null},`handlePointerUp`);return U.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,H,U]),N.useEffect(()=>{let e=B(()=>H(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[H]);let[W,ne]=Ge(e=>{let t=F().filter(e=>!e.disabled),n=Ke(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),K=N.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&(M(e),r&&(L.current=!0))},[T.value]),re=N.useCallback(()=>E?.focus(),[E]),q=N.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&P(e)},[T.value]),ie=r===`popper`?Ce:Se,ae=ie===Ce?{side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:_,avoidCollisions:y}:{};return(0,R.jsx)(ye,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:K,selectedItem:j,onItemLeave:re,itemTextRefCallback:q,focusSelectedItem:V,selectedItemText:ee,position:r,isPositioned:I,searchRef:W,children:(0,R.jsx)(b,{as:be,allowPinchZoom:!0,children:(0,R.jsx)(v,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:d(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,R.jsx)(S,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,R.jsx)(ie,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ae,onPlaced:()=>te(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:d(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>z(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Se=N.forwardRef(B(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=J(Y,n),s=Z(Y,n),[u,d]=N.useState(null),[f,p]=N.useState(null),m=o(t,p),h=G(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=s,S=N.useCallback(()=>{if(a.trigger&&a.valueNode&&u&&f&&v&&y&&b){let e=a.trigger.getBoundingClientRect(),t=f.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-X,d=L(a,[X,Math.max(X,l-c)]);u.style.minWidth=s+`px`,u.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-X,d=L(a,[X,Math.max(X,l-c)]);u.style.minWidth=s+`px`,u.style.right=d+`px`}let o=h(),s=window.innerHeight-X*2,c=v.scrollHeight,l=window.getComputedStyle(f),d=parseInt(l.borderTopWidth,10),p=parseInt(l.paddingTop,10),m=parseInt(l.borderBottomWidth,10),_=parseInt(l.paddingBottom,10),x=d+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-X,D=s-E,O=y.offsetHeight/2,k=y.offsetTop+O,A=d+p+k,j=x-A;if(A<=E){let e=o.length>0&&y===o[o.length-1].ref.current;u.style.bottom=`0px`;let t=f.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+m);u.style.height=n+`px`}else{let e=o.length>0&&y===o[0].ref.current;u.style.top=`0px`;let t=Math.max(E,d+v.offsetTop+(e?w:0)+O)+j;u.style.height=t+`px`,v.scrollTop=A-E+v.offsetTop}u.style.margin=`${X}px 0`,u.style.minHeight=S+`px`,u.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,u,f,v,y,b,a.dir,r]);c(()=>S(),[S]);let[C,w]=N.useState();c(()=>{f&&w(window.getComputedStyle(f).zIndex)},[f]);let T=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,R.jsx)(we,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,R.jsx)(`div`,{ref:d,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,R.jsx)(l.div,{...i,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Ce=N.forwardRef(B(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=X,...a}=e,o=q(n);return(0,R.jsx)(m,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[we,Te]=K(Y,{}),Ee=`SelectViewport`,De=N.forwardRef(B(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Z(Ee,n),s=Te(Ee,n),c=o(t,a.onViewportChange),u=N.useRef(0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,R.jsx)(W.Slot,{scope:n,children:(0,R.jsx)(l.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:d(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(u.current-t.scrollTop);if(e>0){let r=window.innerHeight-X*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}u.current=t.scrollTop})})})]})},`SelectViewport`)),[Oe,ke]=K(`SelectGroup`),Ae=`SelectItem`,[je,Me]=K(Ae),Ne=N.forwardRef(B(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...s}=e,c=J(Ae,n),u=Z(Ae,n),f=c.value===r,[p,m]=N.useState(a??``),[h,g]=N.useState(!1),_=E(e=>u.itemRefCallback?.(e,r,i)),v=o(t,_),y=T(),b=N.useRef(`touch`),x=B(()=>{i||(c.onValueChange(r),c.onOpenChange(!1))},`handleSelect`);return(0,R.jsx)(je,{scope:n,value:r,disabled:i,textId:y,isSelected:f,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,R.jsx)(W.ItemSlot,{scope:n,value:r,disabled:i,textValue:p,children:(0,R.jsx)(l.div,{role:`option`,"aria-labelledby":y,"data-highlighted":h?``:void 0,"aria-selected":f&&h,"data-state":f?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...s,ref:v,onFocus:d(s.onFocus,()=>g(!0)),onBlur:d(s.onBlur,()=>g(!1)),onClick:d(s.onClick,()=>{b.current!==`mouse`&&x()}),onPointerUp:d(s.onPointerUp,()=>{b.current===`mouse`&&x()}),onPointerDown:d(s.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:d(s.onPointerMove,e=>{b.current=e.pointerType,i?u.onItemLeave?.():b.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:d(s.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:d(s.onKeyDown,e=>{i||e.target!==e.currentTarget||(u.searchRef?.current===``||e.key!==` `)&&(H.includes(e.key)&&x(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,Pe=N.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,s=J(Q,n),u=Z(Q,n),d=Me(Q,n),f=oe(Q,n),[p,m]=N.useState(null),h=E(e=>u.itemTextRefCallback?.(e,d.value,d.disabled)),g=o(t,m,d.onItemTextChange,h),_=p?.textContent,v=N.useMemo(()=>(0,R.jsx)(`option`,{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:y,onNativeOptionRemove:b}=f;return c(()=>(y(v),()=>b(v)),[y,b,v]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(l.span,{id:d.textId,...a,ref:g}),d.isSelected&&s.valueNode&&!s.valueNodeHasChildren&&!$(s.value)?M.createPortal(a.children,s.valueNode):null]})},`SelectItemText`)),Fe=`SelectItemIndicator`,Ie=N.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e;return Me(Fe,n).isSelected?(0,R.jsx)(l.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Le=`SelectScrollUpButton`,Re=N.forwardRef(B(function(e,t){let n=Z(Le,e.__scopeSelect),r=Te(Le,e.__scopeSelect),[i,a]=N.useState(!1),s=o(t,r.onScrollButtonChange);return c(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(Ve,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),ze=`SelectScrollDownButton`,Be=N.forwardRef(B(function(e,t){let n=Z(ze,e.__scopeSelect),r=Te(ze,e.__scopeSelect),[i,a]=N.useState(!1),s=o(t,r.onScrollButtonChange);return c(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(Ve,{...e,ref:s,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Ve=N.forwardRef(B(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Z(`SelectScrollButton`,n),o=N.useRef(null),s=G(n),u=N.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return N.useEffect(()=>()=>u(),[u]),c(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,R.jsx)(l.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:d(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:d(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:d(i.onPointerLeave,()=>{u()})})},`SelectScrollButtonImpl`)),He=`SelectBubbleInput`,Ue=N.forwardRef(B(function({__scopeSelect:e,...t},n){let r=J(He,e),{value:i,onValueChange:a,required:s,disabled:c,name:u,autoComplete:d,form:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,h=N.useRef(null),g=o(n,h),v=i??``,y=F(v),b=Array.from(p).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=h.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,R.jsxs)(l.select,{"aria-hidden":!0,required:s,tabIndex:-1,name:u,autoComplete:d,disabled:c,form:f,onChange:e=>a(e.target.value),...t,style:{..._,...t.style},ref:g,defaultValue:v,children:[$(i)&&!b?(0,R.jsx)(`option`,{value:``}):null,Array.from(p)]},m)},`SelectBubbleInput`));function We(e){return typeof e==`function`}B(We,`isFunction`);function $(e){return e===``||e===void 0}B($,`shouldShowPlaceholder`);function Ge(e){let t=E(e),n=N.useRef(``),r=N.useRef(0),i=N.useCallback(e=>{let i=n.current+e;t(i),B((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=N.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}B(Ge,`useTypeaheadSearch`);function Ke(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=qe(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}B(Ke,`findNextItem`);function qe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}B(qe,`wrapArray`);var Je=a(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]);function Ye({...e}){return(0,R.jsx)(ce,{"data-slot":`select`,...e})}function Xe({...e}){return(0,R.jsx)(fe,{"data-slot":`select-value`,...e})}function Ze({className:e,size:t=`default`,children:n,...r}){return(0,R.jsxs)(ue,{"data-slot":`select-trigger`,"data-size":t,className:D(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,R.jsx)(pe,{asChild:!0,children:(0,R.jsx)(k,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function Qe({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,R.jsx)(ge,{children:(0,R.jsxs)(_e,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:D(`relative z-[200] max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,R.jsx)(et,{}),(0,R.jsx)(De,{"data-position":n,className:D(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,R.jsx)(tt,{})]})})}function $e({className:e,children:t,...n}){return(0,R.jsxs)(Ne,{"data-slot":`select-item`,className:D(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,R.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,R.jsx)(Ie,{children:(0,R.jsx)(O,{className:`pointer-events-none`})})}),(0,R.jsx)(Pe,{children:t})]})}function et({className:e,...t}){return(0,R.jsx)(Re,{"data-slot":`select-scroll-up-button`,className:D(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,R.jsx)(Je,{})})}function tt({className:e,...t}){return(0,R.jsx)(Be,{"data-slot":`select-scroll-down-button`,className:D(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,R.jsx)(k,{})})}var nt=`__pisper_empty_value__`;function rt({children:e,className:t,disabled:n,onChange:r,value:i,...a}){let o=N.Children.toArray(e).filter(N.isValidElement).map(e=>{let t=e.props.value??e.props.children??``;return{disabled:e.props.disabled,label:e.props.children,value:String(t)||nt}}),s=String(i??``)||nt;return g()?(0,R.jsxs)(`select`,{"data-slot":`select-trigger`,className:D(`h-[31px] min-h-0 w-full rounded-[var(--r-xs)] border border-[var(--stroke)] bg-[var(--surface-subtle)] px-2.5 py-0 text-[12px] font-normal text-[var(--text)] shadow-none focus-visible:border-[var(--focus)] focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] dark:bg-[var(--solid)]`,t),value:s,disabled:n,onChange:r,...a,children:[!o.some(e=>e.value===s)&&(0,R.jsx)(`option`,{value:s,hidden:!0}),o.map(e=>(0,R.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]}):(0,R.jsxs)(Ye,{value:s,disabled:n,onValueChange:e=>{r?.({target:{value:e===nt?``:e}})},children:[(0,R.jsx)(Ze,{className:D(`h-[31px] min-h-0 w-full rounded-[var(--r-xs)] border border-[var(--stroke)] bg-[var(--surface-subtle)] px-2.5 py-0 text-[12px] font-normal text-[var(--text)] shadow-none focus-visible:border-[var(--focus)] focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] dark:bg-[var(--solid)] [&>svg]:size-[13px] [&>svg]:text-[var(--text-muted)]`,t),...a,children:(0,R.jsx)(Xe,{})}),(0,R.jsx)(Qe,{position:`popper`,align:`start`,className:`min-w-[var(--radix-select-trigger-width)]`,children:o.map(e=>(0,R.jsx)($e,{value:e.value,disabled:e.disabled,className:`text-[12px]`,children:e.label},e.value))})]})}export{L as n,F as r,rt as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{n as i,t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-yjKc6F2w.js";import{t as s}from"./storage-BE5DCCG3.js";import{t as c}from"./file-C8GNXmhJ.js";import{t as l}from"./link-2-CaZP6GWi.js";import{t as u}from"./paperclip-BMRj9kRG.js";import{t as d}from"./trash-2-mhzzyC6i.js";import{t as f}from"./x-bw26XDZM.js";import{Ot as p,R as m,bt as h,c as g,ht as _,i as v,kt as y,n as b,r as x,t as S,xt as C}from"./index-CAWCOpxG.js";import{t as w}from"./field-BAyGDYW_.js";import{t as T}from"./StarOrbit-BlI6MhVr.js";import{t as E}from"./usePagePrimaryAction-Bw0OFTDZ.js";import{t as D}from"./MarkdownMessage-BQ_6o9-O.js";import{n as O}from"./mobile-runtime-recovery-tbTyacip.js";var k=i(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),A=i(`file-play`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]]),j=e(t(),1),M=134217728;function N(e){let t=document.createElement(`a`);t.href=`/api/assets/${encodeURIComponent(e.id)}/download`,t.download=e.name,t.hidden=!0,document.body.append(t),t.click(),t.remove()}function P(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error||Error(`读取资产失败。`)),r.onload=()=>{let e=typeof r.result==`string`?r.result:``,i=e.indexOf(`,`);i<0?n(Error(`资产编码失败。`)):t(e.slice(i+1))},r.readAsDataURL(e)})}function F(){if(typeof window>`u`)return!1;let e=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return!!(window.pisperDesktop?.openAsset||window.__PISPER_MOBILE_APP__&&e)}async function I(e){let t=window.pisperDesktop?.openAsset,n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;if(!t&&!(window.__PISPER_MOBILE_APP__&&n))return N(e),`download`;await O();let r=await fetch(`/api/assets/${encodeURIComponent(e.id)}/download`);if(!r.ok)throw Error(`资产下载失败 (${r.status})`);if((Number(r.headers.get(`content-length`))||0)>M)throw Error(`资产超过 128 MB 原生打开限制。`);let i=await r.blob();if(!i.size||i.size>M)throw Error(`资产内容为空或超过 128 MB 原生打开限制。`);let a=await P(i);return t?await t({name:e.name,data:a}):await n?.(`mobile_open_asset`,{input:{name:e.name,mimeType:e.mimeType||i.type||`application/octet-stream`,data:a}}),`application`}var L=n(),R=[`all`,`image`,`video`,`file`,`link`,`current`];function z(e,t){return t(e===`image`?`assets:assetsPage.images`:e===`video`?`assets:assetsPage.videos`:e===`file`?`assets:assetsPage.files`:e===`link`?`assets:assetsPage.links`:e===`current`?`assets:assetsPage.fromCurrentChat`:`assets:assetsPage.all`)}function B(e){let t=String(e||``),n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?t.slice(n+1).toLowerCase():``}function V({query:e=``,notify:t,registerPrimaryAction:n,onUse:i,requestConfirm:f}){let{t:b}=o(),[C,w]=(0,j.useState)(`all`),[D,O]=(0,j.useState)([]),[M,N]=(0,j.useState)(!0),[P,V]=(0,j.useState)(``),[W,G]=(0,j.useState)(null),[K,q]=(0,j.useState)(!1);E(n,()=>q(!0));let J=(0,j.useCallback)(async()=>{N(!0),V(``);try{let t=new URLSearchParams;e&&t.set(`query`,e),C===`image`&&t.set(`kind`,`image`),C===`video`&&t.set(`kind`,`video`),C===`file`&&t.set(`kind`,`file`),C===`link`&&t.set(`kind`,`link`),C===`current`&&t.set(`sessionId`,localStorage.getItem(s.activeSession)||`__none__`);let n=await r(`/api/assets?${t}`);O(n.assets)}catch(e){V(e instanceof Error?e.message:String(e))}finally{N(!1)}},[e,C]);(0,j.useEffect)(()=>{J()},[J]);let Y=async e=>{if(await f({title:b(`assets:assetsPage.deleteAsset`),message:b(`assets:assetsPage.deleteAssetName`,{name:e.name}),confirmLabel:b(`assets:assetsPage.delete`)}))try{await r(`/api/assets/${encodeURIComponent(e.id)}`,{method:`DELETE`}),O(t=>t.filter(t=>t.id!==e.id)),t(b(`assets:assetsPage.assetDeleted`))}catch(e){V(e instanceof Error?e.message:String(e))}},X=async e=>{try{i(await r(`/api/assets/${encodeURIComponent(e.id)}/content`)),t(b(`assets:assetsPage.nameAddedToChat`,{name:e.name}))}catch(e){V(e instanceof Error?e.message:String(e))}},Z=async e=>{V(``);try{let t=B(e.name),n;if(e.kind===`link`)n=e.url||``;else if(e.kind!==`image`&&!e.mimeType?.startsWith(`video/`)){let t=await r(`/api/assets/${encodeURIComponent(e.id)}/content?preview=1`);t.kind===`text`&&(n=String(t.text||``))}G({...e,text:n,textFormat:t===`md`||e.mimeType===`text/markdown`?`markdown`:`plain`})}catch(e){V(e instanceof Error?e.message:String(e))}},Q=async e=>{V(``);try{t(await I(e)===`application`?b(`assets:assetsPage.openedInApplication`):b(`assets:assetsPage.downloadStarted`))}catch(e){V(e instanceof Error?e.message:String(e))}};return(0,L.jsxs)(`div`,{className:`asset-page flex min-h-[100%] flex-col gap-[12px]`,children:[(0,L.jsx)(`div`,{className:`asset-toolbar [&_>_div:last-child]:flex [&_>_div:last-child]:gap-[7px] max-[650px]:items-stretch max-[650px]:flex-col max-[650px]:[&_>_div:last-child]:justify-end flex items-center justify-between gap-[12px]`,children:(0,L.jsx)(g,{options:R.map(e=>z(e,b)),value:z(C,b),onChange:e=>w(R.find(t=>z(t,b)===e)||`all`)})}),(0,L.jsxs)(`div`,{className:`asset-summary [&_strong]:text-[var(--text)] [&_strong]:text-[13px] max-[650px]:items-start max-[650px]:flex-col flex items-center justify-between gap-[12px] text-[var(--text-secondary)] text-[12px]`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:D.length}),` `,b(`assets:assetsPage.assets`)]}),(0,L.jsx)(`span`,{children:b(`assets:assetsPage.conversationAttachmentsAndAgentOutputsGatherHereAutomatically`)})]}),P&&(0,L.jsxs)(v,{children:[(0,L.jsx)(_,{size:13}),P]}),M?(0,L.jsxs)(x,{children:[(0,L.jsx)(h,{className:`animate-spin`,size:23}),(0,L.jsx)(`h2`,{children:b(`assets:assetsPage.loadingAssets`)})]}):D.length?(0,L.jsx)(`div`,{className:`asset-grid max-[650px]:grid-cols-[1fr] functional grid auto-rows-[minmax(292px,auto)] grid-cols-[repeat(auto-fill,minmax(260px,1fr))] content-start gap-3`,children:D.map(e=>{let t=e.mimeType?.startsWith(`video/`),n=e.kind===`image`?k:t?A:e.kind===`link`?l:c;return(0,L.jsxs)(S,{className:`asset-card [transition:transform_var(--d2)_var(--ease-out),_box-shadow_var(--d2)_var(--ease-out),_border-color_var(--d2)_var(--ease-out)] hover:[transform:translateY(-2px)] hover:shadow-[var(--sh-2)] hover:border-[var(--star-border)] [&_>_strong]:text-[13px] [&_>_span]:m-[5px_0_10px] [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[12px] [&_>_div:last-child]:flex [&_>_div:last-child]:gap-[6px] [&_>_div:last-child]:mt-[auto] max-[650px]:min-h-[200px] functional flex h-full min-h-[292px] flex-col overflow-hidden`,children:[(0,L.jsx)(`button`,{className:`asset-preview [&.blue]:bg-[var(--asset-preview-blue-bg)] [&.blue]:text-[var(--asset-preview-blue-text)] [&.violet]:bg-[var(--asset-preview-violet-bg)] [&.violet]:text-[var(--violet-strong)] [&.yellow]:bg-[var(--warning-soft)] [&.yellow]:text-[var(--amber)] [&.red]:bg-[var(--danger-soft)] [&.red]:text-[var(--danger)] [.asset-card.functional_&::after]:absolute [.asset-card.functional_&::after]:inset-0 [.asset-card.functional_&::after]:rounded-[var(--r-sm)] [.asset-card.functional_&::after]:bg-[rgba(0,_0,_0,_0)] [.asset-card.functional_&::after]:[transition:background_var(--d1)_var(--ease-out)] [.asset-card.functional_&::after]:[content:''] [.asset-card.functional_&::after]:pointer-events-none [.asset-card.functional_&:hover::after]:bg-[rgba(0,_0,_0,_.16)] [.asset-card.functional_&.image]:bg-[var(--surface-hover)] [.asset-card.functional_&.link]:bg-[var(--surface-hover)] [.asset-card.functional_&.link]:text-[var(--success)] [.asset-card.functional_&.file]:bg-[var(--surface-hover)] [.asset-card.functional_&.file]:text-[var(--violet-strong)] [.asset-card.functional_&_img]:relative [.asset-card.functional_&_img]:z-[0] [.asset-card.functional_&_img]:w-full [.asset-card.functional_&_img]:h-full [.asset-card.functional_&_img]:rounded-[var(--r-sm)] [.asset-card.functional_&_img]:object-cover [.asset-card.functional_&_video]:relative [.asset-card.functional_&_video]:z-[0] [.asset-card.functional_&_video]:w-full [.asset-card.functional_&_video]:h-full [.asset-card.functional_&_video]:rounded-[var(--r-sm)] [.asset-card.functional_&_video]:object-cover ${e.kind} ${t?`video`:``} relative -mx-1.5 -mt-1.5 mb-2.5 grid h-44 min-h-0 w-[calc(100%+12px)] shrink-0 place-items-center overflow-hidden rounded-[var(--r-sm)] border-0 bg-[var(--surface-hover)] text-[var(--text-muted)]`,title:b(`assets:assetsPage.preview`),"aria-label":`${b(`assets:assetsPage.preview`)}: ${e.name}`,onClick:()=>Z(e),children:e.kind===`image`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(n,{className:`absolute`,size:38}),(0,L.jsx)(`img`,{className:`block size-full min-h-0 object-cover`,src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`,alt:``,onError:e=>{e.currentTarget.hidden=!0}})]}):t?(0,L.jsx)(`video`,{className:`block size-full min-h-0 object-cover`,src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`,muted:!0,preload:`metadata`}):(0,L.jsx)(n,{size:38})}),(0,L.jsxs)(`div`,{className:`asset-card-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_span]:overflow-hidden [&_span]:text-[var(--text-muted)] [&_span]:text-[13px] [&_span]:text-ellipsis [&_span]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap flex min-w-0 flex-col gap-[4px]`,children:[(0,L.jsx)(`strong`,{title:e.name,children:e.name}),(0,L.jsxs)(`span`,{children:[e.kind===`link`?e.url?new URL(e.url).hostname:``:m(e.size),` `,`·`,` `,e.source===`agent`?b(`assets:assetsPage.agentOutputs`):e.source===`attachment`?b(`assets:assetsPage.chatAttachments`):b(`assets:assetsPage.manualUploads`)]}),e.sessionName&&(0,L.jsx)(`small`,{title:e.sessionName,children:b(`assets:assetsPage.fromName`,{name:e.sessionName})})]}),(0,L.jsxs)(`div`,{className:`asset-card-actions flex-none [.asset-card.functional:hover_&]:opacity-100 [.asset-card.functional:hover_&]:[transform:translateY(0)] [.asset-card.functional:focus-within_&]:opacity-100 [.asset-card.functional:focus-within_&]:[transform:translateY(0)] [&_a]:no-underline flex flex-wrap items-center gap-[5px] [margin-top:auto] [padding-top:10px] opacity-0 [transform:translateY(4px)] [transition:opacity_var(--d1)_var(--ease-out),_transform_var(--d1)_var(--ease-out)] max-[650px]:opacity-100 max-[650px]:transform-none`,children:[e.kind===`link`?(0,L.jsx)(a,{asChild:!0,variant:`outline`,children:(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,L.jsx)(p,{size:13}),b(`assets:assetsPage.open`)]})}):(0,L.jsxs)(a,{variant:`outline`,onClick:()=>Q(e),children:[F()?(0,L.jsx)(p,{size:13}):(0,L.jsx)(y,{size:13}),F()?b(`assets:assetsPage.openInApplication`):b(`assets:assetsPage.download`)]}),(0,L.jsxs)(a,{onClick:()=>X(e),children:[(0,L.jsx)(u,{size:13}),b(`assets:assetsPage.useInChat`)]}),(0,L.jsx)(a,{variant:`destructive`,size:`icon`,className:`ml-auto`,title:b(`assets:assetsPage.deleteAsset`),"aria-label":`${b(`assets:assetsPage.deleteAsset`)}: ${e.name}`,onClick:()=>Y(e),children:(0,L.jsx)(d,{size:13})})]})]},e.id)})}):(0,L.jsxs)(x,{children:[(0,L.jsx)(T,{size:46}),(0,L.jsx)(`h2`,{children:b(`assets:assetsPage.nothingHasGatheredHereYet`)}),(0,L.jsx)(`p`,{children:b(`assets:assetsPage.bringInALinkOrAttachAFileInAConversationPisperWillGatherTheOutputsCreatedAlongTheWay`)}),(0,L.jsxs)(a,{size:`lg`,className:`mt-4`,onClick:()=>q(!0),children:[(0,L.jsx)(l,{size:14}),b(`assets:assetsPage.addLink`)]})]}),W&&(0,L.jsx)(H,{asset:W,onClose:()=>G(null),onUse:()=>X(W),onOpen:()=>Q(W)}),K&&(0,L.jsx)(U,{onClose:()=>q(!1),onCreated:()=>{q(!1),J(),t(b(`assets:assetsPage.linkAssetAdded`))}})]})}function H({asset:e,onClose:t,onUse:n,onOpen:r}){let{t:i}=o(),s=e.mimeType?.startsWith(`video/`);return(0,L.jsx)(`div`,{className:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,L.jsxs)(`section`,{className:`modal asset-preview-modal flex max-h-[calc(100dvh_-_40px)] flex-col overflow-hidden [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)] max-[650px]:p-3 ${e.kind===`image`||s?`w-[min(96vw,1200px)]`:`w-[min(96vw,900px)]`}`,children:[(0,L.jsxs)(b,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{children:e.name}),(0,L.jsx)(`p`,{children:e.kind===`link`?e.url:`${e.mimeType} · ${m(e.size)}`})]}),(0,L.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":i(`assets:assetsPage.closeDialog`),onClick:t,children:(0,L.jsx)(f,{size:17})})]}),(0,L.jsx)(`div`,{className:`asset-modal-content [&_>_img]:max-h-full [&_>_img]:max-w-full [&_>_img]:rounded-[var(--r-sm)] [&_>_img]:object-contain [&_>_video]:aspect-video [&_>_video]:max-h-full [&_>_video]:w-full [&_>_video]:rounded-[var(--r-sm)] [&_>_video]:bg-black [&_>_video]:object-contain [&_>_pre]:m-0 [&_>_pre]:h-full [&_>_pre]:w-full [&_>_pre]:overflow-auto [&_>_pre]:whitespace-pre-wrap [&_>_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_>_pre]:text-[12px] [&_>_pre]:leading-[1.55] [&_>_a]:flex [&_>_a]:items-center [&_>_a]:gap-[7px] [&_>_a]:text-[var(--text-soft)] [&_>_a]:text-[12px] [&_>_a]:[text-decoration:underline] [&_>_a]:[text-underline-offset:2px] [&_>_a]:[word-break:break-all] grid min-h-[min(420px,60dvh)] flex-1 place-items-center overflow-auto [margin-top:14px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-3 max-[650px]:min-h-[240px]`,children:e.kind===`image`?(0,L.jsx)(`img`,{src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`,alt:e.name}):s?(0,L.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`}):e.kind===`link`?(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,L.jsx)(p,{size:16}),e.url]}):e.text===void 0?(0,L.jsxs)(`div`,{className:`asset-file-preview [&_strong]:text-[var(--text)] [&_strong]:text-[13px] [&_span]:text-[12px] [&_span]:leading-[1.55] flex max-w-[400px] flex-col items-center gap-[9px] text-[var(--text-secondary)] text-center`,children:[(0,L.jsx)(c,{size:42}),(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{children:i(`assets:assetsPage.thisFileTypeCanBeDownloadedSupportedDocumentsCanAlsoBeAddedToAChatForAnalysis`)})]}):e.textFormat===`markdown`?(0,L.jsx)(`div`,{className:`h-full w-full overflow-auto text-left`,children:(0,L.jsx)(D,{children:e.text})}):(0,L.jsx)(`pre`,{children:e.text})}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[e.kind!==`link`&&(0,L.jsxs)(a,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:r,children:[F()?(0,L.jsx)(p,{size:14}):(0,L.jsx)(y,{size:14}),F()?i(`assets:assetsPage.openInApplication`):i(`assets:assetsPage.download`)]}),(0,L.jsxs)(a,{size:`lg`,onClick:n,children:[(0,L.jsx)(u,{size:14}),i(`assets:assetsPage.useInChat`)]})]})]})})}function U({onClose:e,onCreated:t}){let{t:n}=o(),[i,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``);return(0,L.jsx)(`div`,{className:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:t=>t.target===t.currentTarget&&e(),children:(0,L.jsxs)(`form`,{className:`modal !w-[min(430px,100%)] max-h-[calc(100dvh_-_40px)] overflow-y-auto [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)]`,onSubmit:async e=>{e.preventDefault(),d(!0),m(``);try{await r(`/api/assets`,{method:`POST`,body:JSON.stringify({kind:`link`,name:i,url:c,source:`upload`})}),t()}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(!1)}},children:[(0,L.jsxs)(b,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{children:n(`assets:assetsPage.addLinkAsset`)}),(0,L.jsx)(`p`,{children:n(`assets:assetsPage.linksCanBeArchivedOpenedOrAddedToAChatAsContext`)})]}),(0,L.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n(`assets:assetsPage.closeDialog`),onClick:e,children:(0,L.jsx)(f,{size:17})})]}),(0,L.jsxs)(w,{variant:`control`,children:[n(`assets:assetsPage.name`),(0,L.jsx)(`input`,{value:i,onChange:e=>s(e.target.value),placeholder:n(`assets:assetsPage.forExampleOpenAIAPIDocs`)})]}),(0,L.jsxs)(w,{variant:`control`,children:[`URL`,(0,L.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/docs`})]}),p&&(0,L.jsxs)(v,{children:[(0,L.jsx)(_,{size:13}),p]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,L.jsx)(a,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:e,children:n(`assets:assetsPage.cancel`)}),(0,L.jsxs)(a,{size:`lg`,disabled:u||!c.trim(),children:[u?(0,L.jsx)(h,{className:`animate-spin`,size:14}):(0,L.jsx)(C,{size:14}),n(u?`assets:assetsPage.adding`:`assets:assetsPage.addLink`)]})]})]})})}export{V as AssetsPage};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{n as i,t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-jYw5s_Yn.js";import{t as s}from"./storage-BE5DCCG3.js";import{t as c}from"./file-C8GNXmhJ.js";import{t as l}from"./link-2-CaZP6GWi.js";import{t as u}from"./paperclip-BMRj9kRG.js";import{t as d}from"./trash-2-mhzzyC6i.js";import{t as f}from"./x-bw26XDZM.js";import{Ot as p,R as m,bt as h,c as g,ht as _,i as v,kt as y,n as b,r as x,t as S,xt as C}from"./index-Bd5A8V1V.js";import{t as w}from"./field-t72VAR-1.js";import{t as T}from"./StarOrbit-BlI6MhVr.js";import{t as E}from"./usePagePrimaryAction-Bw0OFTDZ.js";import{t as D}from"./MarkdownMessage-Dbgb5XkJ.js";import{n as O}from"./mobile-runtime-recovery-tbTyacip.js";var k=i(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),A=i(`file-play`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]]),j=e(t(),1),M=134217728;function N(e){let t=document.createElement(`a`);t.href=`/api/assets/${encodeURIComponent(e.id)}/download`,t.download=e.name,t.hidden=!0,document.body.append(t),t.click(),t.remove()}function P(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error||Error(`读取资产失败。`)),r.onload=()=>{let e=typeof r.result==`string`?r.result:``,i=e.indexOf(`,`);i<0?n(Error(`资产编码失败。`)):t(e.slice(i+1))},r.readAsDataURL(e)})}function F(){if(typeof window>`u`)return!1;let e=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return!!(window.pisperDesktop?.openAsset||window.__PISPER_MOBILE_APP__&&e)}async function I(e){let t=window.pisperDesktop?.openAsset,n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;if(!t&&!(window.__PISPER_MOBILE_APP__&&n))return N(e),`download`;await O();let r=await fetch(`/api/assets/${encodeURIComponent(e.id)}/download`);if(!r.ok)throw Error(`资产下载失败 (${r.status})`);if((Number(r.headers.get(`content-length`))||0)>M)throw Error(`资产超过 128 MB 原生打开限制。`);let i=await r.blob();if(!i.size||i.size>M)throw Error(`资产内容为空或超过 128 MB 原生打开限制。`);let a=await P(i);return t?await t({name:e.name,data:a}):await n?.(`mobile_open_asset`,{input:{name:e.name,mimeType:e.mimeType||i.type||`application/octet-stream`,data:a}}),`application`}var L=n(),R=[`all`,`image`,`video`,`file`,`link`,`current`];function z(e,t){return t(e===`image`?`assets:assetsPage.images`:e===`video`?`assets:assetsPage.videos`:e===`file`?`assets:assetsPage.files`:e===`link`?`assets:assetsPage.links`:e===`current`?`assets:assetsPage.fromCurrentChat`:`assets:assetsPage.all`)}function B(e){let t=String(e||``),n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?t.slice(n+1).toLowerCase():``}function V({query:e=``,notify:t,registerPrimaryAction:n,onUse:i,requestConfirm:f}){let{t:b}=o(),[C,w]=(0,j.useState)(`all`),[D,O]=(0,j.useState)([]),[M,N]=(0,j.useState)(!0),[P,V]=(0,j.useState)(``),[W,G]=(0,j.useState)(null),[K,q]=(0,j.useState)(!1);E(n,()=>q(!0));let J=(0,j.useCallback)(async()=>{N(!0),V(``);try{let t=new URLSearchParams;e&&t.set(`query`,e),C===`image`&&t.set(`kind`,`image`),C===`video`&&t.set(`kind`,`video`),C===`file`&&t.set(`kind`,`file`),C===`link`&&t.set(`kind`,`link`),C===`current`&&t.set(`sessionId`,localStorage.getItem(s.activeSession)||`__none__`);let n=await r(`/api/assets?${t}`);O(n.assets)}catch(e){V(e instanceof Error?e.message:String(e))}finally{N(!1)}},[e,C]);(0,j.useEffect)(()=>{J()},[J]);let Y=async e=>{if(await f({title:b(`assets:assetsPage.deleteAsset`),message:b(`assets:assetsPage.deleteAssetName`,{name:e.name}),confirmLabel:b(`assets:assetsPage.delete`)}))try{await r(`/api/assets/${encodeURIComponent(e.id)}`,{method:`DELETE`}),O(t=>t.filter(t=>t.id!==e.id)),t(b(`assets:assetsPage.assetDeleted`))}catch(e){V(e instanceof Error?e.message:String(e))}},X=async e=>{try{i(await r(`/api/assets/${encodeURIComponent(e.id)}/content`)),t(b(`assets:assetsPage.nameAddedToChat`,{name:e.name}))}catch(e){V(e instanceof Error?e.message:String(e))}},Z=async e=>{V(``);try{let t=B(e.name),n;if(e.kind===`link`)n=e.url||``;else if(e.kind!==`image`&&!e.mimeType?.startsWith(`video/`)){let t=await r(`/api/assets/${encodeURIComponent(e.id)}/content?preview=1`);t.kind===`text`&&(n=String(t.text||``))}G({...e,text:n,textFormat:t===`md`||e.mimeType===`text/markdown`?`markdown`:`plain`})}catch(e){V(e instanceof Error?e.message:String(e))}},Q=async e=>{V(``);try{t(await I(e)===`application`?b(`assets:assetsPage.openedInApplication`):b(`assets:assetsPage.downloadStarted`))}catch(e){V(e instanceof Error?e.message:String(e))}};return(0,L.jsxs)(`div`,{className:`asset-page flex min-h-[100%] flex-col gap-[12px]`,children:[(0,L.jsx)(`div`,{className:`asset-toolbar [&_>_div:last-child]:flex [&_>_div:last-child]:gap-[7px] max-[650px]:items-stretch max-[650px]:flex-col max-[650px]:[&_>_div:last-child]:justify-end flex items-center justify-between gap-[12px]`,children:(0,L.jsx)(g,{options:R.map(e=>z(e,b)),value:z(C,b),onChange:e=>w(R.find(t=>z(t,b)===e)||`all`)})}),(0,L.jsxs)(`div`,{className:`asset-summary [&_strong]:text-[var(--text)] [&_strong]:text-[13px] max-[650px]:items-start max-[650px]:flex-col flex items-center justify-between gap-[12px] text-[var(--text-secondary)] text-[12px]`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{children:D.length}),` `,b(`assets:assetsPage.assets`)]}),(0,L.jsx)(`span`,{children:b(`assets:assetsPage.conversationAttachmentsAndAgentOutputsGatherHereAutomatically`)})]}),P&&(0,L.jsxs)(v,{children:[(0,L.jsx)(_,{size:13}),P]}),M?(0,L.jsxs)(x,{children:[(0,L.jsx)(h,{className:`animate-spin`,size:23}),(0,L.jsx)(`h2`,{children:b(`assets:assetsPage.loadingAssets`)})]}):D.length?(0,L.jsx)(`div`,{className:`asset-grid max-[650px]:grid-cols-[1fr] functional grid auto-rows-[minmax(292px,auto)] grid-cols-[repeat(auto-fill,minmax(260px,1fr))] content-start gap-3`,children:D.map(e=>{let t=e.mimeType?.startsWith(`video/`),n=e.kind===`image`?k:t?A:e.kind===`link`?l:c;return(0,L.jsxs)(S,{className:`asset-card [transition:transform_var(--d2)_var(--ease-out),_box-shadow_var(--d2)_var(--ease-out),_border-color_var(--d2)_var(--ease-out)] hover:[transform:translateY(-2px)] hover:shadow-[var(--sh-2)] hover:border-[var(--star-border)] [&_>_strong]:text-[13px] [&_>_span]:m-[5px_0_10px] [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[12px] [&_>_div:last-child]:flex [&_>_div:last-child]:gap-[6px] [&_>_div:last-child]:mt-[auto] max-[650px]:min-h-[200px] functional flex h-full min-h-[292px] flex-col overflow-hidden`,children:[(0,L.jsx)(`button`,{className:`asset-preview [&.blue]:bg-[var(--asset-preview-blue-bg)] [&.blue]:text-[var(--asset-preview-blue-text)] [&.violet]:bg-[var(--asset-preview-violet-bg)] [&.violet]:text-[var(--violet-strong)] [&.yellow]:bg-[var(--warning-soft)] [&.yellow]:text-[var(--amber)] [&.red]:bg-[var(--danger-soft)] [&.red]:text-[var(--danger)] [.asset-card.functional_&::after]:absolute [.asset-card.functional_&::after]:inset-0 [.asset-card.functional_&::after]:rounded-[var(--r-sm)] [.asset-card.functional_&::after]:bg-[rgba(0,_0,_0,_0)] [.asset-card.functional_&::after]:[transition:background_var(--d1)_var(--ease-out)] [.asset-card.functional_&::after]:[content:''] [.asset-card.functional_&::after]:pointer-events-none [.asset-card.functional_&:hover::after]:bg-[rgba(0,_0,_0,_.16)] [.asset-card.functional_&.image]:bg-[var(--surface-hover)] [.asset-card.functional_&.link]:bg-[var(--surface-hover)] [.asset-card.functional_&.link]:text-[var(--success)] [.asset-card.functional_&.file]:bg-[var(--surface-hover)] [.asset-card.functional_&.file]:text-[var(--violet-strong)] [.asset-card.functional_&_img]:relative [.asset-card.functional_&_img]:z-[0] [.asset-card.functional_&_img]:w-full [.asset-card.functional_&_img]:h-full [.asset-card.functional_&_img]:rounded-[var(--r-sm)] [.asset-card.functional_&_img]:object-cover [.asset-card.functional_&_video]:relative [.asset-card.functional_&_video]:z-[0] [.asset-card.functional_&_video]:w-full [.asset-card.functional_&_video]:h-full [.asset-card.functional_&_video]:rounded-[var(--r-sm)] [.asset-card.functional_&_video]:object-cover ${e.kind} ${t?`video`:``} relative -mx-1.5 -mt-1.5 mb-2.5 grid h-44 min-h-0 w-[calc(100%+12px)] shrink-0 place-items-center overflow-hidden rounded-[var(--r-sm)] border-0 bg-[var(--surface-hover)] text-[var(--text-muted)]`,title:b(`assets:assetsPage.preview`),"aria-label":`${b(`assets:assetsPage.preview`)}: ${e.name}`,onClick:()=>Z(e),children:e.kind===`image`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(n,{className:`absolute`,size:38}),(0,L.jsx)(`img`,{className:`block size-full min-h-0 object-cover`,src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`,alt:``,onError:e=>{e.currentTarget.hidden=!0}})]}):t?(0,L.jsx)(`video`,{className:`block size-full min-h-0 object-cover`,src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`,muted:!0,preload:`metadata`}):(0,L.jsx)(n,{size:38})}),(0,L.jsxs)(`div`,{className:`asset-card-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_span]:overflow-hidden [&_span]:text-[var(--text-muted)] [&_span]:text-[13px] [&_span]:text-ellipsis [&_span]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap flex min-w-0 flex-col gap-[4px]`,children:[(0,L.jsx)(`strong`,{title:e.name,children:e.name}),(0,L.jsxs)(`span`,{children:[e.kind===`link`?e.url?new URL(e.url).hostname:``:m(e.size),` `,`·`,` `,e.source===`agent`?b(`assets:assetsPage.agentOutputs`):e.source===`attachment`?b(`assets:assetsPage.chatAttachments`):b(`assets:assetsPage.manualUploads`)]}),e.sessionName&&(0,L.jsx)(`small`,{title:e.sessionName,children:b(`assets:assetsPage.fromName`,{name:e.sessionName})})]}),(0,L.jsxs)(`div`,{className:`asset-card-actions flex-none [.asset-card.functional:hover_&]:opacity-100 [.asset-card.functional:hover_&]:[transform:translateY(0)] [.asset-card.functional:focus-within_&]:opacity-100 [.asset-card.functional:focus-within_&]:[transform:translateY(0)] [&_a]:no-underline flex flex-wrap items-center gap-[5px] [margin-top:auto] [padding-top:10px] opacity-0 [transform:translateY(4px)] [transition:opacity_var(--d1)_var(--ease-out),_transform_var(--d1)_var(--ease-out)] max-[650px]:opacity-100 max-[650px]:transform-none`,children:[e.kind===`link`?(0,L.jsx)(a,{asChild:!0,variant:`outline`,children:(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,L.jsx)(p,{size:13}),b(`assets:assetsPage.open`)]})}):(0,L.jsxs)(a,{variant:`outline`,onClick:()=>Q(e),children:[F()?(0,L.jsx)(p,{size:13}):(0,L.jsx)(y,{size:13}),F()?b(`assets:assetsPage.openInApplication`):b(`assets:assetsPage.download`)]}),(0,L.jsxs)(a,{onClick:()=>X(e),children:[(0,L.jsx)(u,{size:13}),b(`assets:assetsPage.useInChat`)]}),(0,L.jsx)(a,{variant:`destructive`,size:`icon`,className:`ml-auto`,title:b(`assets:assetsPage.deleteAsset`),"aria-label":`${b(`assets:assetsPage.deleteAsset`)}: ${e.name}`,onClick:()=>Y(e),children:(0,L.jsx)(d,{size:13})})]})]},e.id)})}):(0,L.jsxs)(x,{children:[(0,L.jsx)(T,{size:46}),(0,L.jsx)(`h2`,{children:b(`assets:assetsPage.nothingHasGatheredHereYet`)}),(0,L.jsx)(`p`,{children:b(`assets:assetsPage.bringInALinkOrAttachAFileInAConversationPisperWillGatherTheOutputsCreatedAlongTheWay`)}),(0,L.jsxs)(a,{size:`lg`,className:`mt-4`,onClick:()=>q(!0),children:[(0,L.jsx)(l,{size:14}),b(`assets:assetsPage.addLink`)]})]}),W&&(0,L.jsx)(H,{asset:W,onClose:()=>G(null),onUse:()=>X(W),onOpen:()=>Q(W)}),K&&(0,L.jsx)(U,{onClose:()=>q(!1),onCreated:()=>{q(!1),J(),t(b(`assets:assetsPage.linkAssetAdded`))}})]})}function H({asset:e,onClose:t,onUse:n,onOpen:r}){let{t:i}=o(),s=e.mimeType?.startsWith(`video/`);return(0,L.jsx)(`div`,{className:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,L.jsxs)(`section`,{className:`modal asset-preview-modal flex max-h-[calc(100dvh_-_40px)] flex-col overflow-hidden [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)] max-[650px]:p-3 ${e.kind===`image`||s?`w-[min(96vw,1200px)]`:`w-[min(96vw,900px)]`}`,children:[(0,L.jsxs)(b,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{children:e.name}),(0,L.jsx)(`p`,{children:e.kind===`link`?e.url:`${e.mimeType} · ${m(e.size)}`})]}),(0,L.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":i(`assets:assetsPage.closeDialog`),onClick:t,children:(0,L.jsx)(f,{size:17})})]}),(0,L.jsx)(`div`,{className:`asset-modal-content [&_>_img]:max-h-full [&_>_img]:max-w-full [&_>_img]:rounded-[var(--r-sm)] [&_>_img]:object-contain [&_>_video]:aspect-video [&_>_video]:max-h-full [&_>_video]:w-full [&_>_video]:rounded-[var(--r-sm)] [&_>_video]:bg-black [&_>_video]:object-contain [&_>_pre]:m-0 [&_>_pre]:h-full [&_>_pre]:w-full [&_>_pre]:overflow-auto [&_>_pre]:whitespace-pre-wrap [&_>_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_>_pre]:text-[12px] [&_>_pre]:leading-[1.55] [&_>_a]:flex [&_>_a]:items-center [&_>_a]:gap-[7px] [&_>_a]:text-[var(--text-soft)] [&_>_a]:text-[12px] [&_>_a]:[text-decoration:underline] [&_>_a]:[text-underline-offset:2px] [&_>_a]:[word-break:break-all] grid min-h-[min(420px,60dvh)] flex-1 place-items-center overflow-auto [margin-top:14px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] p-3 max-[650px]:min-h-[240px]`,children:e.kind===`image`?(0,L.jsx)(`img`,{src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`,alt:e.name}):s?(0,L.jsx)(`video`,{controls:!0,playsInline:!0,preload:`metadata`,src:`/api/assets/${encodeURIComponent(e.id)}/download?inline=1`}):e.kind===`link`?(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,L.jsx)(p,{size:16}),e.url]}):e.text===void 0?(0,L.jsxs)(`div`,{className:`asset-file-preview [&_strong]:text-[var(--text)] [&_strong]:text-[13px] [&_span]:text-[12px] [&_span]:leading-[1.55] flex max-w-[400px] flex-col items-center gap-[9px] text-[var(--text-secondary)] text-center`,children:[(0,L.jsx)(c,{size:42}),(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{children:i(`assets:assetsPage.thisFileTypeCanBeDownloadedSupportedDocumentsCanAlsoBeAddedToAChatForAnalysis`)})]}):e.textFormat===`markdown`?(0,L.jsx)(`div`,{className:`h-full w-full overflow-auto text-left`,children:(0,L.jsx)(D,{children:e.text})}):(0,L.jsx)(`pre`,{children:e.text})}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[e.kind!==`link`&&(0,L.jsxs)(a,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:r,children:[F()?(0,L.jsx)(p,{size:14}):(0,L.jsx)(y,{size:14}),F()?i(`assets:assetsPage.openInApplication`):i(`assets:assetsPage.download`)]}),(0,L.jsxs)(a,{size:`lg`,onClick:n,children:[(0,L.jsx)(u,{size:14}),i(`assets:assetsPage.useInChat`)]})]})]})})}function U({onClose:e,onCreated:t}){let{t:n}=o(),[i,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``);return(0,L.jsx)(`div`,{className:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:t=>t.target===t.currentTarget&&e(),children:(0,L.jsxs)(`form`,{className:`modal !w-[min(430px,100%)] max-h-[calc(100dvh_-_40px)] overflow-y-auto [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)]`,onSubmit:async e=>{e.preventDefault(),d(!0),m(``);try{await r(`/api/assets`,{method:`POST`,body:JSON.stringify({kind:`link`,name:i,url:c,source:`upload`})}),t()}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(!1)}},children:[(0,L.jsxs)(b,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{children:n(`assets:assetsPage.addLinkAsset`)}),(0,L.jsx)(`p`,{children:n(`assets:assetsPage.linksCanBeArchivedOpenedOrAddedToAChatAsContext`)})]}),(0,L.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":n(`assets:assetsPage.closeDialog`),onClick:e,children:(0,L.jsx)(f,{size:17})})]}),(0,L.jsxs)(w,{variant:`control`,children:[n(`assets:assetsPage.name`),(0,L.jsx)(`input`,{value:i,onChange:e=>s(e.target.value),placeholder:n(`assets:assetsPage.forExampleOpenAIAPIDocs`)})]}),(0,L.jsxs)(w,{variant:`control`,children:[`URL`,(0,L.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com/docs`})]}),p&&(0,L.jsxs)(v,{children:[(0,L.jsx)(_,{size:13}),p]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,L.jsx)(a,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:e,children:n(`assets:assetsPage.cancel`)}),(0,L.jsxs)(a,{size:`lg`,disabled:u||!c.trim(),children:[u?(0,L.jsx)(h,{className:`animate-spin`,size:14}):(0,L.jsx)(C,{size:14}),n(u?`assets:assetsPage.adding`:`assets:assetsPage.addLink`)]})]})]})})}export{V as AssetsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{n as i,t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-yjKc6F2w.js";import{t as s}from"./AppSelect-CRjRgr38.js";import{t as c}from"./message-circle-Bc_EzZop.js";import{t as l}from"./send-DcLH_sg0.js";import{t as ee}from"./shield-check-BQHFfxVy.js";import{t as u}from"./trash-2-mhzzyC6i.js";import{t as d}from"./x-bw26XDZM.js";import{t as f}from"./input-D1QFzNMx.js";import{B as p,Dt as m,Nt as h,Ot as g,a as _,bt as v,ht as te,i as y,l as b,n as x,o as S,r as C,s as w,t as T,wt as E,xt as ne}from"./index-CAWCOpxG.js";import{t as D}from"./field-BAyGDYW_.js";import{t as O}from"./StarOrbit-BlI6MhVr.js";import{t as k}from"./usePagePrimaryAction-Bw0OFTDZ.js";import"./brand-DIEc3fK8.js";var re=i(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),A=e(t(),1),j=n(),ie=Object.entries({feishu:{Icon:h,tone:`blue`},weixin:{Icon:c,tone:`green`},qq:{Icon:c,tone:`blue`},telegram:{Icon:l,tone:`blue`}});function M(e,t){return t(e===`feishu`?`channels:channelsPage.feishu`:e===`weixin`?`channels:channelsPage.weChat`:e===`qq`?`channels:channelsPage.qq`:`channels:channelsPage.telegram`)}function ae(e,t){return t(e===`feishu`?`channels:channelsPage.feishuAppBot`:e===`weixin`?`channels:channelsPage.weChat`:e===`qq`?`channels:channelsPage.qqBot`:`channels:channelsPage.telegramBot`)}function N(e,t){return t(e===`feishu`?`channels:channelsPage.webSocketPersistentConnection`:e===`weixin`?`channels:channelsPage.tencentILinkPersistentConnection`:e===`qq`?`channels:channelsPage.qqPersistentConnection`:`channels:channelsPage.telegramPersistentConnection`)}function P(e,t){return t(e===`feishu`?`channels:channelsPage.feishuCapabilities`:e===`weixin`?`channels:channelsPage.weChatCapabilities`:e===`qq`?`channels:channelsPage.qqCapabilities`:`channels:channelsPage.telegramCapabilities`)}function F(e){return e===`telegram`}function oe(e,t,n){return t?n(`channels:channelsPage.reconnectName`,{name:M(e,n)}):F(e)?n(`channels:channelsPage.configureName`,{name:M(e,n)}):n(`channels:channelsPage.connectNameByQRCode`,{name:M(e,n)})}function I(e,t){return t(e===`connecting`?`channels:channelsPage.connecting`:e===`connected`?`channels:channelsPage.online`:e===`reconnecting`?`channels:channelsPage.reconnecting`:e===`failed`?`channels:channelsPage.connectionFailed`:`channels:channelsPage.notConnected`)}function se(e){return e===`connected`?`green`:e===`connecting`||e===`reconnecting`?`amber`:e===`failed`?`red`:`gray`}function L(e,t){return t(e===`starting`?`channels:channelsPage.requestingLoginQrCode`:e===`waiting`?`channels:channelsPage.scanAndConfirmConnection`:e===`scanned`?`channels:channelsPage.scannedWaitingForConfirmation`:e===`verification_required`?`channels:channelsPage.enterPairingCode`:e===`authorizing`?`channels:channelsPage.confirmingAuthorization`:e===`connecting`?`channels:channelsPage.authorizationSucceededConnecting`:e===`completed`?`channels:channelsPage.channelConnected`:e===`failed`?`channels:channelsPage.connectionFailed`:`channels:channelsPage.cancelled`)}function R(e,t=`zh-CN`){let n=Math.max(0,Math.ceil((new Date(e).getTime()-Date.now())/1e3));return t===`en-US`?n>=60?`in ${Math.ceil(n/60)} min`:`in ${n} sec`:n>=60?`${Math.ceil(n/60)} 分钟后`:`${n} 秒后`}function z(e){return e instanceof Error?e.message:String(e)}function B({notify:e,registerPrimaryAction:t,requestConfirm:n}){let{t:i,language:d}=o(),[f,h]=(0,A.useState)({providers:[],connections:{feishu:null,weixin:null,qq:null,telegram:null},scopes:[],models:[]}),[g,x]=(0,A.useState)(!0),[L,R]=(0,A.useState)(``),[B,V]=(0,A.useState)(`feishu`),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(``),[K,q]=(0,A.useState)(!1),[J,Y]=(0,A.useState)(``),X=(0,A.useCallback)(async()=>{try{R(``);let e=await r(`/api/channels`);h(e),Y(e.connections?.[B]?.defaultCwd||``)}catch(e){R(z(e))}finally{x(!1)}},[B]);(0,A.useEffect)(()=>{X()},[X]),(0,A.useEffect)(()=>{if(!H?.id||[`completed`,`failed`,`cancelled`].includes(H.status))return;let t=H.id,n=window.setInterval(async()=>{try{let a=H.platform,o=await r(`/api/channels/${a}/onboarding/${encodeURIComponent(t)}`);U({...o,platform:a}),o.status===`completed`&&(window.clearInterval(n),e(i(`channels:channelsPage.nameTwoWayConnectionEstablished`,{name:M(a,i)})),await X(),window.setTimeout(()=>U(null),900))}catch(e){U(t=>t&&{...t,status:`failed`,error:z(e)})}},1500);return()=>window.clearInterval(n)},[H?.id,H?.platform,H?.status,X,e,i]);let Z=async e=>{if(!(f.connections?.[e]&&!await n({title:i(`channels:channelsPage.reconnectName`,{name:M(e,i)}),message:F(e)?i(`channels:channelsPage.configuringAgainWillReplaceTheCurrentNameConnectionContinue`,{name:M(e,i)}):i(`channels:channelsPage.scanningAgainWillReplaceTheCurrentNameConnectionContinue`,{name:M(e,i)}),confirmLabel:F(e)?i(`channels:channelsPage.continueConfiguration`):i(`channels:channelsPage.continueScanning`),tone:`primary`}))){V(e),G(e),U({platform:e,status:`starting`});try{let t=await r(`/api/channels/${e}/onboarding`,{method:`POST`,body:`{}`});`mode`in t&&t.mode===`manual`?U({...t,platform:e,status:`starting`,manual:!0}):U({...t,platform:e})}catch(t){U({platform:e,status:`failed`,error:z(t)})}finally{G(``)}}};k(t,()=>Z(B));let le=async()=>{H?.id&&![`completed`,`failed`,`cancelled`].includes(H.status)&&await r(`/api/channels/${H.platform}/onboarding/${encodeURIComponent(H.id)}`,{method:`DELETE`}).catch(()=>{}),U(null)},Q=async(t,n,i)=>{q(!0);try{let a=await r(`/api/channels/${t}`,{method:`PATCH`,body:JSON.stringify(n)});h(a),Y(a.connections?.[t]?.defaultCwd||``),e(i)}catch(t){e(z(t),`error`)}finally{q(!1)}},ue=async t=>{q(!0);try{h(await r(`/api/channels/${t}/reconnect`,{method:`POST`,body:`{}`})),e(i(`channels:channelsPage.nameReconnected`,{name:M(t,i)}))}catch(t){e(z(t),`error`),X()}finally{q(!1)}},de=async t=>{if(await n({title:i(`channels:channelsPage.disconnectName`,{name:M(t,i)}),message:i(`channels:channelsPage.localCredentialsAndChatMappingsWillBeDeleted`),confirmLabel:i(`channels:channelsPage.disconnect`)}))try{await r(`/api/channels/${t}`,{method:`DELETE`}),await X(),e(i(`channels:channelsPage.nameDisconnected`,{name:M(t,i)}))}catch(t){e(z(t),`error`)}},fe=async t=>{if(await n({title:i(`channels:channelsPage.resetChannelChat`),message:i(`channels:channelsPage.resetTheAppChatLinkedToScope`,{scope:t.title,app:`Pisper`}),confirmLabel:i(`channels:channelsPage.reset`)}))try{await r(`/api/channels/scopes/${encodeURIComponent(t.key)}`,{method:`DELETE`}),await X(),e(i(`channels:channelsPage.channelChatReset`))}catch(t){e(z(t),`error`)}};if(g)return(0,j.jsxs)(C,{children:[(0,j.jsx)(v,{className:`animate-spin`,size:23}),(0,j.jsx)(`h2`,{children:i(`channels:channelsPage.loadingChannels`)})]});let $=f.connections?.[B];return(0,j.jsxs)(`div`,{className:`flex flex-col gap-[12px]`,children:[L&&(0,j.jsxs)(y,{children:[(0,j.jsx)(te,{size:13}),L]}),(0,j.jsx)(`div`,{className:`channel-cards max-[900px]:grid-cols-[1fr] max-[650px]:grid-cols-[1fr] grid grid-cols-[repeat(2,minmax(0,1fr))] gap-[12px]`,children:ie.map(([e,t])=>{let n=f.connections?.[e],r=n?.status||`idle`,o=se(r),s=t.Icon;return(0,j.jsxs)(T,{className:`provider-card channel-platform-card [transition:transform_var(--d2)_var(--ease-out),_box-shadow_var(--d2)_var(--ease-out),_border-color_var(--d2)_var(--ease-out)] hover:[transform:translateY(-2px)] hover:shadow-[var(--sh-2)] hover:border-[var(--star-border)] [&.selected]:border-[var(--accent-border)] [&.selected]:shadow-[0_10px_30px_-24px_var(--blue),0_0_0_2px_var(--selection-ring)] cursor-pointer [transition:border-color_var(--d1)_var(--ease-out),box-shadow_var(--d1)_var(--ease-out)] ${B===e?`selected`:``}`,onClick:()=>{V(e),Y(n?.defaultCwd||``)},children:[(0,j.jsxs)(`div`,{className:`provider-title [&_h2]:text-[14px] [&_p]:mt-[3px] [&_p]:text-[var(--text-secondary)] [&_p]:text-[12px] grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[10px] [margin-bottom:10px]`,children:[(0,j.jsx)(`span`,{className:`provider-icon [&_svg]:w-[19px] [&.green]:bg-[var(--success-soft)] [&.green]:text-[var(--success)] [&.blue]:bg-[var(--brand-blue-soft)] [&.blue]:text-[var(--brand-blue-strong)] [.notification-option_&:not(.blue)]:bg-[var(--surface-muted)] [.notification-option_&:not(.blue)]:text-[var(--text-muted)] grid w-[38px] h-[38px] place-items-center rounded-[var(--r-md)] ${t.tone}`,children:(0,j.jsx)(s,{})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:ae(e,i)}),(0,j.jsx)(`p`,{children:N(e,i)})]}),(0,j.jsx)(b,{tone:o,children:I(r,i)})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.twoWayCapability`),(0,j.jsx)(`span`,{className:`flex min-h-[31px] items-center overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] [padding:0_9px] text-[var(--text-tertiary)] text-[12px] font-[400] text-ellipsis whitespace-nowrap`,children:P(e,i)})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.replyModel`),(0,j.jsx)(`span`,{className:`flex min-h-[31px] items-center overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] [padding:0_9px] text-[var(--text-tertiary)] text-[12px] font-[400] text-ellipsis whitespace-nowrap`,children:n?.replyModel?`${n.replyModel.provider}/${n.replyModel.model}`:i(`channels:channelsPage.useApplicationDefaultModel`)})]}),(0,j.jsxs)(a,{variant:n?`outline`:`default`,size:`lg`,className:`[margin-top:12px] w-full`,disabled:W===e,onClick:t=>{t.stopPropagation(),Z(e)},children:[W===e?(0,j.jsx)(v,{className:`animate-spin`,size:14}):(0,j.jsx)(ne,{size:14}),oe(e,!!n,i)]})]},e)})}),(0,j.jsxs)(`div`,{className:`two-one-grid max-[900px]:grid-cols-[1fr] grid gap-[12px] ${$?`grid-cols-[minmax(0,2fr)_minmax(260px,1fr)]`:`grid-cols-[1fr]`}`,children:[(0,j.jsxs)(T,{children:[(0,j.jsxs)(`div`,{className:`channel-section-head [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[13px] flex items-center justify-between gap-[8px] [margin-bottom:8px]`,children:[(0,j.jsx)(S,{title:i(`channels:channelsPage.channelChats`)}),(0,j.jsx)(`span`,{children:i(`channels:channelsPage.countLinked`,{count:f.scopes.length})})]}),f.scopes.length?f.scopes.map(e=>(0,j.jsxs)(`div`,{className:`route-row [&_div]:flex [&_div]:flex-col [&_div]:gap-[3px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[9px] [border-top:1px_solid_var(--stroke-soft)] [padding:10px_2px]`,children:[(0,j.jsx)(`span`,{className:`route-icon grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:e.platform===`feishu`?(0,j.jsx)(E,{size:14}):e.platform===`telegram`?(0,j.jsx)(l,{size:14}):(0,j.jsx)(c,{size:14})}),(0,j.jsxs)(`div`,{className:`channel-route-copy [.route-row_&]:flex [.route-row_&]:min-w-0 [.route-row_&]:flex-col [.route-row_&]:gap-[3px] [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap`,children:[(0,j.jsxs)(`strong`,{children:[e.title,` `,(0,j.jsx)(b,{tone:e.platform===`feishu`||e.platform===`qq`||e.platform===`telegram`?`blue`:`green`,children:M(e.platform,i)})]}),(0,j.jsxs)(`small`,{children:[e.lastMessage||i(`channels:channelsPage.noMessages`),` ·`,` `,p(e.updatedAt,d)]}),(0,j.jsxs)(`small`,{children:[e.model||i(`channels:channelsPage.defaultModel`),` · `,e.cwd]})]}),(0,j.jsxs)(`div`,{className:`channel-route-controls [.route-row_&]:flex [.route-row_&]:flex-row [.route-row_&]:items-center [.route-row_&]:gap-[4px]`,children:[(0,j.jsx)(b,{tone:`green`,children:i(`channels:channelsPage.twoWay`)}),(0,j.jsx)(a,{variant:`destructive`,size:`icon`,title:i(`channels:channelsPage.resetChat`),"aria-label":`${i(`channels:channelsPage.resetChat`)}: ${e.title}`,onClick:()=>fe(e),children:(0,j.jsx)(u,{size:13})})]})]},e.key)):(0,j.jsxs)(`div`,{className:`channel-route-empty [&_strong]:mt-[9px] [&_strong]:text-[var(--text)] [&_strong]:text-[12px] [&_span]:mt-[4px] [&_span]:text-[13px] [&.compact]:min-h-[110px] [.workflow-assets-panel_&]:min-h-[150px] [.workflow-assets-panel_&]:border-0 [.workflow-assets-panel_&]:bg-transparent grid min-h-[185px] place-content-center justify-items-center text-[var(--text-muted)] text-center`,children:[(0,j.jsx)(O,{size:38}),(0,j.jsx)(`strong`,{children:i(`channels:channelsPage.waitingForTheFirstReplyFromAfar`)}),(0,j.jsx)(`span`,{children:i(`channels:channelsPage.onceConnectedMessagesFromSupportedChannelsWillArriveHereInPisper`)})]})]}),$&&(0,j.jsxs)(T,{className:`test-panel [&_>_p]:m-[8px_0_12px] [&_>_p]:text-[var(--text-secondary)] [&_>_p]:text-[12px] [&_>_p]:leading-[1.5]`,children:[(0,j.jsxs)(`div`,{className:`channel-section-head [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[13px] flex items-center justify-between gap-[8px] [margin-bottom:8px]`,children:[(0,j.jsx)(S,{title:i(`channels:channelsPage.nameSettings`,{name:M(B,i)})}),(0,j.jsx)(`span`,{children:N(B,i)})]}),(0,j.jsxs)(`div`,{className:`channel-live-status [&_>_div]:flex [&_>_div]:min-w-0 [&_>_div]:flex-col [&_>_div]:gap-[3px] [&_strong]:text-[13px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap flex items-center gap-[9px] [margin:11px_0_12px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:10px] ${$.status}`,children:[(0,j.jsx)(`span`,{className:`channel-status-dot [.channel-live-status.connected_&]:bg-[var(--status-green)] [.channel-live-status.connected_&]:shadow-[0_0_0_4px_var(--success-soft)] [.channel-live-status.connecting_&]:bg-[var(--amber)] [.channel-live-status.connecting_&]:shadow-[0_0_0_4px_var(--warning-soft)] [.channel-live-status.connecting_&]:[animation:pulse-dot_1.2s_infinite] [.channel-live-status.reconnecting_&]:bg-[var(--amber)] [.channel-live-status.reconnecting_&]:shadow-[0_0_0_4px_var(--warning-soft)] [.channel-live-status.reconnecting_&]:[animation:pulse-dot_1.2s_infinite] [.channel-live-status.failed_&]:bg-[var(--danger)] [.channel-live-status.failed_&]:shadow-[0_0_0_4px_var(--danger-soft)] w-[8px] h-[8px] [flex:0_0_auto] rounded-[var(--r-pill)] bg-[var(--status-muted)] shadow-[0_0_0_4px_var(--surface-muted)]`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:I($.status,i)}),(0,j.jsx)(`small`,{children:$.lastError||($.status===`connected`?i(`channels:channelsPage.connectedTime`,{time:p($.connectedAt,d)}):i(`channels:channelsPage.establishingPersistentConnection`))})]})]}),(0,j.jsxs)(`div`,{className:`modal-toggle-row [&_>_span]:flex [&_>_span]:flex-col [&_>_span]:gap-[3px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] dark:bg-[var(--surface-subtle)] flex min-h-[45px] items-center justify-between gap-[12px] [margin-top:10px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:8px_10px]`,children:[(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:i(`channels:channelsPage.enableThisChannel`)}),(0,j.jsx)(`small`,{children:i(`channels:channelsPage.turnOffToDisconnectWhileKeepingSignInCredentials`)})]}),(0,j.jsx)(w,{value:$.enabled,disabled:K,ariaLabel:i(`channels:channelsPage.enableThisChannel`),onChange:e=>Q(B,{enabled:e},i(e?`channels:channelsPage.channelEnabled`:`channels:channelsPage.channelPaused`))})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.replyModel`),(0,j.jsxs)(s,{value:$.replyModel?`${$.replyModel.provider}/${$.replyModel.model}`:``,onChange:e=>{let[t,...n]=e.target.value.split(`/`);Q(B,{replyModel:e.target.value?{provider:t,model:n.join(`/`)}:null},i(`channels:channelsPage.channelReplyModelUpdated`))},children:[(0,j.jsx)(`option`,{value:``,children:i(`channels:channelsPage.useApplicationDefaultModel`)}),f.models.map(e=>(0,j.jsx)(`option`,{value:`${e.provider}/${e.model}`,children:e.label},`${e.provider}/${e.model}`))]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.approvalMode`),(0,j.jsxs)(s,{value:$.executionMode,onChange:e=>Q(B,{executionMode:e.target.value},i(`channels:channelsPage.approvalModeUpdated`)),children:[(0,j.jsx)(`option`,{value:`approval-required`,children:i(`channels:channelsPage.approvalRequired`)}),(0,j.jsx)(`option`,{value:`workspace-write`,children:i(`channels:channelsPage.workspaceWrite`)}),(0,j.jsx)(`option`,{value:`full-access`,children:i(`channels:channelsPage.fullAccess`)})]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.executionMode`),(0,j.jsxs)(s,{value:$.runMode,onChange:e=>Q(B,{runMode:e.target.value},i(`channels:channelsPage.executionModeUpdated`)),children:[(0,j.jsx)(`option`,{value:`plan`,children:i(`channels:channelsPage.planMode`)}),(0,j.jsx)(`option`,{value:`goal`,children:i(`channels:channelsPage.goalMode`)}),(0,j.jsx)(`option`,{value:`team`,children:i(`channels:channelsPage.teamMode`)})]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.accessScope`),(0,j.jsxs)(s,{value:$.accessMode,onChange:e=>Q(B,{accessMode:e.target.value===`all`?`all`:`owner`},i(`channels:channelsPage.accessScopeUpdated`)),children:[(0,j.jsx)(`option`,{value:`owner`,disabled:!$.ownerConfigured,children:i(`channels:channelsPage.qrCodeOwnerOnly`)}),(0,j.jsx)(`option`,{value:`all`,children:i(B===`feishu`?`channels:channelsPage.allMembersInTheCurrentTenant`:B===`weixin`?`channels:channelsPage.allWeChatUsersWhoMessageTheBot`:`channels:channelsPage.allUsersWhoMessageTheBot`)})]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.defaultWorkingDirectoryForNewChats`),(0,j.jsxs)(`span`,{className:`channel-setting-input [&_input]:min-w-0 [&_input]:border-0 [&_input]:[outline:0] [&_input]:bg-transparent [&_input]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_input]:text-[12px] dark:[&_input]:bg-[var(--solid)] dark:[&_input]:text-[var(--text)] grid h-[34px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[7px] [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] [padding:3px_3px_3px_9px] text-[var(--text-muted)]`,children:[(0,j.jsx)(m,{size:13}),(0,j.jsx)(`input`,{value:J,onChange:e=>Y(e.target.value)}),(0,j.jsx)(a,{variant:`outline`,disabled:K||J===$.defaultCwd,onClick:()=>Q(B,{defaultCwd:J},i(`channels:channelsPage.defaultWorkingDirectorySaved`)),children:i(`channels:channelsPage.save`)})]})]}),(0,j.jsxs)(_,{children:[(0,j.jsx)(ee,{size:15}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:i(`channels:channelsPage.localSecurityBoundary`)}),(0,j.jsx)(`small`,{children:i(`channels:channelsPage.ownerOnlyAccessRespectsToolPermissionsAndExecutionMode`)})]})]}),(0,j.jsxs)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:[(0,j.jsxs)(a,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:()=>ue(B),disabled:K,children:[(0,j.jsx)(v,{size:14}),i(`channels:channelsPage.reconnect`)]}),(0,j.jsxs)(a,{variant:`destructive`,size:`lg`,onClick:()=>de(B),children:[(0,j.jsx)(re,{size:14}),i(`channels:channelsPage.disconnect`)]})]})]})]}),H&&(0,j.jsx)(ce,{job:H,onClose:le,onRetry:()=>Z(H.platform),onSubmitCredentials:async t=>{try{let n=await r(`/api/channels/${H.platform}/onboarding`,{method:`POST`,body:JSON.stringify(t)});`connections`in n?(h(n),U(null),e(i(`channels:channelsPage.nameTwoWayConnectionEstablished`,{name:M(H.platform,i)})),await X()):`mode`in n&&n.mode===`manual`?U({...n,platform:H.platform,status:`starting`,manual:!0}):U({...n,platform:H.platform,manual:n.mode===`manual`})}catch(e){U(t=>t&&{...t,status:`failed`,error:z(e)})}},notify:e})]})}function ce({job:e,onClose:t,onRetry:n,onSubmitCredentials:i,notify:s}){let{t:c,language:l}=o(),[u,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(``),[y,b]=(0,A.useState)(``),[S,C]=(0,A.useState)(``),[w,T]=(0,A.useState)(!1),E=[`completed`,`failed`,`cancelled`].includes(e.status),O=e.manual||F(e.platform)&&e.mode!==`qr`,k=e.platform===`qq`?!!(m.trim()&&(y.trim()||S.trim())):!!S.trim(),re=async()=>{if(k){T(!0);try{await i({...m.trim()?{appId:m.trim()}:{},...y.trim()?{appSecret:y.trim()}:{},...S.trim()?{token:S.trim()}:{}})}finally{T(!1)}}};return(0,j.jsx)(`div`,{className:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,j.jsxs)(`section`,{className:`modal !w-[min(430px,100%)] max-h-[calc(100dvh_-_40px)] overflow-y-auto [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)] feishu-onboard-modal w-[min(470px,100%)]`,children:[(0,j.jsxs)(x,{children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:c(O?`channels:channelsPage.configureName`:`channels:channelsPage.connectNameByQRCode`,{name:M(e.platform,c)})}),(0,j.jsx)(`p`,{children:e.platform===`feishu`?c(`channels:channelsPage.createTheBotAppThroughTheOfficialFeishuAuthorizationPage`):e.platform===`weixin`?c(`channels:channelsPage.signInToPersonalWeChatThroughTencentILinkBot`):e.platform===`qq`?c(`channels:channelsPage.scanWithQQToCreateOfficialBot`):c(`channels:channelsPage.enterBotCredentialsForName`,{name:M(e.platform,c)})})]}),(0,j.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":c(`channels:channelsPage.closeDialog`),onClick:t,children:(0,j.jsx)(d,{size:17})})]}),O&&!e.id&&!E&&(0,j.jsxs)(`div`,{className:`grid gap-[9px] [margin-top:14px]`,children:[e.platform===`qq`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(D,{variant:`control`,children:[c(`channels:channelsPage.qqAppId`),(0,j.jsx)(f,{value:m,onChange:e=>h(e.target.value)})]}),(0,j.jsxs)(D,{variant:`control`,children:[c(`channels:channelsPage.qqAppSecret`),(0,j.jsx)(f,{type:`password`,value:y,onChange:e=>b(e.target.value)})]}),(0,j.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:c(`channels:channelsPage.qqCredentialsOrToken`)})]}),(0,j.jsxs)(D,{variant:`control`,children:[c(`channels:channelsPage.botToken`),(0,j.jsx)(f,{type:`password`,value:S,onChange:e=>C(e.target.value)})]}),e.setupUrl&&(0,j.jsxs)(_,{children:[e.qrDataUrl&&(0,j.jsx)(`img`,{src:e.qrDataUrl,alt:c(`channels:channelsPage.openOfficialSetupQRCode`),className:`h-[120px] w-[120px] rounded-[var(--r-sm)] bg-white p-1`}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:c(`channels:channelsPage.officialSetupRequired`)}),(0,j.jsx)(`small`,{children:c(`channels:channelsPage.officialSetupInstructions`)}),(0,j.jsxs)(`a`,{href:e.setupUrl,target:`_blank`,rel:`noreferrer`,children:[c(`channels:channelsPage.openOfficialSetup`),(0,j.jsx)(g,{size:12})]})]})]}),(0,j.jsxs)(a,{size:`lg`,disabled:!k||w,onClick:()=>void re(),children:[w?(0,j.jsx)(v,{className:`animate-spin`,size:14}):(0,j.jsx)(ne,{size:14}),c(`channels:channelsPage.connect`)]})]}),(!O||e.id||E)&&(0,j.jsxs)(`div`,{className:`feishu-qr-stage [&_img]:w-[248px] [&_img]:max-w-[86%] [&_img]:[border:1px_solid_var(--stroke-soft)] [&_img]:rounded-[var(--r-md)] [&_img]:bg-[var(--lightbox-action-bg)] [&_img]:p-[8px] [&_img]:shadow-[0_12px_30px_-24px_var(--ink-strong)] [&_strong]:text-[13px] [&_p]:max-w-[330px] [&_p]:text-[var(--danger)] [&_p]:text-[12px] [&_p]:leading-[1.5] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&.completed]:text-[var(--success)] [&.failed]:text-[var(--danger)] flex min-h-[min(330px,52dvh)] flex-col items-center justify-center gap-[10px] [margin-top:14px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-md)] bg-[linear-gradient(180deg,var(--surface-highlight),var(--surface-subtle))] [padding:18px] text-center ${e.status}`,children:[e.qrDataUrl?(0,j.jsx)(`img`,{src:e.qrDataUrl,alt:c(`channels:channelsPage.nameConnectionQRCode`,{name:M(e.platform,c)})}):e.status===`failed`?(0,j.jsx)(te,{size:42}):(0,j.jsx)(v,{className:`animate-spin`,size:32}),(0,j.jsx)(`strong`,{children:O&&!e.id?c(`channels:channelsPage.enterBotCredentialsForName`,{name:M(e.platform,c)}):L(e.status,c)}),e.error&&(0,j.jsx)(`p`,{children:e.error}),e.expireAt&&!E&&(0,j.jsx)(`small`,{children:c(`channels:channelsPage.qrCodeExpiresTime`,{time:R(e.expireAt,l)})})]}),e.needsVerifyCode&&(0,j.jsxs)(`div`,{className:`weixin-verify-code [&_input]:min-w-0 [&_input]:h-[34px] [&_input]:[border:1px_solid_var(--stroke)] [&_input]:rounded-[var(--r-sm)] [&_input]:bg-[var(--solid)] [&_input]:p-[0_10px] [&_input]:text-[var(--text)] [&_input]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_input]:text-[13px] [&_input]:tracking-[.08em] grid grid-cols-[minmax(0,1fr)_auto] gap-[7px] [margin-top:9px]`,children:[(0,j.jsx)(`input`,{value:u,onChange:e=>p(e.target.value.replace(/\D/g,``).slice(0,8)),placeholder:c(`channels:channelsPage.enterTheNumberShownOnYourPhone`)}),(0,j.jsx)(a,{size:`lg`,disabled:!u,onClick:async()=>{try{await r(`/api/channels/${e.platform}/onboarding/${encodeURIComponent(e.id||``)}/verify`,{method:`POST`,body:JSON.stringify({code:u})}),s(c(`channels:channelsPage.pairingCodeSubmitted`))}catch(e){s(z(e),`error`)}},children:c(`channels:channelsPage.submitPairingCode`)})]}),e.qrUrl&&!E&&(0,j.jsx)(a,{asChild:!0,variant:`outline`,size:`lg`,className:`[margin-top:9px] no-underline w-full bg-surface-subtle`,children:(0,j.jsxs)(`a`,{href:e.qrUrl,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsx)(g,{size:14}),c(`channels:channelsPage.cannotScanOpenTheSignInLink`)]})}),(0,j.jsxs)(_,{children:[(0,j.jsx)(ee,{size:15}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:c(`channels:channelsPage.persistentTwoWayConnection`)}),(0,j.jsx)(`small`,{children:e.platform===`feishu`?c(`channels:channelsPage.webSocketReceivesDirectMessagesAndGroupMentions`):e.platform===`weixin`?c(`channels:channelsPage.tencentILinkContinuouslyPollsDirectMessagesAndSupportsTextAndMediaReplies`):P(e.platform,c)})]})]}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,j.jsx)(a,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:t,children:c(E?`channels:channelsPage.off`:`channels:channelsPage.cancel`)}),e.status===`failed`&&(0,j.jsxs)(a,{size:`lg`,onClick:n,children:[(0,j.jsx)(v,{size:14}),c(O?`channels:channelsPage.retry`:`channels:channelsPage.generateANewQRCode`)]})]})]})})}export{B as ChannelsPage};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{n as i,t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-jYw5s_Yn.js";import{t as s}from"./AppSelect-kDqZkETY.js";import{t as c}from"./message-circle-Bc_EzZop.js";import{t as l}from"./send-DcLH_sg0.js";import{t as ee}from"./shield-check-BQHFfxVy.js";import{t as u}from"./trash-2-mhzzyC6i.js";import{t as d}from"./x-bw26XDZM.js";import{t as f}from"./input-D1QFzNMx.js";import{B as p,Dt as m,Nt as h,Ot as g,a as _,bt as v,ht as te,i as y,l as b,n as x,o as S,r as C,s as w,t as T,wt as E,xt as ne}from"./index-Bd5A8V1V.js";import{t as D}from"./field-t72VAR-1.js";import{t as O}from"./StarOrbit-BlI6MhVr.js";import{t as k}from"./usePagePrimaryAction-Bw0OFTDZ.js";import"./brand-DIEc3fK8.js";var re=i(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),A=e(t(),1),j=n(),ie=Object.entries({feishu:{Icon:h,tone:`blue`},weixin:{Icon:c,tone:`green`},qq:{Icon:c,tone:`blue`},telegram:{Icon:l,tone:`blue`}});function M(e,t){return t(e===`feishu`?`channels:channelsPage.feishu`:e===`weixin`?`channels:channelsPage.weChat`:e===`qq`?`channels:channelsPage.qq`:`channels:channelsPage.telegram`)}function ae(e,t){return t(e===`feishu`?`channels:channelsPage.feishuAppBot`:e===`weixin`?`channels:channelsPage.weChat`:e===`qq`?`channels:channelsPage.qqBot`:`channels:channelsPage.telegramBot`)}function N(e,t){return t(e===`feishu`?`channels:channelsPage.webSocketPersistentConnection`:e===`weixin`?`channels:channelsPage.tencentILinkPersistentConnection`:e===`qq`?`channels:channelsPage.qqPersistentConnection`:`channels:channelsPage.telegramPersistentConnection`)}function P(e,t){return t(e===`feishu`?`channels:channelsPage.feishuCapabilities`:e===`weixin`?`channels:channelsPage.weChatCapabilities`:e===`qq`?`channels:channelsPage.qqCapabilities`:`channels:channelsPage.telegramCapabilities`)}function F(e){return e===`telegram`}function oe(e,t,n){return t?n(`channels:channelsPage.reconnectName`,{name:M(e,n)}):F(e)?n(`channels:channelsPage.configureName`,{name:M(e,n)}):n(`channels:channelsPage.connectNameByQRCode`,{name:M(e,n)})}function I(e,t){return t(e===`connecting`?`channels:channelsPage.connecting`:e===`connected`?`channels:channelsPage.online`:e===`reconnecting`?`channels:channelsPage.reconnecting`:e===`failed`?`channels:channelsPage.connectionFailed`:`channels:channelsPage.notConnected`)}function se(e){return e===`connected`?`green`:e===`connecting`||e===`reconnecting`?`amber`:e===`failed`?`red`:`gray`}function L(e,t){return t(e===`starting`?`channels:channelsPage.requestingLoginQrCode`:e===`waiting`?`channels:channelsPage.scanAndConfirmConnection`:e===`scanned`?`channels:channelsPage.scannedWaitingForConfirmation`:e===`verification_required`?`channels:channelsPage.enterPairingCode`:e===`authorizing`?`channels:channelsPage.confirmingAuthorization`:e===`connecting`?`channels:channelsPage.authorizationSucceededConnecting`:e===`completed`?`channels:channelsPage.channelConnected`:e===`failed`?`channels:channelsPage.connectionFailed`:`channels:channelsPage.cancelled`)}function R(e,t=`zh-CN`){let n=Math.max(0,Math.ceil((new Date(e).getTime()-Date.now())/1e3));return t===`en-US`?n>=60?`in ${Math.ceil(n/60)} min`:`in ${n} sec`:n>=60?`${Math.ceil(n/60)} 分钟后`:`${n} 秒后`}function z(e){return e instanceof Error?e.message:String(e)}function B({notify:e,registerPrimaryAction:t,requestConfirm:n}){let{t:i,language:d}=o(),[f,h]=(0,A.useState)({providers:[],connections:{feishu:null,weixin:null,qq:null,telegram:null},scopes:[],models:[]}),[g,x]=(0,A.useState)(!0),[L,R]=(0,A.useState)(``),[B,V]=(0,A.useState)(`feishu`),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(``),[K,q]=(0,A.useState)(!1),[J,Y]=(0,A.useState)(``),X=(0,A.useCallback)(async()=>{try{R(``);let e=await r(`/api/channels`);h(e),Y(e.connections?.[B]?.defaultCwd||``)}catch(e){R(z(e))}finally{x(!1)}},[B]);(0,A.useEffect)(()=>{X()},[X]),(0,A.useEffect)(()=>{if(!H?.id||[`completed`,`failed`,`cancelled`].includes(H.status))return;let t=H.id,n=window.setInterval(async()=>{try{let a=H.platform,o=await r(`/api/channels/${a}/onboarding/${encodeURIComponent(t)}`);U({...o,platform:a}),o.status===`completed`&&(window.clearInterval(n),e(i(`channels:channelsPage.nameTwoWayConnectionEstablished`,{name:M(a,i)})),await X(),window.setTimeout(()=>U(null),900))}catch(e){U(t=>t&&{...t,status:`failed`,error:z(e)})}},1500);return()=>window.clearInterval(n)},[H?.id,H?.platform,H?.status,X,e,i]);let Z=async e=>{if(!(f.connections?.[e]&&!await n({title:i(`channels:channelsPage.reconnectName`,{name:M(e,i)}),message:F(e)?i(`channels:channelsPage.configuringAgainWillReplaceTheCurrentNameConnectionContinue`,{name:M(e,i)}):i(`channels:channelsPage.scanningAgainWillReplaceTheCurrentNameConnectionContinue`,{name:M(e,i)}),confirmLabel:F(e)?i(`channels:channelsPage.continueConfiguration`):i(`channels:channelsPage.continueScanning`),tone:`primary`}))){V(e),G(e),U({platform:e,status:`starting`});try{let t=await r(`/api/channels/${e}/onboarding`,{method:`POST`,body:`{}`});`mode`in t&&t.mode===`manual`?U({...t,platform:e,status:`starting`,manual:!0}):U({...t,platform:e})}catch(t){U({platform:e,status:`failed`,error:z(t)})}finally{G(``)}}};k(t,()=>Z(B));let le=async()=>{H?.id&&![`completed`,`failed`,`cancelled`].includes(H.status)&&await r(`/api/channels/${H.platform}/onboarding/${encodeURIComponent(H.id)}`,{method:`DELETE`}).catch(()=>{}),U(null)},Q=async(t,n,i)=>{q(!0);try{let a=await r(`/api/channels/${t}`,{method:`PATCH`,body:JSON.stringify(n)});h(a),Y(a.connections?.[t]?.defaultCwd||``),e(i)}catch(t){e(z(t),`error`)}finally{q(!1)}},ue=async t=>{q(!0);try{h(await r(`/api/channels/${t}/reconnect`,{method:`POST`,body:`{}`})),e(i(`channels:channelsPage.nameReconnected`,{name:M(t,i)}))}catch(t){e(z(t),`error`),X()}finally{q(!1)}},de=async t=>{if(await n({title:i(`channels:channelsPage.disconnectName`,{name:M(t,i)}),message:i(`channels:channelsPage.localCredentialsAndChatMappingsWillBeDeleted`),confirmLabel:i(`channels:channelsPage.disconnect`)}))try{await r(`/api/channels/${t}`,{method:`DELETE`}),await X(),e(i(`channels:channelsPage.nameDisconnected`,{name:M(t,i)}))}catch(t){e(z(t),`error`)}},fe=async t=>{if(await n({title:i(`channels:channelsPage.resetChannelChat`),message:i(`channels:channelsPage.resetTheAppChatLinkedToScope`,{scope:t.title,app:`Pisper`}),confirmLabel:i(`channels:channelsPage.reset`)}))try{await r(`/api/channels/scopes/${encodeURIComponent(t.key)}`,{method:`DELETE`}),await X(),e(i(`channels:channelsPage.channelChatReset`))}catch(t){e(z(t),`error`)}};if(g)return(0,j.jsxs)(C,{children:[(0,j.jsx)(v,{className:`animate-spin`,size:23}),(0,j.jsx)(`h2`,{children:i(`channels:channelsPage.loadingChannels`)})]});let $=f.connections?.[B];return(0,j.jsxs)(`div`,{className:`flex flex-col gap-[12px]`,children:[L&&(0,j.jsxs)(y,{children:[(0,j.jsx)(te,{size:13}),L]}),(0,j.jsx)(`div`,{className:`channel-cards max-[900px]:grid-cols-[1fr] max-[650px]:grid-cols-[1fr] grid grid-cols-[repeat(2,minmax(0,1fr))] gap-[12px]`,children:ie.map(([e,t])=>{let n=f.connections?.[e],r=n?.status||`idle`,o=se(r),s=t.Icon;return(0,j.jsxs)(T,{className:`provider-card channel-platform-card [transition:transform_var(--d2)_var(--ease-out),_box-shadow_var(--d2)_var(--ease-out),_border-color_var(--d2)_var(--ease-out)] hover:[transform:translateY(-2px)] hover:shadow-[var(--sh-2)] hover:border-[var(--star-border)] [&.selected]:border-[var(--accent-border)] [&.selected]:shadow-[0_10px_30px_-24px_var(--blue),0_0_0_2px_var(--selection-ring)] cursor-pointer [transition:border-color_var(--d1)_var(--ease-out),box-shadow_var(--d1)_var(--ease-out)] ${B===e?`selected`:``}`,onClick:()=>{V(e),Y(n?.defaultCwd||``)},children:[(0,j.jsxs)(`div`,{className:`provider-title [&_h2]:text-[14px] [&_p]:mt-[3px] [&_p]:text-[var(--text-secondary)] [&_p]:text-[12px] grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[10px] [margin-bottom:10px]`,children:[(0,j.jsx)(`span`,{className:`provider-icon [&_svg]:w-[19px] [&.green]:bg-[var(--success-soft)] [&.green]:text-[var(--success)] [&.blue]:bg-[var(--brand-blue-soft)] [&.blue]:text-[var(--brand-blue-strong)] [.notification-option_&:not(.blue)]:bg-[var(--surface-muted)] [.notification-option_&:not(.blue)]:text-[var(--text-muted)] grid w-[38px] h-[38px] place-items-center rounded-[var(--r-md)] ${t.tone}`,children:(0,j.jsx)(s,{})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:ae(e,i)}),(0,j.jsx)(`p`,{children:N(e,i)})]}),(0,j.jsx)(b,{tone:o,children:I(r,i)})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.twoWayCapability`),(0,j.jsx)(`span`,{className:`flex min-h-[31px] items-center overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] [padding:0_9px] text-[var(--text-tertiary)] text-[12px] font-[400] text-ellipsis whitespace-nowrap`,children:P(e,i)})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.replyModel`),(0,j.jsx)(`span`,{className:`flex min-h-[31px] items-center overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] [padding:0_9px] text-[var(--text-tertiary)] text-[12px] font-[400] text-ellipsis whitespace-nowrap`,children:n?.replyModel?`${n.replyModel.provider}/${n.replyModel.model}`:i(`channels:channelsPage.useApplicationDefaultModel`)})]}),(0,j.jsxs)(a,{variant:n?`outline`:`default`,size:`lg`,className:`[margin-top:12px] w-full`,disabled:W===e,onClick:t=>{t.stopPropagation(),Z(e)},children:[W===e?(0,j.jsx)(v,{className:`animate-spin`,size:14}):(0,j.jsx)(ne,{size:14}),oe(e,!!n,i)]})]},e)})}),(0,j.jsxs)(`div`,{className:`two-one-grid max-[900px]:grid-cols-[1fr] grid gap-[12px] ${$?`grid-cols-[minmax(0,2fr)_minmax(260px,1fr)]`:`grid-cols-[1fr]`}`,children:[(0,j.jsxs)(T,{children:[(0,j.jsxs)(`div`,{className:`channel-section-head [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[13px] flex items-center justify-between gap-[8px] [margin-bottom:8px]`,children:[(0,j.jsx)(S,{title:i(`channels:channelsPage.channelChats`)}),(0,j.jsx)(`span`,{children:i(`channels:channelsPage.countLinked`,{count:f.scopes.length})})]}),f.scopes.length?f.scopes.map(e=>(0,j.jsxs)(`div`,{className:`route-row [&_div]:flex [&_div]:flex-col [&_div]:gap-[3px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[9px] [border-top:1px_solid_var(--stroke-soft)] [padding:10px_2px]`,children:[(0,j.jsx)(`span`,{className:`route-icon grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:e.platform===`feishu`?(0,j.jsx)(E,{size:14}):e.platform===`telegram`?(0,j.jsx)(l,{size:14}):(0,j.jsx)(c,{size:14})}),(0,j.jsxs)(`div`,{className:`channel-route-copy [.route-row_&]:flex [.route-row_&]:min-w-0 [.route-row_&]:flex-col [.route-row_&]:gap-[3px] [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap`,children:[(0,j.jsxs)(`strong`,{children:[e.title,` `,(0,j.jsx)(b,{tone:e.platform===`feishu`||e.platform===`qq`||e.platform===`telegram`?`blue`:`green`,children:M(e.platform,i)})]}),(0,j.jsxs)(`small`,{children:[e.lastMessage||i(`channels:channelsPage.noMessages`),` ·`,` `,p(e.updatedAt,d)]}),(0,j.jsxs)(`small`,{children:[e.model||i(`channels:channelsPage.defaultModel`),` · `,e.cwd]})]}),(0,j.jsxs)(`div`,{className:`channel-route-controls [.route-row_&]:flex [.route-row_&]:flex-row [.route-row_&]:items-center [.route-row_&]:gap-[4px]`,children:[(0,j.jsx)(b,{tone:`green`,children:i(`channels:channelsPage.twoWay`)}),(0,j.jsx)(a,{variant:`destructive`,size:`icon`,title:i(`channels:channelsPage.resetChat`),"aria-label":`${i(`channels:channelsPage.resetChat`)}: ${e.title}`,onClick:()=>fe(e),children:(0,j.jsx)(u,{size:13})})]})]},e.key)):(0,j.jsxs)(`div`,{className:`channel-route-empty [&_strong]:mt-[9px] [&_strong]:text-[var(--text)] [&_strong]:text-[12px] [&_span]:mt-[4px] [&_span]:text-[13px] [&.compact]:min-h-[110px] [.workflow-assets-panel_&]:min-h-[150px] [.workflow-assets-panel_&]:border-0 [.workflow-assets-panel_&]:bg-transparent grid min-h-[185px] place-content-center justify-items-center text-[var(--text-muted)] text-center`,children:[(0,j.jsx)(O,{size:38}),(0,j.jsx)(`strong`,{children:i(`channels:channelsPage.waitingForTheFirstReplyFromAfar`)}),(0,j.jsx)(`span`,{children:i(`channels:channelsPage.onceConnectedMessagesFromSupportedChannelsWillArriveHereInPisper`)})]})]}),$&&(0,j.jsxs)(T,{className:`test-panel [&_>_p]:m-[8px_0_12px] [&_>_p]:text-[var(--text-secondary)] [&_>_p]:text-[12px] [&_>_p]:leading-[1.5]`,children:[(0,j.jsxs)(`div`,{className:`channel-section-head [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[13px] flex items-center justify-between gap-[8px] [margin-bottom:8px]`,children:[(0,j.jsx)(S,{title:i(`channels:channelsPage.nameSettings`,{name:M(B,i)})}),(0,j.jsx)(`span`,{children:N(B,i)})]}),(0,j.jsxs)(`div`,{className:`channel-live-status [&_>_div]:flex [&_>_div]:min-w-0 [&_>_div]:flex-col [&_>_div]:gap-[3px] [&_strong]:text-[13px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap flex items-center gap-[9px] [margin:11px_0_12px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:10px] ${$.status}`,children:[(0,j.jsx)(`span`,{className:`channel-status-dot [.channel-live-status.connected_&]:bg-[var(--status-green)] [.channel-live-status.connected_&]:shadow-[0_0_0_4px_var(--success-soft)] [.channel-live-status.connecting_&]:bg-[var(--amber)] [.channel-live-status.connecting_&]:shadow-[0_0_0_4px_var(--warning-soft)] [.channel-live-status.connecting_&]:[animation:pulse-dot_1.2s_infinite] [.channel-live-status.reconnecting_&]:bg-[var(--amber)] [.channel-live-status.reconnecting_&]:shadow-[0_0_0_4px_var(--warning-soft)] [.channel-live-status.reconnecting_&]:[animation:pulse-dot_1.2s_infinite] [.channel-live-status.failed_&]:bg-[var(--danger)] [.channel-live-status.failed_&]:shadow-[0_0_0_4px_var(--danger-soft)] w-[8px] h-[8px] [flex:0_0_auto] rounded-[var(--r-pill)] bg-[var(--status-muted)] shadow-[0_0_0_4px_var(--surface-muted)]`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:I($.status,i)}),(0,j.jsx)(`small`,{children:$.lastError||($.status===`connected`?i(`channels:channelsPage.connectedTime`,{time:p($.connectedAt,d)}):i(`channels:channelsPage.establishingPersistentConnection`))})]})]}),(0,j.jsxs)(`div`,{className:`modal-toggle-row [&_>_span]:flex [&_>_span]:flex-col [&_>_span]:gap-[3px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] dark:bg-[var(--surface-subtle)] flex min-h-[45px] items-center justify-between gap-[12px] [margin-top:10px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:8px_10px]`,children:[(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:i(`channels:channelsPage.enableThisChannel`)}),(0,j.jsx)(`small`,{children:i(`channels:channelsPage.turnOffToDisconnectWhileKeepingSignInCredentials`)})]}),(0,j.jsx)(w,{value:$.enabled,disabled:K,ariaLabel:i(`channels:channelsPage.enableThisChannel`),onChange:e=>Q(B,{enabled:e},i(e?`channels:channelsPage.channelEnabled`:`channels:channelsPage.channelPaused`))})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.replyModel`),(0,j.jsxs)(s,{value:$.replyModel?`${$.replyModel.provider}/${$.replyModel.model}`:``,onChange:e=>{let[t,...n]=e.target.value.split(`/`);Q(B,{replyModel:e.target.value?{provider:t,model:n.join(`/`)}:null},i(`channels:channelsPage.channelReplyModelUpdated`))},children:[(0,j.jsx)(`option`,{value:``,children:i(`channels:channelsPage.useApplicationDefaultModel`)}),f.models.map(e=>(0,j.jsx)(`option`,{value:`${e.provider}/${e.model}`,children:e.label},`${e.provider}/${e.model}`))]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.approvalMode`),(0,j.jsxs)(s,{value:$.executionMode,onChange:e=>Q(B,{executionMode:e.target.value},i(`channels:channelsPage.approvalModeUpdated`)),children:[(0,j.jsx)(`option`,{value:`approval-required`,children:i(`channels:channelsPage.approvalRequired`)}),(0,j.jsx)(`option`,{value:`workspace-write`,children:i(`channels:channelsPage.workspaceWrite`)}),(0,j.jsx)(`option`,{value:`full-access`,children:i(`channels:channelsPage.fullAccess`)})]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.executionMode`),(0,j.jsxs)(s,{value:$.runMode,onChange:e=>Q(B,{runMode:e.target.value},i(`channels:channelsPage.executionModeUpdated`)),children:[(0,j.jsx)(`option`,{value:`plan`,children:i(`channels:channelsPage.planMode`)}),(0,j.jsx)(`option`,{value:`goal`,children:i(`channels:channelsPage.goalMode`)}),(0,j.jsx)(`option`,{value:`team`,children:i(`channels:channelsPage.teamMode`)})]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.accessScope`),(0,j.jsxs)(s,{value:$.accessMode,onChange:e=>Q(B,{accessMode:e.target.value===`all`?`all`:`owner`},i(`channels:channelsPage.accessScopeUpdated`)),children:[(0,j.jsx)(`option`,{value:`owner`,disabled:!$.ownerConfigured,children:i(`channels:channelsPage.qrCodeOwnerOnly`)}),(0,j.jsx)(`option`,{value:`all`,children:i(B===`feishu`?`channels:channelsPage.allMembersInTheCurrentTenant`:B===`weixin`?`channels:channelsPage.allWeChatUsersWhoMessageTheBot`:`channels:channelsPage.allUsersWhoMessageTheBot`)})]})]}),(0,j.jsxs)(D,{variant:`control`,children:[i(`channels:channelsPage.defaultWorkingDirectoryForNewChats`),(0,j.jsxs)(`span`,{className:`channel-setting-input [&_input]:min-w-0 [&_input]:border-0 [&_input]:[outline:0] [&_input]:bg-transparent [&_input]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_input]:text-[12px] dark:[&_input]:bg-[var(--solid)] dark:[&_input]:text-[var(--text)] grid h-[34px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[7px] [border:1px_solid_var(--stroke)] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] [padding:3px_3px_3px_9px] text-[var(--text-muted)]`,children:[(0,j.jsx)(m,{size:13}),(0,j.jsx)(`input`,{value:J,onChange:e=>Y(e.target.value)}),(0,j.jsx)(a,{variant:`outline`,disabled:K||J===$.defaultCwd,onClick:()=>Q(B,{defaultCwd:J},i(`channels:channelsPage.defaultWorkingDirectorySaved`)),children:i(`channels:channelsPage.save`)})]})]}),(0,j.jsxs)(_,{children:[(0,j.jsx)(ee,{size:15}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:i(`channels:channelsPage.localSecurityBoundary`)}),(0,j.jsx)(`small`,{children:i(`channels:channelsPage.ownerOnlyAccessRespectsToolPermissionsAndExecutionMode`)})]})]}),(0,j.jsxs)(`div`,{className:`mt-[15px] flex gap-2 max-[650px]:flex-wrap`,children:[(0,j.jsxs)(a,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:()=>ue(B),disabled:K,children:[(0,j.jsx)(v,{size:14}),i(`channels:channelsPage.reconnect`)]}),(0,j.jsxs)(a,{variant:`destructive`,size:`lg`,onClick:()=>de(B),children:[(0,j.jsx)(re,{size:14}),i(`channels:channelsPage.disconnect`)]})]})]})]}),H&&(0,j.jsx)(ce,{job:H,onClose:le,onRetry:()=>Z(H.platform),onSubmitCredentials:async t=>{try{let n=await r(`/api/channels/${H.platform}/onboarding`,{method:`POST`,body:JSON.stringify(t)});`connections`in n?(h(n),U(null),e(i(`channels:channelsPage.nameTwoWayConnectionEstablished`,{name:M(H.platform,i)})),await X()):`mode`in n&&n.mode===`manual`?U({...n,platform:H.platform,status:`starting`,manual:!0}):U({...n,platform:H.platform,manual:n.mode===`manual`})}catch(e){U(t=>t&&{...t,status:`failed`,error:z(e)})}},notify:e})]})}function ce({job:e,onClose:t,onRetry:n,onSubmitCredentials:i,notify:s}){let{t:c,language:l}=o(),[u,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(``),[y,b]=(0,A.useState)(``),[S,C]=(0,A.useState)(``),[w,T]=(0,A.useState)(!1),E=[`completed`,`failed`,`cancelled`].includes(e.status),O=e.manual||F(e.platform)&&e.mode!==`qr`,k=e.platform===`qq`?!!(m.trim()&&(y.trim()||S.trim())):!!S.trim(),re=async()=>{if(k){T(!0);try{await i({...m.trim()?{appId:m.trim()}:{},...y.trim()?{appSecret:y.trim()}:{},...S.trim()?{token:S.trim()}:{}})}finally{T(!1)}}};return(0,j.jsx)(`div`,{className:`modal-backdrop max-[650px]:p-[8px] fixed z-[70] inset-0 grid place-items-center overflow-y-auto bg-[var(--modal-overlay)] [backdrop-filter:blur(3px)] [padding:20px] [overscroll-behavior:contain] [animation:fade-in_var(--d1)_var(--ease-out)]`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,j.jsxs)(`section`,{className:`modal !w-[min(430px,100%)] max-h-[calc(100dvh_-_40px)] overflow-y-auto [overscroll-behavior:contain] [border:1px_solid_var(--surface-highlight)] rounded-[var(--r-md)] bg-[var(--solid)] p-[18px] shadow-[0_26px_70px_-25px_var(--shadow-strong)] [animation:modal-in_var(--d2)_var(--ease-out)] max-[650px]:max-h-[calc(100dvh_-_16px)] feishu-onboard-modal w-[min(470px,100%)]`,children:[(0,j.jsxs)(x,{children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:c(O?`channels:channelsPage.configureName`:`channels:channelsPage.connectNameByQRCode`,{name:M(e.platform,c)})}),(0,j.jsx)(`p`,{children:e.platform===`feishu`?c(`channels:channelsPage.createTheBotAppThroughTheOfficialFeishuAuthorizationPage`):e.platform===`weixin`?c(`channels:channelsPage.signInToPersonalWeChatThroughTencentILinkBot`):e.platform===`qq`?c(`channels:channelsPage.scanWithQQToCreateOfficialBot`):c(`channels:channelsPage.enterBotCredentialsForName`,{name:M(e.platform,c)})})]}),(0,j.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":c(`channels:channelsPage.closeDialog`),onClick:t,children:(0,j.jsx)(d,{size:17})})]}),O&&!e.id&&!E&&(0,j.jsxs)(`div`,{className:`grid gap-[9px] [margin-top:14px]`,children:[e.platform===`qq`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(D,{variant:`control`,children:[c(`channels:channelsPage.qqAppId`),(0,j.jsx)(f,{value:m,onChange:e=>h(e.target.value)})]}),(0,j.jsxs)(D,{variant:`control`,children:[c(`channels:channelsPage.qqAppSecret`),(0,j.jsx)(f,{type:`password`,value:y,onChange:e=>b(e.target.value)})]}),(0,j.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:c(`channels:channelsPage.qqCredentialsOrToken`)})]}),(0,j.jsxs)(D,{variant:`control`,children:[c(`channels:channelsPage.botToken`),(0,j.jsx)(f,{type:`password`,value:S,onChange:e=>C(e.target.value)})]}),e.setupUrl&&(0,j.jsxs)(_,{children:[e.qrDataUrl&&(0,j.jsx)(`img`,{src:e.qrDataUrl,alt:c(`channels:channelsPage.openOfficialSetupQRCode`),className:`h-[120px] w-[120px] rounded-[var(--r-sm)] bg-white p-1`}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:c(`channels:channelsPage.officialSetupRequired`)}),(0,j.jsx)(`small`,{children:c(`channels:channelsPage.officialSetupInstructions`)}),(0,j.jsxs)(`a`,{href:e.setupUrl,target:`_blank`,rel:`noreferrer`,children:[c(`channels:channelsPage.openOfficialSetup`),(0,j.jsx)(g,{size:12})]})]})]}),(0,j.jsxs)(a,{size:`lg`,disabled:!k||w,onClick:()=>void re(),children:[w?(0,j.jsx)(v,{className:`animate-spin`,size:14}):(0,j.jsx)(ne,{size:14}),c(`channels:channelsPage.connect`)]})]}),(!O||e.id||E)&&(0,j.jsxs)(`div`,{className:`feishu-qr-stage [&_img]:w-[248px] [&_img]:max-w-[86%] [&_img]:[border:1px_solid_var(--stroke-soft)] [&_img]:rounded-[var(--r-md)] [&_img]:bg-[var(--lightbox-action-bg)] [&_img]:p-[8px] [&_img]:shadow-[0_12px_30px_-24px_var(--ink-strong)] [&_strong]:text-[13px] [&_p]:max-w-[330px] [&_p]:text-[var(--danger)] [&_p]:text-[12px] [&_p]:leading-[1.5] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&.completed]:text-[var(--success)] [&.failed]:text-[var(--danger)] flex min-h-[min(330px,52dvh)] flex-col items-center justify-center gap-[10px] [margin-top:14px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-md)] bg-[linear-gradient(180deg,var(--surface-highlight),var(--surface-subtle))] [padding:18px] text-center ${e.status}`,children:[e.qrDataUrl?(0,j.jsx)(`img`,{src:e.qrDataUrl,alt:c(`channels:channelsPage.nameConnectionQRCode`,{name:M(e.platform,c)})}):e.status===`failed`?(0,j.jsx)(te,{size:42}):(0,j.jsx)(v,{className:`animate-spin`,size:32}),(0,j.jsx)(`strong`,{children:O&&!e.id?c(`channels:channelsPage.enterBotCredentialsForName`,{name:M(e.platform,c)}):L(e.status,c)}),e.error&&(0,j.jsx)(`p`,{children:e.error}),e.expireAt&&!E&&(0,j.jsx)(`small`,{children:c(`channels:channelsPage.qrCodeExpiresTime`,{time:R(e.expireAt,l)})})]}),e.needsVerifyCode&&(0,j.jsxs)(`div`,{className:`weixin-verify-code [&_input]:min-w-0 [&_input]:h-[34px] [&_input]:[border:1px_solid_var(--stroke)] [&_input]:rounded-[var(--r-sm)] [&_input]:bg-[var(--solid)] [&_input]:p-[0_10px] [&_input]:text-[var(--text)] [&_input]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_input]:text-[13px] [&_input]:tracking-[.08em] grid grid-cols-[minmax(0,1fr)_auto] gap-[7px] [margin-top:9px]`,children:[(0,j.jsx)(`input`,{value:u,onChange:e=>p(e.target.value.replace(/\D/g,``).slice(0,8)),placeholder:c(`channels:channelsPage.enterTheNumberShownOnYourPhone`)}),(0,j.jsx)(a,{size:`lg`,disabled:!u,onClick:async()=>{try{await r(`/api/channels/${e.platform}/onboarding/${encodeURIComponent(e.id||``)}/verify`,{method:`POST`,body:JSON.stringify({code:u})}),s(c(`channels:channelsPage.pairingCodeSubmitted`))}catch(e){s(z(e),`error`)}},children:c(`channels:channelsPage.submitPairingCode`)})]}),e.qrUrl&&!E&&(0,j.jsx)(a,{asChild:!0,variant:`outline`,size:`lg`,className:`[margin-top:9px] no-underline w-full bg-surface-subtle`,children:(0,j.jsxs)(`a`,{href:e.qrUrl,target:`_blank`,rel:`noreferrer`,children:[(0,j.jsx)(g,{size:14}),c(`channels:channelsPage.cannotScanOpenTheSignInLink`)]})}),(0,j.jsxs)(_,{children:[(0,j.jsx)(ee,{size:15}),(0,j.jsxs)(`span`,{children:[(0,j.jsx)(`strong`,{children:c(`channels:channelsPage.persistentTwoWayConnection`)}),(0,j.jsx)(`small`,{children:e.platform===`feishu`?c(`channels:channelsPage.webSocketReceivesDirectMessagesAndGroupMentions`):e.platform===`weixin`?c(`channels:channelsPage.tencentILinkContinuouslyPollsDirectMessagesAndSupportsTextAndMediaReplies`):P(e.platform,c)})]})]}),(0,j.jsxs)(`div`,{className:`flex justify-end gap-[8px] [margin-top:18px]`,children:[(0,j.jsx)(a,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:t,children:c(E?`channels:channelsPage.off`:`channels:channelsPage.cancel`)}),e.status===`failed`&&(0,j.jsxs)(a,{size:`lg`,onClick:n,children:[(0,j.jsx)(v,{size:14}),c(O?`channels:channelsPage.retry`:`channels:channelsPage.generateANewQRCode`)]})]})]})})}export{B as ChannelsPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Threads-jM2qHsCn.js","assets/vendor-react-CHuvPdJE.js","assets/rolldown-runtime-B0Z9INg1.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/use-animation-visibility-C-GENY2Z.js","assets/react-bits-8ql09OLP.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{f as r}from"./vendor-router-Bw2aAdMs.js";import{t as i}from"./button-XhIEgIsg.js";import{t as a}from"./use-i18n-
|
|
2
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{f as r}from"./vendor-router-Bw2aAdMs.js";import{t as i}from"./button-XhIEgIsg.js";import{t as a}from"./use-i18n-jYw5s_Yn.js";import"./collapsible-U8Wh2f7S.js";import{a as o,n as s,r as c}from"./web-preview-panel-uBOnhY4Z.js";import{i as l,n as u,r as d,t as f}from"./tooltip-DfGEs0yi.js";import{t as p}from"./utils-C8uzG5AZ.js";import{t as m}from"./arrow-right-KWvgbo3p.js";import{t as h}from"./earth-DR_clkZ9.js";import{t as g}from"./loader-circle-72TYCcVQ.js";import{r as _}from"./client-store-ohgbeJNh.js";import{t as v}from"./input-D1QFzNMx.js";import{Ft as y,Ot as b,bt as x,xt as S}from"./index-Bd5A8V1V.js";import{o as C}from"./shortcuts-BIzphxhz.js";import{t as w}from"./vendor-dockview-yY5mBM3U.js";var T=e(t(),1),E=n(),D=(0,T.createContext)(null),O=()=>{let e=(0,T.useContext)(D);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},k=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,T.useState)(n),[s,c]=(0,T.useState)(!1),l=(0,T.useCallback)(e=>{o(e),r?.(e)},[r]),u=(0,T.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:l,url:a}),[s,l,a]);return(0,E.jsx)(D.Provider,{value:u,children:(0,E.jsx)(`div`,{className:p(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},A=({className:e,children:t,...n})=>(0,E.jsx)(`div`,{className:p(`flex shrink-0 items-center gap-1 border-b p-2`,e),...n,children:t}),j=({onClick:e,disabled:t,tooltip:n,children:r,...a})=>(0,E.jsx)(d,{children:(0,E.jsxs)(f,{children:[(0,E.jsx)(l,{asChild:!0,children:(0,E.jsx)(i,{className:`size-8 p-0 hover:text-foreground`,disabled:t,onClick:e,size:`sm`,variant:`ghost`,...a,children:r})}),(0,E.jsx)(u,{children:(0,E.jsx)(`p`,{children:n})})]})}),M=({value:e,onChange:t,onKeyDown:n,...r})=>{let{url:i,setUrl:a}=O(),[o,s]=(0,T.useState)(i),[c,l]=(0,T.useState)(i);i!==o&&(s(i),l(i));let u=e=>{l(e.target.value),t?.(e)},d=(0,T.useCallback)(e=>{e.key===`Enter`&&a(e.target.value),n?.(e)},[n,a]);return(0,E.jsx)(v,{className:`h-8 flex-1 text-sm`,onChange:t??u,onKeyDown:d,placeholder:`Enter URL...`,value:e??c,...r})},N=({className:e,loading:t,src:n,...r})=>{let{url:i}=O();return(0,E.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,E.jsx)(`iframe`,{className:p(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})},P=(0,T.lazy)(()=>r(()=>import(`./Threads-jM2qHsCn.js`).then(e=>({default:e.Threads})),__vite__mapDeps([0,1,2,3,4,5,6])));function F(e){return e?{entries:[e],index:0}:{entries:[],index:-1}}function I({params:e,api:t}){let{t:n}=a(),r=_(e?.url||``,window.location.href)||``,[i,o]=(0,T.useState)(()=>t.isVisible),[c,l]=(0,T.useState)(()=>F(r)),[u,d]=(0,T.useState)(0),[f,p]=(0,T.useState)(!!r),v=c.index>=0&&c.entries[c.index]||``;(0,T.useEffect)(()=>{o(t.isVisible);let e=t.onDidVisibilityChange(({isVisible:e})=>o(e));return()=>e.dispose()},[t]),(0,T.useEffect)(()=>{!r||r===v||(l(F(r)),d(0),p(!0))},[v,r]),(0,T.useEffect)(()=>{t.setTitle(s(v,n(`common:webPreview.title`)))},[t,v,n]);let S=(0,T.useCallback)(e=>{let n=_(e,v||window.location.href);!n||n===v||(l(e=>({entries:[...e.entries.slice(0,e.index+1),n],index:e.index+1})),t.updateParameters({url:n}),d(0),p(!0))},[t,v]),C=(0,T.useCallback)(e=>{let n=c.index+e;if(n<0||n>=c.entries.length)return;let r=c.entries[n];l(e=>({...e,index:n})),t.updateParameters({url:r}),p(!0)},[t,c]),w=(0,T.useCallback)(()=>{d(e=>e+1),p(!0)},[]),D=(0,T.useCallback)(()=>{v&&window.open(v,`_blank`,`noopener,noreferrer`)},[v]);return i?v?(0,E.jsx)(`div`,{className:`web-preview-panel [&_>_div]:rounded-[0] w-full h-full min-w-0 min-h-0 overflow-hidden bg-[var(--panel)]`,onFocusCapture:()=>t.setActive(),children:(0,E.jsxs)(k,{className:`rounded-none border-0`,defaultUrl:v,onUrlChange:S,children:[(0,E.jsxs)(A,{children:[(0,E.jsx)(j,{"aria-label":n(`common:webPreview.back`),disabled:c.index<=0,onClick:()=>C(-1),tooltip:n(`common:webPreview.back`),children:(0,E.jsx)(y,{})}),(0,E.jsx)(j,{"aria-label":n(`common:webPreview.forward`),disabled:c.index>=c.entries.length-1,onClick:()=>C(1),tooltip:n(`common:webPreview.forward`),children:(0,E.jsx)(m,{})}),(0,E.jsx)(j,{"aria-label":n(`common:webPreview.reload`),onClick:w,tooltip:n(`common:webPreview.reload`),children:(0,E.jsx)(x,{})}),(0,E.jsxs)(`div`,{className:`web-preview-address [&_>_svg]:w-[14px] [&_>_svg]:h-[14px] [&_>_svg]:flex-none [&_>_svg]:text-[var(--text-muted)] flex min-w-0 flex-1 items-center gap-[7px] [margin:0_3px]`,children:[(0,E.jsx)(h,{"aria-hidden":`true`}),(0,E.jsx)(M,{"aria-label":n(`common:webPreview.url`),placeholder:n(`common:webPreview.urlPlaceholder`)})]}),(0,E.jsx)(j,{"aria-label":n(`common:webPreview.openExternal`),onClick:D,tooltip:n(`common:webPreview.openExternal`),children:(0,E.jsx)(b,{})})]}),(0,E.jsx)(N,{onLoad:()=>p(!1),src:v,title:n(`common:webPreview.title`),loading:f?(0,E.jsxs)(`div`,{className:`absolute inset-0 grid place-items-center overflow-hidden bg-[color-mix(in_srgb,var(--panel)_86%,transparent)] text-[var(--text-muted)] text-[12px] [backdrop-filter:blur(3px)]`,children:[(0,E.jsx)(T.Suspense,{fallback:null,children:(0,E.jsx)(P,{})}),(0,E.jsxs)(`span`,{className:`relative z-[1] flex items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-pill)] bg-[color-mix(in_srgb,var(--panel)_82%,transparent)] [padding:7px_11px] shadow-[var(--sh-1)]`,children:[(0,E.jsx)(g,{className:`animate-spin`,size:18}),(0,E.jsx)(`span`,{children:n(`common:webPreview.loading`)})]})]}):null},`${v}:${u}`),(0,E.jsx)(`div`,{className:`flex-none [border-top:1px_solid_var(--stroke-soft)] bg-[var(--surface-subtle)] [padding:5px_10px] text-[var(--text-muted)] text-[10px] leading-[1.4]`,children:n(`common:webPreview.embedNotice`)})]},`${c.index}:${v}`)}):(0,E.jsxs)(`div`,{className:`web-preview-panel [&_>_div]:rounded-[0] w-full h-full min-w-0 min-h-0 overflow-hidden bg-[var(--panel)] web-preview-empty [&_strong]:text-[var(--text)] [&_strong]:text-[13px] flex flex-col items-center justify-center gap-[8px] text-[var(--text-muted)]`,onFocusCapture:()=>t.setActive(),children:[(0,E.jsx)(h,{size:24}),(0,E.jsx)(`strong`,{children:n(`common:webPreview.title`)})]}):null}function L({compactDock:e,onDockReady:t,getTabContextMenuItems:n,createSession:r}){let{t:i}=a(),s=C(`primaryAction`),l=(0,T.useMemo)(()=>function({group:e}){let t=i(`navigation:pageHeader.newChat`);return(0,E.jsx)(`button`,{type:`button`,className:`dock-new-session hover:bg-[var(--surface-hover)] hover:text-[var(--text)] focus-visible:relative focus-visible:z-[1] focus-visible:[outline:2px_solid_var(--focus)] focus-visible:[outline-offset:-2px] grid w-[36px] h-[35px] flex-none place-items-center border-0 [border-left:1px_solid_var(--stroke-soft)] bg-transparent text-[var(--text-muted)] cursor-pointer`,title:t,"aria-label":t,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),r(e)},children:(0,E.jsx)(S,{size:15})})},[r,i]),u=(0,T.useMemo)(()=>({session:o,webPreview:I}),[]),d=(0,T.useMemo)(()=>function(){return(0,E.jsx)(c,{onNewSession:()=>r(),newSessionShortcut:s})},[r,s]);return(0,E.jsx)(w,{className:`dockview-theme-light dockview-theme-pisper`,components:u,watermarkComponent:d,leftHeaderActionsComponent:l,onReady:t,getTabContextMenuItems:n,disableFloatingGroups:!0,disableDnd:e,noPanelsOverlay:`watermark`})}export{L as ChatDockView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{n as i,t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,t as n}from"./vendor-react-CHuvPdJE.js";import{t as r}from"./api-B6CluO7V.js";import{n as i,t as a}from"./button-XhIEgIsg.js";import{t as o}from"./use-i18n-jYw5s_Yn.js";import{t as s}from"./utils-C8uzG5AZ.js";import{t as c}from"./storage-BE5DCCG3.js";import{n as l,r as u,t as d}from"./panel-top-CA2GX1Rj.js";import{t as f}from"./panel-left-CVuoi3zo.js";import{t as p}from"./pencil-CxA1IK0x.js";import{t as m}from"./trash-2-mhzzyC6i.js";import{$ as h,B as g,H as _,K as v,U as y,V as b,bt as x,i as S,jt as C,q as w,r as T,t as E,wt as D}from"./index-Bd5A8V1V.js";/* empty css */import{t as O}from"./StarOrbit-BlI6MhVr.js";import{t as k}from"./brand-DIEc3fK8.js";var A=i(`rotate-ccw-clock`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),j=e(t(),1),M=n();function N({className:e,onPointerMove:t,...n}){let r=(0,j.useCallback)(e=>{let n=e.currentTarget.getBoundingClientRect();e.currentTarget.style.setProperty(`--rb-spotlight-x`,`${e.clientX-n.left}px`),e.currentTarget.style.setProperty(`--rb-spotlight-y`,`${e.clientY-n.top}px`),t?.(e)},[t]);return(0,M.jsx)(`div`,{className:s(`rb-spotlight-card`,e),onPointerMove:r,...n})}function P({query:e,navigate:t,notify:n,requestConfirm:i,requestText:s}){let{t:P,language:F}=o(),[I,L]=(0,j.useState)([]),[R,z]=(0,j.useState)(()=>localStorage.getItem(c.activeSession)||``),[B,V]=(0,j.useState)(!0),[H,U]=(0,j.useState)(``),W=(0,j.useCallback)(async()=>{V(!0),U(``);try{let e=await r(`/api/sessions`);L([...e.sessions||[]].sort((e,t)=>Date.parse(t.modified||``)-Date.parse(e.modified||``)))}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},[]);(0,j.useEffect)(()=>(document.title=`${P(`chat:chatHistoryPage.chatHistory`)} · ${k}`,()=>{document.title=k}),[P]),(0,j.useEffect)(()=>{W();let e=()=>W(),t=e=>z(e.detail?.id||localStorage.getItem(c.activeSession)||``);return window.addEventListener(y,e),window.addEventListener(_,t),()=>{window.removeEventListener(y,e),window.removeEventListener(_,t)}},[W]);let G=(0,j.useMemo)(()=>{let t=e.trim().toLowerCase();return t?I.filter(e=>`${e.name||``} ${e.firstMessage||``} ${e.cwd||``} ${e.model||``}`.toLowerCase().includes(t)):I},[e,I]),K=(e,n=`open`)=>{h(e,n),t(`chat`)},q=async e=>{let t=await s({title:P(`chat:chatHistoryPage.renameChat`),inputLabel:P(`chat:chatHistoryPage.chatTitle`),value:e.name,confirmLabel:P(`chat:chatHistoryPage.save`)});if(t!==null&&t!==e.name)try{let i=await r(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:JSON.stringify({name:t})});L(t=>t.map(t=>t.id===e.id?{...t,name:i.name}:t)),w(),n(P(`chat:chatHistoryPage.chatTitleUpdated`))}catch(e){U(e instanceof Error?e.message:String(e))}},J=async e=>{if(await i({title:P(`chat:chatHistoryPage.deleteChat`),message:P(`chat:chatHistoryPage.deleteChatNameThisAlsoRemovesLocalChatHistory`,{name:e.name}),confirmLabel:P(`chat:chatHistoryPage.delete`)}))try{await r(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`DELETE`});let t=I.filter(t=>t.id!==e.id);if(L(t),R===e.id){let e=t[0]?.id||``;z(e),e?localStorage.setItem(c.activeSession,e):localStorage.removeItem(c.activeSession),v(e)}w(),n(P(`chat:chatHistoryPage.chatDeleted`))}catch(e){U(e instanceof Error?e.message:String(e))}};return(0,M.jsxs)(`div`,{className:`flex min-h-[100%] flex-col gap-[12px]`,children:[(0,M.jsxs)(`div`,{className:`chat-history-summary [&_>_div]:flex [&_>_div]:min-w-0 [&_>_div]:items-center [&_>_div]:gap-[10px] [&_>_div]:text-[var(--star-strong)] [&_>_div_>_span]:flex [&_>_div_>_span]:min-w-0 [&_>_div_>_span]:flex-col [&_>_div_>_span]:gap-[2px] [&_strong]:text-[var(--text)] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] flex min-h-[52px] items-center justify-between gap-[12px] [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--panel)] [padding:8px_10px_8px_14px] shadow-[var(--sh-1)]`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(A,{size:18}),(0,M.jsxs)(`span`,{children:[(0,M.jsx)(`strong`,{children:P(`chat:chatHistoryPage.countChatHistoryItems`,{count:I.length})}),(0,M.jsx)(`small`,{children:e?P(`chat:chatHistoryPage.countCurrentlyFiltered`,{count:G.length}):P(`chat:chatHistoryPage.sortedByMostRecentlyUpdated`)})]})]}),(0,M.jsxs)(a,{variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:W,disabled:B,children:[(0,M.jsx)(x,{className:B?`animate-spin`:``,size:14}),P(`chat:chatHistoryPage.refresh`)]})]}),H&&(0,M.jsx)(S,{children:H}),B&&!I.length?(0,M.jsxs)(T,{children:[(0,M.jsx)(x,{className:`animate-spin`,size:22}),(0,M.jsx)(`h2`,{children:P(`chat:chatHistoryPage.loadingChatHistory`)})]}):G.length?(0,M.jsx)(E,{className:`chat-history-list overflow-hidden !p-[5px]`,children:G.map(e=>(0,M.jsxs)(N,{className:`chat-history-row [.chat-history-row_+_&]:[border-top:1px_solid_var(--stroke-soft)] hover:bg-[var(--surface-subtle)] [&.active]:bg-[var(--surface-subtle)] [&.active]:shadow-[inset_3px_0_var(--brand-blue)] grid grid-cols-[minmax(0,1fr)_auto] items-center rounded-[var(--r-sm)] ${e.id===R?`active`:``}`,children:[(0,M.jsxs)(`button`,{className:`chat-history-open [&_>_svg]:text-[var(--text-muted)] max-[650px]:grid-cols-[32px_minmax(0,1fr)_auto] grid w-full min-w-0 min-h-[72px] grid-cols-[34px_minmax(0,1fr)_auto_auto] items-center gap-[10px] border-0 bg-transparent [padding:9px_10px] text-left`,onClick:()=>K(e.id),children:[(0,M.jsx)(`span`,{className:`grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--star-soft)] text-[var(--star-strong)]`,children:(0,M.jsx)(D,{size:15})}),(0,M.jsxs)(`span`,{className:`chat-history-copy [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_>_span]:overflow-hidden [&_>_span]:text-ellipsis [&_>_span]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[var(--text)] [&_strong]:text-[13px] [&_>_span]:text-[var(--text-soft)] [&_>_span]:text-[12px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] max-[650px]:[&_>_span]:max-w-[54vw] flex min-w-0 flex-col gap-[3px]`,children:[(0,M.jsx)(`strong`,{title:e.name||P(`chat:chatHistoryPage.untitledChat`),children:e.name||P(`chat:chatHistoryPage.untitledChat`)}),(0,M.jsx)(`span`,{children:e.firstMessage||P(`chat:chatHistoryPage.noMessageSummary`)}),(0,M.jsxs)(`small`,{children:[b(e.cwd,F),e.model&&!/(^|\/)unknown$/i.test(String(e.model))?` · ${String(e.model).split(`/`).at(-1)}`:``,e.streaming?` · ${P(`chat:chatHistoryPage.agentRunning`)}`:``]})]}),(0,M.jsxs)(`span`,{className:`chat-history-meta [&_strong]:text-[var(--text-soft)] [&_strong]:text-[11px] [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] max-[650px]:hidden flex min-w-[92px] flex-col items-end gap-[3px]`,children:[(0,M.jsx)(`strong`,{children:P(`chat:chatHistoryPage.countMessages`,{count:e.messageCount||0})}),(0,M.jsx)(`small`,{children:g(e.modified,F)})]}),(0,M.jsx)(C,{size:15})]}),(0,M.jsxs)(`div`,{className:`chat-history-actions [&_button]:grid [&_button]:w-[30px] [&_button]:h-[30px] [&_button]:min-h-[30px] [&_button]:place-items-center [&_button]:border-0 [&_button]:rounded-[var(--r-xs)] [&_button]:bg-transparent [&_button]:text-[var(--text-muted)] [&_button:hover]:bg-[var(--solid)] [&_button:hover]:text-[var(--text)] [&_button.active]:bg-[var(--star-soft)] [&_button.active]:text-[var(--star-strong)] [&_button.danger:hover]:bg-[var(--danger-soft)] [&_button.danger:hover]:text-[var(--danger)] max-[650px]:pr-[4px] flex items-center gap-[2px] [padding-right:8px]`,children:[(0,M.jsx)(`button`,{title:P(`chat:chatHistoryPage.splitToLeft`),"aria-label":P(`chat:chatHistoryPage.splitNameToTheLeft`,{name:e.name}),onClick:()=>K(e.id,`left`),children:(0,M.jsx)(f,{size:14})}),(0,M.jsx)(`button`,{title:P(`chat:chatHistoryPage.splitToRight`),"aria-label":P(`chat:chatHistoryPage.splitNameToTheRight`,{name:e.name}),onClick:()=>K(e.id,`right`),children:(0,M.jsx)(l,{size:14})}),(0,M.jsx)(`button`,{title:P(`chat:chatHistoryPage.splitToTop`),"aria-label":P(`chat:chatHistoryPage.splitNameToTheTop`,{name:e.name}),onClick:()=>K(e.id,`above`),children:(0,M.jsx)(d,{size:14})}),(0,M.jsx)(`button`,{title:P(`chat:chatHistoryPage.splitToBottom`),"aria-label":P(`chat:chatHistoryPage.splitNameToTheBottom`,{name:e.name}),onClick:()=>K(e.id,`below`),children:(0,M.jsx)(u,{size:14})}),(0,M.jsx)(`button`,{title:P(`chat:chatHistoryPage.renameChat`),"aria-label":P(`chat:chatHistoryPage.renameChat`),onClick:()=>q(e),children:(0,M.jsx)(p,{size:14})}),(0,M.jsx)(`button`,{className:`danger`,title:P(`chat:chatHistoryPage.deleteChat`),"aria-label":P(`chat:chatHistoryPage.deleteChat`),onClick:()=>J(e),children:(0,M.jsx)(m,{size:14})})]})]},e.id))}):(0,M.jsxs)(T,{children:[(0,M.jsx)(O,{size:48}),(0,M.jsx)(`h2`,{children:P(e?`chat:chatHistoryPage.noMatchingConversations`:`chat:chatHistoryPage.noConversationsHaveLeftAnEchoYet`)}),(0,M.jsx)(`p`,{children:P(e?`chat:chatHistoryPage.tryADifferentSearch`:`chat:chatHistoryPage.onceAConversationBeginsItWillBeQuietlyGatheredHere`)})]})]})}export{P as ChatHistoryPage};
|