@jetcrab/pi-desk 1.1.30-dev → 1.1.31-dev

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.
Files changed (23) hide show
  1. package/package.json +1 -1
  2. package/temp/build/pi-desk/release/.next/BUILD_ID +1 -1
  3. package/temp/build/pi-desk/release/.next/build-manifest.json +2 -2
  4. package/temp/build/pi-desk/release/.next/required-server-files.js +2 -2
  5. package/temp/build/pi-desk/release/.next/required-server-files.json +2 -2
  6. package/temp/build/pi-desk/release/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/temp/build/pi-desk/release/.next/server/app/_global-error.html +1 -1
  8. package/temp/build/pi-desk/release/.next/server/app/_global-error.rsc +1 -1
  9. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/temp/build/pi-desk/release/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/temp/build/pi-desk/release/.next/server/app/api/health/route.js +1 -1
  14. package/temp/build/pi-desk/release/.next/server/app/login/page_client-reference-manifest.js +1 -1
  15. package/temp/build/pi-desk/release/.next/server/app/page.js +1 -1
  16. package/temp/build/pi-desk/release/.next/server/app/page_client-reference-manifest.js +1 -1
  17. package/temp/build/pi-desk/release/.next/server/app/project-preview/page_client-reference-manifest.js +1 -1
  18. package/temp/build/pi-desk/release/.next/server/middleware-build-manifest.js +1 -1
  19. package/temp/build/pi-desk/release/.next/server/pages/500.html +1 -1
  20. package/temp/build/pi-desk/release/.next/static/chunks/app/{page-978906de76a8dcfe.js → page-f42381b1eed4310d.js} +1 -1
  21. package/temp/build/pi-desk/release/.next/trace-build +1 -1
  22. /package/temp/build/pi-desk/release/.next/static/{ErYBfYXAir5b-6rlacGvL → SUWCp0trQPQnnw0za1R_Y}/_buildManifest.js +0 -0
  23. /package/temp/build/pi-desk/release/.next/static/{ErYBfYXAir5b-6rlacGvL → SUWCp0trQPQnnw0za1R_Y}/_ssgManifest.js +0 -0
@@ -276,7 +276,7 @@ description: ${a.description}
276
276
  location: ${a.path}`})}):null,(0,A.jsx)(db,{title:b("viewSkillContent"),content:a.content,truncated:a.truncated})]},a.path)),a.prompts.map(a=>(0,A.jsxs)("article",{className:"border-b py-4 last:border-b-0",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsxs)("code",{className:"font-semibold",children:["/",a.name]}),(0,A.jsx)("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:b("manualOnly")})]}),(0,A.jsx)("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:a.description}),(0,A.jsx)("p",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:a.path}),(0,A.jsx)(db,{title:b("viewPromptContent"),content:a.content,truncated:a.truncated})]},a.path))]})})}function dd({capabilities:a,browserContributions:b}){let{t:c}=(0,Q.Bd)("pluginManagement"),d=a.extensions.some(a=>a.events.length>0||a.commands.length>0||a.shortcuts.length>0||a.flags.length>0||a.messageRenderers.length>0||a.entryRenderers.length>0),e=a.piDesk.methods.length>0||a.piDesk.browserEntries.length>0||a.piDesk.messageDeclarations.length>0||b.length>0,f=a.themes.length>0||a.providers.length>0;return d||e||f?(0,A.jsx)(c7,{title:c("otherCapabilities"),children:(0,A.jsxs)("div",{className:"space-y-2",children:[e?(0,A.jsxs)("div",{className:"rounded-xl border bg-card p-3 text-xs",children:[(0,A.jsx)("p",{className:"font-semibold",children:"Pi Desk"}),(0,A.jsxs)("div",{className:"mt-2 space-y-1.5 text-muted-foreground",children:[a.piDesk.methods.map(a=>(0,A.jsxs)("p",{children:["Method:",(0,A.jsxs)("code",{children:[a.pluginName,"/",a.method]})]},`${a.pluginName}:${a.method}`)),b.map(a=>(0,A.jsxs)("p",{children:[c(c1[a.kind]),":","message-view"===a.kind?a.viewKey:"application"===a.kind?a.title:"widget"===a.kind||"session-header-item"===a.kind?a.contributionName:a.label]},`${a.kind}:${a.contributionName}`)),a.piDesk.messageDeclarations.map(a=>(0,A.jsxs)("p",{children:[c("messageDeclarations"),(0,A.jsxs)("code",{children:[a.pluginName,"/",a.declarationName]})]},`${a.pluginName}:${a.declarationName}`))]})]}):null,d?a.extensions.map(a=>(0,A.jsxs)("div",{className:"rounded-xl border bg-card p-3 text-xs",children:[(0,A.jsx)("code",{className:"block break-all font-semibold",children:a.path}),a.commands.length>0?(0,A.jsxs)("p",{className:"mt-2 leading-5 text-muted-foreground",children:["Commands:",a.commands.map(a=>`/${a.name}`).join("、")]}):null,a.shortcuts.length>0?(0,A.jsxs)("p",{className:"mt-1 leading-5 text-muted-foreground",children:["Shortcuts:",a.shortcuts.map(a=>a.shortcut).join("、")]}):null,a.flags.length>0?(0,A.jsxs)("p",{className:"mt-1 leading-5 text-muted-foreground",children:["Flags:",a.flags.map(a=>`--${a.name}`).join("、")]}):null,a.events.length>0?(0,A.jsxs)("p",{className:"mt-1 leading-5 text-muted-foreground",children:["Events:",a.events.map(a=>a.name).join("、")]}):null]},a.path)):null,f?(0,A.jsxs)("div",{className:"rounded-xl border bg-card p-3 text-xs text-muted-foreground",children:[a.themes.length>0?(0,A.jsxs)("p",{children:["Theme:",a.themes.map(a=>a.name).join("、")]}):null,a.providers.length>0?(0,A.jsxs)("p",{className:"mt-1",children:["Provider:",a.providers.map(a=>a.name).join("、")]}):null]}):null]})}):null}function de({plugin:a,detail:b,detailLoading:c,detailError:d,browserContributions:e,onRetry:f}){let{t:g}=(0,Q.Bd)("pluginManagement"),{locale:h}=(0,cy.i)(),i=function(a,b,c){let d=[];a.tools.length>0&&d.push({label:c("tagTools",{count:a.tools.length}),tone:"neutral"});let e=a.tools.reduce((a,b)=>"active"!==b.state?a:a+ +!!b.promptSnippet+b.promptGuidelineCount,0)+a.skills.filter(a=>a.modelVisible).length;e>0&&d.push({label:c("tagFixed",{count:e}),tone:"prompt"});let f=c2(a).reduce((a,b)=>a+b.count,0);f>0&&d.push({label:c("tagDynamic",{count:f}),tone:"dynamic"});let g=a.tools.filter(a=>"shadowed"!==a.state&&c$.has(a.name)).length;g>0&&d.push({label:c("tagOverride",{count:g}),tone:"override"});let h=a.prompts.length+a.skills.filter(a=>!a.modelVisible).length;h>0&&d.push({label:c("tagManual",{count:h}),tone:"neutral"});let i=b.length+a.piDesk.methods.length+a.piDesk.messageDeclarations.length;i>0&&d.push({label:`Pi Desk ${i}`,tone:"neutral"});let j=a.providers.length+a.themes.length+a.extensions.reduce((a,b)=>a+b.commands.length+b.shortcuts.length+b.flags.length,0);return j>0&&d.push({label:c("tagInteraction",{count:j}),tone:"neutral"}),0===d.length&&a.extensions.length>0&&d.push({label:`Extension ${a.extensions.length}`,tone:"neutral"}),d}(a.capabilities,e,g);return(0,A.jsxs)("div",{className:"space-y-3 text-sm","data-testid":"plugin-capability-detail",children:[(0,A.jsx)("p",{className:"break-all font-mono text-xs text-muted-foreground",children:a.source}),i.length>0?(0,A.jsx)("div",{className:"flex flex-wrap gap-2","aria-label":g("capabilityCategories"),children:i.map(a=>(0,A.jsx)("span",{className:"rounded-md bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:a.label},a.label))}):null,a.capabilities.error?(0,A.jsx)("p",{className:"whitespace-pre-wrap break-words text-sm leading-5 text-status-warning",children:g("incompleteCapabilities",{error:(0,cx.fD)(a.capabilities.error,h)})}):null,c?(0,A.jsxs)("div",{className:"flex items-center gap-2 py-2 text-sm text-muted-foreground",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"}),g("loadingFullDetails")]}):d?(0,A.jsxs)("div",{className:"flex items-start gap-2",role:"alert",children:[(0,A.jsx)("p",{className:"min-w-0 flex-1 break-words text-sm text-destructive",children:d}),(0,A.jsxs)(U.$,{type:"button",size:"sm",variant:"outline",onClick:f,children:[(0,A.jsx)(bO.A,{"data-icon":"inline-start"}),g("retry")]})]}):b?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(da,{detail:b}),(0,A.jsx)(dc,{detail:b})]}):null,(0,A.jsx)(c8,{capabilities:a.capabilities}),(0,A.jsx)(dd,{capabilities:a.capabilities,browserContributions:e})]})}var df=c(31914);let dg=B.createContext(void 0);var dh=c(98553);let di={...dh.dc,checked:a=>a?{"data-checked":""}:{"data-unchecked":""}};var dj=c(36054),dk=c(99188),dl=c(89163),dm=c(61495),dn=c(61287);function dp(a,b,c,d=!0,e){let[f,g]=B.useState(),h=(0,aS.e)(e?`${e}-label`:void 0),i=a??b??f;return(0,av.g)(()=>{let e=a||b||!d?void 0:function(a,b){let c=function(a){if(!a)return;let b=a.parentElement;if(b&&"LABEL"===b.tagName)return b;let c=a.id;if(c){let b=a.nextElementSibling;if(b&&b.htmlFor===c)return b}let d=a.labels;return d&&d[0]}(a);if(c)return!c.id&&b&&(c.id=b),c.id||void 0}(c.current,h);f!==e&&g(e)}),i}var dq=c(42270),dr=c(45699);let ds=B.forwardRef(function(a,b){let{checked:c,className:d,defaultChecked:e,"aria-labelledby":f,form:g,id:h,inputRef:i,name:j,nativeButton:k=!1,onCheckedChange:l,readOnly:m=!1,required:n=!1,disabled:o=!1,render:p,uncheckedValue:q,value:r,style:s,...t}=a,{clearErrors:u}=(0,dm.x)(),{state:v,setTouched:w,setDirty:x,validityData:y,setFilled:z,setFocused:C,validationMode:D,disabled:E,name:F,validation:G}=(0,dk.V$)(),{labelId:H}=(0,dn.H)(),I=E||o,J=F??j,K=B.useRef(null),L=(0,aJ.a)(K,i,G.inputRef),M=B.useRef(null),N=(0,aS.e)(),O=(0,dq.l)({id:h,implicit:!1,controlRef:M}),P=k?void 0:O,[Q,R]=(0,ba.q)({controlled:c,default:!!e,name:"Switch",state:"checked"});(0,dl.I)(M,N,Q,void 0,!I,j),(0,av.g)(()=>{K.current&&z(K.current.checked)},[z]),(0,dr.x)(Q,()=>{u(J),x(Q!==y.initialValue),z(Q),G.change(Q)});let{getButtonProps:S,buttonRef:T}=(0,aH.s)({disabled:I,native:k}),U=dp(f,H,K,!k,P),V={...G.getValidationProps(I),checked:Q,disabled:I,form:g,id:P,name:J,required:n,style:J?df.a:df.Q,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:L,onChange(a){if(a.nativeEvent.defaultPrevented)return;if(m)return void a.preventDefault();let b=a.currentTarget.checked,c=(0,bf.d)(aT.dv,a.nativeEvent);l?.(b,c),c.isCanceled||R(b)},onClick(a){a.stopPropagation()},onFocus(){M.current?.focus()},...void 0!==r?{value:r}:aw.t0},W=B.useMemo(()=>({...v,checked:Q,disabled:I,readOnly:m,required:n}),[v,Q,I,m,n]),X=(0,aG.o)("span",a,{state:W,ref:[b,M,T],props:[{id:k?O:N,role:"switch","aria-checked":Q,"aria-readonly":m||void 0,"aria-required":n||void 0,"aria-labelledby":U,onFocus(){I||C(!0)},onBlur(){let a=K.current;a&&!I&&(w(!0),C(!1),"onBlur"===D&&G.commit(a.checked))},onClick(a){if(m||I)return;a.preventDefault();let b=K.current;b&&(0,dj.B)(b,a)}},t,S,a=>G.getValidationProps(I,a)],stateAttributesMapping:di});return(0,A.jsxs)(dg.Provider,{value:W,children:[X,!Q&&J&&void 0!==q&&(0,A.jsx)("input",{type:"hidden",form:g,name:J,value:q,disabled:I}),(0,A.jsx)("input",{...V,suppressHydrationWarning:!0})]})}),dt=B.forwardRef(function(a,b){let{render:c,className:d,style:e,...f}=a,g=function(){let a=B.useContext(dg);if(void 0===a)throw Error((0,aq.A)(63));return a}();return(0,aG.o)("span",a,{state:g,ref:b,stateAttributesMapping:di,props:f})});function du({className:a,size:b="default",...c}){return(0,A.jsx)(ds,{"data-slot":"switch","data-size":b,className:(0,W.cn)("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",a),...c,children:(0,A.jsx)(dt,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}function dv({plugin:a,displayName:b,browserError:c,disabled:d,pending:e,browserRetryPending:f,onAction:g}){let{t:h}=(0,Q.Bd)("pluginManagement"),i=a.operation?.phase,j="disabled"!==a.status;return(0,A.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-3",children:[e?(0,A.jsxs)("span",{role:"status",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground",children:["waiting"!==i?(0,A.jsx)(R.A,{className:"size-4 animate-spin"}):null,h(i&&"failed"!==i?`phase_${i}`:"submitting")]}):a.updateAvailable&&"extension"!==a.kind&&"failed"!==i?(0,A.jsx)(U.$,{size:"sm",disabled:d,onClick:()=>g("update"),children:h("update")}):null,"failed"===i?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:d||e,onClick:()=>g("retry"),children:h("retry")}):"failed"===a.status?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:d||e,onClick:()=>g("reload"),children:h("reloadOne")}):c&&a.pluginName?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:d||f,onClick:()=>g("retry-browser"),children:h("retryView")}):null,(0,A.jsxs)("label",{className:"flex min-h-8 cursor-pointer items-center gap-2 text-sm text-muted-foreground",children:[(0,A.jsx)(du,{checked:j,"aria-label":h("togglePlugin",{name:b}),disabled:d||e,onCheckedChange:a=>g(a?"enable":"disable")}),h(j?"enabled":"disabled")]}),"extension"!==a.kind?(0,A.jsx)(U.$,{size:"icon-sm",variant:"ghost",className:"text-muted-foreground hover:text-destructive","aria-label":h("removeNamed",{name:b}),title:h("remove"),disabled:d||e,onClick:()=>g("remove"),children:(0,A.jsx)(bN,{})}):null]})}function dw({plugin:a,requestError:b,browserError:c}){let{t:d}=(0,Q.Bd)("pluginManagement"),{locale:e}=(0,cy.i)(),f=a.operation?.phase,g=[b,"failed"===f?a.operation?.message:null,a.error?(0,cx.fD)(a.error.message,e):null,c,a.updateError?d("itemCheckFailed",{error:a.updateError}):null].filter((a,b,c)=>!!a&&c.indexOf(a)===b);return g.length||"waiting"===f||"failed"===a.status?(0,A.jsxs)("div",{className:"space-y-1",children:[g.map(a=>(0,A.jsx)("p",{role:"alert",className:"whitespace-pre-wrap text-sm text-destructive [overflow-wrap:anywhere]",children:a},a)),g.length||"failed"!==a.status?null:(0,A.jsx)("p",{className:"text-sm text-destructive",children:d("notLoaded")}),"waiting"===f&&a.operation?.message?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground [overflow-wrap:anywhere]",children:a.operation.message}):null]}):null}function dx(a){let b=a.startsWith("npm:")?a.slice(4):a,c=/^((?:@[a-z0-9_.-]+\/)?[a-z0-9][a-z0-9_.-]*)(?:@([^\s/]+))?$/i.exec(b);return c?{name:c[1],...c[2]?{version:c[2]}:{}}:null}function dy(a){return a.source.startsWith("npm:")?dx(a.source)?.name??a.source:a.pluginName??("extension"===a.kind?a.source.replaceAll("\\","/").split("/").at(-1):null)??a.source}function dz(a){return`source:${dx(a)?.name??a}`}function dA(a){switch(a.kind){case"batch":return"add"===a.input.action?"batchInstall":"update"===a.input.action?"updateSelected":"del"===a.input.action?"removeSelected":"setChannel";case"add":return"actionAdd";case"update":return"actionUpdate";case"del":return"actionDelete";case"enable":return"enable";case"disable":return"disable";case"reload":return"normal"===a.mode?"restartNormal":"actionReload"}}let dB=E.Yj().trim().min(1).max(128).regex(/^[a-zA-Z][a-zA-Z0-9._-]*$/),dC=E.Yj().trim().url().max(2048).refine(a=>{let b=new URL(a);return["https:","http:"].includes(b.protocol)&&!b.username&&!b.password&&!b.search&&!b.hash},"插件源必须是 HTTP 或 HTTPS 仓库地址"),dD=E.gM("mode",[E.Ik({mode:E.eu("auto")}).strict(),E.Ik({mode:E.eu("local")}).strict(),E.Ik({mode:E.eu("official")}).strict(),E.Ik({mode:E.eu("domestic")}).strict(),E.Ik({mode:E.eu("custom"),registry:dC}).strict()]),dE=E.Ik({description:E.Yj().trim().min(1).max(4e3).optional(),readme:E.Yj().trim().min(1).max(1024).optional()});E.Ik({description:E.Yj().optional(),piDesk:E.Ik({i18n:E.g1(E.Yj().min(1).max(35),dE).optional()}).passthrough().optional()}).passthrough();let dF=E.Ik({downloadSource:dD,recommendedRegistry:dC}).strict(),dG=E.Ik({downloadSource:dD}).strict(),dH=E.Ik({query:E.Yj().trim().max(200).default(""),page:E.ai().int().min(1).max(100).default(1),kind:E.k5(["all","desk","pi"]).default("all"),registry:dC.optional()}).strict(),dI=E.Ik({name:E.Yj().trim().min(1).max(214).regex(/^(?:@[a-z0-9_.-]+\/)?[a-z0-9][a-z0-9_.-]*$/i),version:E.Yj().trim().min(1).max(128).optional(),registry:dC.optional()}).strict(),dJ=E.Ik({name:E.Yj(),description:cx.qf.nullable(),version:E.Yj(),publisher:E.Yj().nullable(),kind:E.k5(["desk","pi","unknown"]),official:E.zM(),registry:dC}).strict(),dK=E.Ik({items:E.YO(dJ),hasMore:E.zM()}).strict(),dL=dJ.extend({versions:E.YO(E.Yj()),readme:cx.qf.nullable(),homepage:E.Yj().nullable(),repository:E.Yj().nullable(),compatible:E.zM().nullable(),compatibilityNote:E.Yj().nullable()}).strict();function dM({id:a,mode:b,registry:c,recommendedRegistry:d,savedRegistry:e,loading:f,saving:g,error:h,override:i,onMode:j,onRegistry:k,onSave:l,onRetry:m}){let{t:n}=(0,Q.Bd)("pluginManagement"),o="auto"===b?d:"official"===b?"https://registry.npmjs.org":"domestic"===b?"https://mirrors.cloud.tencent.com/npm":"custom"===b?e??c:null,p=[...i?[{value:"default",label:n("useDefaultSource")}]:[],...["local","auto","domestic","official","custom"].map(a=>({value:a,label:n(`download_${a}`)}))];return(0,A.jsxs)("div",{className:"min-w-0 space-y-3 text-sm",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)("label",{htmlFor:a,className:"font-medium",children:n(i?"installDownloadSource":"downloadSource")}),(0,A.jsxs)(bS.l6,{value:b,items:p,disabled:f,onValueChange:a=>{a&&!g&&j(a)},children:[(0,A.jsx)(bS.bq,{id:a,className:"max-w-full",children:(0,A.jsx)(bS.yv,{})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[160]",children:p.map(a=>(0,A.jsx)(bS.eb,{value:a.value,disabled:g,children:a.label},a.value))})]}),g?(0,A.jsx)("span",{role:"status",className:"text-muted-foreground",children:n("saving")}):null]}),"custom"===b?(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsx)("label",{htmlFor:`${a}-url`,className:"block",children:n("registryUrl")}),(0,A.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,A.jsx)(bY.p,{id:`${a}-url`,type:"url",value:c,placeholder:"https://registry.example.com",className:"min-w-0 flex-1 basis-48",disabled:g,onChange:a=>k(a.target.value)}),l?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:g,onClick:l,children:n("save")}):null]})]}):!i&&o?(0,A.jsx)("p",{className:"break-all text-xs text-muted-foreground",children:o}):null,h?(0,A.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center gap-2 text-destructive",children:[(0,A.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:h}),m?(0,A.jsx)(U.$,{variant:"outline",size:"sm",onClick:m,children:n("retry")}):null]}):null]})}var dN=c(21556),dO=c(46165),dP=c(75377);function dQ(a){return{checked:b=>a.indeterminate?{}:b?{"data-checked":""}:{"data-unchecked":""},...dh.dc}}let dR=B.createContext({disabled:!1}),dS=B.createContext(void 0),dT=B.createContext(void 0),dU=B.forwardRef(function(a,b){let{checked:c,className:d,defaultChecked:e=!1,"aria-labelledby":f,disabled:g=!1,form:h,id:i,indeterminate:j=!1,inputRef:k,name:l,onCheckedChange:m,parent:n=!1,readOnly:o=!1,render:p,required:q=!1,uncheckedValue:r,value:s,nativeButton:t=!1,style:u,...v}=a,{clearErrors:w}=(0,dm.x)(),{disabled:x,name:y,setDirty:z,setFilled:C,setFocused:D,setTouched:E,state:F,validationMode:G,validityData:H,validation:I}=(0,dk.V$)(),J=B.useContext(dR),{labelId:K,controlId:L,registerControlId:M,getDescriptionProps:N}=(0,dn.H)(),O=B.useContext(dS),P=O?.allValues===void 0?void 0:O.parent,Q=void 0!==P,R=x||J.disabled||O?.disabled||g,S=y??l,T=s??S,U=(0,aS.e)(),V=(0,aS.e)(),W=i||L;Q&&(n?W=V:void 0!==T?W=`${P.id}-${T}`:W||=V);let X={};Q&&(n?X=P.getParentProps():void 0!==T&&(X=P.getChildProps(T)));let{checked:Y=c,indeterminate:Z=j,onCheckedChange:$,..._}=X,aa=O?.value,ab=B.useRef(null),ac=(0,dO.j)(()=>Symbol()),ad=B.useRef(!1),{getButtonProps:ae,buttonRef:af}=(0,aH.s)({disabled:R,native:t}),ag=O?.validation??I,[ah,ai]=(0,ba.q)({controlled:void 0===T||void 0===aa||n?Y:aa.includes(T),default:e,name:"Checkbox",state:"checked"}),aj=Q?!!Y:ah,ak=Q&&Z||j;(0,av.g)(()=>{M!==aw.tE&&(ad.current=!0,M(ac.current,W))},[W,M,ac]),B.useEffect(()=>{let a=ac.current;return()=>{ad.current&&M!==aw.tE&&(ad.current=!1,M(a,void 0))}},[M,ac]),(0,dl.I)(ab,U,ah,void 0,!O&&!R,l);let al=B.useRef(null),am=ag.registerInput,an=O?T:void 0,ao=B.useCallback(a=>am(a,{controlRef:ab,value:an}),[am,an]),ap=(0,aJ.a)(k,al,n?void 0:ao),aq=dp(f,K,al,!t,W??void 0);(0,av.g)(()=>{al.current&&(al.current.indeterminate=ak,ah&&C(!0))},[ah,ak,C]),(0,dr.x)(ah,()=>{O||(w(S),C(ah),z(ah!==H.initialValue),ag.change(ah))});let ar=(0,aX.v6)({checked:ah,disabled:R,form:h,name:n?void 0:S,id:t?void 0:W??void 0,required:q,ref:ap,style:S?df.a:df.Q,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(a){if(a.nativeEvent.defaultPrevented)return;if(o)return void a.preventDefault();let b=a.currentTarget.checked,c=(0,bf.d)(aT.dv,a.nativeEvent);if((m?.(b,c),!c.isCanceled)&&($?.(b,c),!c.isCanceled&&(ai(b),void 0!==T&&void 0!==O&&!n&&!Q))){let a=b?[...O.value,T]:O.value.filter(a=>a!==T);O.setValue(a,c)}},onClick(a){a.stopPropagation()},onFocus(){ab.current?.focus()}},void 0!==s?{value:(O?ah&&s:s)||""}:aw.t0,N,a=>ag.getValidationProps(R,a));B.useEffect(()=>{if(!P||void 0===T)return;let a=P.disabledStatesRef.current;return a.set(T,R),()=>{a.delete(T)}},[P,R,T]);let as=B.useMemo(()=>({...F,checked:aj,disabled:R,readOnly:o,required:q,indeterminate:ak}),[F,aj,R,o,q,ak]),at=dQ(as),au=(0,aG.o)("span",a,{state:as,ref:[af,ab,b],props:[{id:t?W??void 0:U,role:"checkbox","aria-checked":ak?"mixed":aj,"aria-readonly":o||void 0,"aria-required":q||void 0,"aria-labelledby":aq,"data-parent":n?"":void 0,onFocus(){R||D(!0)},onBlur(){let a=al.current;a&&(E(!0),D(!1),"onBlur"===G&&ag.commit(O?aa:a.checked))},onKeyDown(a){if("Enter"!==a.key||(a.preventBaseUIHandler(),a.defaultPrevented))return;let b=al.current?.form??null,c=a.currentTarget,d=a.nativeEvent,e=a.preventDefault,f=d.preventDefault,g=!1;a.preventDefault=()=>{g=!0,e.call(a)},d.preventDefault=()=>{g=!0,f.call(d)},f.call(d),(0,dP.zk)(c).queueMicrotask(()=>{a.preventDefault=e,d.preventDefault=f,g||(function(a){if(!a)return null;for(let b of a.elements){let a=b.tagName;if(("BUTTON"===a||"INPUT"===a)&&"submit"===b.type)return b}return null})(b)?.click()})},onClick(a){if(o||R)return;a.preventDefault();let b=al.current;b&&(0,dj.B)(b,a)}},v,_,ae,N,a=>ag.getValidationProps(R,a)],stateAttributesMapping:at});return(0,A.jsxs)(dT.Provider,{value:as,children:[au,!ah&&!O&&S&&!n&&void 0!==r&&(0,A.jsx)("input",{type:"hidden",form:h,name:S,value:r,disabled:R}),(0,A.jsx)("input",{...ar,suppressHydrationWarning:!0})]})}),dV=B.forwardRef(function(a,b){let{render:c,className:d,style:e,keepMounted:f=!1,...g}=a,h=function(){let a=B.useContext(dT);if(void 0===a)throw Error((0,aq.A)(14));return a}(),i=h.checked||h.indeterminate,{mounted:j,transitionStatus:k,setMounted:l}=(0,bh.$)(i),m=B.useRef(null),n={...h,transitionStatus:k};(0,bi.v)({open:i,ref:m,onComplete(){i||l(!1)}});let o={...dQ(h),...bc.G},p=(0,aG.o)("span",a,{ref:[b,m],state:n,stateAttributesMapping:o,props:g});return f||j?p:null});function dW({className:a,...b}){return(0,A.jsx)(dU,{"data-slot":"checkbox",className:(0,W.cn)("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 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 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",a),...b,children:(0,A.jsx)(dV,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:(0,A.jsx)(bs.A,{})})})}function dX(a){let{t:b}=(0,Q.Bd)("pluginManagement"),{locale:c}=(0,cy.i)(),d=a.snapshot?.plugins??[],e=b=>a.requests.has(dz(b.source))||!!(b.operation&&"failed"!==b.operation.phase),f=d.filter(b=>("updates"!==a.statusFilter||!!b.updateAvailable)&&("disabled"!==a.statusFilter||"disabled"===b.status)&&("failed"!==a.statusFilter||!!("failed"===b.status||b.operation?.phase==="failed"||b.updateError||b.pluginName&&a.browserErrors.has(b.pluginName)))&&`${dy(b)} ${b.description?(0,cx.fD)(b.description,c):""}`.toLocaleLowerCase().includes(a.filter.trim().toLocaleLowerCase())),g=f.filter(a=>"extension"!==a.kind),h=d.filter(b=>a.selected.has(dz(b.source))),i=d.filter(a=>!0===a.updateAvailable&&"extension"!==a.kind&&!e(a)),j=i.filter(b=>a.selected.has(dz(b.source))),k=h.filter(a=>!e(a)),l=g.length>0&&g.every(b=>a.selected.has(dz(b.source))),m=g.some(b=>a.selected.has(dz(b.source))),n=["all","updates","disabled","failed"].map(a=>({value:a,label:b(`statusFilter_${a}`)}));return(0,A.jsxs)("section",{"aria-label":b("installed"),className:"flex min-h-0 min-w-0 flex-col gap-3",children:[(0,A.jsxs)("div",{className:"shrink-0 space-y-3 bg-popover pb-2",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)(bY.p,{"aria-label":b("filterInstalled"),value:a.filter,onChange:b=>a.onFilter(b.target.value),placeholder:b("filterInstalled"),className:"min-w-40 flex-1 basis-52"}),(0,A.jsxs)(bS.l6,{value:a.statusFilter,items:n,onValueChange:b=>{b&&a.onStatusFilter(b)},children:[(0,A.jsx)(bS.bq,{"aria-label":b("filterStatus"),children:(0,A.jsx)(bS.yv,{})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[160]",children:n.map(a=>(0,A.jsx)(bS.eb,{value:a.value,children:a.label},a.value))})]}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.loading||a.disabled,onClick:a.onRefresh,children:b(a.loading?"checkingUpdates":"checkUpdates")}),i.length>0?(0,A.jsx)(U.$,{size:"sm",disabled:a.disabled||a.loading,onClick:a.onUpdateAll,children:b("updateAll",{count:i.length})}):null,d.some(a=>"extension"!==a.kind)?(0,A.jsx)(U.$,{size:"sm",variant:"ghost",onClick:()=>a.onBatchMode(!a.batchMode),children:b(a.batchMode?"finishSelection":"batchManage")}):null]}),a.batchMode?(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-lg bg-muted px-3 py-2",children:[(0,A.jsxs)("label",{className:"flex min-h-8 cursor-pointer items-center gap-2 text-sm",children:[(0,A.jsxs)("span",{className:"relative flex size-4 items-center justify-center",children:[(0,A.jsx)(dW,{checked:l,indeterminate:m&&!l,className:"data-indeterminate:[&_svg]:hidden",disabled:!g.length,onCheckedChange:b=>a.onSelect(g.map(a=>dz(a.source)),b)}),m&&!l?(0,A.jsx)(dN.A,{"aria-hidden":!0,className:"pointer-events-none absolute size-3.5"}):null]}),b(a.filter||"all"!==a.statusFilter?"selectFiltered":"selectAll")]}),(0,A.jsx)("span",{className:"text-sm text-muted-foreground",children:b("selectedCount",{count:h.length})}),h.length?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.disabled||a.loading||!j.length,onClick:a.onUpdateSelected,children:b("updateSelected")}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.disabled||!k.length,onClick:a.onRemoveSelected,children:b("removeSelected")}),(0,A.jsx)(U.$,{size:"sm",variant:"ghost",onClick:()=>a.onSelect([...a.selected],!1),children:b("clearSelection")})]}):null]}):null,a.errors.list?(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive [overflow-wrap:anywhere]",children:a.errors.list}):null]}),(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 overflow-y-auto",children:a.loading&&!a.snapshot?(0,A.jsx)("p",{role:"status",className:"py-6 text-sm text-muted-foreground",children:b("loading")}):f.length?(0,A.jsx)("div",{className:"divide-y rounded-lg border bg-card",children:f.map(d=>{let f=dy(d),g=dz(d.source),h=d.pluginName?a.browserErrors.get(d.pluginName)??null:null;return(0,A.jsx)("article",{"aria-label":f,className:`min-w-0 px-4 py-3 ${a.selected.has(g)&&a.batchMode?"bg-accent/40":""}`,children:(0,A.jsxs)("div",{className:"flex items-start gap-3",children:[a.batchMode&&"extension"!==d.kind?(0,A.jsx)("div",{className:"flex min-h-8 shrink-0 items-center",children:(0,A.jsx)(dW,{checked:a.selected.has(g),"aria-label":b("selectPlugin",{name:f}),onCheckedChange:b=>a.onSelect([g],b)})}):null,(0,A.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[(0,A.jsxs)("div",{className:"flex min-w-0 flex-1 basis-64 flex-wrap items-center gap-x-2 gap-y-1",children:[(0,A.jsx)(U.$,{variant:"link",className:"h-auto min-h-8 min-w-0 max-w-full justify-start p-0 text-left text-sm font-semibold whitespace-normal no-underline hover:underline [overflow-wrap:anywhere]","aria-label":b("viewDetails",{name:f}),onClick:()=>a.onDetail(d.source),children:f}),d.version?(0,A.jsxs)("span",{className:"text-xs text-muted-foreground",children:["v",d.version]}):null,d.updateAvailable?(0,A.jsx)("span",{className:"inline-flex rounded-md bg-status-success/10 px-2 py-0.5 text-xs font-medium text-status-success",children:d.availableVersion?b("newVersion",{version:d.availableVersion}):b("updateAvailable")}):null,d.updateTag&&"latest"!==d.updateTag?(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:"dev"===d.updateTag?b("channelDev"):d.updateTag}):null]}),(0,A.jsx)(dv,{plugin:d,displayName:f,browserError:h,disabled:a.disabled,pending:e(d),browserRetryPending:a.requests.has(`entry:${d.pluginName}`),onAction:b=>a.onAction(d,b)})]}),d.description?(0,A.jsx)("p",{className:"line-clamp-2 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:(0,cx.fD)(d.description,c)}):null,(0,A.jsx)(dw,{plugin:d,browserError:h,requestError:a.errors[g]??a.errors[`entry:${d.pluginName}`]})]})]})},g)})}):(0,A.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:b(a.filter||"all"!==a.statusFilter?"noMatches":"empty")})})]})}function dY(a){let{t:b}=(0,Q.Bd)("pluginManagement"),{locale:c}=(0,cy.i)(),d=new Map(a.snapshot?.plugins.filter(a=>a.source.startsWith("npm:")).map(a=>[dx(a.source)?.name,a]));return(0,A.jsxs)("section",{className:"min-w-0 space-y-4","aria-label":b("searchPlugins"),children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)("label",{htmlFor:"plugin-catalog-query",className:"sr-only",children:b("searchPlugins")}),(0,A.jsx)(bY.p,{id:"plugin-catalog-query",value:a.query,placeholder:b("searchPlaceholder"),className:"min-w-40 flex-1 basis-56",maxLength:200,onChange:b=>a.onQuery(b.target.value),onCompositionStart:a.onCompositionStart,onCompositionEnd:a.onCompositionEnd}),(0,A.jsxs)(bS.l6,{value:a.searchSource,items:[{value:"public",label:b("publicNpm")},{value:"custom",label:b("customSearchSource")}],onValueChange:b=>{b&&a.onSearchSource(b)},children:[(0,A.jsx)(bS.bq,{"aria-label":b("searchSource"),children:(0,A.jsx)(bS.yv,{})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[160]",children:[(0,A.jsx)(bS.eb,{value:"public",children:b("publicNpm")}),(0,A.jsx)(bS.eb,{value:"custom",children:b("customSearchSource")})]})]}),(0,A.jsxs)(bS.l6,{value:a.kind,items:["all","desk","pi"].map(a=>({value:a,label:b(`kind_${a}`)})),onValueChange:b=>{b&&a.onKind(b)},children:[(0,A.jsx)(bS.bq,{"aria-label":b("pluginKind"),children:(0,A.jsx)(bS.yv,{})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[160]",children:["all","desk","pi"].map(a=>(0,A.jsx)(bS.eb,{value:a,children:b(`kind_${a}`)},a))})]}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.disabled,onClick:a.onDirectInstall,children:b("directInstall")}),"custom"===a.searchSource?(0,A.jsxs)("div",{className:"w-full space-y-1",children:[(0,A.jsx)("label",{htmlFor:"plugin-search-registry",className:"block text-sm",children:b("searchRegistryUrl")}),(0,A.jsx)(bY.p,{id:"plugin-search-registry",type:"url",value:a.registry,onChange:b=>a.onRegistry(b.target.value),placeholder:"https://registry.example.com"})]}):null]}),a.error?(0,A.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center gap-2 text-sm text-destructive",children:[(0,A.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:a.error}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",onClick:a.onRetry,children:b("retry")})]}):null,a.items.length?(0,A.jsx)("div",{className:"@container/catalog divide-y rounded-lg border bg-card",children:a.items.map(e=>{let f=d.get(e.name),g=dz(`npm:${e.name}`),h=f?.description??e.description,i=!!(f?.operation&&"failed"!==f.operation.phase),j=a.requests.has(g)||i||a.preparing.has(e.name),k=f&&(f.operation?.action!=="add"||"failed"!==f.operation.phase),l=a.installErrors[e.name]??a.errors[g]??(f?.error?(0,cx.fD)(f.error.message,c):null);return(0,A.jsxs)("article",{"aria-label":e.name,className:"grid min-w-0 gap-x-4 gap-y-2 px-4 py-3 @xl/catalog:grid-cols-[minmax(0,1fr)_auto]",children:[(0,A.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)(U.$,{variant:"link",className:"h-auto min-h-8 min-w-0 max-w-full p-0 text-left text-sm font-semibold whitespace-normal no-underline hover:underline [overflow-wrap:anywhere]",onClick:()=>a.onDetail(e),children:e.name}),(0,A.jsxs)("span",{className:"text-xs text-muted-foreground",children:["v",k&&f.version?f.version:e.version]}),k&&f.updateAvailable?(0,A.jsx)("span",{className:"rounded-md bg-status-success/10 px-2 py-0.5 text-xs font-medium text-status-success",children:f.availableVersion?b("newVersion",{version:f.availableVersion}):b("updateAvailable")}):null,(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:b(`kind_${e.kind}`)}),e.publisher?(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:e.publisher}):null]}),(0,A.jsx)("p",{className:"line-clamp-2 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:h?(0,cx.fD)(h,c):b("noPluginDescription")})]}),(0,A.jsx)("div",{className:"flex min-h-8 items-center self-start @xl/catalog:justify-end",children:j?(0,A.jsx)("span",{role:"status",className:"text-sm text-muted-foreground",children:i?b(`phase_${f?.operation?.phase}`):a.preparing.has(e.name)?b("loadingPackage"):b("submitting")}):k?(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)("span",{className:"text-sm text-muted-foreground",children:b("alreadyInstalled")}),f.updateAvailable?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.disabled,onClick:()=>a.onUpdate(f.source),children:b("update")}):null]}):(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.disabled,onClick:()=>a.onInstall(e),children:b("install")})}),l?(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive [overflow-wrap:anywhere] @xl/catalog:col-span-2",children:l}):null,f?.operation?.phase==="failed"&&f.operation.message?(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive [overflow-wrap:anywhere] @xl/catalog:col-span-2",children:f.operation.message}):null]},e.name)})}):null,a.loading?(0,A.jsx)("p",{role:"status",className:"py-4 text-sm text-muted-foreground",children:b("searching")}):a.error||!a.searched||a.items.length?null:(0,A.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:b("noSearchResults")}),a.hasMore?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.loading,onClick:a.onMore,children:b("loadMore")}):null]})}let dZ=(0,cT.F)("flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",{variants:{orientation:{horizontal:"*:data-slot:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg! [&>[data-slot]~[data-slot]]:rounded-l-none [&>[data-slot]~[data-slot]]:border-l-0",vertical:"flex-col *:data-slot:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg! [&>[data-slot]~[data-slot]]:rounded-t-none [&>[data-slot]~[data-slot]]:border-t-0"}},defaultVariants:{orientation:"horizontal"}});function d$({className:a,orientation:b,...c}){return(0,A.jsx)("div",{role:"group","data-slot":"button-group","data-orientation":b,className:(0,W.cn)(dZ({orientation:b}),a),...c})}var d_=c(59582),d0=c(19480),d1=c(36331),d2=c(67645),d3=c(75367),d4=c(13010),d5=c(71663),d6=c(23759);let d7={abandonedHeadElementChild:{reason:"Unexpected metadata element after head",description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:"Unexpected abruptly closed empty comment",description:"Unexpected `>` or `->`. Expected `--\x3e` to close comments"},abruptDoctypePublicIdentifier:{reason:"Unexpected abruptly closed public identifier",description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:"Unexpected abruptly closed system identifier",description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:"Unexpected non-digit at start of numeric character reference",description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:"Unexpected CDATA section in HTML",description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:"Unexpected too big numeric character reference",description:"Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)"},closingOfElementWithOpenChildElements:{reason:"Unexpected closing tag with open child elements",description:"Unexpectedly closing tag. Expected other tags to be closed first",url:!1},controlCharacterInInputStream:{reason:"Unexpected control character",description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:"Unexpected control character reference",description:"Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace"},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:"Unexpected duplicate attribute",description:"Unexpectedly double attribute. Expected attributes to occur only once"},endTagWithAttributes:{reason:"Unexpected attribute on closing tag",description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:"Unexpected slash at end of closing tag",description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:"Unexpected unopened end tag",description:"Unexpected end tag. Expected no end tag or another end tag",url:!1},eofBeforeTagName:{reason:"Unexpected end of file",description:"Unexpected end of file. Expected tag name instead"},eofInCdata:{reason:"Unexpected end of file in CDATA",description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:"Unexpected end of file in comment",description:"Unexpected end of file. Expected `--\x3e` to close the comment"},eofInDoctype:{reason:"Unexpected end of file in doctype",description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:"Unexpected end of file in element that can only contain text",description:"Unexpected end of file. Expected text or a closing tag",url:!1},eofInScriptHtmlCommentLikeText:{reason:"Unexpected end of file in comment inside script",description:"Unexpected end of file. Expected `--\x3e` to close the comment"},eofInTag:{reason:"Unexpected end of file in tag",description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:"Incorrectly closed comment",description:"Unexpected `%c-1`. Expected `--\x3e` to close the comment"},incorrectlyOpenedComment:{reason:"Incorrectly opened comment",description:"Unexpected `%c`. Expected `\x3c!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:"Invalid sequence after doctype name",description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:"Invalid first character in tag name",description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:"Misplaced doctype",description:"Unexpected doctype. Expected doctype before head",url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:"Missing attribute value",description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:"Missing doctype before other content",description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:"Missing doctype name",description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:"Missing public identifier in doctype",description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:"Missing system identifier in doctype",description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:"Missing name in end tag",description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:"Missing quote before public identifier in doctype",description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:"Missing quote before system identifier in doctype",description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:"Missing semicolon after character reference",description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:"Missing whitespace after public identifier in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:"Missing whitespace after system identifier in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:"Missing whitespace before doctype name",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:"Missing whitespace between attributes",description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:"Missing whitespace between public and system identifiers in doctype",description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:"Unexpected nested comment",description:"Unexpected `\x3c!--`. Expected `--\x3e`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:"Unexpected non-conforming doctype declaration",description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:"Unexpected trailing slash on start tag of non-void element",description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:"Unexpected noncharacter code point referenced by character reference",description:"Unexpected code point. Do not use noncharacters in HTML"},noncharacterInInputStream:{reason:"Unexpected noncharacter character",description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:"Unexpected NULL character referenced by character reference",description:"Unexpected code point. Do not use NULL characters in HTML"},openElementsLeftAfterEof:{reason:"Unexpected end of file",description:"Unexpected end of file. Expected closing tag instead",url:!1},surrogateCharacterReference:{reason:"Unexpected surrogate character referenced by character reference",description:"Unexpected code point. Do not use lone surrogate characters in HTML"},surrogateInInputStream:{reason:"Unexpected surrogate character",description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:"Invalid character after system identifier in doctype",description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:"Unexpected character in attribute name",description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:"Unexpected character in unquoted attribute value",description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:"Unexpected equals sign before attribute name",description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:"Unexpected NULL character",description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:"Unexpected question mark instead of tag name",description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:"Unexpected slash in tag",description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:"Unexpected unknown named character reference",description:"Unexpected character reference. Expected known named character references"}},d8=/-[a-z]/g,d9=/%c(?:([-+])(\d+))?/g,ea=/%x/g,eb={2:!0,1:!1,0:null},ec={};function ed(a){return a.charAt(1).toUpperCase()}var ee=c(24536),ef=c(10261);let eg=function(a,b,c){let d=(0,ef.C)(c);if(!a||!a.type||!a.children)throw Error("Expected parent node");if("number"==typeof b){if(b<0||b===1/0)throw Error("Expected positive finite number as index")}else if((b=a.children.indexOf(b))<0)throw Error("Expected child node or index");for(;++b<a.children.length;)if(d(a.children[b],b,a))return a.children[b]},eh=function(a){if(null==a)return ej;if("string"==typeof a){var b;return b=a,ei(function(a){return a.tagName===b})}if("object"==typeof a){var c=a;let b=[],d=-1;for(;++d<c.length;)b[d]=eh(c[d]);return ei(function(...a){let c=-1;for(;++c<b.length;)if(b[c].apply(this,a))return!0;return!1})}if("function"==typeof a)return ei(a);throw Error("Expected function, string, or array as `test`")};function ei(a){return function(b,c,d){var e;return!!(null!==(e=b)&&"object"==typeof e&&"type"in e&&"tagName"in e&&a.call(this,b,"number"==typeof c?c:void 0,d||void 0))}}function ej(a){return!!(a&&"object"==typeof a&&"type"in a&&"element"===a.type&&"tagName"in a&&"string"==typeof a.tagName)}let ek=/\n/g,el=/[\t ]+/g,em=eh("br"),en=eh(function(a){return"td"===a.tagName||"th"===a.tagName}),eo=eh("p"),ep=eh("tr"),eq=eh(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",function(a){return!!(a.properties||{}).hidden},function(a){return"dialog"===a.tagName&&!(a.properties||{}).open}]),er=eh(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function es(a,b){let c,d=String(a.value),e=[],f=[],g=0;for(;g<=d.length;){ek.lastIndex=g;let a=ek.exec(d),c=a&&"index"in a?a.index:d.length;e.push(function(a,b,c){let d,e=[],f=0;for(;f<a.length;){el.lastIndex=f;let c=el.exec(a);d=c?c.index:a.length,f||d||!c||b||e.push(""),f!==d&&e.push(a.slice(f,d)),f=c?d+c[0].length:d}return f===d||c||e.push(""),e.join(" ")}(d.slice(g,c).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),0!==g||b.breakBefore,c!==d.length||b.breakAfter)),g=c+1}let h=-1;for(;++h<e.length;)8203===e[h].charCodeAt(e[h].length-1)||h<e.length-1&&8203===e[h+1].charCodeAt(0)?(f.push(e[h]),c=void 0):e[h]?("number"==typeof c&&f.push(c),f.push(e[h]),c=0):(0===h||h===e.length-1)&&f.push(0);return f}function et(a,b){if("element"===a.type){let c=a.properties||{};switch(a.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return c.wrap?"pre-wrap":"pre";case"td":case"th":return c.noWrap?"nowrap":b.whitespace;case"textarea":return"pre-wrap"}}return b.whitespace}var eu=c(15573),ev=c(46379);let ew={},ex=[];function ey(a){let b=a||ew;return function(a,c){(0,ev.VG)(a,"element",function(a,d){let e,f=Array.isArray(a.properties.className)?a.properties.className:ex,g=f.includes("language-math"),h=f.includes("math-display"),i=f.includes("math-inline"),j=h;if(!g&&!h&&!i)return;let k=d[d.length-1],l=a;if("code"===a.tagName&&g&&k&&"element"===k.type&&"pre"===k.tagName&&(l=k,k=d[d.length-2],j=!0),!k)return;let m=function(a,b){let c,d="children"in a?a.children:[],e=er(a),f=et(a,{whitespace:(b||{}).whitespace||"normal",breakBefore:!1,breakAfter:!1}),g=[];("text"===a.type||"comment"===a.type)&&g.push(...es(a,{whitespace:f,breakBefore:!0,breakAfter:!0}));let h=-1;for(;++h<d.length;)g.push(...function a(b,c,d){return"element"===b.type?function(b,c,d){let e,f,g=et(b,d),h=b.children||[],i=-1,j=[];if(eq(b))return j;for(em(b)||ep(b)&&eg(c,b,ep)?f="\n":eo(b)?(e=2,f=2):er(b)&&(e=1,f=1);++i<h.length;)j=j.concat(a(h[i],b,{whitespace:g,breakBefore:i?void 0:e,breakAfter:i<h.length-1?em(h[i+1]):f}));return en(b)&&eg(c,b,en)&&j.push(" "),e&&j.unshift(e),f&&j.push(f),j}(b,c,d):"text"===b.type?"normal"===d.whitespace?es(b,d):[String(b.value)]:[]}(d[h],a,{whitespace:f,breakBefore:h?void 0:e,breakAfter:h<d.length-1?em(d[h+1]):e}));let i=[];for(h=-1;++h<g.length;){let a=g[h];"number"==typeof a?void 0!==c&&a>c&&(c=a):a&&(void 0!==c&&c>-1&&i.push("\n".repeat(c)||" "),c=-1,i.push(a))}return i.join("")}(l,{whitespace:"pre"});try{e=eu.default.renderToString(m,{...b,displayMode:j,throwOnError:!0})}catch(g){let f=g.name.toLowerCase();c.message("Could not render math with KaTeX",{ancestors:[...d,a],cause:g,place:a.position,ruleId:f,source:"rehype-katex"});try{e=eu.default.renderToString(m,{...b,displayMode:j,strict:"ignore",throwOnError:!1})}catch{e=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(b.errorColor||"#cc0000"),title:String(g)},children:[{type:"text",value:m}]}]}}if("string"==typeof e){var n,o;let a,b,c,d,f,g;e=(n={fragment:!0},o=e,b=(a=n||ec).onerror,c=o instanceof d5.T?o:new d5.T(o),f=(a.fragment?d4.oH:d4.qg)(d=String(c),{sourceCodeLocationInfo:!0,onParseError:a.onerror?function(e){let f=e.code,g=f.replace(d8,ed),h=a[g],i=null==h||h,j="number"==typeof i?i:+!!i;if(j){let a=d7[g];(0,d2.ok)(a,"expected known error from `parse5`");let d=new d6.o(k(a.reason),{place:{start:{line:e.startLine,column:e.startCol,offset:e.startOffset},end:{line:e.endLine,column:e.endCol,offset:e.endOffset}},ruleId:f,source:"hast-util-from-html"});c.path&&(d.file=c.path,d.name=c.path+":"+d.name),d.fatal=eb[j],d.note=k(a.description),d.url=!1===a.url?void 0:"https://html.spec.whatwg.org/multipage/parsing.html#parse-error-"+f,(0,d2.ok)(b,"`internalOnerror` is not passed if `onerror` is not set"),b(d)}function k(a){return a.replace(d9,function(a,b,c){var f;let g=(c?Number.parseInt(c,10):0)*("-"===b?-1:1);return"`"===(f=d.charAt(e.startOffset+g))?"` ` `":f}).replace(ea,function(){return"0x"+d.charCodeAt(e.startOffset).toString(16).toUpperCase()})}}:null,scriptingEnabled:!1}),g=(0,d3.D)(f,{file:c,space:a.space,verbose:a.verbose}),(0,ee.YR)(g,function(a){delete a.position}),delete g.data,g).children}let p=k.children.indexOf(l);return k.children.splice(p,1,...e),ev._Z})}}var ez=c(93310),eA=c(82245),eB=c(65510);let eC={tokenize:function(a,b,c){let d=this,e=d.events[d.events.length-1],f=e&&"linePrefix"===e[1].type?e[2].sliceSerialize(e[1],!0).length:0,g=0;return function(b){return a.enter("mathFlow"),a.enter("mathFlowFence"),a.enter("mathFlowFenceSequence"),function b(d){return 36===d?(a.consume(d),g++,b):g<2?c(d):(a.exit("mathFlowFenceSequence"),(0,eA.N)(a,h,"whitespace")(d))}(b)};function h(b){return null===b||(0,eB.HP)(b)?i(b):(a.enter("mathFlowFenceMeta"),a.enter("chunkString",{contentType:"string"}),function b(d){return null===d||(0,eB.HP)(d)?(a.exit("chunkString"),a.exit("mathFlowFenceMeta"),i(d)):36===d?c(d):(a.consume(d),b)}(b))}function i(c){return(a.exit("mathFlowFence"),d.interrupt)?b(c):a.attempt(eD,j,m)(c)}function j(b){return a.attempt({tokenize:n,partial:!0},m,k)(b)}function k(b){return(f?(0,eA.N)(a,l,"linePrefix",f+1):l)(b)}function l(b){return null===b?m(b):(0,eB.HP)(b)?a.attempt(eD,j,m)(b):(a.enter("mathFlowValue"),function b(c){return null===c||(0,eB.HP)(c)?(a.exit("mathFlowValue"),l(c)):(a.consume(c),b)}(b))}function m(c){return a.exit("mathFlow"),b(c)}function n(a,b,c){let e=0;return(0,eA.N)(a,function(b){return a.enter("mathFlowFence"),a.enter("mathFlowFenceSequence"),function b(d){return 36===d?(e++,a.consume(d),b):e<g?c(d):(a.exit("mathFlowFenceSequence"),(0,eA.N)(a,f,"whitespace")(d))}(b)},"linePrefix",d.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function f(d){return null===d||(0,eB.HP)(d)?(a.exit("mathFlowFence"),b(d)):c(d)}}},concrete:!0,name:"mathFlow"},eD={tokenize:function(a,b,c){let d=this;return function(c){return null===c?b(c):(a.enter("lineEnding"),a.consume(c),a.exit("lineEnding"),e)};function e(a){return d.parser.lazy[d.now().line]?c(a):b(a)}},partial:!0};function eE(a){let b,c,d=a.length-4,e=3;if(("lineEnding"===a[3][1].type||"space"===a[e][1].type)&&("lineEnding"===a[d][1].type||"space"===a[d][1].type)){for(b=e;++b<d;)if("mathTextData"===a[b][1].type){a[d][1].type="mathTextPadding",a[e][1].type="mathTextPadding",e+=2,d-=2;break}}for(b=e-1,d++;++b<=d;)void 0===c?b!==d&&"lineEnding"!==a[b][1].type&&(c=b):(b===d||"lineEnding"===a[b][1].type)&&(a[c][1].type="mathTextData",b!==c+2&&(a[c][1].end=a[b-1][1].end,a.splice(c+2,b-c-2),d-=b-c-2,b=c+2),c=void 0);return a}function eF(a){return 36!==a||"characterEscape"===this.events[this.events.length-1][1].type}let eG={};function eH(a){let b,c=a||eG,d=this.data(),e=d.micromarkExtensions||(d.micromarkExtensions=[]),f=d.fromMarkdownExtensions||(d.fromMarkdownExtensions=[]),g=d.toMarkdownExtensions||(d.toMarkdownExtensions=[]);e.push({flow:{36:eC},text:{36:(null==(b=(c||{}).singleDollarTextMath)&&(b=!0),{tokenize:function(a,c,d){let e,f,g=0;return function(c){return a.enter("mathText"),a.enter("mathTextSequence"),function c(e){return 36===e?(a.consume(e),g++,c):g<2&&!b?d(e):(a.exit("mathTextSequence"),h(e))}(c)};function h(b){return null===b?d(b):36===b?(f=a.enter("mathTextSequence"),e=0,function b(d){return 36===d?(a.consume(d),e++,b):e===g?(a.exit("mathTextSequence"),a.exit("mathText"),c(d)):(f.type="mathTextData",i(d))}(b)):32===b?(a.enter("space"),a.consume(b),a.exit("space"),h):(0,eB.HP)(b)?(a.enter("lineEnding"),a.consume(b),a.exit("lineEnding"),h):(a.enter("mathTextData"),i(b))}function i(b){return null===b||32===b||36===b||(0,eB.HP)(b)?(a.exit("mathTextData"),h(b)):(a.consume(b),i)}},resolve:eE,previous:eF,name:"mathText"})}}),f.push(function(){return{enter:{mathFlow:function(a){this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[{type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]}]}},a)},mathFlowFenceMeta:function(){this.buffer()},mathText:function(a){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},a),this.buffer()}},exit:{mathFlow:function(a){let b=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),c=this.stack[this.stack.length-1];(0,d2.ok)("math"===c.type),this.exit(a),c.value=b;let d=c.data.hChildren[0];(0,d2.ok)("element"===d.type),(0,d2.ok)("code"===d.tagName),d.children.push({type:"text",value:b}),this.data.mathFlowInside=void 0},mathFlowFence:function(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)},mathFlowFenceMeta:function(){let a=this.resume(),b=this.stack[this.stack.length-1];(0,d2.ok)("math"===b.type),b.meta=a},mathFlowValue:a,mathText:function(a){let b=this.resume(),c=this.stack[this.stack.length-1];(0,d2.ok)("inlineMath"===c.type),this.exit(a),c.value=b,c.data.hChildren.push({type:"text",value:b})},mathTextData:a}};function a(a){this.config.enter.data.call(this,a),this.config.exit.data.call(this,a)}}()),g.push(function(a){let b=(a||{}).singleDollarTextMath;return null==b&&(b=!0),c.peek=function(){return"$"},{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:"\n",inConstruct:"mathFlowMeta"},{character:"$",after:b?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:function(a,b,c,d){let e=a.value||"",f=c.createTracker(d),g="$".repeat(Math.max((0,ez.D)(e,"$")+1,2)),h=c.enter("mathFlow"),i=f.move(g);if(a.meta){let b=c.enter("mathFlowMeta");i+=f.move(c.safe(a.meta,{after:"\n",before:i,encode:["$"],...f.current()})),b()}return i+=f.move("\n"),e&&(i+=f.move(e+"\n")),i+=f.move(g),h(),i},inlineMath:c}};function c(a,c,d){let e=a.value||"",f=1;for(!b&&f++;RegExp("(^|[^$])"+"\\$".repeat(f)+"([^$]|$)").test(e);)f++;let g="$".repeat(f);/[^ \r\n]/.test(e)&&(/^[ \r\n]/.test(e)&&/[ \r\n]$/.test(e)||/^\$|\$$/.test(e))&&(e=" "+e+" ");let h=-1;for(;++h<d.unsafe.length;){let a,b=d.unsafe[h];if(!b.atBreak)continue;let c=d.compilePattern(b);for(;a=c.exec(e);){let b=a.index;10===e.codePointAt(b)&&13===e.codePointAt(b-1)&&b--,e=e.slice(0,b)+" "+e.slice(a.index+1)}}return g+e+g}}(c))}var eI=function(a={}){var b,c;return{name:"katex",type:"math",remarkPlugin:[eH,{singleDollarTextMath:null!=(b=a.singleDollarTextMath)&&b}],rehypePlugin:[ey,{errorColor:null!=(c=a.errorColor)?c:"var(--color-muted-foreground)"}],getStyles:()=>"katex/dist/katex.min.css"}}(),eJ=c(15407),eK=c(26775),eL=c(88131);c(38863),c(35705),c(92471),c(52600),c(25668),c(67961);var eM=c(52072),eN=c(18767),eO=c(4629),eP=c(44272),eQ=c(36122),eR=c(3117),eS=c(31519),eT="comm",eU="rule",eV="decl",eW="@keyframes",eX="@layer",eY=Math.abs,eZ=String.fromCharCode;function e$(a,b,c){return a.replace(b,c)}function e_(a,b){return 0|a.charCodeAt(b)}function e0(a,b,c){return a.slice(b,c)}function e1(a){return a.length}function e2(a,b){return b.push(a),a}function e3(a,b){for(var c="",d=0;d<a.length;d++)c+=b(a[d],d,a,b)||"";return c}function e4(a,b,c,d){switch(a.type){case eX:if(a.children.length)break;case"@import":case"@namespace":case eV:return a.return=a.return||a.value;case eT:return"";case eW:return a.return=a.value+"{"+e3(a.children,d)+"}";case eU:if(!e1(a.value=a.props.join(",")))return""}return e1(c=e3(a.children,d))?a.return=a.value+"{"+c+"}":""}var e5=1,e6=1,e7=0,e8=0,e9=0,fa="";function fb(a,b,c,d,e,f,g,h){return{value:a,root:b,parent:c,type:d,props:e,children:f,line:e5,column:e6,length:g,return:"",siblings:h}}function fc(){return e9=e8<e7?e_(fa,e8++):0,e6++,10===e9&&(e6=1,e5++),e9}function fd(){return e_(fa,e8)}function fe(a){switch(a){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function ff(a){var b,c;return(b=e8-1,c=function a(b){for(;fc();)switch(e9){case b:return e8;case 34:case 39:34!==b&&39!==b&&a(e9);break;case 40:41===b&&a(b);break;case 92:fc()}return e8}(91===a?a+2:40===a?a+1:a),e0(fa,b,c)).trim()}function fg(a,b,c,d,e,f,g,h,i,j,k,l){for(var m=e-1,n=0===e?f:[""],o=n.length,p=0,q=0,r=0;p<d;++p)for(var s=0,t=e0(a,m+1,m=eY(q=g[p])),u=a;s<o;++s)(u=(q>0?n[s]+" "+t:e$(t,/&\f/g,n[s])).trim())&&(i[r++]=u);return fb(a,b,c,0===e?eU:h,i,j,k,l)}function fh(a,b,c,d,e){return fb(a,b,c,eV,e0(a,0,d),e0(a,d+1,-1),d,e)}var fi=c(13308),fj=c(19929),fk=c(1640),fl=c(24415),fm=c(76482);function fn(a){if(null==a)return!0;if((0,fk.X)(a))return("function"==typeof a.splice||"string"==typeof a||!!(0,fj.P)(a)||!!(0,fm.i)(a)||!!(0,fl.N)(a))&&0===a.length;if("object"==typeof a||"function"==typeof a){let b;if(a instanceof Map||a instanceof Set)return 0===a.size;let c=Object.keys(a);return(b=a?.constructor,a===("function"==typeof b?b.prototype:Object.prototype))?0===c.filter(a=>"constructor"!==a).length:0===c.length}return!0}var fo={id:"c4",detector:(0,eQ.K)(a=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(a),"detector"),loader:(0,eQ.K)(async()=>{let{diagram:a}=await c.e(55397).then(c.bind(c,55397));return{id:"c4",diagram:a}},"loader")},fp="flowchart",fq=(0,eQ.K)((a,b)=>b?.flowchart?.defaultRenderer!=="dagre-wrapper"&&b?.flowchart?.defaultRenderer!=="elk"&&/^\s*graph/.test(a),"detector"),fr=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(72169),c.e(24419)]).then(c.bind(c,24419));return{id:fp,diagram:a}},"loader"),fs={id:fp,detector:fq,loader:fr},ft="flowchart-v2",fu=(0,eQ.K)((a,b)=>b?.flowchart?.defaultRenderer!=="dagre-d3"&&(b?.flowchart?.defaultRenderer==="elk"&&(b.layout="elk"),!!/^\s*graph/.test(a)&&b?.flowchart?.defaultRenderer==="dagre-wrapper"||/^\s*flowchart/.test(a)),"detector"),fv=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(72169),c.e(24419)]).then(c.bind(c,24419));return{id:ft,diagram:a}},"loader"),fw={id:ft,detector:fu,loader:fv},fx="swimlane",fy=(0,eQ.K)(a=>/^\s*swimlane-beta\b/.test(a),"detector"),fz=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(72169),c.e(67336)]).then(c.bind(c,67336));return{id:fx,diagram:a}},"loader"),fA={id:fx,detector:fy,loader:fz},fB={id:"er",detector:(0,eQ.K)(a=>/^\s*erDiagram/.test(a),"detector"),loader:(0,eQ.K)(async()=>{let{diagram:a}=await c.e(71633).then(c.bind(c,71633));return{id:"er",diagram:a}},"loader")},fC="gitGraph",fD=(0,eQ.K)(a=>/^\s*gitGraph/.test(a),"detector"),fE=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(43218)]).then(c.bind(c,43218));return{id:fC,diagram:a}},"loader"),fF={id:fC,detector:fD,loader:fE},fG="gantt",fH=(0,eQ.K)(a=>/^\s*gantt/.test(a),"detector"),fI=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(68592).then(c.bind(c,68592));return{id:fG,diagram:a}},"loader"),fJ={id:fG,detector:fH,loader:fI},fK="info",fL=(0,eQ.K)(a=>/^\s*info/.test(a),"detector"),fM=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(51491)]).then(c.bind(c,51491));return{id:fK,diagram:a}},"loader"),fN={id:fK,detector:fL,loader:fM},fO={id:"pie",detector:(0,eQ.K)(a=>/^\s*pie/.test(a),"detector"),loader:(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(36778)]).then(c.bind(c,36778));return{id:"pie",diagram:a}},"loader")},fP="quadrantChart",fQ=(0,eQ.K)(a=>/^\s*quadrantChart/.test(a),"detector"),fR=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(37861).then(c.bind(c,37861));return{id:fP,diagram:a}},"loader"),fS={id:fP,detector:fQ,loader:fR},fT="xychart",fU=(0,eQ.K)(a=>/^\s*xychart(-beta)?/.test(a),"detector"),fV=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(50825).then(c.bind(c,50825));return{id:fT,diagram:a}},"loader"),fW={id:fT,detector:fU,loader:fV},fX="requirement",fY=(0,eQ.K)(a=>/^\s*requirement(Diagram)?/.test(a),"detector"),fZ=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(3392).then(c.bind(c,3392));return{id:fX,diagram:a}},"loader"),f$={id:fX,detector:fY,loader:fZ},f_="sequence",f0=(0,eQ.K)(a=>/^\s*sequenceDiagram/.test(a),"detector"),f1=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(20129).then(c.bind(c,20129));return{id:f_,diagram:a}},"loader"),f2={id:f_,detector:f0,loader:f1},f3="class",f4=(0,eQ.K)((a,b)=>b?.class?.defaultRenderer!=="dagre-wrapper"&&/^\s*classDiagram/.test(a),"detector"),f5=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(25726),c.e(19010)]).then(c.bind(c,19010));return{id:f3,diagram:a}},"loader"),f6={id:f3,detector:f4,loader:f5},f7="classDiagram",f8=(0,eQ.K)((a,b)=>!!/^\s*classDiagram/.test(a)&&b?.class?.defaultRenderer==="dagre-wrapper"||/^\s*classDiagram-v2/.test(a),"detector"),f9=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(25726),c.e(25279)]).then(c.bind(c,25279));return{id:f7,diagram:a}},"loader"),ga={id:f7,detector:f8,loader:f9},gb="state",gc=(0,eQ.K)((a,b)=>b?.state?.defaultRenderer!=="dagre-wrapper"&&/^\s*stateDiagram/.test(a),"detector"),gd=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(21723),c.e(35807),c.e(88882),c.e(97395),c.e(67541)]).then(c.bind(c,67541));return{id:gb,diagram:a}},"loader"),ge={id:gb,detector:gc,loader:gd},gf="stateDiagram",gg=(0,eQ.K)((a,b)=>!!(/^\s*stateDiagram-v2/.test(a)||/^\s*stateDiagram/.test(a)&&b?.state?.defaultRenderer==="dagre-wrapper"),"detector"),gh=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(97395),c.e(25601)]).then(c.bind(c,25601));return{id:gf,diagram:a}},"loader"),gi={id:gf,detector:gg,loader:gh},gj="journey",gk=(0,eQ.K)(a=>/^\s*journey/.test(a),"detector"),gl=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(55083).then(c.bind(c,55083));return{id:gj,diagram:a}},"loader"),gm={id:gj,detector:gk,loader:gl},gn={draw:(0,eQ.K)((a,b,c)=>{eP.R.debug("rendering svg for syntax error\n");let d=(0,eJ.D)(b),e=d.append("g");d.attr("viewBox","0 0 2412 512"),(0,eO.a$)(d,100,512,!0),e.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),e.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),e.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),e.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),e.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),e.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),e.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),e.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${c}`)},"draw")},go={db:{},renderer:gn,parser:{parse:(0,eQ.K)(()=>{},"parse")}},gp="flowchart-elk",gq=(0,eQ.K)((a,b={})=>!!(/^\s*flowchart-elk/.test(a)||/^\s*(flowchart|graph)/.test(a)&&b?.flowchart?.defaultRenderer==="elk")&&(b.layout="elk",!0),"detector"),gr=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(72169),c.e(24419)]).then(c.bind(c,24419));return{id:gp,diagram:a}},"loader"),gs={id:gp,detector:gq,loader:gr},gt="timeline",gu=(0,eQ.K)(a=>/^\s*timeline/.test(a),"detector"),gv=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(39751).then(c.bind(c,39751));return{id:gt,diagram:a}},"loader"),gw={id:gt,detector:gu,loader:gv},gx="mindmap",gy=(0,eQ.K)(a=>/^\s*mindmap/.test(a),"detector"),gz=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(65729).then(c.bind(c,65729));return{id:gx,diagram:a}},"loader"),gA={id:gx,detector:gy,loader:gz},gB="kanban",gC=(0,eQ.K)(a=>/^\s*kanban/.test(a),"detector"),gD=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(17683).then(c.bind(c,40064));return{id:gB,diagram:a}},"loader"),gE={id:gB,detector:gC,loader:gD},gF="sankey",gG=(0,eQ.K)(a=>/^\s*sankey(-beta)?/.test(a),"detector"),gH=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(96686).then(c.bind(c,96686));return{id:gF,diagram:a}},"loader"),gI={id:gF,detector:gG,loader:gH},gJ="packet",gK=(0,eQ.K)(a=>/^\s*packet(-beta)?/.test(a),"detector"),gL=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(63309)]).then(c.bind(c,63309));return{id:gJ,diagram:a}},"loader"),gM={id:gJ,detector:gK,loader:gL},gN="radar",gO=(0,eQ.K)(a=>/^\s*radar-beta/.test(a),"detector"),gP=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(34410)]).then(c.bind(c,34410));return{id:gN,diagram:a}},"loader"),gQ={id:gN,detector:gO,loader:gP},gR="block",gS=(0,eQ.K)(a=>/^\s*block(-beta)?/.test(a),"detector"),gT=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(21723),c.e(80578)]).then(c.bind(c,80578));return{id:gR,diagram:a}},"loader"),gU={id:gR,detector:gS,loader:gT},gV="treeView",gW=(0,eQ.K)(a=>/^\s*treeView-beta/.test(a),"detector"),gX=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(59812)]).then(c.bind(c,59812));return{id:gV,diagram:a}},"loader"),gY={id:gV,detector:gW,loader:gX},gZ="architecture",g$=(0,eQ.K)(a=>/^\s*architecture/.test(a),"detector"),g_=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(41),c.e(39750)]).then(c.bind(c,39750));return{id:gZ,diagram:a}},"loader"),g0={id:gZ,detector:g$,loader:g_},g1="eventmodeling",g2=(0,eQ.K)(a=>/^\s*eventmodeling/.test(a),"detector"),g3=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(53056)]).then(c.bind(c,53056));return{id:g1,diagram:a}},"loader"),g4={id:g1,detector:g2,loader:g3},g5="ishikawa",g6=(0,eQ.K)(a=>/^\s*ishikawa(-beta)?\b/i.test(a),"detector"),g7=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(39839).then(c.bind(c,39839));return{id:g5,diagram:a}},"loader"),g8={id:g5,detector:g6,loader:g7},g9="venn",ha=(0,eQ.K)(a=>/^\s*venn-beta/.test(a),"detector"),hb=(0,eQ.K)(async()=>{let{diagram:a}=await c.e(69149).then(c.bind(c,69149));return{id:g9,diagram:a}},"loader"),hc={id:g9,detector:ha,loader:hb},hd="treemap",he=(0,eQ.K)(a=>/^\s*treemap/.test(a),"detector"),hf=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(42818)]).then(c.bind(c,42818));return{id:hd,diagram:a}},"loader"),hg={id:hd,detector:he,loader:hf},hh="wardley",hi=(0,eQ.K)(a=>/^\s*wardley-beta/i.test(a),"detector"),hj=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(81295)]).then(c.bind(c,81295));return{id:hh,diagram:a}},"loader"),hk={id:hh,detector:hi,loader:hj},hl="cynefin",hm=(0,eQ.K)(a=>/^\s*cynefin-beta(?:[\s:]|$)/.test(a),"detector"),hn=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(88329)]).then(c.bind(c,88329));return{id:hl,diagram:a}},"loader"),ho={id:hl,detector:hm,loader:hn},hp="railroad",hq=(0,eQ.K)(a=>/^\s*railroad-beta/i.test(a),"detector"),hr=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(66066),c.e(53275)]).then(c.bind(c,53275));return{id:hp,diagram:a}},"loader"),hs={id:hp,detector:hq,loader:hr},ht="railroadEbnf",hu=(0,eQ.K)(a=>/^\s*railroad-ebnf-beta/i.test(a),"detector"),hv=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(66066),c.e(96276)]).then(c.bind(c,96276));return{id:ht,diagram:a}},"loader"),hw={id:ht,detector:hu,loader:hv},hx="railroadAbnf",hy=(0,eQ.K)(a=>/^\s*railroad-abnf-beta/i.test(a),"detector"),hz=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(66066),c.e(95492)]).then(c.bind(c,95492));return{id:hx,diagram:a}},"loader"),hA={id:hx,detector:hy,loader:hz},hB="railroadPeg",hC=(0,eQ.K)(a=>/^\s*railroad-peg-beta/i.test(a),"detector"),hD=(0,eQ.K)(async()=>{let{diagram:a}=await Promise.all([c.e(26667),c.e(66066),c.e(69648)]).then(c.bind(c,69648));return{id:hB,diagram:a}},"loader"),hE={id:hB,detector:hC,loader:hD},hF=!1,hG=(0,eQ.K)(()=>{hF||(hF=!0,(0,eO.Js)("error",go,a=>"error"===a.toLowerCase().trim()),(0,eO.Js)("---",{db:{clear:(0,eQ.K)(()=>{},"clear")},styles:{},renderer:{draw:(0,eQ.K)(()=>{},"draw")},parser:{parse:(0,eQ.K)(()=>{throw Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:(0,eQ.K)(()=>null,"init")},a=>a.toLowerCase().trimStart().startsWith("---")),(0,eO.Xd)(gs,gA,g0),(0,eO.Xd)(fo,gE,ga,f6,fB,fJ,fN,fO,f$,f2,fA,fw,fs,gw,fF,gi,ge,gm,fS,gI,gM,fW,gU,g4,gY,gQ,g8,hg,hs,hw,hA,hE,hc,hk,ho))},"addDiagrams"),hH=(0,eQ.K)(async()=>{eP.R.debug("Loading registered diagrams");let a=(await Promise.allSettled(Object.entries(eO.mW).map(async([a,{detector:b,loader:c}])=>{if(c)try{(0,eO.Gs)(a)}catch{try{let{diagram:a,id:d}=await c();(0,eO.Js)(d,a,b)}catch(b){throw eP.R.error(`Failed to load external diagram with key ${a}. Removing from detectors.`),delete eO.mW[a],b}}}))).filter(a=>"rejected"===a.status);if(a.length>0){for(let b of(eP.R.error(`Failed to load ${a.length} external diagrams`),a))eP.R.error(b);throw Error(`Failed to load ${a.length} external diagrams`)}},"loadRegisteredDiagrams");function hI(a,b){a.attr("role","graphics-document document"),""!==b&&a.attr("aria-roledescription",b)}function hJ(a,b,c,d){if(void 0!==a.insert){if(c){let b=`chart-desc-${d}`;a.attr("aria-describedby",b),a.insert("desc",":first-child").attr("id",b).text(c)}if(b){let c=`chart-title-${d}`;a.attr("aria-labelledby",c),a.insert("title",":first-child").attr("id",c).text(b)}}}(0,eQ.K)(hI,"setA11yDiagramInfo"),(0,eQ.K)(hJ,"addSVGa11yTitleDescription");var hK=class a{constructor(a,b,c,d,e){this.type=a,this.text=b,this.db=c,this.parser=d,this.renderer=e}static{(0,eQ.K)(this,"Diagram")}static async fromText(b,c={}){let d=(0,eO.zj)(),e=(0,eO.Ch)(b,d);b=(0,eN.C4)(b)+"\n";try{(0,eO.Gs)(e)}catch{let a=(0,eO.J$)(e);if(!a)throw new eO.C0(`Diagram ${e} not found.`);let{id:b,diagram:c}=await a();(0,eO.Js)(b,c)}let{db:f,parser:g,renderer:h,init:i}=(0,eO.Gs)(e);return g.parser&&(g.parser.yy=f),f.clear?.(),i?.(d),c.title&&f.setDiagramTitle?.(c.title),await g.parse(b),new a(e,b,f,g,h)}async render(a,b){await this.renderer.draw(this.text,a,b,this)}getParser(){return this.parser}getType(){return this.type}},hL=[],hM=(0,eQ.K)(()=>{hL.forEach(a=>{a()}),hL=[]},"attachFunctions"),hN=(0,eQ.K)(a=>a.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function hO(a){let b=a.match(eO.EJ);if(!b)return{text:a,metadata:{}};let c=b[1],d=c?b[2].split("\n").map(a=>a.startsWith(c)?a.slice(c.length):a).join("\n"):b[2],e=(0,eK.H)(d,{schema:eK.r})??{};e="object"!=typeof e||Array.isArray(e)?{}:e;let f={};return e.displayMode&&(f.displayMode=e.displayMode.toString()),e.title&&(f.title=e.title.toString()),e.config&&(f.config=e.config),{text:a.slice(b[0].length),metadata:f}}(0,eQ.K)(hO,"extractFrontMatter");var hP=(0,eQ.K)(a=>a.replace(/\r\n?/g,"\n").replace(/<(\w+)([^>]*)>/g,(a,b,c)=>"<"+b+c.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),hQ=(0,eQ.K)(a=>{let{text:b,metadata:c}=hO(a),{displayMode:d,title:e,config:f={}}=c;return d&&(f.gantt||(f.gantt={}),f.gantt.displayMode=d),{title:e,config:f,text:b}},"processFrontmatter"),hR=(0,eQ.K)(a=>{let b=eN._K.detectInit(a)??{},c=eN._K.detectDirective(a,"wrap");return Array.isArray(c)?b.wrap=c.some(({type:a})=>"wrap"===a):c?.type==="wrap"&&(b.wrap=!0),{text:(0,eN.vU)(a),directive:b}},"processDirectives");function hS(a){let b=hQ(hP(a)),c=hR(b.text),d=(0,eN.$t)(b.config,c.directive);return{code:a=hN(c.text),title:b.title,config:d}}function hT(a){return btoa(Array.from(new TextEncoder().encode(a),a=>String.fromCodePoint(a)).join(""))}(0,eQ.K)(hS,"preprocessDiagram"),(0,eQ.K)(hT,"toBase64");var hU=["foreignobject"],hV=["dominant-baseline"];function hW(a){let b=hS(a);return(0,eO.cL)(),(0,eO.xA)(b.config??{}),b}async function hX(a,b){hG();try{let{code:b,config:c}=hW(a);return{diagramType:(await h7(b)).type,config:c}}catch(a){if(b?.suppressErrors)return!1;throw a}}(0,eQ.K)(hW,"processAndSetConfigs"),(0,eQ.K)(hX,"parse");var hY=(0,eQ.K)((a,b,c=[])=>{let d=(0,eO.Df)(`{ ${c.join(" !important; ")} !important; }`);return`.${a} ${b} ${d}`},"cssImportantStyles"),hZ=(0,eQ.K)((a,b=new Map)=>{let c=new CSSStyleSheet;if(void 0!==a.fontFamily&&c.insertRule(`:root { --mermaid-font-family: ${a.fontFamily}}`,c.cssRules.length),void 0!==a.altFontFamily&&c.insertRule(`:root { --mermaid-alt-font-family: ${a.altFontFamily}}`,c.cssRules.length),b instanceof Map){let d=(0,eO.E)(a)?["> *","span"]:["rect","polygon","ellipse","circle","path"];b.forEach(a=>{fn(a.styles)||d.forEach(b=>{c.insertRule(hY(a.id,b,a.styles),c.cssRules.length)}),fn(a.textStyles)||c.insertRule(hY(a.id,"tspan",(a?.textStyles||[]).map(a=>a.replace("color","fill"))),c.cssRules.length)})}let d="";if(void 0!==a.themeCSS)if("function"==typeof c.replaceSync){let b=new CSSStyleSheet;b.replaceSync(a.themeCSS),d=(0,eO.KG)(b)+"\n"}else d+=`${a.themeCSS}
277
277
  `;return d+(0,eO.KG)(c)},"createCssStyles"),h$=(0,eQ.K)((a,b)=>{var c,d,e,f,g;return e3((e=function a(b,c,d,e,f,g,h,i,j){for(var k,l,m,n,o=0,p=0,q=h,r=0,s=0,t=0,u=1,v=1,w=1,x=0,y=0,z="",A=f,B=g,C=e,D=z;v;)switch(t=y,y=fc()){case 40:108!=t&&58==e_(D,q-1)?(x++,D+="("):D+=ff(y);break;case 41:x--,D+=")";break;case 34:case 39:case 91:D+=ff(y);break;case 9:case 10:case 13:case 32:if(x>0){D+=eZ(y);break}D+=function(a){for(;e9=fd();)if(e9<33)fc();else break;return fe(a)>2||fe(e9)>3?"":" "}(t);break;case 92:D+=function(a,b){for(var c;--b&&fc()&&!(e9<48)&&!(e9>102)&&(!(e9>57)||!(e9<65))&&(!(e9>70)||!(e9<97)););return c=e8+(b<6&&32==fd()&&32==fc()),e0(fa,a,c)}(e8-1,7);continue;case 47:switch(fd()){case 42:case 47:e2((k=function(a,b){for(;fc();)if(a+e9===57)break;else if(a+e9===84&&47===fd())break;return"/*"+e0(fa,b,e8-1)+"*"+eZ(47===a?a:fc())}(fc(),e8),l=c,m=d,n=j,fb(k,l,m,eT,eZ(e9),e0(k,2,-2),0,n)),j),(5==fe(t||1)||5==fe(fd()||1))&&e1(D)&&" "!==e0(D,-1,void 0)&&(D+=" ");break;default:D+="/"}break;case 123*u:i[o++]=e1(D)*w;case 125*u:case 59:case 0:if(x>0&&y){D+=eZ(y);break}switch(y){case 0:case 125:v=0;case 59+p:-1==w&&(D=e$(D,/\f/g,"")),s>0&&(e1(D)-q||0===u)&&e2(s>32?fh(D+";",e,d,q-1,j):fh(e$(D," ","")+";",e,d,q-2,j),j);break;case 59:D+=";";default:if(e2(C=fg(D,c,d,o,p,f,i,z,A=[],B=[],q,g),g),123===y)if(0===p)a(D,c,C,C,A,g,q,i,B);else{switch(r){case 99:if(110===e_(D,3))break;case 108:if(97===e_(D,2))break;default:p=0;case 100:case 109:case 115:}p?a(b,C,C,e&&e2(fg(b,C,C,0,0,f,i,z,f,A=[],q,B),B),f,B,q,i,e?A:B):a(D,C,C,C,[""],B,0,i,B)}}o=p=s=0,u=w=1,z=D="",q=h;break;case 58:q=1+e1(D),s=t;default:if(u<1){if(123==y)--u;else if(125==y&&0==u++&&125==(e9=e8>0?e_(fa,--e8):0,e6--,10===e9&&(e6=1,e5--),e9))continue}switch(D+=eZ(y),y*u){case 38:w=p>0?1:(D+="\f",-1);break;case 44:if(x>0)break;i[o++]=(e1(D)-1)*w,w=1;break;case 64:45===fd()&&(D+=ff(fc())),r=fd(),p=q=e1(z=D+=function(a){for(;!fe(fd());)fc();return e0(fa,a,e8)}(e8)),y++;break;case 45:45===t&&2==e1(D)&&(u=0)}}return g}("",null,null,null,[""],(d=c=`${a}{${b}}`,e5=e6=1,e7=e1(fa=d),e8=0,c=[]),0,[0],c),fa="",e),(g=(f=[(0,eQ.K)(function(b,c,d,e){"rule"===b.type&&Array.isArray(b.props)?b.parent&&b.parent.type===eW||(b.props=b.props.map(c=>c===a&&Array.isArray(b.children)&&b.children.every(a=>"decl"===a.type&&new Set(["font-family","font-size","fill"]).has(a.props))||(c.startsWith(`${a} `)||c.startsWith(`${a}>`))&&!c.startsWith(`${a} ||`)?c:`${a} ${c}`)):b.type.startsWith("@")&&(["@media","@supports",eX,"@scope","@container","@starting-style",eW].includes(b.type)||(eP.R.warn(`Removing unsupported at-rule ${b.type} from CSS`),b.type=eT))},"addNamespace"),e4]).length,function(a,b,c,d){for(var e="",h=0;h<g;h++)e+=f[h](a,b,c,d)||"";return e}))},"compileCSS"),h_=(0,eQ.K)((a,b,c,d)=>{let e=hZ(a,c),f=(0,eO.tM)(b,e,{...a.themeVariables,theme:a.theme,look:a.look},d);return h$(d,f)},"createUserStyles"),h0=(0,eQ.K)((a="",b,c)=>{let d=a;return c||b||(d=d.replace(/marker-end="url\([\d+./:=?A-Za-z-]*?#/g,'marker-end="url(#')),d=(d=(0,eN.Sm)(d)).replace(/<br>/g,"<br/>")},"cleanUpSvgCode"),h1=(0,eQ.K)((a="",b)=>{let c=b?.viewBox?.baseVal?.height?b.viewBox.baseVal.height+"px":"100%",d=hT(`<body style="margin:0">${a}</body>`);return`<iframe style="width:100%;height:${c};border:0;margin:0;" src="data:text/html;charset=UTF-8;base64,${d}" sandbox="allow-top-navigation-by-user-activation allow-popups">
278
278
  The "iframe" tag is not supported by your browser.
279
- </iframe>`},"putIntoIFrame"),h2=(0,eQ.K)((a,b,c,d,e)=>{let f=a.append("div");f.attr("id",c),d&&f.attr("style",d);let g=f.append("svg").attr("id",b).attr("width","100%").attr("xmlns","http://www.w3.org/2000/svg");return e&&g.attr("xmlns:xlink",e),g.append("g"),a},"appendDivSvgG");function h3(a,b){return a.append("iframe").attr("id",b).attr("style","width: 100%; height: 100%;").attr("sandbox","")}(0,eQ.K)(h3,"sandboxedIframe");var h4=(0,eQ.K)((a,b,c,d)=>{a.getElementById(b)?.remove(),a.getElementById(c)?.remove(),a.getElementById(d)?.remove()},"removeExistingElements"),h5=(0,eQ.K)(async function(a,b,c){let d,e;hG();let f=hW(b);b=f.code;let g=(0,eO.zj)();eP.R.debug(g),b.length>(g?.maxTextSize??5e4)&&(b="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa");let h=`#${a}`,i="i"+a,j="#"+i,k="d"+a,l="#"+k,m=(0,eQ.K)(()=>{let a=o?j:l,b=(0,eS.Ltv)(a).node();b&&"remove"in b&&b.remove()},"removeTempElements"),n=(0,eS.Ltv)(document.body),o="sandbox"===g.securityLevel,p="loose"===g.securityLevel,q=g.fontFamily;if(void 0!==c){if(c&&(c.innerHTML=""),o){let a=h3((0,eS.Ltv)(c),i);(n=(0,eS.Ltv)(a.nodes()[0].contentDocument.body)).node().style.margin="0"}else n=(0,eS.Ltv)(c);h2(n,a,k,`font-family: ${q}`,"http://www.w3.org/1999/xlink")}else{if(h4(document,a,k,i),o){let a=h3((0,eS.Ltv)(document.body),i);(n=(0,eS.Ltv)(a.nodes()[0].contentDocument.body)).node().style.margin="0"}else n=(0,eS.Ltv)("body");h2(n,a,k)}try{d=await hK.fromText(b,{title:f.title})}catch(a){if(g.suppressErrorRendering)throw m(),a;d=await hK.fromText("error"),e=a}let r=n.select(l).node(),s=d.type,t=r.firstChild,u=t.firstChild,v=h_(g,s,d.renderer.getClasses?.(b,d),h),w=document.createElement("style");w.innerHTML=v,t.insertBefore(w,u);try{await d.renderer.draw(b,a,"11.16.1",d)}catch(c){throw g.suppressErrorRendering?m():gn.draw(b,a,"11.16.1"),c}h8(s,n.select(`${l} svg`),d.db.getAccTitle?.(),d.db.getAccDescription?.()),n.select(`[id="${a}"]`).selectAll("foreignobject > *").attr("xmlns","http://www.w3.org/1999/xhtml");let x=n.select(l).node().innerHTML;if(eP.R.debug("config.arrowMarkerAbsolute",g.arrowMarkerAbsolute),x=h0(x,o,(0,eO._3)(g.arrowMarkerAbsolute)),o?x=h1(x,n.select(l+" svg").node()):p||(x=fi.A.sanitize(x,{ADD_TAGS:hU,ADD_ATTR:hV,HTML_INTEGRATION_POINTS:{foreignobject:!0}})),hM(),e)throw e;return m(),{diagramType:s,svg:x,bindFunctions:d.db.bindFunctions}},"render");function h6(a={}){let b=(0,eO.hH)({},a);b?.fontFamily&&!b.themeVariables?.fontFamily&&(b.themeVariables||(b.themeVariables={}),b.themeVariables.fontFamily=b.fontFamily),(0,eO.wZ)(b),b?.theme&&b.theme in eO.H$?b.themeVariables=eO.H$[b.theme].getThemeVariables(b.themeVariables):b&&(b.themeVariables=eO.H$.default.getThemeVariables(b.themeVariables));let c="object"==typeof b?(0,eO.UU)(b):(0,eO.Q2)();(0,eP.H)(c.logLevel),hG()}(0,eQ.K)(h6,"initialize");var h7=(0,eQ.K)((a,b={})=>{let{code:c}=hS(a);return hK.fromText(c,b)},"getDiagramFromText");function h8(a,b,c,d){hI(b,a),hJ(b,c,d,b.attr("id"))}(0,eQ.K)(h8,"addA11yInfo");var h9=Object.freeze({render:h5,parse:hX,getDiagramFromText:h7,initialize:h6,getConfig:eO.zj,setConfig:eO.Nk,getSiteConfig:eO.Q2,updateSiteConfig:eO.B6,reset:(0,eQ.K)(()=>{(0,eO.cL)()},"reset"),globalReset:(0,eQ.K)(()=>{(0,eO.cL)(eO.sb)},"globalReset"),defaultConfig:eO.sb});(0,eP.H)((0,eO.zj)().logLevel),(0,eO.cL)((0,eO.zj)());var ia=(0,eQ.K)((a,b,c)=>{eP.R.warn(a),(0,eN.dq)(a)?(c&&c(a.str,a.hash),b.push({...a,message:a.str,error:a})):(c&&c(a),a instanceof Error&&b.push({str:a.message,message:a.message,hash:a.name,error:a}))},"handleError"),ib=(0,eQ.K)(async function(a={querySelector:".mermaid"}){try{await ic(a)}catch(b){if((0,eN.dq)(b)&&eP.R.error(b.str),iq.parseError&&iq.parseError(b),!a.suppressErrors)throw eP.R.error("Use the suppressErrors option to suppress these errors"),b}},"run"),ic=(0,eQ.K)(async function({postRenderCallback:a,querySelector:b,nodes:c}={querySelector:".mermaid"}){let d,e,f=h9.getConfig();if(eP.R.debug(`${!a?"No ":""}Callback function found`),c)d=c;else if(b)d=document.querySelectorAll(b);else throw Error("Nodes and querySelector are both undefined");eP.R.debug(`Found ${d.length} diagrams`),f?.startOnLoad!==void 0&&(eP.R.debug("Start On Load: "+f?.startOnLoad),h9.updateSiteConfig({startOnLoad:f?.startOnLoad}));let g=new eN._K.InitIDGenerator(f.deterministicIds,f.deterministicIDSeed),h=[];for(let b of Array.from(d)){if(eP.R.info("Rendering diagram: "+b.id),b.getAttribute("data-processed"))continue;b.setAttribute("data-processed","true");let c=`mermaid-${g.next()}`;e=b.innerHTML,e=(0,eR.T)(eN._K.entityDecode(e)).trim().replace(/<br\s*\/?>/gi,"<br/>");let d=eN._K.detectInit(e);d&&eP.R.debug("Detected early reinit: ",d);try{let{svg:d,bindFunctions:f}=await io(c,e,b);b.innerHTML=d,a&&await a(c),f&&f(b)}catch(a){ia(a,h,iq.parseError)}}if(h.length>0)throw h[0]},"runThrowsErrors"),id=(0,eQ.K)(function(a){h9.initialize(a)},"initialize"),ie=(0,eQ.K)(async function(a,b,c){eP.R.warn("mermaid.init is deprecated. Please use run instead."),a&&id(a);let d={postRenderCallback:c,querySelector:".mermaid"};"string"==typeof b?d.querySelector=b:b&&(b instanceof HTMLElement?d.nodes=[b]:d.nodes=b),await ib(d)},"init"),ig=(0,eQ.K)(async(a,{lazyLoad:b=!0}={})=>{hG(),(0,eO.Xd)(...a),!1===b&&await hH()},"registerExternalDiagrams"),ih=(0,eQ.K)(function(){if(iq.startOnLoad){let{startOnLoad:a}=h9.getConfig();a&&iq.run().catch(a=>eP.R.error("Mermaid failed to initialize",a))}},"contentLoaded");"u">typeof document&&window.addEventListener("load",ih,!1);var ii=(0,eQ.K)(function(a){iq.parseError=a},"setParseErrorHandler"),ij=[],ik=!1,il=(0,eQ.K)(async()=>{if(!ik){for(ik=!0;ij.length>0;){let a=ij.shift();if(a)try{await a()}catch(a){eP.R.error("Error executing queue",a)}}ik=!1}},"executeQueue"),im=(0,eQ.K)(async(a,b)=>new Promise((c,d)=>{let e=(0,eQ.K)(()=>new Promise((e,f)=>{h9.parse(a,b).then(a=>{e(a),c(a)},a=>{eP.R.error("Error parsing",a),iq.parseError?.(a),f(a),d(a)})}),"performCall");ij.push(e),il().catch(d)}),"parse"),io=(0,eQ.K)((a,b,c)=>new Promise((d,e)=>{let f=(0,eQ.K)(()=>new Promise((f,g)=>{h9.render(a,b,c).then(a=>{f(a),d(a)},a=>{eP.R.error("Error parsing",a),iq.parseError?.(a),g(a),e(a)})}),"performCall");ij.push(f),il().catch(e)}),"render"),ip=(0,eQ.K)(()=>Object.keys(eO.mW).map(a=>({id:a})),"getRegisteredDiagramsMetadata"),iq={startOnLoad:!0,mermaidAPI:h9,parse:im,render:io,init:ie,run:ib,registerExternalDiagrams:ig,registerLayoutLoaders:eL.sO,initialize:id,parseError:void 0,contentLoaded:ih,setParseErrorHandler:ii,detectType:eO.Ch,registerIconPacks:eM.pC,getRegisteredDiagramsMetadata:ip},ir={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},is=function(a={}){let b=!1,c={...ir,...a.config},d={initialize(d){c={...ir,...a.config,...d},iq.initialize(c),b=!0},render:async(a,d)=>(b||(iq.initialize(c),b=!0),await iq.render(a,d))};return{name:"mermaid",type:"diagram",language:"mermaid",getMermaid:a=>(a&&d.initialize(a),d)}}(),it=c(38684);let iu=({className:a,from:b,...c})=>(0,A.jsx)("div",{className:(0,W.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===b?"is-user ml-auto justify-end":"is-assistant",a),...c}),iv=({children:a,className:b,...c})=>(0,A.jsx)("div",{className:(0,W.cn)("flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-base leading-[1.8]","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",b),...c,children:a}),iw=({tooltip:a,children:b,label:c,variant:d="ghost",size:e="icon-sm",...f})=>{let g=(0,A.jsxs)(U.$,{size:e,type:"button",variant:d,...f,children:[b,(0,A.jsx)("span",{className:"sr-only",children:c||a})]});return a?(0,A.jsx)(d_.Bc,{children:(0,A.jsxs)(d_.m_,{children:[(0,A.jsx)(d_.k$,{render:g}),(0,A.jsx)(d_.ZI,{children:(0,A.jsx)("p",{children:a})})]})}):g},ix={cjk:d0.h,code:d1.a,math:eI,mermaid:is},iy=(0,B.memo)(({className:a,...b})=>(0,A.jsx)(it.jH,{className:(0,W.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",a),plugins:ix,...b}),(a,b)=>a.children===b.children&&b.isAnimating===a.isAnimating);iy.displayName="MessageResponse";let iz=({className:a,children:b,...c})=>(0,A.jsx)("div",{className:(0,W.cn)("mt-4 flex w-full items-center justify-between gap-4",a),...c,children:b});function iA({readme:a}){let{t:b}=(0,Q.Bd)("pluginManagement"),{locale:c}=(0,cy.i)(),[d,e]=(0,B.useState)(null),f=a&&"string"!=typeof a?a.translations:{},g=Object.keys(f).filter(a=>/^(zh(?:-|$)|en(?:-|$))/.test(a)),h=d&&void 0!==f[d]?d:null,i=a?h?f[h]:(0,cx.fD)(a,c):null;return(0,A.jsxs)("section",{className:"min-w-0 space-y-3","aria-label":b("readme"),children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,A.jsx)("h3",{className:"text-sm font-semibold",children:b("readme")}),g.length>0?(0,A.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,A.jsx)("span",{children:b("readmeLanguage")}),(0,A.jsxs)(bS.l6,{value:h??"",onValueChange:a=>e(a||null),children:[(0,A.jsx)(bS.bq,{"aria-label":b("readmeLanguage"),children:(0,A.jsx)(bS.yv,{children:h?h.startsWith("zh")?"中文":"English":b("defaultLanguage")})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[160]",children:[(0,A.jsx)(bS.eb,{value:"",children:b("defaultLanguage")}),g.map(a=>(0,A.jsx)(bS.eb,{value:a,children:a.startsWith("zh")?"中文":"English"},a))]})]})]}):null]}),i?(0,A.jsx)("div",{className:"min-w-0 overflow-x-auto text-base leading-relaxed [overflow-wrap:anywhere]",children:(0,A.jsx)(iy,{mode:"static",isAnimating:!1,skipHtml:!0,controls:!1,className:"min-w-0 [&_img]:max-w-full [&_pre]:overflow-x-auto",children:i})}):(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:b("noReadme")})]})}function iB({value:a,label:b,placeholder:c,disabled:d,onChange:e}){let{t:f}=(0,Q.Bd)("pluginManagement"),g=[...c?[{value:"",label:c}]:[],{value:"latest",label:f("channelLatest")},{value:"dev",label:f("channelDev")},...a&&!["latest","dev"].includes(a)?[{value:a,label:a}]:[]];return(0,A.jsxs)(bS.l6,{value:a,items:g,onOpenChange:(a,b)=>{a&&d&&b.cancel()},onValueChange:a=>{null===a||d||e(a)},children:[(0,A.jsx)(bS.bq,{"aria-label":b,"aria-disabled":d,className:"max-w-full aria-disabled:opacity-50",children:(0,A.jsx)(bS.yv,{})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[160]",children:g.map(a=>(0,A.jsx)(bS.eb,{value:a.value,disabled:d,children:a.label},a.value))})]})}function iC(a){if(!a)return null;try{let b=new URL(a);return["https:","http:"].includes(b.protocol)?b.href:null}catch{return null}}function iD(a){let{t:b}=(0,Q.Bd)("pluginManagement"),{locale:c}=(0,cy.i)(),d=a.detail,e=a.installed&&a.installedVersion===d.version,f=iC(d.homepage),g=iC(d.repository),h=[...new Set([d.version,...d.versions])];return(0,A.jsxs)("div",{className:"min-w-0 space-y-5",children:[(0,A.jsxs)("div",{className:"space-y-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,A.jsxs)("span",{children:["v",d.version]}),(0,A.jsx)("span",{children:b(`kind_${d.kind}`)}),d.publisher?(0,A.jsx)("span",{className:"[overflow-wrap:anywhere]",children:d.publisher}):null]}),d.description?(0,A.jsx)("p",{className:"text-sm text-muted-foreground [overflow-wrap:anywhere]",children:(0,cx.fD)(d.description,c)}):null,!1===d.compatible?(0,A.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[b("incompatible"),d.compatibilityNote?` \xb7 ${d.compatibilityNote}`:""]}):null,(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[a.pending?(0,A.jsx)("span",{role:"status",className:"text-sm text-muted-foreground",children:a.operationMessage??b("submitting")}):e?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{className:"text-sm text-muted-foreground",children:b("alreadyInstalled")}),a.updateAvailable?(0,A.jsx)(U.$,{size:"sm",disabled:a.disabled,onClick:a.onUpdate,children:b("update")}):null]}):(0,A.jsx)(U.$,{size:"sm",disabled:a.disabled||!1===d.compatible,onClick:a.onInstall,children:b(a.installed?"installVersion":"install")}),f?(0,A.jsx)("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline underline-offset-4",children:b("homepage")}):null,g?(0,A.jsx)("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline underline-offset-4",children:b("repository")}):null]}),a.error?(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive [overflow-wrap:anywhere]",children:a.error}):null]}),(0,A.jsxs)(cs.Nt,{className:"rounded-lg border",children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-9 w-full items-center justify-between px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[b("advancedOptions"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsxs)("div",{className:"space-y-3 px-3 pb-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,A.jsx)("span",{children:b("installChannel")}),(0,A.jsx)(iB,{value:a.channel,label:b("installChannel"),placeholder:b("defaultChannel"),disabled:a.pending,onChange:a.onChannel}),(0,A.jsxs)(bS.l6,{value:d.version,items:h.map(a=>({value:a,label:a})),onOpenChange:(b,c)=>{b&&a.pending&&c.cancel()},onValueChange:b=>{b&&!a.pending&&a.onVersion(b)},children:[(0,A.jsx)(bS.bq,{"aria-label":b("version"),"aria-disabled":a.pending,children:(0,A.jsx)(bS.yv,{})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[160]",children:h.map(b=>(0,A.jsx)(bS.eb,{value:b,disabled:a.pending,children:b},b))})]})]}),(0,A.jsx)(dM,{id:"plugin-detail-download",mode:a.downloadMode,registry:a.downloadRegistry,override:!0,saving:a.pending,onMode:a.onDownloadMode,onRegistry:a.onDownloadRegistry})]})})]}),(0,A.jsx)("div",{className:"border-t pt-4",children:(0,A.jsx)(iA,{readme:d.readme},`${d.name}@${d.version}`)})]})}var iE=c(13221);function iF(a){let{t:b}=(0,Q.Bd)("pluginManagement");return(0,A.jsxs)("section",{"aria-label":b("directInstall"),className:"min-w-0 space-y-3 rounded-lg border bg-card p-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,A.jsx)("h3",{className:"text-sm font-semibold",children:b("directInstall")}),(0,A.jsx)(U.$,{size:"sm",variant:"ghost",onClick:a.onClose,children:b("close")})]}),(0,A.jsx)("label",{htmlFor:"plugin-direct-source",className:"block text-sm font-medium",children:b("source")}),(0,A.jsx)(iE.T,{id:"plugin-direct-source",value:a.source,placeholder:b("batchSourcePlaceholder"),rows:2,disabled:a.pending,onChange:b=>a.onSource(b.target.value)}),a.isNpm||a.multiple?(0,A.jsxs)(cs.Nt,{children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-8 items-center gap-2 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[b("advancedOptions"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,A.jsx)("span",{children:b("installChannel")}),(0,A.jsx)(iB,{value:a.tag,label:b("installChannel"),placeholder:b("defaultChannel"),disabled:a.pending,onChange:a.onTag})]}),a.isNpm?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.loading,onClick:a.onRead,children:b(a.loading?"loadingPackage":"readPackage")}):null,a.detail?(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,A.jsx)("span",{className:"min-w-0 font-medium [overflow-wrap:anywhere]",children:a.detail.name}),(0,A.jsxs)(bS.l6,{value:a.selectedVersion,onOpenChange:(b,c)=>{b&&(a.loading||a.pending)&&c.cancel()},items:[{value:"",label:b("automaticVersion")},...[...new Set([a.detail.version,...a.detail.versions])].map(a=>({value:a,label:a}))],onValueChange:b=>{null===b||a.loading||a.pending||a.onVersion(b)},children:[(0,A.jsx)(bS.bq,{"aria-label":b("version"),"aria-disabled":a.loading||a.pending,className:"max-w-full",children:(0,A.jsx)(bS.yv,{})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[160]",children:[(0,A.jsx)(bS.eb,{value:"",disabled:a.loading||a.pending,children:b("automaticVersion")}),[...new Set([a.detail.version,...a.detail.versions])].map(b=>(0,A.jsx)(bS.eb,{value:b,disabled:a.loading||a.pending,children:b},b))]})]}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:b("targetVersion",{version:a.detail.version})})]}):null,(0,A.jsx)(dM,{id:"plugin-direct-download",mode:a.override,registry:a.registry,override:!0,saving:a.pending,onMode:a.onMode,onRegistry:a.onRegistry})]})})]}):null,a.error?(0,A.jsx)("p",{role:"alert",className:"text-sm whitespace-pre-wrap text-destructive [overflow-wrap:anywhere]",children:a.error}):null,a.operationMessage?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground [overflow-wrap:anywhere]",children:a.operationMessage}):null,(0,A.jsx)(U.$,{size:"sm",disabled:a.disabled||a.loading||a.pending||!a.source.trim(),onClick:a.onInstall,children:b(a.pending?"installing":a.multiple?"batchInstall":"install")})]})}function iG({confirmation:a,onClose:b,onConfirm:c}){let{t:d}=(0,Q.Bd)("pluginManagement"),e=a?d(dA(a)):null,f=a?.kind==="del"||a?.kind==="batch"&&"del"===a.input.action,g=a?.kind==="add"||a?.kind==="batch"&&"add"===a.input.action;return(0,A.jsx)(b7.YV,{open:!!a,onOpenChange:a=>{a||b()},children:(0,A.jsxs)(b7.hA,{className:"z-[150] max-w-lg",backdropClassName:"z-[140]",children:[(0,A.jsxs)(b7.Hl,{className:"p-4 pr-12",children:[(0,A.jsx)(b7.YM,{children:d("confirmAction",{action:e})}),(0,A.jsx)(b7.uX,{children:d(f?"removeDescription":g?"thirdPartyDescription":a?.kind==="reload"?"normal"===a.mode?"restartNormalDescription":"restartDescription":"confirmChange")})]}),(0,A.jsx)(b7._Y,{className:"min-h-0",children:(0,A.jsx)("div",{className:"min-w-0 p-4 pt-0",children:a?.kind==="batch"?(0,A.jsx)("ul",{className:"space-y-2 text-sm",children:("add"===a.input.action?a.input.items.map(a=>a.source):a.input.sources).map(a=>(0,A.jsx)("li",{className:"font-medium [overflow-wrap:anywhere]",children:a.startsWith("npm:")?dx(a)?.name??a:a},a))}):a?.kind==="add"?(0,A.jsxs)("dl",{className:"space-y-3 text-sm",children:[(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("packageName")}),(0,A.jsx)("dd",{className:"mt-1 font-medium [overflow-wrap:anywhere]",children:a.package?.name??a.input.source})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("version")}),(0,A.jsx)("dd",{className:"[overflow-wrap:anywhere]",children:a.package?.version??dx(a.input.source)?.version??d("fromSource")})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("publisher")}),(0,A.jsx)("dd",{className:"[overflow-wrap:anywhere]",children:a.package?.publisher??d("unknownPublisher")})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("source")}),(0,A.jsx)("dd",{className:"[overflow-wrap:anywhere]",children:a.input.registry??a.package?.registry??a.input.source})]})]}):a&&"reload"!==a.kind?(0,A.jsx)("p",{className:"text-sm font-medium [overflow-wrap:anywhere]",children:a.source.startsWith("npm:")?dx(a.source)?.name??a.source:a.source}):null})}),(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{size:"sm",variant:"outline",onClick:b,children:d("cancel")}),(0,A.jsx)(U.$,{size:"sm",variant:f?"destructive":"default",onClick:()=>{a&&c(a)},children:e})]})]})})}function iH({basicMode:a=!1,snapshot:b,biz:c,onSnapshot:d,onRestartScheduled:e}){let{t:f}=(0,Q.Bd)("pluginManagement"),{locale:g}=(0,cy.i)(),[h,i]=(0,B.useState)("installed"),[j,k]=(0,B.useState)(""),[l,m]=(0,B.useState)("all"),[n,o]=(0,B.useState)(!1),[p,q]=(0,B.useState)(()=>new Set),[r,s]=(0,B.useState)(""),[t,u]=(0,B.useState)(!1),v=function({basicMode:a=!1,biz:b,snapshot:c,onSnapshot:d,onRestartScheduled:e}){let{t:f}=(0,Q.Bd)("pluginManagement"),g=(0,bJ.t4)();(0,bJ.So)();let[h,i]=(0,B.useState)(!1),[j,k]=(0,B.useState)(()=>new Set),l=(0,B.useRef)(new Set),[m,n]=(0,B.useState)(null),[o,p]=(0,B.useState)({}),[q,r]=(0,B.useState)(null),[s,t]=(0,B.useState)(null),[u,v]=(0,B.useState)(!1),[w,x]=(0,B.useState)(null),y=(0,B.useRef)(0),z=(0,B.useRef)(0),A=(0,B.useRef)(!0),C=(a,b)=>{b?l.current.add(a):l.current.delete(a),A.current&&k(new Set(l.current))},D=(a,b)=>{A.current&&p(c=>{let d={...c};return b?d[a]=b:delete d[a],d})},E=a=>{let b=dz(a);return l.current.has(b)||!!c?.plugins.some(a=>dz(a.source)===b&&a.operation&&"failed"!==a.operation.phase)},F=async(a=!1)=>{let c=++z.current,e=await b.list(a);A.current&&c===z.current&&d(e)},G=async a=>{let c="add"===a.action?a.items.map(a=>a.source):a.sources,e=c.filter(a=>!E(a));if(c.filter(E).forEach(a=>D(dz(a),f("sourceBusy"))),!e.length)return;let g=e.map(dz);g.forEach(a=>{C(a,!0),D(a,null)}),n(null);let h=[...e];try{let c=await b.list(),e=Date.now()+9e5;for(;h.length;){let g=c.plugins.filter(a=>a.operation&&"failed"!==a.operation.phase),i="tag"===a.action?32:Math.max(0,32-g.length);if(!i){if(g.some(a=>a.operation?.phase==="waiting")||Date.now()>=e){h.forEach(a=>D(dz(a),f("batchWaiting")));break}await new Promise(a=>setTimeout(a,750)),c=await b.list(),A.current&&(z.current+=1,d(c));continue}let j=h.slice(0,i),k="add"===a.action?{...a,items:a.items.filter(a=>j.includes(a.source))}:{...a,sources:j},l=await b.batch(k);c=l.snapshot,A.current&&(z.current+=1,d(c)),l.results.forEach(a=>D(dz(a.source),a.error)),j.forEach(a=>C(dz(a),!1)),h=h.slice(j.length)}}catch(b){let a=b instanceof Error?b.message:f("batchFailed");h.forEach(b=>D(dz(b),a))}finally{g.forEach(a=>C(a,!1))}},H=async a=>{if("batch"===a.kind)return void await G(a.input);if("reload"!==a.kind&&E("add"===a.kind?a.input.source:a.source))return;let c="reload"===a.kind?"reload":dz("add"===a.kind?a.input.source:a.source);if(!l.current.has(c)){C(c,!0),n(null),D(c,null);try{let c="add"===a.kind?await b.add(a.input):"update"===a.kind?await b.update(a.source):"del"===a.kind?await b.del(a.source):"enable"===a.kind||"disable"===a.kind?await b.setEnabled(a.source,"enable"===a.kind):await b.reload(a.mode);if(!A.current)return;z.current+=1,d(c),"reload"===a.kind?e():await F()}catch(b){D(c,b instanceof Error?b.message:f("actionFailed",{action:f(dA(a))}))}finally{C(c,!1)}}},I=(a,b)=>{let c={kind:"add",input:a,package:b};b?.official===!0?H(c):n(c)},J=async a=>{let c=a?.[0]?dz(a[0]):"apply";if(!l.current.has(c)){C(c,!0),D(c,null);try{let c=await b.apply(a);A.current&&(z.current+=1,d(c),await F())}catch(a){D(c,a instanceof Error?a.message:f("actionFailed",{action:f("reloadOne")}))}finally{C(c,!1)}}},K=async(a,b)=>{if(!l.current.has(a)){C(a,!0),D(a,null);try{await b()}catch(b){D(a,b instanceof Error?b.message:f("retryFailed"))}finally{C(a,!1)}}},L=async a=>{let c=++y.current;v(!0),x(null);try{let d=await b.get(a);A.current&&c===y.current&&t(d)}catch(a){A.current&&c===y.current&&x(a instanceof Error?a.message:f("detailFailed"))}finally{A.current&&c===y.current&&v(!1)}};return{loading:h,requests:j,confirmation:m,setConfirmation:n,errors:o,detailSource:q,detail:s,detailLoading:u,detailError:w,pluginHost:g,refresh:async(a,b)=>{if(l.current.has("check"))return;let d=a??c?.plugins.filter(a=>"package"===a.kind&&(!b||a.updateTag===b)).map(a=>a.source)??[],e=d.filter(E),g=d.filter(a=>!E(a));if(e.forEach(a=>D(dz(a),f("sourceBusy"))),!g.length)return;let h=g.map(dz);C("check",!0),h.forEach(a=>C(a,!0)),i(!0),D("list",null);try{if(a||e.length)for(let a=0;a<g.length&&(await F({checkUpdates:!0,sources:g.slice(a,a+32),...b?{tag:b}:{}}),A.current);a+=32);else await F({checkUpdates:!0,...b?{tag:b}:{}})}catch(a){D("list",a instanceof Error?a.message:f("updateCheckFailed"))}finally{C("check",!1),h.forEach(a=>C(a,!1)),A.current&&i(!1)}},executeBatch:G,execute:H,requestInstall:I,applyChanges:J,loadDetail:L,openDetail:a=>{r(a),t(null),L(a)},closeDetail:()=>{y.current+=1,r(null),t(null),x(null),v(!1)},handleControlAction:(a,b)=>{switch(b){case"reload":J([a.source]);break;case"update":H({kind:"update",source:a.source});break;case"remove":n({kind:"del",source:a.source});break;case"enable":case"disable":H({kind:b,source:a.source});break;case"retry-browser":a.pluginName&&K(`entry:${a.pluginName}`,()=>g.retryEntry(a.pluginName));break;case"retry":{let b=a.operation?.action;"apply"===b?J([a.source]):"add"===b?I({source:a.source}):b&&H({kind:b,source:a.source})}}},refreshEntries:()=>K("entries",()=>g.refreshEntries())}}({biz:c,snapshot:b,onSnapshot:d,onRestartScheduled:e,basicMode:a}),w=function(a){let{t:b}=(0,Q.Bd)("pluginManagement"),[c,d]=(0,B.useState)(""),[e,f]=(0,B.useState)(!1),[g,h]=(0,B.useState)("all"),[i,j]=(0,B.useState)("public"),[k,l]=(0,B.useState)(""),[m,n]=(0,B.useState)([]),[o,p]=(0,B.useState)(!1),[q,r]=(0,B.useState)(1),[s,t]=(0,B.useState)(!1),[u,v]=(0,B.useState)(null),[w,x]=(0,B.useState)(!1),[y,z]=(0,B.useState)(null),[A,C]=(0,B.useState)(null),[D,E]=(0,B.useState)(!1),[F,G]=(0,B.useState)(null),[H,I]=(0,B.useState)(()=>new Set),[J,K]=(0,B.useState)({}),L=(0,B.useRef)(0),M=(0,B.useRef)(0),N=(0,B.useRef)(new Set),O=(0,B.useRef)(null),[P,R]=(0,B.useState)(!1),[S,T]=(0,B.useState)("default"),[U,V]=(0,B.useState)(""),W=(0,B.useRef)(!0),X=(0,B.useCallback)(async(c,d)=>{t(!0),v(null);try{let b=await a.searchCatalog(c);if(!W.current||d!==L.current)return;n(a=>{let d=1===c.page?b.items:[...a,...b.items],e=a=>a.official?0:"desk"===a.kind?1:"pi"===a.kind?2:3;return[...new Map(d.map(a=>[a.name,a])).values()].sort((a,b)=>e(a)-e(b))}),r(c.page),p(b.hasMore),x(!0)}catch(a){W.current&&d===L.current&&v(a instanceof Error?a.message:b("searchFailed"))}finally{W.current&&d===L.current&&t(!1)}},[a,b]),Y=async(c,d=c.version)=>{let e=++M.current;E(!0),G(null),K(a=>{let b={...a};return delete b[c.name],b});try{let b=await a.getCatalog({name:c.name,registry:c.registry,version:d});W.current&&e===M.current&&C(b)}catch(a){W.current&&e===M.current&&G(a instanceof Error?a.message:b("detailFailed"))}finally{W.current&&e===M.current&&E(!1)}};return{query:c,setQuery:d,composing:e,beginComposition:()=>{L.current+=1,O.current=null,t(!1),f(!0)},endComposition:()=>f(!1),kind:g,setKind:h,searchSource:i,setSearchSource:j,registry:k,setRegistry:l,items:m,loading:s,error:u,searched:w,hasMore:o,loadMore:()=>{O.current&&!s&&o&&X({...O.current,page:q+1},L.current)},retry:()=>{if(e||s)return;let a="custom"===i?dC.safeParse(k):null;if(a&&!a.success)return void v(b("invalidRegistry"));let d={query:c.trim(),kind:g,page:1,...a?.success?{registry:a.data}:{}};O.current=d,n([]),X(d,++L.current)},selection:y,detail:A,detailLoading:D,detailError:F,openDetail:a=>{z(a),C(null),T("default"),V(""),Y(a)},closeDetail:()=>{M.current+=1,z(null),C(null),E(!1),G(null)},loadDetail:Y,prepareInstall:async(c,d)=>{if(!N.current.has(c.name)){N.current.add(c.name),I(new Set(N.current)),K(a=>{let b={...a};return delete b[c.name],b});try{let e=await a.getCatalog({name:c.name,version:c.version,registry:c.registry});if(!W.current)return;if(!1===e.compatible)return void K(a=>({...a,[c.name]:b("installIncompatible")}));d(e)}catch(a){W.current&&K(d=>({...d,[c.name]:a instanceof Error?a.message:b("detailFailed")}))}finally{N.current.delete(c.name),W.current&&I(new Set(N.current))}}},preparing:H,installErrors:J,downloadMode:S,setDownloadMode:T,downloadRegistry:U,setDownloadRegistry:V,installDetail:a=>{if(!A||D)return;if(!1===A.compatible)return void K(a=>({...a,[A.name]:b("installIncompatible")}));let c="default"===S?null:dD.safeParse("custom"===S?{mode:S,registry:U}:{mode:S});c&&!c.success?K(a=>({...a,[A.name]:b("invalidRegistry")})):(K(a=>{let b={...a};return delete b[A.name],b}),a({source:`npm:${A.name}@${A.version}`,registry:A.registry,...c?.success?{downloadSource:c.data}:{}},A))}}}(c),x=function(a,b){let{t:c}=(0,Q.Bd)("pluginManagement"),[d,e]=(0,B.useState)(null),[f,g]=(0,B.useState)("auto"),[h,i]=(0,B.useState)(""),[j,k]=(0,B.useState)(!1),[l,m]=(0,B.useState)(!1),[n,o]=(0,B.useState)(null),p=(0,B.useRef)(!0),q=(0,B.useRef)(!1),r=(0,B.useRef)(0),s=(0,B.useRef)("load"),t=async()=>{let b=r.current;k(!0),o(null);try{let c=await a.getCatalogSettings();if(!p.current)return;b===r.current?(e(c),g(c.downloadSource.mode),"custom"===c.downloadSource.mode&&i(c.downloadSource.registry)):e(a=>a??c)}catch(a){s.current="load",p.current&&o(a instanceof Error?a.message:c("settingsFailed"))}finally{p.current&&k(!1)}},u=async(d=f)=>{if(q.current)return;let i=dD.safeParse("custom"===d?{mode:d,registry:h}:{mode:d});if(!i.success){s.current="save",o(c("invalidRegistry"));return}q.current=!0,m(!0),o(null);try{let c=await a.saveCatalogSettings(i.data);p.current&&(e(c),g(c.downloadSource.mode),b())}catch(a){s.current="save",p.current&&o(a instanceof Error?a.message:c("settingsFailed"))}finally{q.current=!1,p.current&&m(!1)}};return{settings:d,mode:f,registry:h,setRegistry:a=>{r.current+=1,i(a)},loading:j,saving:l,error:n,load:t,save:u,changeMode:a=>{r.current+=1,g(a),"custom"!==a&&u(a)},retry:()=>"save"===s.current?u():t()}}(c,()=>{a||v.refresh()}),y=function(a,b=[]){let{t:c}=(0,Q.Bd)("pluginManagement"),[d,e]=(0,B.useState)(!1),[f,g]=(0,B.useState)(""),[h,i]=(0,B.useState)(""),[j,k]=(0,B.useState)(null),[l,m]=(0,B.useState)(null),[n,o]=(0,B.useState)(!1),[p,q]=(0,B.useState)(null),[r,s]=(0,B.useState)("default"),[t,u]=(0,B.useState)(""),v=(0,B.useRef)(0),w=(0,B.useRef)(!0),x=f.split(/\r?\n/).map(a=>a.trim()).filter(Boolean),y=1===x.length?dx(x[0]):null,z=()=>{v.current+=1,m(null),o(!1),q(null)},A=async d=>{let e;if(!y)return null;void 0!==d&&k(d||null);let f=b.find(a=>dx(a.source)?.name===y.name)?.updateTag,g=y.version??(h||f||"latest"),i=""===d?g:d??j??g;if("custom"===r){let a=dC.safeParse(t);if(!a.success)return q(c("invalidRegistry")),null;e=a.data}else"official"===r?e="https://registry.npmjs.org":"domestic"===r&&(e="https://registry.npmmirror.com");let l=++v.current;o(!0),m(null),q(null);try{let b=await a.getCatalog({...y,...i?{version:i}:{},...e?{registry:e}:{}});if(!w.current||l!==v.current)return null;return m(b),b}catch(a){return w.current&&l===v.current&&q(a instanceof Error?a.message:c("detailFailed")),null}finally{w.current&&l===v.current&&o(!1)}},C=async(a,b)=>{if(!x.length||n)return;q(null);let d="default"===r?null:dD.safeParse("custom"===r?{mode:r,registry:t}:{mode:r});if(d&&!d.success)return void q(c("invalidRegistry"));let e={...h?{tag:h}:{},...d?.success?{downloadSource:d.data}:{}};if(x.length>1){let a=x.map(dx);if(x.length>32||a.some(a=>!a))return void q(c(x.length>32?"batchLimit":"batchNpmOnly"));let d=new Map;return a.forEach(a=>{a&&d.set(a.name,{source:`npm:${a.name}${a.version?`@${a.version}`:""}`,...e})}),void b([...d.values()])}if(!y)return void a({source:x[0]});let f=l?Promise.resolve(l):A(j??void 0),g=v.current,i=await f;if(i&&w.current&&g===v.current){if(!1===i.compatible)return void q(c("installIncompatible"));a({source:`npm:${i.name}${j||y.version?`@${j??y.version}`:""}`,registry:i.registry,...e},i)}};return{open:d,setOpen:e,source:f,sources:x,tag:h,selectedVersion:j??"",setTag:a=>{z(),k(null),i(a)},changeSource:a=>{z(),k(null),g(a)},spec:y,detail:l,loading:n,error:p,override:r,setOverride:a=>{z(),s(a)},registry:t,setRegistry:a=>{z(),u(a)},loadDetail:A,install:C}}(c,b?.plugins),z=a||v.requests.has("reload"),C=new Map(v.pluginHost.getFailedEntries().map(a=>[a.pluginName,a.error.message])),D=v.pluginHost.getEntryListError(),E=b?.plugins.find(a=>a.source===v.detailSource),F=w.selection?b?.plugins.find(a=>a.source.startsWith("npm:")&&dx(a.source)?.name===w.selection?.name):void 0,G=w.selection?dz(`npm:${w.selection.name}`):"",H=dz(y.detail?`npm:${y.detail.name}`:y.spec?`npm:${y.spec.name}`:y.source.trim()),I=b?.plugins.find(a=>dz(a.source)===H),J=a=>{let c=b?.plugins.find(b=>dz(b.source)===dz(a));return v.requests.has(dz(a))||!!(c?.operation&&"failed"!==c.operation.phase)},K=J(`npm:${w.selection?.name??""}`),L=y.sources.some(J),M=y.sources.map(a=>{let c=dz(a),d=b?.plugins.find(a=>dz(a.source)===c),e=v.errors[c]??(d?.operation?.phase==="failed"?d.operation.message:null);return e?`${a}: ${e}`:null}).filter(Boolean).join("\n"),N=!!(v.detailSource||w.selection),O=(0,B.useRef)(null),P=(0,B.useRef)(null),R=()=>{P.current=document.activeElement instanceof HTMLElement?document.activeElement:null},S=a=>{let c=b?.plugins.find(b=>dx(b.source)?.name===a.name);return{...a,version:c?.updateTag??"latest"}},T=a=>b?.plugins.filter(b=>"extension"!==b.kind&&!0===b.updateAvailable&&!J(b.source)&&(!a||p.has(dz(b.source)))).map(a=>a.source)??[],V=a=>a?f(`phase_${a}`):null,W=()=>{i("installed"),y.setOpen(!0)};return(0,A.jsxs)("div",{className:"flex h-full min-h-0 min-w-0 flex-col",children:[(0,A.jsxs)("header",{className:"shrink-0 space-y-3 border-b p-4 sm:px-6",children:[N?(0,A.jsxs)(U.$,{ref:O,size:"sm",variant:"ghost",className:"-ml-2",onClick:()=>{v.closeDetail(),w.closeDetail()},children:[(0,A.jsx)(Z.A,{}),f("backToList")]}):null,(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,A.jsx)("h2",{className:"min-w-0 text-xl font-semibold [overflow-wrap:anywhere]",children:N?E?dy(E):w.selection?.name??f("details"):f("title")}),(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[N?null:(0,A.jsxs)(cq.AM,{children:[(0,A.jsxs)(cq.Wv,{render:(0,A.jsx)(U.$,{size:"sm",variant:"ghost"}),children:[f("downloadSource"),":",x.loading&&!x.settings?f("loading"):f(`download_${x.settings?.downloadSource.mode??x.mode}`),(0,A.jsx)(cr.A,{className:"size-4"})]}),(0,A.jsx)(cq.hl,{align:"end",positionerClassName:"z-[150]",className:"w-80 max-w-[calc(100vw-2rem)]",children:(0,A.jsx)(dM,{id:"plugin-default-download",mode:x.mode,registry:x.registry,savedRegistry:x.settings?.downloadSource.mode==="custom"?x.settings.downloadSource.registry:void 0,recommendedRegistry:x.settings?.recommendedRegistry,loading:x.loading,saving:x.saving,error:x.error,onMode:a=>{"default"!==a&&x.changeMode(a)},onRegistry:x.setRegistry,onSave:()=>void x.save(),onRetry:()=>void x.retry()})})]}),a||b?.restartRequired?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:v.requests.has("reload"),onClick:()=>v.setConfirmation({kind:"reload",mode:a?"normal":void 0}),children:f(a?"restartNormal":"restartApply")}):null]})]}),a?(0,A.jsx)("p",{role:"status",className:"rounded-lg bg-muted p-3 text-sm",children:f("basicModeNotice")}):null,b?.restartRequired?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:f("pendingRestart")}):null,b?.loadError||D?(0,A.jsxs)("div",{role:"alert",className:"max-h-32 space-y-1 overflow-y-auto text-sm text-destructive",children:[b?.loadError?(0,A.jsx)("p",{className:"[overflow-wrap:anywhere]",children:(0,cx.fD)(b.loadError,g)}):null,D?(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)("p",{className:"min-w-0 [overflow-wrap:anywhere]",children:D}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:v.requests.has("entries"),onClick:()=>void v.refreshEntries(),children:f("retry")})]}):null]}):null,v.errors.reload||v.errors.entries?(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive [overflow-wrap:anywhere]",children:v.errors.reload??v.errors.entries}):null]}),(0,A.jsxs)(cU,{value:h,onValueChange:a=>i(String(a)),className:`min-h-0 flex-1 gap-0 ${N?"hidden":""}`,children:[(0,A.jsx)("div",{className:"shrink-0 border-b px-4 pt-2 sm:px-6",children:(0,A.jsxs)(cW,{variant:"line","aria-label":f("title"),className:"h-9",children:[(0,A.jsxs)(cX,{value:"installed",className:"px-3",children:[f("installedTab"),b?(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:b.plugins.length}):null]}),(0,A.jsx)(cX,{value:"search",className:"px-3",children:f("searchPlugins")})]})}),(0,A.jsx)(cY,{value:"installed",keepMounted:!0,className:"flex min-h-0 flex-col overflow-hidden p-4 data-[hidden]:hidden sm:p-6",children:(0,A.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[y.open?(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar max-h-1/2 shrink-0 overflow-y-auto",children:(0,A.jsx)(iF,{source:y.source,isNpm:!!y.spec,multiple:y.sources.length>1,tag:y.tag,selectedVersion:y.selectedVersion,onTag:y.setTag,detail:y.detail,loading:y.loading,pending:L,disabled:z,error:y.error??(M||null),operationMessage:L?V(I?.operation?.phase)??f("submitting"):null,override:y.override,registry:y.registry,onSource:y.changeSource,onMode:y.setOverride,onRegistry:y.setRegistry,onRead:()=>void y.loadDetail(),onVersion:a=>void y.loadDetail(a),onInstall:()=>void y.install(v.requestInstall,a=>v.setConfirmation({kind:"batch",input:{action:"add",items:a}})),onClose:()=>y.setOpen(!1)})}):null,(0,A.jsx)(dX,{snapshot:b,loading:v.loading,filter:j,statusFilter:l,batchMode:n,selected:p,onStatusFilter:m,onBatchMode:a=>{o(a),a||q(new Set)},onSelect:(a,b)=>{q(c=>{let d=new Set(c);return a.forEach(a=>{b?d.add(a):d.delete(a)}),d})},onUpdateAll:()=>void v.executeBatch({action:"update",sources:T(!1)}),onUpdateSelected:()=>void v.executeBatch({action:"update",sources:T(!0)}),onRemoveSelected:()=>v.setConfirmation({kind:"batch",input:{action:"del",sources:b?.plugins.filter(a=>p.has(dz(a.source))&&!J(a.source)).map(a=>a.source)??[]}}),disabled:z,requests:v.requests,errors:v.errors,browserErrors:C,onFilter:k,onDetail:a=>{R(),w.closeDetail(),v.openDetail(a)},onAction:v.handleControlAction,onRefresh:()=>void v.refresh()}),b?.plugins.length||y.open?null:(0,A.jsx)(U.$,{size:"sm",variant:"outline",className:"shrink-0 self-start",disabled:z,onClick:W,children:f("directInstall")})]})}),(0,A.jsx)(cY,{value:"search",keepMounted:!0,className:"pi-desk-chat-scrollbar min-h-0 overflow-y-auto p-4 data-[hidden]:hidden sm:p-6",children:(0,A.jsx)(dY,{query:w.query,kind:w.kind,searchSource:w.searchSource,registry:w.registry,items:w.items,loading:w.loading,error:w.error,searched:w.searched,hasMore:w.hasMore,disabled:z,snapshot:b,requests:v.requests,preparing:w.preparing,errors:v.errors,installErrors:w.installErrors,onQuery:w.setQuery,onCompositionStart:w.beginComposition,onCompositionEnd:w.endComposition,onKind:w.setKind,onSearchSource:a=>{w.setSearchSource(a),"custom"!==a||w.registry||x.settings?.downloadSource.mode!=="custom"||w.setRegistry(x.settings.downloadSource.registry)},onRegistry:w.setRegistry,onDetail:a=>{R(),v.closeDetail(),s(""),u(!1),w.openDetail(S(a))},onInstall:a=>{w.prepareInstall(S(a),a=>v.requestInstall({source:`npm:${a.name}`,registry:a.registry},a))},onUpdate:a=>void v.execute({kind:"update",source:a}),onMore:w.loadMore,onRetry:w.retry,onDirectInstall:W})})]}),N?(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:E?(0,A.jsxs)("div",{className:"min-w-0 space-y-5",children:[(0,A.jsxs)("div",{className:"space-y-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[E.version?(0,A.jsxs)("span",{children:["v",E.version]}):null,E.updateAvailable?(0,A.jsx)("span",{className:"rounded-md bg-status-success/10 px-2 py-0.5 text-xs font-medium text-status-success",children:E.availableVersion?f("newVersion",{version:E.availableVersion}):f("updateAvailable")}):null]}),(0,A.jsx)(dv,{plugin:E,displayName:dy(E),browserError:E.pluginName?C.get(E.pluginName)??null:null,disabled:z,pending:J(E.source),browserRetryPending:v.requests.has(`entry:${E.pluginName}`),onAction:a=>v.handleControlAction(E,a)})]}),E.description?(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:(0,cx.fD)(E.description,g)}):null,(0,A.jsx)(dw,{plugin:E,requestError:v.errors[dz(E.source)],browserError:E.pluginName?C.get(E.pluginName)??null:null})]}),(0,A.jsxs)(cs.Nt,{className:"rounded-lg border",children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-9 w-full items-center justify-between px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[f("advancedOptions"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-3 px-3 pb-3",children:[E.source.startsWith("npm:")?(0,A.jsx)(iB,{value:E.updateTag??"latest",label:f("installChannel"),disabled:z||J(E.source),onChange:a=>void v.executeBatch({action:"tag",sources:[E.source],tag:a})}):null,(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:z||J(E.source)&&E.operation?.phase!=="waiting",onClick:()=>v.handleControlAction(E,"reload"),children:f("reloadOne")})]})})]}),v.detailLoading?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:f("loadingPackage")}):null,v.detail?.readme?(0,A.jsx)(iA,{readme:v.detail.readme},E.source):null,(0,A.jsxs)(cs.Nt,{className:"border-t pt-2",children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-9 w-full items-center justify-between text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[f("capabilityDetails"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsx)(de,{plugin:E,detail:v.detail,detailLoading:v.detailLoading,detailError:v.detailError,browserContributions:E.pluginName?v.pluginHost.getRegisteredBrowserDescriptors().find(a=>a.pluginName===E.pluginName)?.contributions??[]:[],onRetry:()=>void v.loadDetail(E.source)})})]}),v.detailError?(0,A.jsxs)("div",{role:"alert",className:"flex items-center gap-2 text-sm text-destructive",children:[(0,A.jsx)("span",{children:v.detailError}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",onClick:()=>void v.loadDetail(E.source),children:f("retry")})]}):null]}):w.selection?(0,A.jsxs)(A.Fragment,{children:[w.detailLoading?(0,A.jsx)("p",{role:"status",className:"mb-3 text-sm text-muted-foreground",children:f("loadingPackage")}):null,w.detailError?(0,A.jsxs)("div",{role:"alert",className:"mb-3 space-y-2 text-sm",children:[(0,A.jsx)("p",{className:"text-destructive [overflow-wrap:anywhere]",children:w.detailError}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",onClick:()=>void w.loadDetail(w.selection),children:f("retry")})]}):null,w.detail?(0,A.jsx)(iD,{detail:w.detail,disabled:z||!!w.detailError,pending:K||w.detailLoading,installed:!!(F&&(F.operation?.action!=="add"||"failed"!==F.operation.phase)),installedVersion:F?.version??null,updateAvailable:!!F?.updateAvailable,error:w.installErrors[w.detail.name]??v.errors[G]??(F?.operation?.phase==="failed"?F.operation.message:null),operationMessage:w.detailLoading?f("loadingPackage"):V(F?.operation?.phase),channel:r,onChannel:a=>{s(a),u(!1),w.loadDetail(w.selection,a||F?.updateTag||"latest")},downloadMode:w.downloadMode,downloadRegistry:w.downloadRegistry,onDownloadMode:w.setDownloadMode,onDownloadRegistry:w.setDownloadRegistry,onVersion:a=>{u(!0),w.loadDetail(w.selection,a)},onInstall:()=>w.installDetail((a,b)=>v.requestInstall({...a,source:t?a.source:`npm:${b.name}`,...r?{tag:r}:{}},b)),onUpdate:()=>{F&&v.execute({kind:"update",source:F.source})}}):null]}):(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:f("pluginRemoved")})}):null,(0,A.jsx)(iG,{confirmation:v.confirmation,onClose:()=>v.setConfirmation(null),onConfirm:a=>void v.execute(a)})]})}var iI=c(98945);let iJ=E.Yj().trim().min(1).max(2048),iK=E.YO(iJ).min(1).max(32),iL=E.Ik({phase:E.k5(["package","entry","setup","resources","resolve","native"]),message:cx.qf.refine(a=>"string"==typeof a?a.length>0:a.default.length>0)}).strict(),iM=E.Yj().trim().min(1).max(4096),iN=E.Yj().trim().min(1).max(256),iO=E.Yj().max(32768),iP=E.Ik({name:iN,label:iO,state:E.k5(["active","inactive","shadowed"]),description:iO,promptSnippet:iO.nullable(),promptGuidelineCount:E.ai().int().nonnegative(),promptGuidelinePreview:iO.nullable()}).strict(),iQ=E.Ik({name:iN,label:iO,state:E.k5(["active","inactive","shadowed"]),description:iO,parameters:iI.Dz,promptSnippet:iO.nullable(),promptGuidelines:E.YO(iO)}).strict(),iR=E.Ik({path:iM,events:E.YO(E.Ik({name:iN,count:E.ai().int().positive()}).strict()),commands:E.YO(E.Ik({name:iN,description:iO.nullable()}).strict()),shortcuts:E.YO(E.Ik({shortcut:iN,description:iO.nullable()}).strict()),flags:E.YO(E.Ik({name:iN,type:E.k5(["boolean","string"]),description:iO.nullable(),default:E.KC([E.zM(),E.Yj(),E.ch()])}).strict()),messageRenderers:E.YO(iN),entryRenderers:E.YO(iN)}).strict(),iS=E.Ik({name:iN,description:iO,path:iM}).strict(),iT=iS.extend({modelVisible:E.zM()}).strict(),iU=iS.extend({content:E.Yj().max(65536),truncated:E.zM()}).strict(),iV=iU.extend({modelVisible:E.zM()}).strict(),iW=E.Ik({name:iN,path:iM}).strict(),iX=E.Ik({name:iN,kind:E.k5(["config","native"])}).strict(),iY=E.Ik({methods:E.YO(E.Ik({pluginName:iN,method:iN}).strict()),browserEntries:E.YO(E.Ik({pluginName:iN}).strict()),messageDeclarations:E.YO(E.Ik({pluginName:iN,declarationName:iN,priority:E.ai().int().safe()}).strict())}).strict(),iZ=E.Ik({error:cx.qf.refine(a=>"string"==typeof a?a.length<=32768:[a.default,...Object.values(a.translations)].every(a=>a.length<=32768)).nullable(),extensions:E.YO(iR),tools:E.YO(iP),skills:E.YO(iT),prompts:E.YO(iS),themes:E.YO(iW),providers:E.YO(iX),piDesk:iY}).strict(),i$=E.Ik({action:E.k5(["add","update","del","apply","enable","disable"]),phase:E.k5(["queued","checking","applying","waiting","failed"]),message:E.Yj().max(4e3).nullable()}).strict(),i_=(0,F._G)({path:"plugins/management-update",bodySchema:E.Ik({}).strict()}),i0=E.Ik({source:iJ,kind:E.k5(["package","extension"]).default("package"),operation:i$.nullable().default(null),pluginName:E.Yj().trim().min(1).nullable(),description:cx.qf.nullable().default(null),version:E.Yj().trim().min(1).nullable(),updateAvailable:E.zM().nullable(),updateTag:dB.nullable().optional(),availableVersion:E.Yj().min(1).nullable().optional(),updateError:E.Yj().max(4e3).nullable().optional(),status:E.k5(["ready","available","disabled","failed"]),error:iL.nullable(),capabilities:iZ}).strict(),i1=E.Ik({source:iJ,readme:cx.qf.nullable().default(null),tools:E.YO(iQ),skills:E.YO(iV),prompts:E.YO(iU)}).strict(),i2=E.Ik({plugins:E.YO(i0),restartRequired:E.zM(),loadError:cx.qf.refine(a=>"string"==typeof a?a.length>0:a.default.length>0).nullable()}).strict(),i3=E.Ik({sources:E.YO(iJ).min(1).max(32).optional()}).strict(),i4=E.Ik({}).strict().extend({mode:E.k5(["normal","basic"]).optional()}).strict(),i5=E.Ik({checkUpdates:E.zM().optional(),sources:iK.optional(),tag:dB.optional()}).strict(),i6=E.Ik({source:iJ}).strict(),i7=i6.extend({downloadSource:dD.optional(),registry:dC.optional(),tag:dB.optional()}).strict(),i8=E.gM("action",[E.Ik({action:E.eu("add"),items:E.YO(i7).min(1).max(32)}).strict(),E.Ik({action:E.eu("update"),sources:iK}).strict(),E.Ik({action:E.eu("del"),sources:iK}).strict(),E.Ik({action:E.eu("tag"),sources:iK,tag:dB}).strict()]),i9=E.Ik({snapshot:i2,results:E.YO(E.Ik({source:iJ,error:E.Yj().max(4e3).nullable()}).strict()).max(32)}).strict(),ja=i6.extend({enabled:E.zM()}).strict();async function jb(a,b,c,d){return bX(a,b,c,d,{fallbackMessage:"插件管理请求失败"})}function jc({pluginName:a,descriptor:b,source:c,cwd:d,onPreviewFile:e,onRevealFile:f,onHeaderActionsChange:g}){let h=`${c.workId}\u0000${c.sessionId}\u0000${c.branchId}\u0000${d}`;return(0,A.jsx)(cu,{pluginName:a,kind:"session-sidebar-tab",contributionName:b.contributionName,target:{kind:"session-sidebar-tab",source:c,cwd:d,files:{preview:e,reveal:f},setHeaderActions:g},targetKey:h,layout:"fill"})}function jd({pluginName:a,descriptor:b,onClose:c,onBeforeLeaveChange:d}){let e=(0,bJ.t4)();(0,bJ.So)();let f=e.getEntryState(a);"ready"===f.status?f.runtime:f.status;let g=(0,B.useMemo)(()=>({kind:"settings-page",close:()=>{e.getEntryState(a)===f&&c()},setBeforeLeave:b=>{e.getEntryState(a)===f&&d(b)}}),[f,d,c,a,e]);return(0,A.jsx)(cu,{pluginName:a,kind:"settings-page",contributionName:b.contributionName,target:g,className:"pi-desk-chat-scrollbar h-full min-h-0 overflow-auto"})}function je({source:a,placement:b}){let{t:c}=(0,Q.Bd)("workbench"),d=(0,bJ.So)(),e=(0,B.useMemo)(()=>({kind:"widget",source:a}),[a]),f=JSON.stringify([a.workId,a.sessionId,a.branchId]),g=d.flatMap(a=>a.contributions.flatMap(c=>"widget"===c.kind&&c.placement===b?[{pluginName:a.pluginName,descriptor:c}]:[]));return 0===g.length?null:(0,A.jsx)("div",{"data-testid":`plugin-widgets-${b}`,"aria-label":c("composer"),className:"min-w-0 w-full",children:g.map(({pluginName:a,descriptor:b})=>(0,A.jsx)(cu,{pluginName:a,kind:"widget",contributionName:b.contributionName,target:e,targetKey:f,layout:"inline"},`${a}:${b.contributionName}:${f}`))})}function jf({pluginName:a,contributionName:b,presentation:c,source:d,icon:e,label:f,onSelected:g}){let h=(0,bJ.t4)();(0,bJ.So)();let i=h.getEntryState(a),j=(0,bK.G)(),{t:k}=(0,Q.Bd)("workbench"),l=(0,B.useRef)(null),m=(0,B.useRef)(!1),[n,o]=(0,B.useState)(!1),p=async()=>{let e=l.current;if(!e||e.signal.aborted||m.current)return;let f=()=>!e.signal.aborted&&h.getEntryState(a)===i;m.current=!0,o(!0);try{await h.invokeSessionHeaderAction({pluginName:a,contributionName:b,presentation:c,source:d,signal:e.signal}),f()&&g?.()}catch(g){if(!f())return;let e=g instanceof Error?g.message:k("operationFailed");console.error("[Pi Desk][PluginHost] 会话标题操作失败",{pluginName:a,contributionName:b,presentation:c,source:d,message:e}),j.error(e)}finally{f()&&(m.current=!1,o(!1))}};return(0,A.jsxs)(U.$,{type:"button",variant:"ghost",size:"sm","aria-label":f,"aria-busy":n,disabled:n,"data-testid":"plugin-session-header-action","data-plugin-name":a,"data-contribution-name":b,"data-presentation":c,className:(0,W.cn)("overflow"===c&&"w-full justify-start whitespace-normal text-left"),onClick:()=>void p(),children:[(0,A.jsx)(co,{icon:e,className:"size-4"}),(0,A.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:f})]})}function jg(a){return`${a.pluginName}:${a.descriptor.contributionName}`}function jh({item:a,source:b,presentation:c,onSelected:d,onContentChange:e}){let f=a.descriptor[c],g=(0,B.useMemo)(()=>({kind:"session-header-item",source:b,presentation:c}),[c,b]),h=JSON.stringify([b.workId,b.sessionId,b.branchId,c]),i=(0,B.useRef)(null),[j,k]=(0,B.useState)(!1);return"action"===f.type?(0,A.jsx)(jf,{pluginName:a.pluginName,contributionName:a.descriptor.contributionName,presentation:c,source:b,icon:f.icon,label:f.label,onSelected:d}):(0,A.jsx)("div",{"data-testid":"plugin-session-header-custom","data-plugin-name":a.pluginName,"data-contribution-name":a.descriptor.contributionName,"data-presentation":c,className:(0,W.cn)("min-w-0 shrink-0","overflow"===c&&"w-full",!j&&"pointer-events-none invisible absolute"),"aria-hidden":!j,inert:!j,style:"inline"===c&&"custom"===a.descriptor.inline.type?{width:`${a.descriptor.inline.minWidthRem}rem`}:void 0,children:(0,A.jsx)("div",{ref:i,children:(0,A.jsx)(cu,{pluginName:a.pluginName,kind:"session-header-item",contributionName:a.descriptor.contributionName,target:g,targetKey:h,layout:"inline"})})})}function ji({source:a,title:b}){let{t:c}=(0,Q.Bd)("workbench"),d=(0,bJ.So)(),e=(0,B.useMemo)(()=>d.flatMap(a=>a.contributions.flatMap(b=>"session-header-item"===b.kind?[{pluginName:a.pluginName,descriptor:b}]:[])),[d]),f=(0,B.useRef)(null),g=(0,B.useRef)(null),h=(0,B.useRef)(new Map),i=(0,B.useRef)(null),j=(0,B.useCallback)((a,b)=>{h.current.get(a)!==b&&(h.current.set(a,b),i.current?.())},[]),[k,l]=(0,B.useState)(null),[m,n]=(0,B.useState)(!1),o=k?.items===e?k.count:e.length,p=k?.items===e?k.occupied:e.some(a=>"action"===a.descriptor.inline.type),q=e.slice(0,o),r=e.slice(o);return(0,A.jsxs)("div",{ref:f,className:"relative flex min-w-0 flex-1 items-center","data-testid":"plugin-session-header",children:[(0,A.jsx)("div",{className:"min-w-[3rem] flex-1",children:b}),e.length>0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:(0,W.cn)("flex shrink-0 items-center gap-1",p&&"ml-1"),"data-testid":"session-header-items",children:[q.map(b=>(0,A.jsx)(jh,{item:b,source:a,presentation:"inline",onContentChange:j},jg(b))),r.length>0?(0,A.jsxs)(cq.AM,{open:m,onOpenChange:n,children:[(0,A.jsx)(cq.Wv,{render:(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":c("moreActions"),"data-testid":"session-header-more"}),children:(0,A.jsx)(an,{className:"size-4"})}),(0,A.jsxs)(cq.hl,{align:"end",finalFocus:!0,className:"pi-desk-chat-scrollbar max-h-[min(28rem,var(--available-height))] gap-1 overflow-auto p-1","data-testid":"session-header-overflow","aria-label":c("moreActions"),children:[(0,A.jsx)(cq.eO,{className:"sr-only",children:c("moreActions")}),m?r.map(b=>(0,A.jsx)(jh,{item:b,source:a,presentation:"overflow",onSelected:()=>n(!1)},jg(b))):null]})]}):null]}),(0,A.jsx)("div",{ref:g,"aria-hidden":"true",inert:!0,className:"pointer-events-none invisible absolute inset-0 overflow-hidden",children:(0,A.jsxs)("div",{className:"flex w-max items-center",children:[(0,A.jsx)("span",{"data-header-title-width":!0,className:"inline-block w-[3rem]"}),(0,A.jsx)("span",{"data-header-gap-width":!0,className:"inline-block w-1"}),(0,A.jsx)("span",{"data-header-more-width":!0,className:(0,U.r)({variant:"ghost",size:"icon-sm"}),children:(0,A.jsx)(an,{className:"size-4"})}),e.map(a=>"action"===a.descriptor.inline.type?(0,A.jsxs)("span",{"data-header-item-width":!0,className:(0,U.r)({variant:"ghost",size:"sm"}),children:[(0,A.jsx)(co,{icon:a.descriptor.inline.icon,className:"size-4"}),(0,A.jsx)("span",{children:a.descriptor.inline.label})]},jg(a)):(0,A.jsx)("span",{"data-header-item-width":!0,className:"inline-block shrink-0",style:{width:`${a.descriptor.inline.minWidthRem}rem`}},jg(a)))]})})]}):null]})}let jj=(0,S.A)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);var jk=c(91477);let jl=(0,S.A)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var jm=c(9665),jn=c(60816);let jo="1.1.30-dev".trim()||"未知",jp="2026-10-28T23:14:15+08:00".trim()||null;var jq=c(68578),jr=c(22207),js=c(79918),jt=c(82709),ju=c(96478),jv=c(23423),jw=c(51949);let jx=E.Yj().min(1).max(jw.uV).refine(a=>!a.includes("\0")&&(a.startsWith("/")||a.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(a)),"必须是绝对路径"),jy=E.Ik({cwd:jv.m4.nullable()}).strict(),jz=E.Ik({skillPath:jx,name:E.Yj().min(1),description:E.Yj(),packageSource:E.Yj().nullable()}).strict(),jA=E.Ik({skills:E.YO(jz),diagnostics:E.YO(E.Ik({path:E.Yj(),message:cx.qf}).strict())}).strict(),jB=jy.extend({skillPath:jx}),jC=jB.extend({path:jw.rh}).strict(),jD=E.Ik({entries:E.YO(E.Ik({name:E.Yj().min(1),type:E.k5(["directory","file"])}).strict()).max(jw.xm),truncated:E.zM()}).strict(),jE=jB.extend({path:jw._g}).strict(),jF=E.gM("kind",[E.Ik({kind:E.eu("text"),content:E.Yj(),size:E.ai().int().nonnegative().max(jw.NL),readOnlyReason:cx.qf.nullable()}).strict(),E.Ik({kind:E.eu("image"),mimeType:jw.CT,data:E.Yj(),size:E.ai().int().nonnegative()}).strict(),E.Ik({kind:E.eu("unsupported"),size:E.ai().int().nonnegative(),reason:E.Yj()}).strict()]),jG=jE.extend({content:E.Yj().max(jw.NL)}).strict(),jH=E.Ik({}).strict(),jI={path:"/api/skills/list",request:jy,response:jA},jJ={path:"/api/skill-files/list",request:jC,response:jD},jK={path:"/api/skill-files/get",request:jE,response:jF},jL={path:"/api/skill-files/replace",request:jG,response:jH},jM=E.Ik({code:E.ai(),msg:E.Yj(),data:E.L5(),i18n:jt.N.optional()});async function jN(a,b,c,d){let e=await fetch(b.path,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":a},body:JSON.stringify(b.request.parse(c)),signal:d}),f=jM.parse(await e.json());if(!e.ok||0!==f.code||null===f.data)throw Error(f.msg?(0,bW.B)(f):"Skills 请求失败");return b.response.parse(f.data)}function jO(a){(0,ju.ZQ)({wrapLines:a})}async function jP(a){let b=a.skillPath.replaceAll("\\","/");await navigator.clipboard.writeText(b.slice(0,b.lastIndexOf("/")+1)+a.path)}var jQ=c(60632);function jR(a){return(0,bW.B)({msg:jQ.P["zh-CN"][a],i18n:{key:`skills:${a}`}})}function jS(a){return JSON.stringify(a)}function jT(a){return JSON.stringify([a.cwd,a.skillPath,a.path])}function jU(a){return a.replace(/\r\n|\r/g,"\n")}function jV(a){return a?.file?.kind==="text"&&a.draft!==jU(a.file.content)}let jW=(0,S.A)("file-code",[["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:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),jX=(0,S.A)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);var jY=c(51314);function jZ(a){let{t:b}=(0,Q.Bd)("common"),{wrapLines:c}=(0,ju.TX)();a.path;let d=(0,B.useRef)(null);(0,B.useRef)(null),(0,B.useRef)(null),(0,B.useRef)(null),(0,B.useRef)(null),(0,B.useRef)(0),(0,B.useRef)(a);let[e,f]=(0,B.useState)(!1),[g,h]=(0,B.useState)(!1);return(0,A.jsxs)("div",{"data-testid":"code-editor",className:"relative h-full min-h-0 w-full overflow-hidden bg-background",children:[(0,A.jsx)("div",{ref:d,className:"size-full"}),!g&&(0,A.jsx)("div",{role:"status",className:"absolute inset-0 flex items-center justify-center p-6 text-sm text-muted-foreground",children:b(e?"editorFailed":"editorLoading")})]})}c(82386);var j$=c(85544);function j_({file:a,path:b}){let{t:c}=(0,Q.Bd)("skills"),d=(0,B.useMemo)(()=>[{src:`data:${a.mimeType};base64,${a.data}`,alt:b}],[a,b]);return(0,A.jsx)(j$.k,{mode:"inline",slides:d,className:"h-full w-full",ariaLabel:c("imagePreview")})}function j0(a){let{document:b,skill:c,dirty:d,loading:e,saving:f,opening:g}=a,{t:h}=(0,Q.Bd)("skills"),{locale:i}=(0,cy.i)();if(!b)return(0,A.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[(0,A.jsx)(jW,{className:"size-6 text-muted-foreground"}),(0,A.jsx)("h3",{className:"text-sm font-medium",children:h("chooseFile")}),(0,A.jsx)("p",{className:"max-w-xs text-sm leading-6 text-muted-foreground",children:h("chooseFileDescription")})]});let j=b.file,k=j?.kind==="text"?j.readOnlyReason:null;return(0,A.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,A.jsxs)("div",{className:"flex min-h-14 shrink-0 flex-wrap items-center gap-2 border-b px-4 py-2",children:[(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("p",{className:"truncate text-xs text-muted-foreground",title:c?.description,children:[c?.name??b.target.skillPath.split("/").at(-2),(0,A.jsx)("span",{className:"mx-1.5",children:"/"}),h(null===b.target.cwd?"global":"project"),` \xb7 ${h(c?.packageSource?"package":"local")}`]}),(0,A.jsx)("p",{className:"mt-1 truncate font-mono text-sm",title:b.target.path,children:b.target.path})]}),j?.kind==="text"&&(0,A.jsxs)("span",{role:"status","aria-label":h(f?"saving":g?"switchingFile":d?"unsavedChanges":k?"readOnlyFile":"fileSaved"),className:"hidden shrink-0 items-center gap-1 text-xs text-muted-foreground sm:flex",children:[f||g?(0,A.jsx)(R.A,{className:"size-3.5 animate-spin"}):d?(0,A.jsx)("span",{className:"size-1.5 rounded-full bg-status-warning"}):k?(0,A.jsx)(jX,{className:"size-3.5"}):(0,A.jsx)(bs.A,{className:"size-3.5"}),h(f?"saving":g?"switchingFile":d?"unsaved":k?"readOnly":"saved")]}),d&&(0,A.jsx)("span",{"aria-label":h("unsavedChanges"),className:"size-2 shrink-0 rounded-full bg-status-warning sm:hidden"}),(0,A.jsx)(U.$,{variant:"ghost",size:"icon","aria-label":h("copySkillPath"),title:h("copyPath"),onClick:a.onCopy,children:(0,A.jsx)(bM.A,{className:"size-4"})}),(0,A.jsxs)(U.$,{"aria-label":h("saveSkill"),disabled:!d||!!k||e||f,onClick:a.onSave,children:[f?(0,A.jsx)(R.A,{className:"size-4 animate-spin"}):(0,A.jsx)(bL,{className:"size-4"}),h("save")]})]}),k&&(0,A.jsxs)("div",{role:"note",className:"flex shrink-0 items-start gap-2 border-b bg-muted px-4 py-2 text-sm leading-5 text-muted-foreground",children:[(0,A.jsx)(jX,{className:"mt-0.5 size-3.5 shrink-0"}),(0,A.jsx)("p",{children:(0,cx.fD)(k,i)})]}),b.error&&(0,A.jsxs)("div",{role:"alert",className:"shrink-0 border-b bg-muted px-4 py-2 text-sm text-destructive",children:[b.error,!j&&(0,A.jsx)(U.$,{variant:"ghost",size:"sm",onClick:a.onReload,children:h("reload")})]}),(0,A.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:e&&!j?(0,A.jsxs)("div",{role:"status",className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"}),h("loadingFile")]}):j?.kind==="text"?(0,A.jsx)(jZ,{path:b.target.skillPath.slice(0,b.target.skillPath.lastIndexOf("/")+1)+b.target.path,content:b.draft,size:j.size,readOnly:!!k||f||g,onChange:a.onChange,onSave:a.onSave}):j?.kind==="image"?(0,A.jsx)(j_,{file:j,path:b.target.path}):j?.kind==="unsupported"?(0,A.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[(0,A.jsx)(jW,{className:"mb-2 size-8"}),(0,A.jsx)("p",{children:j.reason}),(0,A.jsx)("p",{children:h("fileSize",{size:j.size.toLocaleString("en"===i?"en-US":"zh-CN")})})]}):null}),j?.kind==="text"&&(0,A.jsxs)("div",{className:"flex min-h-9 shrink-0 items-center justify-between gap-2 border-t px-3 py-1 text-xs text-muted-foreground",children:[(0,A.jsxs)("span",{className:"truncate",children:["UTF-8 \xb7 ",h(k?"readOnly":"saveShortcut")]}),(0,A.jsxs)(U.$,{variant:"ghost",size:"sm","aria-label":h("wrapLines"),"aria-pressed":a.wrapLines,onClick:a.onWrapLines,children:[(0,A.jsx)(jY.A,{className:"size-3.5"}),h("wrapLines")]})]})]})}function j1({open:a,saving:b,path:c,error:d,onDecide:e}){let{t:f}=(0,Q.Bd)("skills");return(0,A.jsx)(b7.YV,{open:a,onOpenChange:a=>{a||b||e("cancel")},children:(0,A.jsxs)(b7.hA,{className:"z-[150]",showCloseButton:!b,children:[(0,A.jsxs)(b7.Hl,{className:"p-4 pr-12",children:[(0,A.jsx)(b7.YM,{children:f("saveChangesTitle")}),(0,A.jsx)(b7.uX,{children:f("saveChangesDescription",{path:c??""})})]}),d&&(0,A.jsx)("p",{role:"alert",className:"px-4 pb-4 text-sm text-destructive",children:d}),(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{variant:"outline",disabled:b,onClick:()=>void e("cancel"),children:f("cancel")}),(0,A.jsx)(U.$,{variant:"ghost",disabled:b,onClick:()=>void e("discard"),children:f("discard")}),(0,A.jsx)(U.$,{disabled:b,onClick:()=>void e("save"),children:f(b?"savingChanges":"saveContinue")})]})]})})}var j2=c(83401);let j3=(0,S.A)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var j4=c(89101);function j5(a,b){return!!(a&&a.cwd===b.cwd&&a.skillPath===b.skillPath&&a.path===b.path)}function j6({target:a,props:b,depth:c=0,skillName:d}){let{t:e}=(0,Q.Bd)("skills"),f=b.directories[jT(a)],{onLoadDirectory:g}=b;return f?.error?(0,A.jsxs)("div",{className:"px-3 py-2 text-xs text-destructive",children:[f.error,(0,A.jsx)(U.$,{variant:"ghost",size:"sm",onClick:()=>void b.onLoadDirectory(a),children:e("retryFolder")})]}):f?.data?(0,A.jsxs)("div",{className:"relative ml-5 border-l border-border/70 py-1 pl-3",children:[f.data.entries.map(f=>{let g=a.path?`${a.path}/${f.name}`:f.name,h={...a,path:g};if("directory"===f.type)return(0,A.jsx)(j7,{target:h,props:b,depth:c,name:f.name,skillName:d},g);let i=j5(b.selected,h),j=j5(b.pending,h);return(0,A.jsxs)(U.$,{variant:"ghost","aria-label":e("skillFile",{path:`${d}/${g}`}),"aria-pressed":i,title:g,className:(0,W.cn)("min-h-9 w-full justify-start text-left font-normal text-muted-foreground",i&&"font-medium",j&&"bg-muted text-foreground"),onClick:()=>void b.onOpenFile(h),children:["SKILL.md"===f.name?(0,A.jsx)(j2.A,{className:"size-3.5 shrink-0"}):(0,A.jsx)(jW,{className:"size-3.5 shrink-0"}),(0,A.jsx)("span",{className:"min-w-0 flex-1 truncate",children:f.name}),j&&(0,A.jsx)(R.A,{className:"size-3.5 shrink-0 animate-spin"})]},g)}),0===f.data.entries.length&&(0,A.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:e("emptyFolder")}),f.data.truncated&&(0,A.jsx)("p",{className:"px-3 py-2 text-sm text-status-warning",children:e("folderTruncated")})]}):(0,A.jsx)("p",{role:"status",className:"px-4 py-2 text-xs text-muted-foreground",children:e("loadingFolder")})}function j7({target:a,props:b,depth:c,name:d,skillName:e}){let{t:f}=(0,Q.Bd)("skills"),[g,h]=(0,B.useState)(!1);return(0,A.jsxs)("div",{children:[(0,A.jsxs)(U.$,{variant:"ghost","aria-expanded":g,"aria-label":f("skillFolder",{path:`${e}/${a.path}`}),className:(0,W.cn)("min-h-9 w-full justify-start font-normal text-muted-foreground",g&&"bg-muted text-foreground"),onClick:()=>h(!g),children:[g?(0,A.jsx)(cr.A,{className:"size-3.5 shrink-0"}):(0,A.jsx)(br.A,{className:"size-3.5 shrink-0"}),(0,A.jsx)(ch.A,{className:"size-3.5 shrink-0"}),(0,A.jsx)("span",{className:"truncate",children:d})]}),g&&(0,A.jsx)("div",{className:c>3?"-ml-3":void 0,children:(0,A.jsx)(j6,{target:a,props:b,depth:c+1,skillName:e})})]})}function j8({cwd:a,skill:b,props:c}){let{t:d}=(0,Q.Bd)("skills"),e=c.selected?.cwd===a&&c.selected.skillPath===b.skillPath,f=c.pending?.cwd===a&&c.pending.skillPath===b.skillPath,[g,h]=(0,B.useState)(null),i=g??e,j=async()=>{if(i)return void h(!1);let d=b.skillPath.replaceAll("\\","/").split("/").at(-1);await c.onOpenFile({cwd:a,skillPath:b.skillPath,path:d})&&h(!0)};return(0,A.jsxs)("div",{className:"py-0.5",children:[(0,A.jsxs)(U.$,{variant:"ghost","aria-label":d("skillName",{name:b.name}),"aria-expanded":i,title:`${b.description}
279
+ </iframe>`},"putIntoIFrame"),h2=(0,eQ.K)((a,b,c,d,e)=>{let f=a.append("div");f.attr("id",c),d&&f.attr("style",d);let g=f.append("svg").attr("id",b).attr("width","100%").attr("xmlns","http://www.w3.org/2000/svg");return e&&g.attr("xmlns:xlink",e),g.append("g"),a},"appendDivSvgG");function h3(a,b){return a.append("iframe").attr("id",b).attr("style","width: 100%; height: 100%;").attr("sandbox","")}(0,eQ.K)(h3,"sandboxedIframe");var h4=(0,eQ.K)((a,b,c,d)=>{a.getElementById(b)?.remove(),a.getElementById(c)?.remove(),a.getElementById(d)?.remove()},"removeExistingElements"),h5=(0,eQ.K)(async function(a,b,c){let d,e;hG();let f=hW(b);b=f.code;let g=(0,eO.zj)();eP.R.debug(g),b.length>(g?.maxTextSize??5e4)&&(b="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa");let h=`#${a}`,i="i"+a,j="#"+i,k="d"+a,l="#"+k,m=(0,eQ.K)(()=>{let a=o?j:l,b=(0,eS.Ltv)(a).node();b&&"remove"in b&&b.remove()},"removeTempElements"),n=(0,eS.Ltv)(document.body),o="sandbox"===g.securityLevel,p="loose"===g.securityLevel,q=g.fontFamily;if(void 0!==c){if(c&&(c.innerHTML=""),o){let a=h3((0,eS.Ltv)(c),i);(n=(0,eS.Ltv)(a.nodes()[0].contentDocument.body)).node().style.margin="0"}else n=(0,eS.Ltv)(c);h2(n,a,k,`font-family: ${q}`,"http://www.w3.org/1999/xlink")}else{if(h4(document,a,k,i),o){let a=h3((0,eS.Ltv)(document.body),i);(n=(0,eS.Ltv)(a.nodes()[0].contentDocument.body)).node().style.margin="0"}else n=(0,eS.Ltv)("body");h2(n,a,k)}try{d=await hK.fromText(b,{title:f.title})}catch(a){if(g.suppressErrorRendering)throw m(),a;d=await hK.fromText("error"),e=a}let r=n.select(l).node(),s=d.type,t=r.firstChild,u=t.firstChild,v=h_(g,s,d.renderer.getClasses?.(b,d),h),w=document.createElement("style");w.innerHTML=v,t.insertBefore(w,u);try{await d.renderer.draw(b,a,"11.16.1",d)}catch(c){throw g.suppressErrorRendering?m():gn.draw(b,a,"11.16.1"),c}h8(s,n.select(`${l} svg`),d.db.getAccTitle?.(),d.db.getAccDescription?.()),n.select(`[id="${a}"]`).selectAll("foreignobject > *").attr("xmlns","http://www.w3.org/1999/xhtml");let x=n.select(l).node().innerHTML;if(eP.R.debug("config.arrowMarkerAbsolute",g.arrowMarkerAbsolute),x=h0(x,o,(0,eO._3)(g.arrowMarkerAbsolute)),o?x=h1(x,n.select(l+" svg").node()):p||(x=fi.A.sanitize(x,{ADD_TAGS:hU,ADD_ATTR:hV,HTML_INTEGRATION_POINTS:{foreignobject:!0}})),hM(),e)throw e;return m(),{diagramType:s,svg:x,bindFunctions:d.db.bindFunctions}},"render");function h6(a={}){let b=(0,eO.hH)({},a);b?.fontFamily&&!b.themeVariables?.fontFamily&&(b.themeVariables||(b.themeVariables={}),b.themeVariables.fontFamily=b.fontFamily),(0,eO.wZ)(b),b?.theme&&b.theme in eO.H$?b.themeVariables=eO.H$[b.theme].getThemeVariables(b.themeVariables):b&&(b.themeVariables=eO.H$.default.getThemeVariables(b.themeVariables));let c="object"==typeof b?(0,eO.UU)(b):(0,eO.Q2)();(0,eP.H)(c.logLevel),hG()}(0,eQ.K)(h6,"initialize");var h7=(0,eQ.K)((a,b={})=>{let{code:c}=hS(a);return hK.fromText(c,b)},"getDiagramFromText");function h8(a,b,c,d){hI(b,a),hJ(b,c,d,b.attr("id"))}(0,eQ.K)(h8,"addA11yInfo");var h9=Object.freeze({render:h5,parse:hX,getDiagramFromText:h7,initialize:h6,getConfig:eO.zj,setConfig:eO.Nk,getSiteConfig:eO.Q2,updateSiteConfig:eO.B6,reset:(0,eQ.K)(()=>{(0,eO.cL)()},"reset"),globalReset:(0,eQ.K)(()=>{(0,eO.cL)(eO.sb)},"globalReset"),defaultConfig:eO.sb});(0,eP.H)((0,eO.zj)().logLevel),(0,eO.cL)((0,eO.zj)());var ia=(0,eQ.K)((a,b,c)=>{eP.R.warn(a),(0,eN.dq)(a)?(c&&c(a.str,a.hash),b.push({...a,message:a.str,error:a})):(c&&c(a),a instanceof Error&&b.push({str:a.message,message:a.message,hash:a.name,error:a}))},"handleError"),ib=(0,eQ.K)(async function(a={querySelector:".mermaid"}){try{await ic(a)}catch(b){if((0,eN.dq)(b)&&eP.R.error(b.str),iq.parseError&&iq.parseError(b),!a.suppressErrors)throw eP.R.error("Use the suppressErrors option to suppress these errors"),b}},"run"),ic=(0,eQ.K)(async function({postRenderCallback:a,querySelector:b,nodes:c}={querySelector:".mermaid"}){let d,e,f=h9.getConfig();if(eP.R.debug(`${!a?"No ":""}Callback function found`),c)d=c;else if(b)d=document.querySelectorAll(b);else throw Error("Nodes and querySelector are both undefined");eP.R.debug(`Found ${d.length} diagrams`),f?.startOnLoad!==void 0&&(eP.R.debug("Start On Load: "+f?.startOnLoad),h9.updateSiteConfig({startOnLoad:f?.startOnLoad}));let g=new eN._K.InitIDGenerator(f.deterministicIds,f.deterministicIDSeed),h=[];for(let b of Array.from(d)){if(eP.R.info("Rendering diagram: "+b.id),b.getAttribute("data-processed"))continue;b.setAttribute("data-processed","true");let c=`mermaid-${g.next()}`;e=b.innerHTML,e=(0,eR.T)(eN._K.entityDecode(e)).trim().replace(/<br\s*\/?>/gi,"<br/>");let d=eN._K.detectInit(e);d&&eP.R.debug("Detected early reinit: ",d);try{let{svg:d,bindFunctions:f}=await io(c,e,b);b.innerHTML=d,a&&await a(c),f&&f(b)}catch(a){ia(a,h,iq.parseError)}}if(h.length>0)throw h[0]},"runThrowsErrors"),id=(0,eQ.K)(function(a){h9.initialize(a)},"initialize"),ie=(0,eQ.K)(async function(a,b,c){eP.R.warn("mermaid.init is deprecated. Please use run instead."),a&&id(a);let d={postRenderCallback:c,querySelector:".mermaid"};"string"==typeof b?d.querySelector=b:b&&(b instanceof HTMLElement?d.nodes=[b]:d.nodes=b),await ib(d)},"init"),ig=(0,eQ.K)(async(a,{lazyLoad:b=!0}={})=>{hG(),(0,eO.Xd)(...a),!1===b&&await hH()},"registerExternalDiagrams"),ih=(0,eQ.K)(function(){if(iq.startOnLoad){let{startOnLoad:a}=h9.getConfig();a&&iq.run().catch(a=>eP.R.error("Mermaid failed to initialize",a))}},"contentLoaded");"u">typeof document&&window.addEventListener("load",ih,!1);var ii=(0,eQ.K)(function(a){iq.parseError=a},"setParseErrorHandler"),ij=[],ik=!1,il=(0,eQ.K)(async()=>{if(!ik){for(ik=!0;ij.length>0;){let a=ij.shift();if(a)try{await a()}catch(a){eP.R.error("Error executing queue",a)}}ik=!1}},"executeQueue"),im=(0,eQ.K)(async(a,b)=>new Promise((c,d)=>{let e=(0,eQ.K)(()=>new Promise((e,f)=>{h9.parse(a,b).then(a=>{e(a),c(a)},a=>{eP.R.error("Error parsing",a),iq.parseError?.(a),f(a),d(a)})}),"performCall");ij.push(e),il().catch(d)}),"parse"),io=(0,eQ.K)((a,b,c)=>new Promise((d,e)=>{let f=(0,eQ.K)(()=>new Promise((f,g)=>{h9.render(a,b,c).then(a=>{f(a),d(a)},a=>{eP.R.error("Error parsing",a),iq.parseError?.(a),g(a),e(a)})}),"performCall");ij.push(f),il().catch(e)}),"render"),ip=(0,eQ.K)(()=>Object.keys(eO.mW).map(a=>({id:a})),"getRegisteredDiagramsMetadata"),iq={startOnLoad:!0,mermaidAPI:h9,parse:im,render:io,init:ie,run:ib,registerExternalDiagrams:ig,registerLayoutLoaders:eL.sO,initialize:id,parseError:void 0,contentLoaded:ih,setParseErrorHandler:ii,detectType:eO.Ch,registerIconPacks:eM.pC,getRegisteredDiagramsMetadata:ip},ir={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0},is=function(a={}){let b=!1,c={...ir,...a.config},d={initialize(d){c={...ir,...a.config,...d},iq.initialize(c),b=!0},render:async(a,d)=>(b||(iq.initialize(c),b=!0),await iq.render(a,d))};return{name:"mermaid",type:"diagram",language:"mermaid",getMermaid:a=>(a&&d.initialize(a),d)}}(),it=c(38684);let iu=({className:a,from:b,...c})=>(0,A.jsx)("div",{className:(0,W.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===b?"is-user ml-auto justify-end":"is-assistant",a),...c}),iv=({children:a,className:b,...c})=>(0,A.jsx)("div",{className:(0,W.cn)("flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-base leading-[1.8]","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",b),...c,children:a}),iw=({tooltip:a,children:b,label:c,variant:d="ghost",size:e="icon-sm",...f})=>{let g=(0,A.jsxs)(U.$,{size:e,type:"button",variant:d,...f,children:[b,(0,A.jsx)("span",{className:"sr-only",children:c||a})]});return a?(0,A.jsx)(d_.Bc,{children:(0,A.jsxs)(d_.m_,{children:[(0,A.jsx)(d_.k$,{render:g}),(0,A.jsx)(d_.ZI,{children:(0,A.jsx)("p",{children:a})})]})}):g},ix={cjk:d0.h,code:d1.a,math:eI,mermaid:is},iy=(0,B.memo)(({className:a,...b})=>(0,A.jsx)(it.jH,{className:(0,W.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",a),plugins:ix,...b}),(a,b)=>a.children===b.children&&b.isAnimating===a.isAnimating);iy.displayName="MessageResponse";let iz=({className:a,children:b,...c})=>(0,A.jsx)("div",{className:(0,W.cn)("mt-4 flex w-full items-center justify-between gap-4",a),...c,children:b});function iA({readme:a}){let{t:b}=(0,Q.Bd)("pluginManagement"),{locale:c}=(0,cy.i)(),[d,e]=(0,B.useState)(null),f=a&&"string"!=typeof a?a.translations:{},g=Object.keys(f).filter(a=>/^(zh(?:-|$)|en(?:-|$))/.test(a)),h=d&&void 0!==f[d]?d:null,i=a?h?f[h]:(0,cx.fD)(a,c):null;return(0,A.jsxs)("section",{className:"min-w-0 space-y-3","aria-label":b("readme"),children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,A.jsx)("h3",{className:"text-sm font-semibold",children:b("readme")}),g.length>0?(0,A.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,A.jsx)("span",{children:b("readmeLanguage")}),(0,A.jsxs)(bS.l6,{value:h??"",onValueChange:a=>e(a||null),children:[(0,A.jsx)(bS.bq,{"aria-label":b("readmeLanguage"),children:(0,A.jsx)(bS.yv,{children:h?h.startsWith("zh")?"中文":"English":b("defaultLanguage")})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[160]",children:[(0,A.jsx)(bS.eb,{value:"",children:b("defaultLanguage")}),g.map(a=>(0,A.jsx)(bS.eb,{value:a,children:a.startsWith("zh")?"中文":"English"},a))]})]})]}):null]}),i?(0,A.jsx)("div",{className:"min-w-0 overflow-x-auto text-base leading-relaxed [overflow-wrap:anywhere]",children:(0,A.jsx)(iy,{mode:"static",isAnimating:!1,skipHtml:!0,controls:!1,className:"min-w-0 [&_img]:max-w-full [&_pre]:overflow-x-auto",children:i})}):(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:b("noReadme")})]})}function iB({value:a,label:b,placeholder:c,disabled:d,onChange:e}){let{t:f}=(0,Q.Bd)("pluginManagement"),g=[...c?[{value:"",label:c}]:[],{value:"latest",label:f("channelLatest")},{value:"dev",label:f("channelDev")},...a&&!["latest","dev"].includes(a)?[{value:a,label:a}]:[]];return(0,A.jsxs)(bS.l6,{value:a,items:g,onOpenChange:(a,b)=>{a&&d&&b.cancel()},onValueChange:a=>{null===a||d||e(a)},children:[(0,A.jsx)(bS.bq,{"aria-label":b,"aria-disabled":d,className:"max-w-full aria-disabled:opacity-50",children:(0,A.jsx)(bS.yv,{})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[160]",children:g.map(a=>(0,A.jsx)(bS.eb,{value:a.value,disabled:d,children:a.label},a.value))})]})}function iC(a){if(!a)return null;try{let b=new URL(a);return["https:","http:"].includes(b.protocol)?b.href:null}catch{return null}}function iD(a){let{t:b}=(0,Q.Bd)("pluginManagement"),{locale:c}=(0,cy.i)(),d=a.detail,e=a.installed&&a.installedVersion===d.version,f=iC(d.homepage),g=iC(d.repository),h=[...new Set([d.version,...d.versions])];return(0,A.jsxs)("div",{className:"min-w-0 space-y-5",children:[(0,A.jsxs)("div",{className:"space-y-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,A.jsxs)("span",{children:["v",d.version]}),(0,A.jsx)("span",{children:b(`kind_${d.kind}`)}),d.publisher?(0,A.jsx)("span",{className:"[overflow-wrap:anywhere]",children:d.publisher}):null]}),d.description?(0,A.jsx)("p",{className:"text-sm text-muted-foreground [overflow-wrap:anywhere]",children:(0,cx.fD)(d.description,c)}):null,!1===d.compatible?(0,A.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[b("incompatible"),d.compatibilityNote?` \xb7 ${d.compatibilityNote}`:""]}):null,(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[a.pending?(0,A.jsx)("span",{role:"status",className:"text-sm text-muted-foreground",children:a.operationMessage??b("submitting")}):e?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{className:"text-sm text-muted-foreground",children:b("alreadyInstalled")}),a.updateAvailable?(0,A.jsx)(U.$,{size:"sm",disabled:a.disabled,onClick:a.onUpdate,children:b("update")}):null]}):(0,A.jsx)(U.$,{size:"sm",disabled:a.disabled||!1===d.compatible,onClick:a.onInstall,children:b(a.installed?"installVersion":"install")}),f?(0,A.jsx)("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline underline-offset-4",children:b("homepage")}):null,g?(0,A.jsx)("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline underline-offset-4",children:b("repository")}):null]}),a.error?(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive [overflow-wrap:anywhere]",children:a.error}):null]}),(0,A.jsxs)(cs.Nt,{className:"rounded-lg border",children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-9 w-full items-center justify-between px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[b("advancedOptions"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsxs)("div",{className:"space-y-3 px-3 pb-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,A.jsx)("span",{children:b("installChannel")}),(0,A.jsx)(iB,{value:a.channel,label:b("installChannel"),placeholder:b("defaultChannel"),disabled:a.pending,onChange:a.onChannel}),(0,A.jsxs)(bS.l6,{value:d.version,items:h.map(a=>({value:a,label:a})),onOpenChange:(b,c)=>{b&&a.pending&&c.cancel()},onValueChange:b=>{b&&!a.pending&&a.onVersion(b)},children:[(0,A.jsx)(bS.bq,{"aria-label":b("version"),"aria-disabled":a.pending,children:(0,A.jsx)(bS.yv,{})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[160]",children:h.map(b=>(0,A.jsx)(bS.eb,{value:b,disabled:a.pending,children:b},b))})]})]}),(0,A.jsx)(dM,{id:"plugin-detail-download",mode:a.downloadMode,registry:a.downloadRegistry,override:!0,saving:a.pending,onMode:a.onDownloadMode,onRegistry:a.onDownloadRegistry})]})})]}),(0,A.jsx)("div",{className:"border-t pt-4",children:(0,A.jsx)(iA,{readme:d.readme},`${d.name}@${d.version}`)})]})}var iE=c(13221);function iF(a){let{t:b}=(0,Q.Bd)("pluginManagement");return(0,A.jsxs)("section",{"aria-label":b("directInstall"),className:"min-w-0 space-y-3 rounded-lg border bg-card p-4",children:[(0,A.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,A.jsx)("h3",{className:"text-sm font-semibold",children:b("directInstall")}),(0,A.jsx)(U.$,{size:"sm",variant:"ghost",onClick:a.onClose,children:b("close")})]}),(0,A.jsx)("label",{htmlFor:"plugin-direct-source",className:"block text-sm font-medium",children:b("source")}),(0,A.jsx)(iE.T,{id:"plugin-direct-source",value:a.source,placeholder:b("batchSourcePlaceholder"),rows:2,disabled:a.pending,onChange:b=>a.onSource(b.target.value)}),a.isNpm||a.multiple?(0,A.jsxs)(cs.Nt,{children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-8 items-center gap-2 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[b("advancedOptions"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsxs)("div",{className:"space-y-3 pt-2",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,A.jsx)("span",{children:b("installChannel")}),(0,A.jsx)(iB,{value:a.tag,label:b("installChannel"),placeholder:b("defaultChannel"),disabled:a.pending,onChange:a.onTag})]}),a.isNpm?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:a.loading,onClick:a.onRead,children:b(a.loading?"loadingPackage":"readPackage")}):null,a.detail?(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,A.jsx)("span",{className:"min-w-0 font-medium [overflow-wrap:anywhere]",children:a.detail.name}),(0,A.jsxs)(bS.l6,{value:a.selectedVersion,onOpenChange:(b,c)=>{b&&(a.loading||a.pending)&&c.cancel()},items:[{value:"",label:b("automaticVersion")},...[...new Set([a.detail.version,...a.detail.versions])].map(a=>({value:a,label:a}))],onValueChange:b=>{null===b||a.loading||a.pending||a.onVersion(b)},children:[(0,A.jsx)(bS.bq,{"aria-label":b("version"),"aria-disabled":a.loading||a.pending,className:"max-w-full",children:(0,A.jsx)(bS.yv,{})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[160]",children:[(0,A.jsx)(bS.eb,{value:"",disabled:a.loading||a.pending,children:b("automaticVersion")}),[...new Set([a.detail.version,...a.detail.versions])].map(b=>(0,A.jsx)(bS.eb,{value:b,disabled:a.loading||a.pending,children:b},b))]})]}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:b("targetVersion",{version:a.detail.version})})]}):null,(0,A.jsx)(dM,{id:"plugin-direct-download",mode:a.override,registry:a.registry,override:!0,saving:a.pending,onMode:a.onMode,onRegistry:a.onRegistry})]})})]}):null,a.error?(0,A.jsx)("p",{role:"alert",className:"text-sm whitespace-pre-wrap text-destructive [overflow-wrap:anywhere]",children:a.error}):null,a.operationMessage?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground [overflow-wrap:anywhere]",children:a.operationMessage}):null,(0,A.jsx)(U.$,{size:"sm",disabled:a.disabled||a.loading||a.pending||!a.source.trim(),onClick:a.onInstall,children:b(a.pending?"installing":a.multiple?"batchInstall":"install")})]})}function iG({confirmation:a,onClose:b,onConfirm:c}){let{t:d}=(0,Q.Bd)("pluginManagement"),e=a?d(dA(a)):null,f=a?.kind==="del"||a?.kind==="batch"&&"del"===a.input.action,g=a?.kind==="add"||a?.kind==="batch"&&"add"===a.input.action;return(0,A.jsx)(b7.YV,{open:!!a,onOpenChange:a=>{a||b()},children:(0,A.jsxs)(b7.hA,{className:"z-[150] max-w-lg",backdropClassName:"z-[140]",children:[(0,A.jsxs)(b7.Hl,{className:"p-4 pr-12",children:[(0,A.jsx)(b7.YM,{children:d("confirmAction",{action:e})}),(0,A.jsx)(b7.uX,{children:d(f?"removeDescription":g?"thirdPartyDescription":a?.kind==="reload"?"normal"===a.mode?"restartNormalDescription":"restartDescription":"confirmChange")})]}),(0,A.jsx)(b7._Y,{className:"min-h-0",children:(0,A.jsx)("div",{className:"min-w-0 p-4 pt-0",children:a?.kind==="batch"?(0,A.jsx)("ul",{className:"space-y-2 text-sm",children:("add"===a.input.action?a.input.items.map(a=>a.source):a.input.sources).map(a=>(0,A.jsx)("li",{className:"font-medium [overflow-wrap:anywhere]",children:a.startsWith("npm:")?dx(a)?.name??a:a},a))}):a?.kind==="add"?(0,A.jsxs)("dl",{className:"space-y-3 text-sm",children:[(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("packageName")}),(0,A.jsx)("dd",{className:"mt-1 font-medium [overflow-wrap:anywhere]",children:a.package?.name??a.input.source})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("version")}),(0,A.jsx)("dd",{className:"[overflow-wrap:anywhere]",children:a.package?.version??dx(a.input.source)?.version??d("fromSource")})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("publisher")}),(0,A.jsx)("dd",{className:"[overflow-wrap:anywhere]",children:a.package?.publisher??d("unknownPublisher")})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:d("source")}),(0,A.jsx)("dd",{className:"[overflow-wrap:anywhere]",children:a.input.registry??a.package?.registry??a.input.source})]})]}):a&&"reload"!==a.kind?(0,A.jsx)("p",{className:"text-sm font-medium [overflow-wrap:anywhere]",children:a.source.startsWith("npm:")?dx(a.source)?.name??a.source:a.source}):null})}),(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{size:"sm",variant:"outline",onClick:b,children:d("cancel")}),(0,A.jsx)(U.$,{size:"sm",variant:f?"destructive":"default",onClick:()=>{a&&c(a)},children:e})]})]})})}function iH({basicMode:a=!1,snapshot:b,biz:c,onSnapshot:d,onRestartScheduled:e}){let{t:f}=(0,Q.Bd)("pluginManagement"),{locale:g}=(0,cy.i)(),[h,i]=(0,B.useState)("installed"),[j,k]=(0,B.useState)(""),[l,m]=(0,B.useState)("all"),[n,o]=(0,B.useState)(!1),[p,q]=(0,B.useState)(()=>new Set),[r,s]=(0,B.useState)(""),[t,u]=(0,B.useState)(!1),v=function({basicMode:a=!1,biz:b,snapshot:c,onSnapshot:d,onRestartScheduled:e}){let{t:f}=(0,Q.Bd)("pluginManagement"),g=(0,bJ.t4)();(0,bJ.So)();let[h,i]=(0,B.useState)(!1),[j,k]=(0,B.useState)(()=>new Set),l=(0,B.useRef)(new Set),[m,n]=(0,B.useState)(null),[o,p]=(0,B.useState)({}),[q,r]=(0,B.useState)(null),[s,t]=(0,B.useState)(null),[u,v]=(0,B.useState)(!1),[w,x]=(0,B.useState)(null),y=(0,B.useRef)(0),z=(0,B.useRef)(0),A=(0,B.useRef)(!0),C=(a,b)=>{b?l.current.add(a):l.current.delete(a),A.current&&k(new Set(l.current))},D=(a,b)=>{A.current&&p(c=>{let d={...c};return b?d[a]=b:delete d[a],d})},E=a=>{let b=dz(a);return l.current.has(b)||!!c?.plugins.some(a=>dz(a.source)===b&&a.operation&&"failed"!==a.operation.phase)},F=async(a=!1)=>{let c=++z.current,e=await b.list(a);A.current&&c===z.current&&d(e)},G=async a=>{let c="add"===a.action?a.items.map(a=>a.source):a.sources,e=c.filter(a=>!E(a));if(c.filter(E).forEach(a=>D(dz(a),f("sourceBusy"))),!e.length)return;let g=e.map(dz);g.forEach(a=>{C(a,!0),D(a,null)}),n(null);let h=[...e];try{let c=await b.list(),e=Date.now()+9e5;for(;h.length;){let g=c.plugins.filter(a=>a.operation&&"failed"!==a.operation.phase),i="tag"===a.action?32:Math.max(0,32-g.length);if(!i){if(g.some(a=>a.operation?.phase==="waiting")||Date.now()>=e){h.forEach(a=>D(dz(a),f("batchWaiting")));break}await new Promise(a=>setTimeout(a,750)),c=await b.list(),A.current&&(z.current+=1,d(c));continue}let j=h.slice(0,i),k="add"===a.action?{...a,items:a.items.filter(a=>j.includes(a.source))}:{...a,sources:j},l=await b.batch(k);c=l.snapshot,A.current&&(z.current+=1,d(c)),l.results.forEach(a=>D(dz(a.source),a.error)),j.forEach(a=>C(dz(a),!1)),h=h.slice(j.length)}}catch(b){let a=b instanceof Error?b.message:f("batchFailed");h.forEach(b=>D(dz(b),a))}finally{g.forEach(a=>C(a,!1))}},H=async a=>{if("batch"===a.kind)return void await G(a.input);if("reload"!==a.kind&&E("add"===a.kind?a.input.source:a.source))return;let c="reload"===a.kind?"reload":dz("add"===a.kind?a.input.source:a.source);if(!l.current.has(c)){C(c,!0),n(null),D(c,null);try{let c="add"===a.kind?await b.add(a.input):"update"===a.kind?await b.update(a.source):"del"===a.kind?await b.del(a.source):"enable"===a.kind||"disable"===a.kind?await b.setEnabled(a.source,"enable"===a.kind):await b.reload(a.mode);if(!A.current)return;z.current+=1,d(c),"reload"===a.kind?e():await F()}catch(b){D(c,b instanceof Error?b.message:f("actionFailed",{action:f(dA(a))}))}finally{C(c,!1)}}},I=(a,b)=>{let c={kind:"add",input:a,package:b};b?.official===!0?H(c):n(c)},J=async a=>{let c=a?.[0]?dz(a[0]):"apply";if(!l.current.has(c)){C(c,!0),D(c,null);try{let c=await b.apply(a);A.current&&(z.current+=1,d(c),await F())}catch(a){D(c,a instanceof Error?a.message:f("actionFailed",{action:f("reloadOne")}))}finally{C(c,!1)}}},K=async(a,b)=>{if(!l.current.has(a)){C(a,!0),D(a,null);try{await b()}catch(b){D(a,b instanceof Error?b.message:f("retryFailed"))}finally{C(a,!1)}}},L=async a=>{let c=++y.current;v(!0),x(null);try{let d=await b.get(a);A.current&&c===y.current&&t(d)}catch(a){A.current&&c===y.current&&x(a instanceof Error?a.message:f("detailFailed"))}finally{A.current&&c===y.current&&v(!1)}};return{loading:h,requests:j,confirmation:m,setConfirmation:n,errors:o,detailSource:q,detail:s,detailLoading:u,detailError:w,pluginHost:g,refresh:async(a,b)=>{if(l.current.has("check"))return;let d=a??c?.plugins.filter(a=>"package"===a.kind&&(!b||a.updateTag===b)).map(a=>a.source)??[],e=d.filter(E),g=d.filter(a=>!E(a));if(e.forEach(a=>D(dz(a),f("sourceBusy"))),!g.length)return;let h=g.map(dz);C("check",!0),h.forEach(a=>C(a,!0)),i(!0),D("list",null);try{if(a||e.length)for(let a=0;a<g.length&&(await F({checkUpdates:!0,sources:g.slice(a,a+32),...b?{tag:b}:{}}),A.current);a+=32);else await F({checkUpdates:!0,...b?{tag:b}:{}})}catch(a){D("list",a instanceof Error?a.message:f("updateCheckFailed"))}finally{C("check",!1),h.forEach(a=>C(a,!1)),A.current&&i(!1)}},executeBatch:G,execute:H,requestInstall:I,applyChanges:J,loadDetail:L,openDetail:a=>{r(a),t(null),L(a)},closeDetail:()=>{y.current+=1,r(null),t(null),x(null),v(!1)},handleControlAction:(a,b)=>{switch(b){case"reload":J([a.source]);break;case"update":H({kind:"update",source:a.source});break;case"remove":n({kind:"del",source:a.source});break;case"enable":case"disable":H({kind:b,source:a.source});break;case"retry-browser":a.pluginName&&K(`entry:${a.pluginName}`,()=>g.retryEntry(a.pluginName));break;case"retry":{let b=a.operation?.action;"apply"===b?J([a.source]):"add"===b?I({source:a.source}):b&&H({kind:b,source:a.source})}}},refreshEntries:()=>K("entries",()=>g.refreshEntries())}}({biz:c,snapshot:b,onSnapshot:d,onRestartScheduled:e,basicMode:a}),w=function(a){let{t:b}=(0,Q.Bd)("pluginManagement"),[c,d]=(0,B.useState)(""),[e,f]=(0,B.useState)(!1),[g,h]=(0,B.useState)("all"),[i,j]=(0,B.useState)("public"),[k,l]=(0,B.useState)(""),[m,n]=(0,B.useState)([]),[o,p]=(0,B.useState)(!1),[q,r]=(0,B.useState)(1),[s,t]=(0,B.useState)(!1),[u,v]=(0,B.useState)(null),[w,x]=(0,B.useState)(!1),[y,z]=(0,B.useState)(null),[A,C]=(0,B.useState)(null),[D,E]=(0,B.useState)(!1),[F,G]=(0,B.useState)(null),[H,I]=(0,B.useState)(()=>new Set),[J,K]=(0,B.useState)({}),L=(0,B.useRef)(0),M=(0,B.useRef)(0),N=(0,B.useRef)(new Set),O=(0,B.useRef)(null),[P,R]=(0,B.useState)(!1),[S,T]=(0,B.useState)("default"),[U,V]=(0,B.useState)(""),W=(0,B.useRef)(!0),X=(0,B.useCallback)(async(c,d)=>{t(!0),v(null);try{let b=await a.searchCatalog(c);if(!W.current||d!==L.current)return;n(a=>{let d=1===c.page?b.items:[...a,...b.items],e=a=>a.official?0:"desk"===a.kind?1:"pi"===a.kind?2:3;return[...new Map(d.map(a=>[a.name,a])).values()].sort((a,b)=>e(a)-e(b))}),r(c.page),p(b.hasMore),x(!0)}catch(a){W.current&&d===L.current&&v(a instanceof Error?a.message:b("searchFailed"))}finally{W.current&&d===L.current&&t(!1)}},[a,b]),Y=async(c,d=c.version)=>{let e=++M.current;E(!0),G(null),K(a=>{let b={...a};return delete b[c.name],b});try{let b=await a.getCatalog({name:c.name,registry:c.registry,version:d});W.current&&e===M.current&&C(b)}catch(a){W.current&&e===M.current&&G(a instanceof Error?a.message:b("detailFailed"))}finally{W.current&&e===M.current&&E(!1)}};return{query:c,setQuery:d,composing:e,beginComposition:()=>{L.current+=1,O.current=null,t(!1),f(!0)},endComposition:()=>f(!1),kind:g,setKind:h,searchSource:i,setSearchSource:j,registry:k,setRegistry:l,items:m,loading:s,error:u,searched:w,hasMore:o,loadMore:()=>{O.current&&!s&&o&&X({...O.current,page:q+1},L.current)},retry:()=>{if(e||s)return;let a="custom"===i?dC.safeParse(k):null;if(a&&!a.success)return void v(b("invalidRegistry"));let d={query:c.trim(),kind:g,page:1,...a?.success?{registry:a.data}:{}};O.current=d,n([]),X(d,++L.current)},selection:y,detail:A,detailLoading:D,detailError:F,openDetail:a=>{z(a),C(null),T("default"),V(""),Y(a)},closeDetail:()=>{M.current+=1,z(null),C(null),E(!1),G(null)},loadDetail:Y,prepareInstall:async(c,d)=>{if(!N.current.has(c.name)){N.current.add(c.name),I(new Set(N.current)),K(a=>{let b={...a};return delete b[c.name],b});try{let e=await a.getCatalog({name:c.name,version:c.version,registry:c.registry});if(!W.current)return;if(!1===e.compatible)return void K(a=>({...a,[c.name]:b("installIncompatible")}));d(e)}catch(a){W.current&&K(d=>({...d,[c.name]:a instanceof Error?a.message:b("detailFailed")}))}finally{N.current.delete(c.name),W.current&&I(new Set(N.current))}}},preparing:H,installErrors:J,downloadMode:S,setDownloadMode:T,downloadRegistry:U,setDownloadRegistry:V,installDetail:a=>{if(!A||D)return;if(!1===A.compatible)return void K(a=>({...a,[A.name]:b("installIncompatible")}));let c="default"===S?null:dD.safeParse("custom"===S?{mode:S,registry:U}:{mode:S});c&&!c.success?K(a=>({...a,[A.name]:b("invalidRegistry")})):(K(a=>{let b={...a};return delete b[A.name],b}),a({source:`npm:${A.name}@${A.version}`,registry:A.registry,...c?.success?{downloadSource:c.data}:{}},A))}}}(c),x=function(a,b){let{t:c}=(0,Q.Bd)("pluginManagement"),[d,e]=(0,B.useState)(null),[f,g]=(0,B.useState)("auto"),[h,i]=(0,B.useState)(""),[j,k]=(0,B.useState)(!1),[l,m]=(0,B.useState)(!1),[n,o]=(0,B.useState)(null),p=(0,B.useRef)(!0),q=(0,B.useRef)(!1),r=(0,B.useRef)(0),s=(0,B.useRef)("load"),t=async()=>{let b=r.current;k(!0),o(null);try{let c=await a.getCatalogSettings();if(!p.current)return;b===r.current?(e(c),g(c.downloadSource.mode),"custom"===c.downloadSource.mode&&i(c.downloadSource.registry)):e(a=>a??c)}catch(a){s.current="load",p.current&&o(a instanceof Error?a.message:c("settingsFailed"))}finally{p.current&&k(!1)}},u=async(d=f)=>{if(q.current)return;let i=dD.safeParse("custom"===d?{mode:d,registry:h}:{mode:d});if(!i.success){s.current="save",o(c("invalidRegistry"));return}q.current=!0,m(!0),o(null);try{let c=await a.saveCatalogSettings(i.data);p.current&&(e(c),g(c.downloadSource.mode),b())}catch(a){s.current="save",p.current&&o(a instanceof Error?a.message:c("settingsFailed"))}finally{q.current=!1,p.current&&m(!1)}};return{settings:d,mode:f,registry:h,setRegistry:a=>{r.current+=1,i(a)},loading:j,saving:l,error:n,load:t,save:u,changeMode:a=>{r.current+=1,g(a),"custom"!==a&&u(a)},retry:()=>"save"===s.current?u():t()}}(c,()=>{a||v.refresh()}),y=function(a,b=[]){let{t:c}=(0,Q.Bd)("pluginManagement"),[d,e]=(0,B.useState)(!1),[f,g]=(0,B.useState)(""),[h,i]=(0,B.useState)(""),[j,k]=(0,B.useState)(null),[l,m]=(0,B.useState)(null),[n,o]=(0,B.useState)(!1),[p,q]=(0,B.useState)(null),[r,s]=(0,B.useState)("default"),[t,u]=(0,B.useState)(""),v=(0,B.useRef)(0),w=(0,B.useRef)(!0),x=f.split(/\r?\n/).map(a=>a.trim()).filter(Boolean),y=1===x.length?dx(x[0]):null,z=()=>{v.current+=1,m(null),o(!1),q(null)},A=async d=>{let e;if(!y)return null;void 0!==d&&k(d||null);let f=b.find(a=>dx(a.source)?.name===y.name)?.updateTag,g=y.version??(h||f||"latest"),i=""===d?g:d??j??g;if("custom"===r){let a=dC.safeParse(t);if(!a.success)return q(c("invalidRegistry")),null;e=a.data}else"official"===r?e="https://registry.npmjs.org":"domestic"===r&&(e="https://registry.npmmirror.com");let l=++v.current;o(!0),m(null),q(null);try{let b=await a.getCatalog({...y,...i?{version:i}:{},...e?{registry:e}:{}});if(!w.current||l!==v.current)return null;return m(b),b}catch(a){return w.current&&l===v.current&&q(a instanceof Error?a.message:c("detailFailed")),null}finally{w.current&&l===v.current&&o(!1)}},C=async(a,b)=>{if(!x.length||n)return;q(null);let d="default"===r?null:dD.safeParse("custom"===r?{mode:r,registry:t}:{mode:r});if(d&&!d.success)return void q(c("invalidRegistry"));let e={...h?{tag:h}:{},...d?.success?{downloadSource:d.data}:{}};if(x.length>1){let a=x.map(dx);if(x.length>32||a.some(a=>!a))return void q(c(x.length>32?"batchLimit":"batchNpmOnly"));let d=new Map;return a.forEach(a=>{a&&d.set(a.name,{source:`npm:${a.name}${a.version?`@${a.version}`:""}`,...e})}),void b([...d.values()])}if(!y)return void a({source:x[0]});let f=l?Promise.resolve(l):A(j??void 0),g=v.current,i=await f;if(i&&w.current&&g===v.current){if(!1===i.compatible)return void q(c("installIncompatible"));a({source:`npm:${i.name}${j||y.version?`@${j??y.version}`:""}`,registry:i.registry,...e},i)}};return{open:d,setOpen:e,source:f,sources:x,tag:h,selectedVersion:j??"",setTag:a=>{z(),k(null),i(a)},changeSource:a=>{z(),k(null),g(a)},spec:y,detail:l,loading:n,error:p,override:r,setOverride:a=>{z(),s(a)},registry:t,setRegistry:a=>{z(),u(a)},loadDetail:A,install:C}}(c,b?.plugins),z=a||v.requests.has("reload"),C=new Map(v.pluginHost.getFailedEntries().map(a=>[a.pluginName,a.error.message])),D=v.pluginHost.getEntryListError(),E=b?.plugins.find(a=>a.source===v.detailSource),F=w.selection?b?.plugins.find(a=>a.source.startsWith("npm:")&&dx(a.source)?.name===w.selection?.name):void 0,G=w.selection?dz(`npm:${w.selection.name}`):"",H=dz(y.detail?`npm:${y.detail.name}`:y.spec?`npm:${y.spec.name}`:y.source.trim()),I=b?.plugins.find(a=>dz(a.source)===H),J=a=>{let c=b?.plugins.find(b=>dz(b.source)===dz(a));return v.requests.has(dz(a))||!!(c?.operation&&"failed"!==c.operation.phase)},K=J(`npm:${w.selection?.name??""}`),L=y.sources.some(J),M=y.sources.map(a=>{let c=dz(a),d=b?.plugins.find(a=>dz(a.source)===c),e=v.errors[c]??(d?.operation?.phase==="failed"?d.operation.message:null);return e?`${a}: ${e}`:null}).filter(Boolean).join("\n"),N=!!(v.detailSource||w.selection),O=(0,B.useRef)(null),P=(0,B.useRef)(null),R=()=>{P.current=document.activeElement instanceof HTMLElement?document.activeElement:null},S=a=>{let c=b?.plugins.find(b=>dx(b.source)?.name===a.name);return{...a,version:c?.updateTag??"latest"}},T=a=>b?.plugins.filter(b=>"extension"!==b.kind&&!0===b.updateAvailable&&!J(b.source)&&(!a||p.has(dz(b.source)))).map(a=>a.source)??[],V=a=>a?f(`phase_${a}`):null,W=()=>{i("installed"),y.setOpen(!0)};return(0,A.jsxs)("div",{className:"flex h-full min-h-0 min-w-0 flex-col",children:[(0,A.jsxs)("header",{className:"shrink-0 space-y-3 border-b p-4 sm:px-6",children:[N?(0,A.jsxs)(U.$,{ref:O,size:"sm",variant:"ghost",className:"-ml-2",onClick:()=>{v.closeDetail(),w.closeDetail()},children:[(0,A.jsx)(Z.A,{}),f("backToList")]}):null,(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,A.jsx)("h2",{className:"min-w-0 text-xl font-semibold [overflow-wrap:anywhere]",children:N?E?dy(E):w.selection?.name??f("details"):f("title")}),(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[N?null:(0,A.jsxs)(cq.AM,{children:[(0,A.jsxs)(cq.Wv,{render:(0,A.jsx)(U.$,{size:"sm",variant:"ghost"}),children:[f("downloadSource"),":",x.loading&&!x.settings?f("loading"):f(`download_${x.settings?.downloadSource.mode??x.mode}`),(0,A.jsx)(cr.A,{className:"size-4"})]}),(0,A.jsx)(cq.hl,{align:"end",positionerClassName:"z-[150]",className:"w-80 max-w-[calc(100vw-2rem)]",children:(0,A.jsx)(dM,{id:"plugin-default-download",mode:x.mode,registry:x.registry,savedRegistry:x.settings?.downloadSource.mode==="custom"?x.settings.downloadSource.registry:void 0,recommendedRegistry:x.settings?.recommendedRegistry,loading:x.loading,saving:x.saving,error:x.error,onMode:a=>{"default"!==a&&x.changeMode(a)},onRegistry:x.setRegistry,onSave:()=>void x.save(),onRetry:()=>void x.retry()})})]}),a||b?.restartRequired?(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:v.requests.has("reload"),onClick:()=>v.setConfirmation({kind:"reload",mode:a?"normal":void 0}),children:f(a?"restartNormal":"restartApply")}):null]})]}),a?(0,A.jsx)("p",{role:"status",className:"rounded-lg bg-muted p-3 text-sm",children:f("basicModeNotice")}):null,b?.restartRequired?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:f("pendingRestart")}):null,b?.loadError||D?(0,A.jsxs)("div",{role:"alert",className:"max-h-32 space-y-1 overflow-y-auto text-sm text-destructive",children:[b?.loadError?(0,A.jsx)("p",{className:"[overflow-wrap:anywhere]",children:(0,cx.fD)(b.loadError,g)}):null,D?(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)("p",{className:"min-w-0 [overflow-wrap:anywhere]",children:D}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:v.requests.has("entries"),onClick:()=>void v.refreshEntries(),children:f("retry")})]}):null]}):null,v.errors.reload||v.errors.entries?(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive [overflow-wrap:anywhere]",children:v.errors.reload??v.errors.entries}):null]}),(0,A.jsxs)(cU,{value:h,onValueChange:a=>i(String(a)),className:`min-h-0 flex-1 gap-0 ${N?"hidden":""}`,children:[(0,A.jsx)("div",{className:"shrink-0 border-b px-4 pt-2 sm:px-6",children:(0,A.jsxs)(cW,{variant:"line","aria-label":f("title"),className:"h-9",children:[(0,A.jsxs)(cX,{value:"installed",className:"px-3",children:[f("installedTab"),b?(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:b.plugins.length}):null]}),(0,A.jsx)(cX,{value:"search",className:"px-3",children:f("searchPlugins")})]})}),(0,A.jsx)(cY,{value:"installed",keepMounted:!0,className:"flex min-h-0 flex-col overflow-hidden p-4 data-[hidden]:hidden sm:p-6",children:(0,A.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[y.open?(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar max-h-1/2 shrink-0 overflow-y-auto",children:(0,A.jsx)(iF,{source:y.source,isNpm:!!y.spec,multiple:y.sources.length>1,tag:y.tag,selectedVersion:y.selectedVersion,onTag:y.setTag,detail:y.detail,loading:y.loading,pending:L,disabled:z,error:y.error??(M||null),operationMessage:L?V(I?.operation?.phase)??f("submitting"):null,override:y.override,registry:y.registry,onSource:y.changeSource,onMode:y.setOverride,onRegistry:y.setRegistry,onRead:()=>void y.loadDetail(),onVersion:a=>void y.loadDetail(a),onInstall:()=>void y.install(v.requestInstall,a=>v.setConfirmation({kind:"batch",input:{action:"add",items:a}})),onClose:()=>y.setOpen(!1)})}):null,(0,A.jsx)(dX,{snapshot:b,loading:v.loading,filter:j,statusFilter:l,batchMode:n,selected:p,onStatusFilter:m,onBatchMode:a=>{o(a),a||q(new Set)},onSelect:(a,b)=>{q(c=>{let d=new Set(c);return a.forEach(a=>{b?d.add(a):d.delete(a)}),d})},onUpdateAll:()=>void v.executeBatch({action:"update",sources:T(!1)}),onUpdateSelected:()=>void v.executeBatch({action:"update",sources:T(!0)}),onRemoveSelected:()=>v.setConfirmation({kind:"batch",input:{action:"del",sources:b?.plugins.filter(a=>p.has(dz(a.source))&&!J(a.source)).map(a=>a.source)??[]}}),disabled:z,requests:v.requests,errors:v.errors,browserErrors:C,onFilter:k,onDetail:a=>{R(),w.closeDetail(),v.openDetail(a)},onAction:v.handleControlAction,onRefresh:()=>void v.refresh()}),b?.plugins.length||y.open?null:(0,A.jsx)(U.$,{size:"sm",variant:"outline",className:"shrink-0 self-start",disabled:z,onClick:W,children:f("directInstall")})]})}),(0,A.jsx)(cY,{value:"search",keepMounted:!0,className:"pi-desk-chat-scrollbar min-h-0 overflow-y-auto p-4 data-[hidden]:hidden sm:p-6",children:(0,A.jsx)(dY,{query:w.query,kind:w.kind,searchSource:w.searchSource,registry:w.registry,items:w.items,loading:w.loading,error:w.error,searched:w.searched,hasMore:w.hasMore,disabled:z,snapshot:b,requests:v.requests,preparing:w.preparing,errors:v.errors,installErrors:w.installErrors,onQuery:w.setQuery,onCompositionStart:w.beginComposition,onCompositionEnd:w.endComposition,onKind:w.setKind,onSearchSource:a=>{w.setSearchSource(a),"custom"!==a||w.registry||x.settings?.downloadSource.mode!=="custom"||w.setRegistry(x.settings.downloadSource.registry)},onRegistry:w.setRegistry,onDetail:a=>{R(),v.closeDetail(),s(""),u(!1),w.openDetail(S(a))},onInstall:a=>{w.prepareInstall(S(a),a=>v.requestInstall({source:`npm:${a.name}`,registry:a.registry},a))},onUpdate:a=>void v.execute({kind:"update",source:a}),onMore:w.loadMore,onRetry:w.retry,onDirectInstall:W})})]}),N?(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:E?(0,A.jsxs)("div",{className:"min-w-0 space-y-5",children:[(0,A.jsxs)("div",{className:"space-y-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[E.version?(0,A.jsxs)("span",{children:["v",E.version]}):null,E.updateAvailable?(0,A.jsx)("span",{className:"rounded-md bg-status-success/10 px-2 py-0.5 text-xs font-medium text-status-success",children:E.availableVersion?f("newVersion",{version:E.availableVersion}):f("updateAvailable")}):null]}),(0,A.jsx)(dv,{plugin:E,displayName:dy(E),browserError:E.pluginName?C.get(E.pluginName)??null:null,disabled:z,pending:J(E.source),browserRetryPending:v.requests.has(`entry:${E.pluginName}`),onAction:a=>v.handleControlAction(E,a)})]}),E.description?(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:(0,cx.fD)(E.description,g)}):null,(0,A.jsx)(dw,{plugin:E,requestError:v.errors[dz(E.source)],browserError:E.pluginName?C.get(E.pluginName)??null:null})]}),(0,A.jsxs)(cs.Nt,{className:"rounded-lg border",children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-9 w-full items-center justify-between px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[f("advancedOptions"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-3 px-3 pb-3",children:[E.source.startsWith("npm:")?(0,A.jsx)(iB,{value:E.updateTag??"latest",label:f("installChannel"),disabled:z||J(E.source),onChange:a=>void v.executeBatch({action:"tag",sources:[E.source],tag:a})}):null,(0,A.jsx)(U.$,{size:"sm",variant:"outline",disabled:z||J(E.source)&&E.operation?.phase!=="waiting",onClick:()=>v.handleControlAction(E,"reload"),children:f("reloadOne")})]})})]}),v.detailLoading?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:f("loadingPackage")}):null,v.detail?.readme?(0,A.jsx)(iA,{readme:v.detail.readme},E.source):null,(0,A.jsxs)(cs.Nt,{className:"border-t pt-2",children:[(0,A.jsxs)(cs.R6,{className:"group flex min-h-9 w-full items-center justify-between text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[f("capabilityDetails"),(0,A.jsx)(cr.A,{className:"size-4 transition-transform group-aria-expanded:rotate-180"})]}),(0,A.jsx)(cs.Ke,{keepMounted:!0,className:"hidden data-open:block",children:(0,A.jsx)(de,{plugin:E,detail:v.detail,detailLoading:v.detailLoading,detailError:v.detailError,browserContributions:E.pluginName?v.pluginHost.getRegisteredBrowserDescriptors().find(a=>a.pluginName===E.pluginName)?.contributions??[]:[],onRetry:()=>void v.loadDetail(E.source)})})]}),v.detailError?(0,A.jsxs)("div",{role:"alert",className:"flex items-center gap-2 text-sm text-destructive",children:[(0,A.jsx)("span",{children:v.detailError}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",onClick:()=>void v.loadDetail(E.source),children:f("retry")})]}):null]}):w.selection?(0,A.jsxs)(A.Fragment,{children:[w.detailLoading?(0,A.jsx)("p",{role:"status",className:"mb-3 text-sm text-muted-foreground",children:f("loadingPackage")}):null,w.detailError?(0,A.jsxs)("div",{role:"alert",className:"mb-3 space-y-2 text-sm",children:[(0,A.jsx)("p",{className:"text-destructive [overflow-wrap:anywhere]",children:w.detailError}),(0,A.jsx)(U.$,{size:"sm",variant:"outline",onClick:()=>void w.loadDetail(w.selection),children:f("retry")})]}):null,w.detail?(0,A.jsx)(iD,{detail:w.detail,disabled:z||!!w.detailError,pending:K||w.detailLoading,installed:!!(F&&(F.operation?.action!=="add"||"failed"!==F.operation.phase)),installedVersion:F?.version??null,updateAvailable:!!F?.updateAvailable,error:w.installErrors[w.detail.name]??v.errors[G]??(F?.operation?.phase==="failed"?F.operation.message:null),operationMessage:w.detailLoading?f("loadingPackage"):V(F?.operation?.phase),channel:r,onChannel:a=>{s(a),u(!1),w.loadDetail(w.selection,a||F?.updateTag||"latest")},downloadMode:w.downloadMode,downloadRegistry:w.downloadRegistry,onDownloadMode:w.setDownloadMode,onDownloadRegistry:w.setDownloadRegistry,onVersion:a=>{u(!0),w.loadDetail(w.selection,a)},onInstall:()=>w.installDetail((a,b)=>v.requestInstall({...a,source:t?a.source:`npm:${b.name}`,...r?{tag:r}:{}},b)),onUpdate:()=>{F&&v.execute({kind:"update",source:F.source})}}):null]}):(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:f("pluginRemoved")})}):null,(0,A.jsx)(iG,{confirmation:v.confirmation,onClose:()=>v.setConfirmation(null),onConfirm:a=>void v.execute(a)})]})}var iI=c(98945);let iJ=E.Yj().trim().min(1).max(2048),iK=E.YO(iJ).min(1).max(32),iL=E.Ik({phase:E.k5(["package","entry","setup","resources","resolve","native"]),message:cx.qf.refine(a=>"string"==typeof a?a.length>0:a.default.length>0)}).strict(),iM=E.Yj().trim().min(1).max(4096),iN=E.Yj().trim().min(1).max(256),iO=E.Yj().max(32768),iP=E.Ik({name:iN,label:iO,state:E.k5(["active","inactive","shadowed"]),description:iO,promptSnippet:iO.nullable(),promptGuidelineCount:E.ai().int().nonnegative(),promptGuidelinePreview:iO.nullable()}).strict(),iQ=E.Ik({name:iN,label:iO,state:E.k5(["active","inactive","shadowed"]),description:iO,parameters:iI.Dz,promptSnippet:iO.nullable(),promptGuidelines:E.YO(iO)}).strict(),iR=E.Ik({path:iM,events:E.YO(E.Ik({name:iN,count:E.ai().int().positive()}).strict()),commands:E.YO(E.Ik({name:iN,description:iO.nullable()}).strict()),shortcuts:E.YO(E.Ik({shortcut:iN,description:iO.nullable()}).strict()),flags:E.YO(E.Ik({name:iN,type:E.k5(["boolean","string"]),description:iO.nullable(),default:E.KC([E.zM(),E.Yj(),E.ch()])}).strict()),messageRenderers:E.YO(iN),entryRenderers:E.YO(iN)}).strict(),iS=E.Ik({name:iN,description:iO,path:iM}).strict(),iT=iS.extend({modelVisible:E.zM()}).strict(),iU=iS.extend({content:E.Yj().max(65536),truncated:E.zM()}).strict(),iV=iU.extend({modelVisible:E.zM()}).strict(),iW=E.Ik({name:iN,path:iM}).strict(),iX=E.Ik({name:iN,kind:E.k5(["config","native"])}).strict(),iY=E.Ik({methods:E.YO(E.Ik({pluginName:iN,method:iN}).strict()),browserEntries:E.YO(E.Ik({pluginName:iN}).strict()),messageDeclarations:E.YO(E.Ik({pluginName:iN,declarationName:iN,priority:E.ai().int().safe()}).strict())}).strict(),iZ=E.Ik({error:cx.qf.refine(a=>"string"==typeof a?a.length<=32768:[a.default,...Object.values(a.translations)].every(a=>a.length<=32768)).nullable(),extensions:E.YO(iR),tools:E.YO(iP),skills:E.YO(iT),prompts:E.YO(iS),themes:E.YO(iW),providers:E.YO(iX),piDesk:iY}).strict(),i$=E.Ik({action:E.k5(["add","update","del","apply","enable","disable"]),phase:E.k5(["queued","checking","applying","waiting","failed"]),message:E.Yj().max(4e3).nullable()}).strict(),i_=(0,F._G)({path:"plugins/management-update",bodySchema:E.Ik({}).strict()}),i0=E.Ik({source:iJ,kind:E.k5(["package","extension"]).default("package"),operation:i$.nullable().default(null),pluginName:E.Yj().trim().min(1).nullable(),description:cx.qf.nullable().default(null),version:E.Yj().trim().min(1).nullable(),updateAvailable:E.zM().nullable(),updateTag:dB.nullable().optional(),availableVersion:E.Yj().min(1).nullable().optional(),updateError:E.Yj().max(4e3).nullable().optional(),status:E.k5(["ready","available","disabled","failed"]),error:iL.nullable(),capabilities:iZ}).strict(),i1=E.Ik({source:iJ,readme:cx.qf.nullable().default(null),tools:E.YO(iQ),skills:E.YO(iV),prompts:E.YO(iU)}).strict(),i2=E.Ik({plugins:E.YO(i0),restartRequired:E.zM(),loadError:cx.qf.refine(a=>"string"==typeof a?a.length>0:a.default.length>0).nullable()}).strict(),i3=E.Ik({sources:E.YO(iJ).min(1).max(32).optional()}).strict(),i4=E.Ik({}).strict().extend({mode:E.k5(["normal","basic"]).optional()}).strict(),i5=E.Ik({checkUpdates:E.zM().optional(),sources:iK.optional(),tag:dB.optional()}).strict(),i6=E.Ik({source:iJ}).strict(),i7=i6.extend({downloadSource:dD.optional(),registry:dC.optional(),tag:dB.optional()}).strict(),i8=E.gM("action",[E.Ik({action:E.eu("add"),items:E.YO(i7).min(1).max(32)}).strict(),E.Ik({action:E.eu("update"),sources:iK}).strict(),E.Ik({action:E.eu("del"),sources:iK}).strict(),E.Ik({action:E.eu("tag"),sources:iK,tag:dB}).strict()]),i9=E.Ik({snapshot:i2,results:E.YO(E.Ik({source:iJ,error:E.Yj().max(4e3).nullable()}).strict()).max(32)}).strict(),ja=i6.extend({enabled:E.zM()}).strict();async function jb(a,b,c,d){return bX(a,b,c,d,{fallbackMessage:"插件管理请求失败"})}function jc({pluginName:a,descriptor:b,source:c,cwd:d,onPreviewFile:e,onRevealFile:f,onHeaderActionsChange:g}){let h=`${c.workId}\u0000${c.sessionId}\u0000${c.branchId}\u0000${d}`;return(0,A.jsx)(cu,{pluginName:a,kind:"session-sidebar-tab",contributionName:b.contributionName,target:{kind:"session-sidebar-tab",source:c,cwd:d,files:{preview:e,reveal:f},setHeaderActions:g},targetKey:h,layout:"fill"})}function jd({pluginName:a,descriptor:b,onClose:c,onBeforeLeaveChange:d}){let e=(0,bJ.t4)();(0,bJ.So)();let f=e.getEntryState(a);"ready"===f.status?f.runtime:f.status;let g=(0,B.useMemo)(()=>({kind:"settings-page",close:()=>{e.getEntryState(a)===f&&c()},setBeforeLeave:b=>{e.getEntryState(a)===f&&d(b)}}),[f,d,c,a,e]);return(0,A.jsx)(cu,{pluginName:a,kind:"settings-page",contributionName:b.contributionName,target:g,className:"pi-desk-chat-scrollbar h-full min-h-0 overflow-auto"})}function je({source:a,placement:b}){let{t:c}=(0,Q.Bd)("workbench"),d=(0,bJ.So)(),e=(0,B.useMemo)(()=>({kind:"widget",source:a}),[a]),f=JSON.stringify([a.workId,a.sessionId,a.branchId]),g=d.flatMap(a=>a.contributions.flatMap(c=>"widget"===c.kind&&c.placement===b?[{pluginName:a.pluginName,descriptor:c}]:[]));return 0===g.length?null:(0,A.jsx)("div",{"data-testid":`plugin-widgets-${b}`,"aria-label":c("composer"),className:"min-w-0 w-full",children:g.map(({pluginName:a,descriptor:b})=>(0,A.jsx)(cu,{pluginName:a,kind:"widget",contributionName:b.contributionName,target:e,targetKey:f,layout:"inline"},`${a}:${b.contributionName}:${f}`))})}function jf({pluginName:a,contributionName:b,presentation:c,source:d,icon:e,label:f,onSelected:g}){let h=(0,bJ.t4)();(0,bJ.So)();let i=h.getEntryState(a),j=(0,bK.G)(),{t:k}=(0,Q.Bd)("workbench"),l=(0,B.useRef)(null),m=(0,B.useRef)(!1),[n,o]=(0,B.useState)(!1),p=async()=>{let e=l.current;if(!e||e.signal.aborted||m.current)return;let f=()=>!e.signal.aborted&&h.getEntryState(a)===i;m.current=!0,o(!0);try{await h.invokeSessionHeaderAction({pluginName:a,contributionName:b,presentation:c,source:d,signal:e.signal}),f()&&g?.()}catch(g){if(!f())return;let e=g instanceof Error?g.message:k("operationFailed");console.error("[Pi Desk][PluginHost] 会话标题操作失败",{pluginName:a,contributionName:b,presentation:c,source:d,message:e}),j.error(e)}finally{f()&&(m.current=!1,o(!1))}};return(0,A.jsxs)(U.$,{type:"button",variant:"ghost",size:"sm","aria-label":f,"aria-busy":n,disabled:n,"data-testid":"plugin-session-header-action","data-plugin-name":a,"data-contribution-name":b,"data-presentation":c,className:(0,W.cn)("overflow"===c&&"w-full justify-start whitespace-normal text-left"),onClick:()=>void p(),children:[(0,A.jsx)(co,{icon:e,className:"size-4"}),(0,A.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:f})]})}function jg(a){return`${a.pluginName}:${a.descriptor.contributionName}`}function jh({item:a,source:b,presentation:c,onSelected:d,onContentChange:e}){let f=a.descriptor[c],g=(0,B.useMemo)(()=>({kind:"session-header-item",source:b,presentation:c}),[c,b]),h=JSON.stringify([b.workId,b.sessionId,b.branchId,c]),i=(0,B.useRef)(null),[j,k]=(0,B.useState)(!1);return"action"===f.type?(0,A.jsx)(jf,{pluginName:a.pluginName,contributionName:a.descriptor.contributionName,presentation:c,source:b,icon:f.icon,label:f.label,onSelected:d}):(0,A.jsx)("div",{"data-testid":"plugin-session-header-custom","data-plugin-name":a.pluginName,"data-contribution-name":a.descriptor.contributionName,"data-presentation":c,className:(0,W.cn)("min-w-0 shrink-0","overflow"===c&&"w-full",!j&&"pointer-events-none invisible absolute"),"aria-hidden":!j,inert:!j,style:"inline"===c&&"custom"===a.descriptor.inline.type?{width:`${a.descriptor.inline.minWidthRem}rem`}:void 0,children:(0,A.jsx)("div",{ref:i,children:(0,A.jsx)(cu,{pluginName:a.pluginName,kind:"session-header-item",contributionName:a.descriptor.contributionName,target:g,targetKey:h,layout:"inline"})})})}function ji({source:a,title:b}){let{t:c}=(0,Q.Bd)("workbench"),d=(0,bJ.So)(),e=(0,B.useMemo)(()=>d.flatMap(a=>a.contributions.flatMap(b=>"session-header-item"===b.kind?[{pluginName:a.pluginName,descriptor:b}]:[])),[d]),f=(0,B.useRef)(null),g=(0,B.useRef)(null),h=(0,B.useRef)(new Map),i=(0,B.useRef)(null),j=(0,B.useCallback)((a,b)=>{h.current.get(a)!==b&&(h.current.set(a,b),i.current?.())},[]),[k,l]=(0,B.useState)(null),[m,n]=(0,B.useState)(!1),o=k?.items===e?k.count:e.length,p=k?.items===e?k.occupied:e.some(a=>"action"===a.descriptor.inline.type),q=e.slice(0,o),r=e.slice(o);return(0,A.jsxs)("div",{ref:f,className:"relative flex min-w-0 flex-1 items-center","data-testid":"plugin-session-header",children:[(0,A.jsx)("div",{className:"min-w-[3rem] flex-1",children:b}),e.length>0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:(0,W.cn)("flex shrink-0 items-center gap-1",p&&"ml-1"),"data-testid":"session-header-items",children:[q.map(b=>(0,A.jsx)(jh,{item:b,source:a,presentation:"inline",onContentChange:j},jg(b))),r.length>0?(0,A.jsxs)(cq.AM,{open:m,onOpenChange:n,children:[(0,A.jsx)(cq.Wv,{render:(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":c("moreActions"),"data-testid":"session-header-more"}),children:(0,A.jsx)(an,{className:"size-4"})}),(0,A.jsxs)(cq.hl,{align:"end",finalFocus:!0,className:"pi-desk-chat-scrollbar max-h-[min(28rem,var(--available-height))] gap-1 overflow-auto p-1","data-testid":"session-header-overflow","aria-label":c("moreActions"),children:[(0,A.jsx)(cq.eO,{className:"sr-only",children:c("moreActions")}),m?r.map(b=>(0,A.jsx)(jh,{item:b,source:a,presentation:"overflow",onSelected:()=>n(!1)},jg(b))):null]})]}):null]}),(0,A.jsx)("div",{ref:g,"aria-hidden":"true",inert:!0,className:"pointer-events-none invisible absolute inset-0 overflow-hidden",children:(0,A.jsxs)("div",{className:"flex w-max items-center",children:[(0,A.jsx)("span",{"data-header-title-width":!0,className:"inline-block w-[3rem]"}),(0,A.jsx)("span",{"data-header-gap-width":!0,className:"inline-block w-1"}),(0,A.jsx)("span",{"data-header-more-width":!0,className:(0,U.r)({variant:"ghost",size:"icon-sm"}),children:(0,A.jsx)(an,{className:"size-4"})}),e.map(a=>"action"===a.descriptor.inline.type?(0,A.jsxs)("span",{"data-header-item-width":!0,className:(0,U.r)({variant:"ghost",size:"sm"}),children:[(0,A.jsx)(co,{icon:a.descriptor.inline.icon,className:"size-4"}),(0,A.jsx)("span",{children:a.descriptor.inline.label})]},jg(a)):(0,A.jsx)("span",{"data-header-item-width":!0,className:"inline-block shrink-0",style:{width:`${a.descriptor.inline.minWidthRem}rem`}},jg(a)))]})})]}):null]})}let jj=(0,S.A)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);var jk=c(91477);let jl=(0,S.A)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var jm=c(9665),jn=c(60816);let jo="1.1.31-dev".trim()||"未知",jp="2026-10-29T01:47:38+08:00".trim()||null;var jq=c(68578),jr=c(22207),js=c(79918),jt=c(82709),ju=c(96478),jv=c(23423),jw=c(51949);let jx=E.Yj().min(1).max(jw.uV).refine(a=>!a.includes("\0")&&(a.startsWith("/")||a.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(a)),"必须是绝对路径"),jy=E.Ik({cwd:jv.m4.nullable()}).strict(),jz=E.Ik({skillPath:jx,name:E.Yj().min(1),description:E.Yj(),packageSource:E.Yj().nullable()}).strict(),jA=E.Ik({skills:E.YO(jz),diagnostics:E.YO(E.Ik({path:E.Yj(),message:cx.qf}).strict())}).strict(),jB=jy.extend({skillPath:jx}),jC=jB.extend({path:jw.rh}).strict(),jD=E.Ik({entries:E.YO(E.Ik({name:E.Yj().min(1),type:E.k5(["directory","file"])}).strict()).max(jw.xm),truncated:E.zM()}).strict(),jE=jB.extend({path:jw._g}).strict(),jF=E.gM("kind",[E.Ik({kind:E.eu("text"),content:E.Yj(),size:E.ai().int().nonnegative().max(jw.NL),readOnlyReason:cx.qf.nullable()}).strict(),E.Ik({kind:E.eu("image"),mimeType:jw.CT,data:E.Yj(),size:E.ai().int().nonnegative()}).strict(),E.Ik({kind:E.eu("unsupported"),size:E.ai().int().nonnegative(),reason:E.Yj()}).strict()]),jG=jE.extend({content:E.Yj().max(jw.NL)}).strict(),jH=E.Ik({}).strict(),jI={path:"/api/skills/list",request:jy,response:jA},jJ={path:"/api/skill-files/list",request:jC,response:jD},jK={path:"/api/skill-files/get",request:jE,response:jF},jL={path:"/api/skill-files/replace",request:jG,response:jH},jM=E.Ik({code:E.ai(),msg:E.Yj(),data:E.L5(),i18n:jt.N.optional()});async function jN(a,b,c,d){let e=await fetch(b.path,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":a},body:JSON.stringify(b.request.parse(c)),signal:d}),f=jM.parse(await e.json());if(!e.ok||0!==f.code||null===f.data)throw Error(f.msg?(0,bW.B)(f):"Skills 请求失败");return b.response.parse(f.data)}function jO(a){(0,ju.ZQ)({wrapLines:a})}async function jP(a){let b=a.skillPath.replaceAll("\\","/");await navigator.clipboard.writeText(b.slice(0,b.lastIndexOf("/")+1)+a.path)}var jQ=c(60632);function jR(a){return(0,bW.B)({msg:jQ.P["zh-CN"][a],i18n:{key:`skills:${a}`}})}function jS(a){return JSON.stringify(a)}function jT(a){return JSON.stringify([a.cwd,a.skillPath,a.path])}function jU(a){return a.replace(/\r\n|\r/g,"\n")}function jV(a){return a?.file?.kind==="text"&&a.draft!==jU(a.file.content)}let jW=(0,S.A)("file-code",[["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:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),jX=(0,S.A)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);var jY=c(51314);function jZ(a){let{t:b}=(0,Q.Bd)("common"),{wrapLines:c}=(0,ju.TX)();a.path;let d=(0,B.useRef)(null);(0,B.useRef)(null),(0,B.useRef)(null),(0,B.useRef)(null),(0,B.useRef)(null),(0,B.useRef)(0),(0,B.useRef)(a);let[e,f]=(0,B.useState)(!1),[g,h]=(0,B.useState)(!1);return(0,A.jsxs)("div",{"data-testid":"code-editor",className:"relative h-full min-h-0 w-full overflow-hidden bg-background",children:[(0,A.jsx)("div",{ref:d,className:"size-full"}),!g&&(0,A.jsx)("div",{role:"status",className:"absolute inset-0 flex items-center justify-center p-6 text-sm text-muted-foreground",children:b(e?"editorFailed":"editorLoading")})]})}c(82386);var j$=c(85544);function j_({file:a,path:b}){let{t:c}=(0,Q.Bd)("skills"),d=(0,B.useMemo)(()=>[{src:`data:${a.mimeType};base64,${a.data}`,alt:b}],[a,b]);return(0,A.jsx)(j$.k,{mode:"inline",slides:d,className:"h-full w-full",ariaLabel:c("imagePreview")})}function j0(a){let{document:b,skill:c,dirty:d,loading:e,saving:f,opening:g}=a,{t:h}=(0,Q.Bd)("skills"),{locale:i}=(0,cy.i)();if(!b)return(0,A.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[(0,A.jsx)(jW,{className:"size-6 text-muted-foreground"}),(0,A.jsx)("h3",{className:"text-sm font-medium",children:h("chooseFile")}),(0,A.jsx)("p",{className:"max-w-xs text-sm leading-6 text-muted-foreground",children:h("chooseFileDescription")})]});let j=b.file,k=j?.kind==="text"?j.readOnlyReason:null;return(0,A.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,A.jsxs)("div",{className:"flex min-h-14 shrink-0 flex-wrap items-center gap-2 border-b px-4 py-2",children:[(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("p",{className:"truncate text-xs text-muted-foreground",title:c?.description,children:[c?.name??b.target.skillPath.split("/").at(-2),(0,A.jsx)("span",{className:"mx-1.5",children:"/"}),h(null===b.target.cwd?"global":"project"),` \xb7 ${h(c?.packageSource?"package":"local")}`]}),(0,A.jsx)("p",{className:"mt-1 truncate font-mono text-sm",title:b.target.path,children:b.target.path})]}),j?.kind==="text"&&(0,A.jsxs)("span",{role:"status","aria-label":h(f?"saving":g?"switchingFile":d?"unsavedChanges":k?"readOnlyFile":"fileSaved"),className:"hidden shrink-0 items-center gap-1 text-xs text-muted-foreground sm:flex",children:[f||g?(0,A.jsx)(R.A,{className:"size-3.5 animate-spin"}):d?(0,A.jsx)("span",{className:"size-1.5 rounded-full bg-status-warning"}):k?(0,A.jsx)(jX,{className:"size-3.5"}):(0,A.jsx)(bs.A,{className:"size-3.5"}),h(f?"saving":g?"switchingFile":d?"unsaved":k?"readOnly":"saved")]}),d&&(0,A.jsx)("span",{"aria-label":h("unsavedChanges"),className:"size-2 shrink-0 rounded-full bg-status-warning sm:hidden"}),(0,A.jsx)(U.$,{variant:"ghost",size:"icon","aria-label":h("copySkillPath"),title:h("copyPath"),onClick:a.onCopy,children:(0,A.jsx)(bM.A,{className:"size-4"})}),(0,A.jsxs)(U.$,{"aria-label":h("saveSkill"),disabled:!d||!!k||e||f,onClick:a.onSave,children:[f?(0,A.jsx)(R.A,{className:"size-4 animate-spin"}):(0,A.jsx)(bL,{className:"size-4"}),h("save")]})]}),k&&(0,A.jsxs)("div",{role:"note",className:"flex shrink-0 items-start gap-2 border-b bg-muted px-4 py-2 text-sm leading-5 text-muted-foreground",children:[(0,A.jsx)(jX,{className:"mt-0.5 size-3.5 shrink-0"}),(0,A.jsx)("p",{children:(0,cx.fD)(k,i)})]}),b.error&&(0,A.jsxs)("div",{role:"alert",className:"shrink-0 border-b bg-muted px-4 py-2 text-sm text-destructive",children:[b.error,!j&&(0,A.jsx)(U.$,{variant:"ghost",size:"sm",onClick:a.onReload,children:h("reload")})]}),(0,A.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:e&&!j?(0,A.jsxs)("div",{role:"status",className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"}),h("loadingFile")]}):j?.kind==="text"?(0,A.jsx)(jZ,{path:b.target.skillPath.slice(0,b.target.skillPath.lastIndexOf("/")+1)+b.target.path,content:b.draft,size:j.size,readOnly:!!k||f||g,onChange:a.onChange,onSave:a.onSave}):j?.kind==="image"?(0,A.jsx)(j_,{file:j,path:b.target.path}):j?.kind==="unsupported"?(0,A.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[(0,A.jsx)(jW,{className:"mb-2 size-8"}),(0,A.jsx)("p",{children:j.reason}),(0,A.jsx)("p",{children:h("fileSize",{size:j.size.toLocaleString("en"===i?"en-US":"zh-CN")})})]}):null}),j?.kind==="text"&&(0,A.jsxs)("div",{className:"flex min-h-9 shrink-0 items-center justify-between gap-2 border-t px-3 py-1 text-xs text-muted-foreground",children:[(0,A.jsxs)("span",{className:"truncate",children:["UTF-8 \xb7 ",h(k?"readOnly":"saveShortcut")]}),(0,A.jsxs)(U.$,{variant:"ghost",size:"sm","aria-label":h("wrapLines"),"aria-pressed":a.wrapLines,onClick:a.onWrapLines,children:[(0,A.jsx)(jY.A,{className:"size-3.5"}),h("wrapLines")]})]})]})}function j1({open:a,saving:b,path:c,error:d,onDecide:e}){let{t:f}=(0,Q.Bd)("skills");return(0,A.jsx)(b7.YV,{open:a,onOpenChange:a=>{a||b||e("cancel")},children:(0,A.jsxs)(b7.hA,{className:"z-[150]",showCloseButton:!b,children:[(0,A.jsxs)(b7.Hl,{className:"p-4 pr-12",children:[(0,A.jsx)(b7.YM,{children:f("saveChangesTitle")}),(0,A.jsx)(b7.uX,{children:f("saveChangesDescription",{path:c??""})})]}),d&&(0,A.jsx)("p",{role:"alert",className:"px-4 pb-4 text-sm text-destructive",children:d}),(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{variant:"outline",disabled:b,onClick:()=>void e("cancel"),children:f("cancel")}),(0,A.jsx)(U.$,{variant:"ghost",disabled:b,onClick:()=>void e("discard"),children:f("discard")}),(0,A.jsx)(U.$,{disabled:b,onClick:()=>void e("save"),children:f(b?"savingChanges":"saveContinue")})]})]})})}var j2=c(83401);let j3=(0,S.A)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var j4=c(89101);function j5(a,b){return!!(a&&a.cwd===b.cwd&&a.skillPath===b.skillPath&&a.path===b.path)}function j6({target:a,props:b,depth:c=0,skillName:d}){let{t:e}=(0,Q.Bd)("skills"),f=b.directories[jT(a)],{onLoadDirectory:g}=b;return f?.error?(0,A.jsxs)("div",{className:"px-3 py-2 text-xs text-destructive",children:[f.error,(0,A.jsx)(U.$,{variant:"ghost",size:"sm",onClick:()=>void b.onLoadDirectory(a),children:e("retryFolder")})]}):f?.data?(0,A.jsxs)("div",{className:"relative ml-5 border-l border-border/70 py-1 pl-3",children:[f.data.entries.map(f=>{let g=a.path?`${a.path}/${f.name}`:f.name,h={...a,path:g};if("directory"===f.type)return(0,A.jsx)(j7,{target:h,props:b,depth:c,name:f.name,skillName:d},g);let i=j5(b.selected,h),j=j5(b.pending,h);return(0,A.jsxs)(U.$,{variant:"ghost","aria-label":e("skillFile",{path:`${d}/${g}`}),"aria-pressed":i,title:g,className:(0,W.cn)("min-h-9 w-full justify-start text-left font-normal text-muted-foreground",i&&"font-medium",j&&"bg-muted text-foreground"),onClick:()=>void b.onOpenFile(h),children:["SKILL.md"===f.name?(0,A.jsx)(j2.A,{className:"size-3.5 shrink-0"}):(0,A.jsx)(jW,{className:"size-3.5 shrink-0"}),(0,A.jsx)("span",{className:"min-w-0 flex-1 truncate",children:f.name}),j&&(0,A.jsx)(R.A,{className:"size-3.5 shrink-0 animate-spin"})]},g)}),0===f.data.entries.length&&(0,A.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:e("emptyFolder")}),f.data.truncated&&(0,A.jsx)("p",{className:"px-3 py-2 text-sm text-status-warning",children:e("folderTruncated")})]}):(0,A.jsx)("p",{role:"status",className:"px-4 py-2 text-xs text-muted-foreground",children:e("loadingFolder")})}function j7({target:a,props:b,depth:c,name:d,skillName:e}){let{t:f}=(0,Q.Bd)("skills"),[g,h]=(0,B.useState)(!1);return(0,A.jsxs)("div",{children:[(0,A.jsxs)(U.$,{variant:"ghost","aria-expanded":g,"aria-label":f("skillFolder",{path:`${e}/${a.path}`}),className:(0,W.cn)("min-h-9 w-full justify-start font-normal text-muted-foreground",g&&"bg-muted text-foreground"),onClick:()=>h(!g),children:[g?(0,A.jsx)(cr.A,{className:"size-3.5 shrink-0"}):(0,A.jsx)(br.A,{className:"size-3.5 shrink-0"}),(0,A.jsx)(ch.A,{className:"size-3.5 shrink-0"}),(0,A.jsx)("span",{className:"truncate",children:d})]}),g&&(0,A.jsx)("div",{className:c>3?"-ml-3":void 0,children:(0,A.jsx)(j6,{target:a,props:b,depth:c+1,skillName:e})})]})}function j8({cwd:a,skill:b,props:c}){let{t:d}=(0,Q.Bd)("skills"),e=c.selected?.cwd===a&&c.selected.skillPath===b.skillPath,f=c.pending?.cwd===a&&c.pending.skillPath===b.skillPath,[g,h]=(0,B.useState)(null),i=g??e,j=async()=>{if(i)return void h(!1);let d=b.skillPath.replaceAll("\\","/").split("/").at(-1);await c.onOpenFile({cwd:a,skillPath:b.skillPath,path:d})&&h(!0)};return(0,A.jsxs)("div",{className:"py-0.5",children:[(0,A.jsxs)(U.$,{variant:"ghost","aria-label":d("skillName",{name:b.name}),"aria-expanded":i,title:`${b.description}
280
280
  ${b.skillPath}`,className:(0,W.cn)("min-h-14 w-full justify-start whitespace-normal text-left",i&&"bg-accent hover:bg-accent",e&&"text-foreground"),onClick:()=>void j(),children:[i?(0,A.jsx)(cr.A,{className:"size-3.5 shrink-0 text-muted-foreground"}):(0,A.jsx)(br.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)("p",{className:"truncate text-sm font-medium",children:b.name}),b.description&&(0,A.jsx)("p",{className:"mt-0.5 truncate text-xs font-normal text-muted-foreground",children:b.description})]}),f?(0,A.jsx)(R.A,{className:"size-3.5 shrink-0 animate-spin text-muted-foreground"}):b.packageSource?(0,A.jsx)(j3,{"aria-label":d("packageSkill"),className:"size-3.5 shrink-0 text-muted-foreground"}):null]}),i&&(0,A.jsx)(j6,{target:{cwd:a,skillPath:b.skillPath,path:""},props:c,skillName:b.name})]})}function j9({cwd:a,name:b,props:c}){let{t:d}=(0,Q.Bd)("skills"),{locale:e}=(0,cy.i)(),f=c.selected?.cwd===a||c.pending?.cwd===a,[g,h]=(0,B.useState)(null),{onLoadScope:i}=c,j=c.scopes[jS(a)],k=c.query.trim().toLowerCase(),l=g??(null===a||c.focusedCwd===a||f),m=l||!!k,n=`${b} ${a??""}`.toLowerCase().includes(k),o=j?.data?.skills.filter(a=>!k||n||`${a.name} ${a.description}`.toLowerCase().includes(k))??[];if(k&&j?.data&&!o.length&&!n&&!j.error)return null;let p=null===a;return(0,A.jsxs)("section",{className:"mx-2 mt-2 min-w-0 border-b pb-2","aria-label":p?d("globalSkills"):d("projectSkills",{name:b}),children:[(0,A.jsxs)(U.$,{variant:"ghost",className:"min-h-14 w-full justify-start text-left","aria-label":d("skillsGroup",{name:p?d("global"):b}),"aria-expanded":m,onClick:()=>h(!l),children:[m?(0,A.jsx)(cr.A,{className:"size-4 shrink-0"}):(0,A.jsx)(br.A,{className:"size-4 shrink-0"}),p?(0,A.jsx)(cl,{className:"size-4 shrink-0 text-primary"}):(0,A.jsx)(ch.A,{className:"size-4 shrink-0 text-muted-foreground"}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)("p",{className:"truncate text-sm font-semibold",children:p?d("globalSkills"):b}),a&&(0,A.jsx)("p",{title:a,className:"mt-1 truncate text-xs font-normal text-muted-foreground",children:a})]}),j?.loading?(0,A.jsx)(R.A,{className:"size-3.5 shrink-0 animate-spin text-muted-foreground"}):j?.data?(0,A.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground",children:k?o.length:j.data.skills.length}):null]}),m&&(0,A.jsxs)("div",{className:"px-1 py-1",children:[j?.error&&(0,A.jsxs)("p",{className:"px-3 py-2 text-xs text-destructive",children:[j.error,(0,A.jsx)(U.$,{variant:"ghost",size:"sm",onClick:()=>void c.onLoadScope(a),children:d("retryGroup")})]}),o.map(b=>(0,A.jsx)(j8,{cwd:a,skill:b,props:c},b.skillPath)),j?.data&&0===o.length&&!j.error&&(0,A.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:d(k?"noSkillMatches":"noSkills")}),!!j?.data?.diagnostics.length&&(0,A.jsxs)("details",{className:"mx-2 mb-1 mt-2 rounded-md bg-muted p-2 text-sm text-muted-foreground",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-status-warning",children:d("diagnostics",{count:j.data.diagnostics.length})}),(0,A.jsx)("div",{className:"mt-2 space-y-3",children:j.data.diagnostics.map((a,b)=>(0,A.jsxs)("div",{children:[(0,A.jsx)("p",{className:"break-words",children:(0,cx.fD)(a.message,e)}),(0,A.jsx)("p",{className:"mt-1 break-all text-xs",children:a.path})]},`${a.path}:${b}`))})]})]})]})}function ka(a){let{t:b}=(0,Q.Bd)("skills");return(0,A.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,A.jsx)("div",{className:"shrink-0 border-b p-3",children:(0,A.jsxs)(j4.MG,{children:[(0,A.jsx)(j4.Sq,{children:(0,A.jsx)(bZ.A,{className:"size-4"})}),(0,A.jsx)(j4.iV,{"aria-label":b("searchSkills"),value:a.query,onChange:b=>a.onQuery(b.target.value),placeholder:b("searchSkillsPlaceholder")})]})}),(0,A.jsxs)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain pb-4",children:[(0,A.jsx)(j9,{cwd:null,name:b("global"),props:a}),(0,A.jsxs)("div",{className:"flex items-center gap-2 px-4 pb-1 pt-5",children:[(0,A.jsx)("span",{className:"h-px flex-1 bg-border"}),(0,A.jsx)("p",{className:"shrink-0 text-xs font-medium text-muted-foreground",children:b("workspaceCount",{count:a.projects.length})}),(0,A.jsx)("span",{className:"h-px flex-1 bg-border"})]}),a.projects.map(b=>(0,A.jsx)(j9,{cwd:b.cwd,name:b.projectName,props:a},b.cwd)),0===a.projects.length&&(0,A.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:b("workspaceEmpty")})]})]})}function kb({projects:a,focusedCwd:b,onBeforeLeaveChange:c}){let{t:d}=(0,Q.Bd)("skills"),{clientId:e}=(0,bR.gM)(),f=(0,bK.G)(),g=(0,B.useMemo)(()=>({list:(a,b)=>jN(e,jI,a,b),listFiles:(a,b)=>jN(e,jJ,a,b),getFile:(a,b)=>jN(e,jK,a,b),async replaceFile(a){await jN(e,jL,a)}}),[e]),h=function(a,b){let[c,d]=(0,B.useState)({}),[e,f]=(0,B.useState)({}),g=(0,B.useRef)(new Map),h=(0,B.useRef)(!0),i=(0,B.useCallback)(async b=>{let c=jS(b),e=`scope:${c}`;g.current.get(e)?.abort();let f=new AbortController;g.current.set(e,f),d(a=>({...a,[c]:{data:a[c]?.data??null,loading:!0,error:null}}));try{let e=await a.list({cwd:b},f.signal);!f.signal.aborted&&h.current&&d(a=>({...a,[c]:{data:e,loading:!1,error:null}}))}catch(a){!f.signal.aborted&&h.current&&d(b=>({...b,[c]:{data:b[c]?.data??null,loading:!1,error:a instanceof Error?a.message:jR("skillsReadFailed")}}))}finally{g.current.get(e)===f&&g.current.delete(e)}},[a]),j=(0,B.useCallback)(async b=>{let c=jT(b),d=`directory:${c}`;g.current.get(d)?.abort();let e=new AbortController;g.current.set(d,e),f(a=>({...a,[c]:{data:a[c]?.data??null,loading:!0,error:null}}));try{let d=await a.listFiles(b,e.signal);!e.signal.aborted&&h.current&&f(a=>({...a,[c]:{data:d,loading:!1,error:null}}))}catch(a){!e.signal.aborted&&h.current&&f(b=>({...b,[c]:{data:null,loading:!1,error:a instanceof Error?a.message:jR("directoryReadFailed")}}))}finally{g.current.get(d)===e&&g.current.delete(d)}},[a]);return JSON.stringify(b.map(a=>a.cwd)),{scopes:c,directories:e,loadScope:i,loadDirectory:j}}(g,a),{loadScope:i}=h,j=function(a,b){let{wrapLines:c}=(0,ju.TX)(),[d,e]=(0,B.useState)(null),f=(0,B.useRef)(null),g=(0,B.useRef)(!0),[h,i]=(0,B.useState)(!1),[j,k]=(0,B.useState)(null),[l,m]=(0,B.useState)(!1),n=(0,B.useRef)(null),o=(0,B.useRef)(!1),p=(0,B.useRef)(null),[q,r]=(0,B.useState)(!1),s=(0,B.useRef)(null),t=(0,B.useCallback)(a=>{g.current&&(f.current=a,e(a))},[]),u=(0,B.useCallback)(()=>{if(n.current)return n.current;let c=f.current;if(!c||c.file?.kind!=="text"||c.file.readOnlyReason)return Promise.resolve(!1);if(!jV(c))return Promise.resolve(!0);m(!0);let d=(async()=>{try{await a.replaceFile({...c.target,content:c.draft});let d=f.current;return d?.file?.kind==="text"&&d.target===c.target&&t({...d,file:{...d.file,content:c.draft},error:null}),g.current&&b(c.target.cwd),!0}catch(b){let a=f.current;return a?.target===c.target&&t({...a,error:b instanceof Error?b.message:jR("saveFailed")}),!1}finally{n.current=null,g.current&&m(!1)}})();return n.current=d,d},[t,a,b]),v=(0,B.useCallback)(async()=>{let a;if(n.current&&await n.current,!g.current)return!1;if(!jV(f.current))return!0;if(s.current)return s.current.promise;let b=new Promise(b=>{a=b});return s.current={promise:b,resolve:a},r(!0),b},[]),w=(0,B.useCallback)(async a=>{if(!s.current||n.current||"save"===a&&(!await u()||jV(f.current)))return;if("discard"===a){let a=f.current;a?.file?.kind==="text"&&t({...a,draft:jU(a.file.content),error:null})}let b=s.current;s.current=null,r(!1),b?.resolve("cancel"!==a)},[t,u]),x=(0,B.useCallback)(async b=>{if(o.current)return!1;o.current=!0;try{if(!await v()||!g.current)return!1;p.current?.abort();let c=new AbortController;p.current=c,k(b),i(!0);try{let d=await a.getFile(b,c.signal);if(c.signal.aborted||!g.current)return!1;return t({target:b,file:d,draft:"text"===d.kind?jU(d.content):"",error:null}),!0}catch(a){if(!c.signal.aborted){let c=f.current,d=a instanceof Error?a.message:jR("fileReadFailed");t(c?{...c,error:d}:{target:b,file:null,draft:"",error:d})}return!1}finally{g.current&&(k(null),i(!1))}}finally{o.current=!1}},[t,v,a]),y=(0,B.useCallback)(a=>{let b=f.current;b?.file?.kind!=="text"||b.file.readOnlyReason||b.draft===a||t({...b,draft:a})},[t]),z=jV(d);return{document:d,dirty:z,loading:h,openingTarget:j,saving:l,confirmOpen:q,wrapLines:c,setWrapLines:jO,change:y,open:x,save:u,beforeLeave:v,decide:w}}(g,(0,B.useCallback)(a=>{i(a)},[i])),{document:k,open:l}=j,[m,n]=(0,B.useState)(""),[o,p]=(0,B.useState)(!1),[q,r]=(0,B.useState)(!0);(0,B.useRef)(!1),(0,B.useRef)(b);let s=(0,B.useCallback)(async a=>{let b=await l(a);return b&&p(!1),b},[l]),t=async()=>{if(j.document)try{await jP(j.document.target),f.success(d("pathCopied"))}catch{f.error(d("copyFailed"))}},u=j.document?.target??null,v=u?h.scopes[jS(u.cwd)]?.data?.skills.find(a=>a.skillPath===u.skillPath)??null:null,w=Object.values(h.scopes).some(a=>a.loading)||Object.values(h.directories).some(a=>a.loading),x={projects:a,focusedCwd:b,query:m,onQuery:n,scopes:h.scopes,directories:h.directories,selected:u,pending:j.openingTarget,onLoadScope:h.loadScope,onLoadDirectory:h.loadDirectory,onOpenFile:s};return(0,A.jsxs)("section",{"aria-label":d("skillsManagement"),className:"flex h-full min-h-0 flex-col bg-background",children:[(0,A.jsxs)("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-4 py-2",children:[(0,A.jsx)(U.$,{variant:"ghost",size:"icon",className:"lg:hidden","aria-label":d("openSkillsFolder"),onClick:()=>p(!0),children:(0,A.jsx)(jm.A,{className:"size-4"})}),(0,A.jsx)(U.$,{variant:"ghost",size:"icon",className:"hidden lg:inline-flex","aria-label":d(q?"collapseSkillsFolder":"expandSkillsFolder"),onClick:()=>r(!q),children:q?(0,A.jsx)(jr.A,{className:"size-4"}):(0,A.jsx)(js.A,{className:"size-4"})}),(0,A.jsx)("h2",{className:"text-xl font-semibold",children:"Skills"}),(0,A.jsx)("div",{className:"flex-1"}),(0,A.jsxs)(U.$,{variant:"ghost",size:"sm",disabled:w,"aria-label":d("refreshSkillsFolder"),onClick:()=>{for(let a of Object.keys(h.scopes))h.loadScope(JSON.parse(a));for(let a of Object.keys(h.directories)){let[b,c,d]=JSON.parse(a);h.loadDirectory({cwd:b,skillPath:c,path:d})}},children:[w?(0,A.jsx)(R.A,{className:"size-3.5 animate-spin"}):(0,A.jsx)(bO.A,{className:"size-3.5"}),d("refreshFolder")]})]}),(0,A.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,A.jsx)("aside",{"aria-label":d("skillsProjectFolder"),className:(0,W.cn)("hidden w-64 shrink-0 border-r bg-sidebar xl:w-72",q&&"lg:block"),children:(0,A.jsx)(ka,{...x})}),(0,A.jsx)("main",{className:"min-h-0 min-w-0 flex-1",children:(0,A.jsx)(j0,{document:j.document,skill:v,dirty:j.dirty,loading:j.loading,saving:j.saving,opening:!!j.openingTarget,wrapLines:j.wrapLines,onWrapLines:()=>j.setWrapLines(!j.wrapLines),onChange:j.change,onSave:()=>void j.save(),onReload:()=>{u&&s(u)},onCopy:()=>void t()})})]}),(0,A.jsx)(b7.YV,{open:o,onOpenChange:p,children:(0,A.jsxs)(b7.hA,{className:"left-0 top-[var(--pi-desk-window-inset)] z-[130] h-[var(--pi-desk-content-height)] max-h-[var(--pi-desk-content-height)] w-[min(360px,calc(100dvw-2rem))] max-w-none translate-x-0 translate-y-0 rounded-l-none",finalFocus:!1,children:[(0,A.jsx)(b7.Hl,{className:"shrink-0 border-b px-4 py-3 pr-12",children:(0,A.jsx)(b7.YM,{children:d("skillsFolderTitle")})}),(0,A.jsx)("div",{className:"min-h-0 flex-1",children:(0,A.jsx)(ka,{...x})})]})}),(0,A.jsx)(j1,{open:j.confirmOpen,saving:j.saving,path:u?.path??null,error:j.document?.error??null,onDecide:j.decide})]})}let kc=(0,S.A)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]),kd=(0,S.A)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),ke=(0,S.A)("dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);var kf=c(99022);function kg(){let{t:a}=(0,Q.Bd)("common"),[b,c]=(0,B.useState)(null),d=(0,B.useRef)(null),e=(0,B.useRef)(null),f=a=>{let b=d.current;d.current=null,c(null),b?.(a)};return{confirm:a=>(d.current?.(!1),c(a),new Promise(a=>{d.current=a})),dialog:b?(0,A.jsx)(b7.YV,{open:!0,onOpenChange:a=>{a||f(!1)},children:(0,A.jsxs)(b7.hA,{initialFocus:e,className:"z-[130] max-w-[27.5rem]",children:[(0,A.jsxs)(b7.Hl,{className:"p-4 pr-12",children:[(0,A.jsx)(b7.YM,{children:b.title}),(0,A.jsx)(b7.uX,{className:"break-words",children:b.description})]}),b.content?(0,A.jsx)(b7._Y,{className:"grid grid-rows-[minmax(0,1fr)]",children:b.content}):null,(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{ref:e,variant:"outline",onClick:()=>f(!1),children:a("cancel")}),(0,A.jsx)(U.$,{variant:b.confirmVariant??"destructive",onClick:()=>f(!0),children:b.confirmLabel??a("delete")})]})]})}):null}}var kh=c(76499);async function ki(a,b,c,d,e){let f=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":a},body:JSON.stringify(c),signal:e});401===f.status&&window.location.replace("/login");let g=await f.json();if(!f.ok||0!==g.code||null===g.data)throw Error(0===g.code?(0,bW.B)({msg:"登录保护设置处理失败",i18n:{key:"auth:settingsFailed"}}):(0,bW.B)(g));return d.parse(g.data)}async function kj(a){await ki(a,"/api/auth/logout",{},kh.Xm),window.location.replace("/login")}async function kk(a,b){let c=kh.uZ.safeParse(b);if(!c.success)throw Error((0,bW.B)({msg:"密码不符合要求,请按输入框下方的规则调整。",i18n:{key:"auth:settingsInvalid"}}));await ki(a,"/api/auth-settings/replace",c.data,kh.Kc),window.location.replace(null===b.password?"/":"/login")}function kl(){let{t:a}=(0,Q.Bd)("auth"),b=function(){let{t:a}=(0,Q.Bd)("auth"),{clientId:b}=(0,bR.gM)(),{confirm:c,dialog:d}=kg(),[e,f]=(0,B.useState)(null),[g,h]=(0,B.useState)(!0),[i,j]=(0,B.useState)(!1),[k,l]=(0,B.useState)(!1),[m,n]=(0,B.useState)(null),[o,p]=(0,B.useState)(0),[q,r]=(0,B.useState)(""),s=(0,B.useRef)(!1),t=async()=>{if(!s.current&&e){s.current=!0,j(!0),n(null);try{await kk(b,{password:q})}catch(b){s.current=!1,j(!1),n(b instanceof Error?b.message:a("settingsFailed"))}}},u=async()=>{if(!s.current&&e){if(s.current=!0,!await c({title:a("disableTitle"),description:a("disableDescription"),confirmLabel:a("disable")})){s.current=!1;return}j(!0),n(null);try{await kk(b,{password:null})}catch(b){s.current=!1,j(!1),n(b instanceof Error?b.message:a("settingsFailed"))}}},v=async()=>{if(!s.current&&e?.enabled){s.current=!0,l(!0),n(null);try{await kj(b)}catch(b){s.current=!1,l(!1),n(b instanceof Error?b.message:a("logoutFailed"))}}};return{settings:e,loading:g,saving:i,signingOut:k,error:m,password:q,setPassword:r,save:t,generatePassword:()=>{if(!s.current)try{r(function(){for(;;){let a=Array.from(crypto.getRandomValues(new Uint8Array(16)),a=>"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@"[a%64]).join("");if(/[A-Z]/.test(a)&&/[a-z]/.test(a)&&/[0-9]/.test(a)&&/[!@]/.test(a))return a}}()),n(null)}catch{n(a("generatePasswordFailed"))}},disable:u,logout:v,dialog:d,retry:()=>{h(!0),n(null),p(a=>a+1)}}}(),c=b.settings?.enabled??!1,d=b.saving||b.signingOut;return(0,A.jsxs)("section",{"aria-labelledby":"auth-settings-title",className:"@container min-w-0 space-y-6",children:[(0,A.jsx)("h2",{id:"auth-settings-title",className:"text-xl font-semibold",children:a("settings:loginProtection")}),b.loading?(0,A.jsx)("p",{className:"text-sm text-muted-foreground",role:"status",children:a("common:loading")}):b.settings?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 rounded-xl bg-muted p-4",children:[(0,A.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,A.jsx)(c?bP:kc,{className:"size-5 shrink-0","aria-hidden":"true"}),(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsx)("p",{className:"text-sm font-semibold",children:a("protection")}),(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:a(c?"enabled":"disabled")})]})]}),c?(0,A.jsxs)(U.$,{type:"button",variant:"outline",className:"border-destructive/50 text-destructive hover:bg-destructive/10 hover:text-destructive",disabled:d,"aria-busy":b.signingOut,onClick:()=>void b.logout(),children:[b.signingOut?(0,A.jsx)(R.A,{className:"motion-safe:animate-spin","aria-hidden":"true"}):(0,A.jsx)(kd,{"aria-hidden":"true"}),a(b.signingOut?"signingOut":"logout")]}):null]}),(0,A.jsxs)("form",{className:"grid gap-4 @min-[36rem]:grid-cols-[10rem_minmax(0,1fr)] @min-[36rem]:gap-6","aria-busy":d,onSubmit:a=>{a.preventDefault(),b.save()},children:[(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsx)("h3",{className:"text-sm font-semibold",children:a(c?"changePassword":"setPassword")}),c?null:(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:a("publicAccess")})]}),(0,A.jsxs)("div",{className:"min-w-0 max-w-[40rem] space-y-4",children:[(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,A.jsx)("label",{className:"block text-sm font-medium",htmlFor:"auth-password",children:a(c?"newPassword":"password")}),(0,A.jsxs)(U.$,{type:"button",variant:"ghost",size:"sm",disabled:d,title:a("generatePasswordHint"),onClick:b.generatePassword,children:[(0,A.jsx)(ke,{"aria-hidden":"true"}),a("generatePassword")]})]}),(0,A.jsx)(kf.k,{id:"auth-password",name:"password",className:"[&::-ms-reveal]:hidden",autoComplete:"new-password",minLength:12,maxLength:64,required:!0,disabled:d,value:b.password,"aria-describedby":`auth-password-hint${b.error?" auth-settings-error":""}`,onChange:a=>b.setPassword(a.target.value)}),(0,A.jsx)("p",{id:"auth-password-hint",className:"text-sm text-muted-foreground",children:a("passwordHint")})]}),b.error?(0,A.jsx)("p",{id:"auth-settings-error",className:"text-sm text-destructive",role:"alert",children:b.error}):null,(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:a("saveEffect")}),(0,A.jsxs)(U.$,{type:"submit",disabled:d,children:[b.saving?(0,A.jsx)(R.A,{className:"motion-safe:animate-spin","aria-hidden":"true"}):null,a(b.saving?"saving":c?"saveAndSignIn":"enable")]})]})]}),c?(0,A.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4 border-t pt-4",children:[(0,A.jsxs)("details",{className:"group min-w-0 flex-1 text-sm",children:[(0,A.jsxs)("summary",{className:"flex min-h-8 w-fit cursor-pointer items-center gap-1 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:[(0,A.jsx)(br.A,{className:"size-4 shrink-0 transition-transform group-open:rotate-90","aria-hidden":"true"}),a("recovery")]}),(0,A.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,A.jsx)("p",{className:"text-muted-foreground",children:a("recoveryDescription")}),(0,A.jsx)("code",{className:"block break-all text-xs",children:b.settings.configPath})]})]}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",className:"text-muted-foreground",disabled:d,onClick:()=>void b.disable(),children:a("disable")})]}):null]}):(0,A.jsxs)("div",{className:"space-y-3",children:[(0,A.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:b.error}),(0,A.jsx)(U.$,{variant:"outline",onClick:b.retry,children:a("common:retry")})]}),b.dialog]})}var km=c(82589),kn=c(26213);let ko=Object.freeze({apply:(0,F.Vc)({path:"app-runtime/apply",inputSchema:kn.$C,outputSchema:kn.Pq}),update:(0,F._G)({path:"app-runtime/update",bodySchema:kn.YT})});var kp=c(37222);async function kq(a,b,c,d){let e=(0,kp.fx)();if(!e)return"cancelled";let f=a!==e.locale;if(f&&!window.confirm(b))return"cancelled";if(f&&d&&!await d())return"blocked";try{await c.request(ko.apply,{key:"settings",update:{region:{locale:a}}})}catch{return"save-failed"}return f&&window.location.reload(),"changed"}async function kr(a,b){try{return await b.request(ko.apply,{key:"settings",update:{region:{timeZone:a}}}),!0}catch{return!1}}function ks({canLeave:a}){let{t:b}=(0,Q.Bd)("settings"),c=(0,cy.i)(),{appSocket:d}=(0,bR.gM)(),[e,f]=(0,B.useState)(null),[g,h]=(0,B.useState)(()=>new Date),i=(0,B.useMemo)(()=>[...["UTC",...Intl.supportedValuesOf("timeZone").filter(a=>"UTC"!==a)].map(a=>({value:a,label:a.replaceAll("_"," ")}))],[]),j=async c=>{f(null);let e=await kq(c,b("common:reloadConfirm"),d,a);"save-failed"===e&&f(b("common:localeError")),"blocked"===e&&f(b("common:reloadBlocked"))},k=async a=>{f(await kr(a,d)?null:b("common:timeZoneError"))};return(0,A.jsxs)("section",{className:"@container min-w-0 space-y-6","aria-labelledby":"region-settings-title",children:[(0,A.jsx)("h2",{id:"region-settings-title",className:"text-xl font-semibold",children:b("region")}),(0,A.jsxs)("div",{className:"grid max-w-[40rem] gap-6 @min-[32rem]:grid-cols-2",children:[(0,A.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,A.jsx)("label",{className:"block text-sm font-medium",htmlFor:"region-language",children:b("language")}),(0,A.jsxs)(bS.l6,{value:c.localePreference,onValueChange:a=>{("zh-CN"===a||"en"===a)&&j(a)},children:[(0,A.jsx)(bS.bq,{id:"region-language",className:"w-full",children:(0,A.jsx)(bS.yv,{children:"zh-CN"===c.localePreference?b("common:chinese"):"English"})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[120]",children:[(0,A.jsx)(bS.eb,{value:"zh-CN",children:b("common:chinese")}),(0,A.jsx)(bS.eb,{value:"en",children:"English"})]})]}),(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:b("currentLanguage",{locale:c.locale})}),c.pendingLocale&&(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:b("common:languagePending")}),(0,A.jsx)(U.$,{type:"button",size:"sm",variant:"outline",onClick:()=>void j(c.localePreference),children:b("reloadLanguage")})]})]}),(0,A.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,A.jsx)("span",{className:"block text-sm font-medium",children:b("timeZone")}),(0,A.jsx)(km.b,{value:c.timeZonePreference,options:i,onChange:a=>void k(a),ariaLabel:b("timeZone"),searchPlaceholder:b("searchTimeZones"),emptyText:b("common:unavailable"),className:"w-full"}),(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:b("currentTimeZone",{timeZone:c.timeZone})})]})]}),(0,A.jsxs)("div",{className:"space-y-1 rounded-xl bg-muted p-4",children:[(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:b("timeExample")}),(0,A.jsx)("p",{className:"text-sm font-medium tabular-nums",children:new Intl.DateTimeFormat("en"===c.locale?"en-US":"zh-CN",{timeZone:c.timeZone,year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(g)})]}),e&&(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:e})]})}let kt=(0,S.A)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),ku=(0,S.A)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),kv=(0,S.A)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);var kw=c(84524);function kx({label:a,value:b,options:c,onChange:d,layout:e="list",disabled:f=!1}){let g=c.some(a=>a.value===b);return(0,A.jsx)("div",{role:"radiogroup","aria-label":a,onKeyDown:a=>{if(f||a.nativeEvent.isComposing||a.altKey||a.ctrlKey||a.metaKey)return;let e=["ArrowRight","ArrowDown"].includes(a.key)?1:["ArrowLeft","ArrowUp"].includes(a.key)?-1:0;if(!e&&"Home"!==a.key&&"End"!==a.key)return;a.preventDefault();let g=Math.max(0,c.findIndex(a=>a.value===b)),h="Home"===a.key?0:"End"===a.key?c.length-1:(g+e+c.length)%c.length,i=c[h];i&&(d(i.value),a.currentTarget.querySelectorAll('[role="radio"]')[h]?.focus())},className:(0,W.cn)("segmented"===e?"inline-flex max-w-full flex-wrap gap-0.5 rounded-lg bg-muted p-0.5":"grid gap-2"),children:c.map((a,c)=>{let h=a.value===b,i=a.icon;return(0,A.jsxs)("button",{type:"button",role:"radio","aria-checked":h,tabIndex:h||!g&&0===c?0:-1,disabled:f,"data-testid":a.testId,onClick:()=>d(a.value),className:(0,W.cn)("flex min-w-0 cursor-pointer items-center gap-2 text-left text-sm leading-5 outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset","segmented"===e?"min-h-7 rounded-md px-2 py-0.5":"min-h-9 rounded-lg border border-transparent px-3 py-2",h?"segmented"===e?"bg-card text-card-foreground shadow-sm":"border-border bg-accent text-accent-foreground":"text-muted-foreground hover:bg-foreground/8 hover:text-foreground"),children:[i?(0,A.jsx)(i,{className:"size-4 shrink-0"}):null,(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsx)("span",{className:"block font-medium",children:a.label}),a.description?(0,A.jsx)("span",{className:"mt-1 block text-sm font-normal text-muted-foreground",children:a.description}):null]}),"list"===e?(0,A.jsx)(bs.A,{"aria-hidden":"true",className:(0,W.cn)("size-4 shrink-0",!h&&"invisible")}):null]},a.value)})})}var ky=c(72062),kz=c(2191),kA=c(84074),kB=c(96436),kC=c(53437),kD=c(47836),kE=c.n(kD);let kF={code:{copy:!0,download:!1}};function kG({href:a,children:b,...c}){return delete c.node,(0,A.jsx)("a",{...c,href:a,target:"_blank",rel:"noopener noreferrer",children:b})}function kH({src:a,alt:b,className:c,onError:d,...e}){let{t:f}=(0,Q.Bd)("conversation"),[g,h]=(0,B.useState)(!1),[i,j]=(0,B.useState)(!1),k=b||f("image"),l=(0,B.useMemo)(()=>"string"==typeof a&&a?[{src:a,alt:k}]:[],[k,a]);if(delete e.node,0===l.length)return null;if(i)return(0,A.jsx)("span",{className:kE().imageFallback,children:f("imageUnavailable")});let m=l[0].src;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("button",{type:"button",className:kE().imageTrigger,"aria-label":f("previewImage",{name:k}),onClick:()=>h(!0),children:[(0,A.jsx)("img",{...e,src:m,alt:k,"data-streamdown":"image",className:(0,W.cn)(kE().image,c),onError:a=>{j(!0),d?.(a)}}),(0,A.jsx)("span",{className:kE().imageAction,"aria-hidden":"true",children:(0,A.jsx)(ah.A,{className:"size-4"})})]}),g?(0,A.jsx)(j$.k,{mode:"modal",open:!0,slides:l,ariaLabel:f("imagePreview"),onClose:()=>h(!1)}):null]})}function kI({className:a,isAnimating:b,components:c,...d}){let e=(0,bK.G)(),{t:f}=(0,Q.Bd)("conversation"),{locale:g}=(0,cy.i)();return(0,A.jsx)("div",{className:"contents",onClickCapture:a=>{if("u">typeof navigator&&"function"==typeof navigator.clipboard?.writeText)return;let b=function(a){if(!(a instanceof Element))return null;let b=a.closest('[data-streamdown="code-block-copy-button"]');return b?b.closest('[data-streamdown="code-block"]')?.querySelector('[data-streamdown="code-block-body"]')?.textContent??null:null}(a.target);null!==b&&(a.preventDefault(),a.stopPropagation(),(0,cZ.x)(b).then(a=>{a||e.error(f("codeCopyFailed"))}))},children:(0,A.jsx)(iy,{className:(0,W.cn)("space-y-0",kE().markdown,kC.om,a),controls:kF,isAnimating:b,lineNumbers:!1,allowedTags:kC.IV,remarkPlugins:kC.XC,components:{...kC.e6,...c,a:kG,img:kH},...d,translations:"zh-CN"===g?kB.X:void 0})})}let kJ=[{value:"system",label:"common:system",icon:kt},{value:"light",label:"themeLight",icon:ku},{value:"dark",label:"themeDark",icon:kv}],kK=[{value:"compact",label:"sizeCompact"},{value:"standard",label:"sizeStandard"},{value:"large",label:"sizeLarge"}];function kL(){let{t:a}=(0,Q.Bd)("settings"),b=(0,B.useSyncExternalStore)(ky.Cy,ky.Is,()=>kw.Pl),c=(0,B.useSyncExternalStore)(kA.wm,kA.Ev,()=>kz.Y8);return(0,A.jsxs)("section",{"aria-labelledby":"settings-appearance-title",className:"@container grid gap-6",children:[(0,A.jsx)("h2",{id:"settings-appearance-title",className:"text-xl font-semibold",children:a("appearance")}),(0,A.jsxs)("div",{className:"grid min-w-0 gap-6 @min-[40rem]:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[(0,A.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,A.jsxs)("div",{className:"space-y-2 border-b pb-4",children:[(0,A.jsx)("h3",{className:"text-sm font-medium",children:a("theme")}),(0,A.jsx)(kx,{label:a("theme"),layout:"segmented",value:b,options:kJ.map(b=>({...b,label:a(b.label)})),onChange:ky.VS})]}),(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("h3",{className:"text-sm font-medium",children:a("displaySize")}),(0,A.jsx)(kx,{label:a("displaySize"),layout:"segmented",value:c,options:kK.map(b=>({...b,label:a(b.label)})),onChange:kA.$y})]})]}),(0,A.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,A.jsx)("h3",{className:"text-sm font-medium",children:a("displayPreview")}),(0,A.jsx)("div",{"aria-label":a("displayPreview"),className:"min-w-0 rounded-xl bg-muted p-4",children:(0,A.jsx)(kI,{mode:"static",isAnimating:!1,children:a("displayPreviewContent")})})]})]})]})}let kM=(0,S.A)("circle-minus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),kN=(0,S.A)("mouse-pointer-click",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]),kO=(0,S.A)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),kP=(0,S.A)("image-down",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),kQ=(0,S.A)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);var kR=c(52660);let kS=new Set,kT="activate";function kU(){}function kV(){return kU(),kT}function kW(a){if(kU(),kT!==a){kT=a;try{window.localStorage.setItem("pi-super:new-work-session-behavior",a)}catch{}for(let a of[...kS])a()}}function kX(a){return kS.add(a),()=>kS.delete(a)}let kY=[{value:"none",label:"behaviorNone",description:"behaviorNoneDescription",icon:kM,testId:"new-work-session-behavior-none"},{value:"activate",label:"behaviorActivate",description:"behaviorActivateDescription",icon:kN,testId:"new-work-session-behavior-activate"},{value:"pin",label:"behaviorPin",description:"behaviorPinDescription",icon:kO,testId:"new-work-session-behavior-pin"}],kZ=[{value:"compressed",label:"imageCompressed",description:"imageCompressedDescription",icon:kP,testId:"image-preview-mode-compressed"},{value:"original",label:"imageOriginal",description:"imageOriginalDescription",icon:kQ,testId:"image-preview-mode-original"}];function k$(){let{t:a}=(0,Q.Bd)("settings"),b=(0,B.useSyncExternalStore)(kX,kV,kV),c=(0,B.useSyncExternalStore)(kR.ku,kR.Wq,kR.Wq);return(0,A.jsxs)("section",{"aria-labelledby":"settings-habits-title",className:"@container grid min-w-0 gap-6",children:[(0,A.jsxs)("div",{children:[(0,A.jsx)("h2",{id:"settings-habits-title",className:"text-xl font-semibold",children:a("habits")}),(0,A.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a("browserOnly")})]}),(0,A.jsxs)("div",{className:"grid min-w-0 gap-6 lg:@min-[40rem]:grid-cols-2",children:[(0,A.jsxs)("section",{className:"hidden min-w-0 lg:block","aria-labelledby":"new-session-behavior-title",children:[(0,A.jsx)("h3",{id:"new-session-behavior-title",className:"mb-3 text-sm font-semibold",children:a("newSessionBehavior")}),(0,A.jsx)(kx,{label:a("newSessionBehavior"),value:b,options:kY.map(b=>({...b,label:a(b.label),description:a(b.description)})),onChange:kW}),(0,A.jsx)("p",{className:"mt-3 text-sm text-muted-foreground",children:a("desktopOnlyBehavior")})]}),(0,A.jsxs)("section",{className:"min-w-0 lg:border-t lg:pt-4 lg:@min-[40rem]:border-t-0 lg:@min-[40rem]:border-l lg:@min-[40rem]:pt-0 lg:@min-[40rem]:pl-6","aria-labelledby":"image-preview-mode-title",children:[(0,A.jsx)("h3",{id:"image-preview-mode-title",className:"mb-3 text-sm font-semibold",children:a("imagePreviewMode")}),(0,A.jsx)(kx,{label:a("imagePreviewMode"),value:c,options:kZ.map(b=>({...b,label:a(b.label),description:a(b.description)})),onChange:kR.lU}),(0,A.jsx)("p",{className:"mt-3 text-sm text-muted-foreground",children:a("imagePreviewApply")})]})]})]})}let k_=(0,S.A)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),k0={off:"thinkingOff",minimal:"thinkingMinimal",low:"thinkingLow",medium:"thinkingMedium",high:"thinkingHigh",xhigh:"thinkingXhigh",max:"thinkingMax"};function k1({projectDefaults:a}){let{t:b}=(0,Q.Bd)("settings");return(0,A.jsx)("ul",{className:"space-y-3 px-4 pb-4",children:a.map(({cwd:a,from:c,to:d})=>(0,A.jsxs)("li",{className:"space-y-1",children:[(0,A.jsx)("p",{className:"break-all font-medium",children:a}),(0,A.jsxs)("p",{className:"break-all text-muted-foreground",children:[c.provider,"/",c.modelId," \xb7 ",b(k0[c.thinkingLevel]),(0,A.jsx)("span",{className:"mx-1.5",children:"→"}),(0,A.jsx)("span",{className:"text-foreground",children:d?(0,A.jsxs)(A.Fragment,{children:[d.provider,"/",d.modelId," \xb7 ",b(k0[d.thinkingLevel])]}):b("clearProjectDefault")})]})]},a))})}var k2=c(175),k3=c(41994);let k4=E.Yj().trim().min(1).max(128),k5=E.Yj().trim().min(1).max(256),k6=E.Yj().trim().min(1).max(256),k7=E.Yj().trim().min(1).nullable(),k8=E.g1(E.Yj().trim().min(1),E.Yj()),k9=E.Yj().trim().min(1).max(128),la=E.g1(E.Yj(),E.Pq()),lb=E.Ik({level:k2.$,providerValue:E.Yj().trim().min(1).nullable()}).strict(),lc=E.Ik({input:E.ai().nonnegative().finite(),output:E.ai().nonnegative().finite(),cacheRead:E.ai().nonnegative().finite(),cacheWrite:E.ai().nonnegative().finite()}).strict(),ld=E.Ik({supportsDeveloperRole:E.zM().nullable(),thinkingFormat:E.Yj().trim().min(1).max(128).nullable(),requiresReasoningContentOnAssistantMessages:E.zM().nullable()}).strict(),le=E.Ik({modelId:k5,name:k6,api:k9.nullable(),baseUrl:k7,reasoning:E.zM(),thinkingLevels:E.YO(lb).min(1).max(7),input:E.YO(E.k5(["text","image"])).min(1).max(2),contextWindow:E.ai().int().positive().max(Number.MAX_SAFE_INTEGER),maxTokens:E.ai().int().positive().max(Number.MAX_SAFE_INTEGER),cost:lc.nullable(),headers:k8,compat:ld.nullable()}).strict().superRefine((a,b)=>{let c=new Set;for(let d of a.thinkingLevels)c.has(d.level)&&b.addIssue({code:"custom",message:`思考等级 ${d.level} 重复`}),c.add(d.level),("xhigh"===d.level||"max"===d.level)&&null===d.providerValue&&b.addIssue({code:"custom",message:`${d.level} 必须配置 Provider 映射`});a.reasoning||1===a.thinkingLevels.length&&c.has("off")||b.addIssue({code:"custom",message:"非推理模型只允许 off 思考等级"})}),lf=E.Ik({provider:k4,name:k7,baseUrl:k7,api:k9.nullable(),apiKey:E.Yj().nullable(),authHeader:E.zM().nullable(),headers:k8,models:E.YO(le)}).strict().superRefine((a,b)=>{let c=new Set;for(let d of a.models)c.has(d.modelId)&&b.addIssue({code:"custom",message:`模型 ${d.modelId} 重复`}),c.add(d.modelId)}),lg=E.Ik({provider:k4,modelId:k5,thinkingLevel:k2.$,color:E.Yj().regex(/^#[0-9a-fA-F]{6}$/).nullable()}).strict(),lh=E.Ik({provider:k4,modelId:k5,name:k6,input:E.YO(E.k5(["text","image"])).min(1).max(2),contextWindow:E.ai().int().positive().max(Number.MAX_SAFE_INTEGER),thinkingLevels:E.YO(k2.$).min(1).max(7)}).strict(),li=E.Ik({provider:k4,modelId:k5,thinkingLevel:k2.$}).strict(),lj=E.Ik({contextWindow:E.ai().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),maxTokens:E.ai().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),cost:lc.partial().optional()}).strict(),lk=E.Ik({provider:k4,modelId:k5,overrides:lj}).strict(),ll=E.Ik({provider:k4,name:k6,loggedIn:E.zM(),subscription:E.zM(),models:E.YO(le)}).strict();E.Ik({}).strict();let lm=E.Ik({providers:E.YO(lf),presets:E.YO(lg),models:E.YO(lh),nativeConfig:la,accountModels:E.YO(lk),accounts:E.YO(ll)}).strict(),ln=E.Ik({provider:k4,modelId:k5}).strict(),lo=E.Ik({from:ln,to:ln}).strict(),lp=E.Ik({providers:E.YO(lf).optional(),presets:E.YO(lg).optional(),accountModels:E.YO(lk).optional(),modelReplacements:E.YO(lo).optional()}).strict().refine(a=>void 0!==a.providers||void 0!==a.presets||void 0!==a.accountModels,{message:"请提交需要保存的模型配置"}),lq=E.KC([lp,E.Ik({nativeConfig:la}).strict()]),lr=E.Ik({}).strict(),ls=E.Ik({projectDefaults:E.YO(E.Ik({cwd:jv.m4,from:li,to:li.nullable()}).strict())}).strict(),lt=E.Ik({query:E.Yj().trim().max(256),refresh:E.zM(),page:E.Ik({index:E.ai().int().positive(),size:E.ai().int().positive().max(100)}).strict()}).strict(),lu=E.Ik({reasoning:E.zM(),thinkingLevels:E.YO(lb).min(1).max(7),input:E.YO(E.k5(["text","image"])).min(1).max(2),contextWindow:E.ai().int().positive().max(Number.MAX_SAFE_INTEGER),maxTokens:E.ai().int().positive().max(Number.MAX_SAFE_INTEGER),cost:lc.nullable()}).strict(),lv=E.Ik({provider:k4,providerName:k6,modelId:k5,official:E.zM(),defaults:lu}).strict(),lw=E.Ik({referenceId:E.Yj().trim().min(1).max(512),name:k6,match:E.k5(["exact","similar"]).nullable(),sources:E.YO(lv).min(1)}).strict(),lx=E.Ik({updatedAt:k3.k,refreshResult:E.k5(["not-requested","updated","unchanged","partial","cached"]),page:E.Ik({index:E.ai().int().positive(),size:E.ai().int().positive(),total:E.ai().int().nonnegative()}).strict(),models:E.YO(lw)}).strict();E.Ik({cwd:jv.m4}).strict();let ly=E.Ik({cwd:jv.m4,default:li.nullable(),models:E.YO(lh)}).strict(),lz=E.Ik({cwd:jv.m4,default:li.nullable()}).strict(),lA=E.Ik({}).strict();var lB=c(59411);let lC=null,lD=null,lE=new Map;function lF(a){if(null===a)return"<root>";let b=a.replaceAll("\\","/");return/^[A-Za-z]:\//.test(b)?b.toLowerCase():b}function lG(){}function lH(a,b){try{window.localStorage.setItem(a,JSON.stringify(b))}catch{}}function lI(a){lC=a,lH("pi-desk:pi-directories",a)}function lJ(){}function lK(a){return lJ(),lE.get(lF(a))??null}let lL=new Map;function lM(a){let b,c=ly.safeParse(a);if(!c.success)return;let d=(b=c.data.cwd.replaceAll("\\","/"),/^[A-Za-z]:\//.test(b)?b.toLowerCase():b);for(lL.delete(d),lL.set(d,c.data);lL.size>64;){let a=lL.keys().next().value;if(void 0===a)break;lL.delete(a)}try{window.localStorage.setItem("pi-desk:project-model-defaults",JSON.stringify(Object.fromEntries(lL)))}catch{}}function lN(a){let b=lq.safeParse(a);if(!b.success){let a=b.error.issues[0]?.path.at(-1);if("modelId"===a)throw Error("请填写模型 ID 后再保存配置。");if("provider"===a)throw Error("请填写 Provider ID 后再保存配置。");throw Error("模型配置不完整或格式不正确,请检查必填字段和数值。")}return b.data}E.KC([E.k5(["appearance","region","habits","auth","models","mcp-settings","capability-modes","skills","plugins","about"]),E.Uy(["plugin:",E.Yj(),":",E.Yj()])]),E.k5(["providers","presets","project-default"]);function lO({open:a,text:b,error:c,saving:d,dirty:e,onChange:f,onClose:g,onSave:h}){let{t:i}=(0,Q.Bd)("settings");return(0,A.jsx)(b7.YV,{open:a,onOpenChange:a=>{a||g()},children:(0,A.jsxs)(b7.hA,{className:"max-w-[52rem]",initialFocus:!1,showCloseButton:!d,children:[(0,A.jsxs)(b7.Hl,{className:"border-b px-4 py-4 pr-12",children:[(0,A.jsx)(b7.YM,{children:i("nativeConfig")}),(0,A.jsx)(b7.uX,{children:i("nativeConfigScope")})]}),(0,A.jsx)(b7._Y,{className:"max-h-[70dvh]",children:(0,A.jsxs)("div",{className:"space-y-3 p-4",children:[(0,A.jsx)(iE.T,{"aria-label":i("nativeConfigEditor"),value:b,disabled:d,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"min-h-[min(28rem,50dvh)] resize-y font-mono text-sm",onChange:a=>f(a.target.value)}),c?(0,A.jsx)("p",{role:"alert",className:"break-words text-sm text-destructive",children:c}):null]})}),(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",disabled:d,onClick:g,children:i("cancel",{ns:"common"})}),(0,A.jsxs)(U.$,{type:"button",disabled:d||!e,onClick:h,children:[d?(0,A.jsx)(R.A,{className:"animate-spin"}):null,i(d?"savingModels":"saveNativeConfig")]})]})]})})}var lP=c(71794);let lQ="u">typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function lR(a){let b=Object.prototype.toString.call(a);return"[object Window]"===b||"[object global]"===b}function lS(a){return"nodeType"in a}function lT(a){var b,c;return a?lR(a)?a:lS(a)&&null!=(b=null==(c=a.ownerDocument)?void 0:c.defaultView)?b:window:window}function lU(a){let{Document:b}=lT(a);return a instanceof b}function lV(a){return!lR(a)&&a instanceof lT(a).HTMLElement}function lW(a){return a instanceof lT(a).SVGElement}function lX(a){return a?lR(a)?a.document:lS(a)?lU(a)?a:lV(a)||lW(a)?a.ownerDocument:document:document:document}let lY=lQ?B.useLayoutEffect:B.useEffect;function lZ(a){let b=(0,B.useRef)(a);return lY(()=>{b.current=a}),(0,B.useCallback)(function(){for(var a=arguments.length,c=Array(a),d=0;d<a;d++)c[d]=arguments[d];return null==b.current?void 0:b.current(...c)},[])}function l$(a,b){void 0===b&&(b=[a]);let c=(0,B.useRef)(a);return lY(()=>{c.current!==a&&(c.current=a)},b),c}function l_(a,b){let c=(0,B.useRef)();return(0,B.useMemo)(()=>{let b=a(c.current);return c.current=b,b},[...b])}function l0(a){let b=lZ(a),c=(0,B.useRef)(null),d=(0,B.useCallback)(a=>{a!==c.current&&(null==b||b(a,c.current)),c.current=a},[]);return[c,d]}function l1(a){let b=(0,B.useRef)();return(0,B.useEffect)(()=>{b.current=a},[a]),b.current}let l2={};function l3(a,b){return(0,B.useMemo)(()=>{if(b)return b;let c=null==l2[a]?0:l2[a]+1;return l2[a]=c,a+"-"+c},[a,b])}function l4(a){return function(b){for(var c=arguments.length,d=Array(c>1?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];return d.reduce((b,c)=>{for(let[d,e]of Object.entries(c)){let c=b[d];null!=c&&(b[d]=c+a*e)}return b},{...b})}}let l5=l4(1),l6=l4(-1);function l7(a){if(!a)return!1;let{KeyboardEvent:b}=lT(a.target);return b&&a instanceof b}function l8(a){if(function(a){if(!a)return!1;let{TouchEvent:b}=lT(a.target);return b&&a instanceof b}(a)){if(a.touches&&a.touches.length){let{clientX:b,clientY:c}=a.touches[0];return{x:b,y:c}}else if(a.changedTouches&&a.changedTouches.length){let{clientX:b,clientY:c}=a.changedTouches[0];return{x:b,y:c}}}return"clientX"in a&&"clientY"in a?{x:a.clientX,y:a.clientY}:null}let l9=Object.freeze({Translate:{toString(a){if(!a)return;let{x:b,y:c}=a;return"translate3d("+(b?Math.round(b):0)+"px, "+(c?Math.round(c):0)+"px, 0)"}},Scale:{toString(a){if(!a)return;let{scaleX:b,scaleY:c}=a;return"scaleX("+b+") scaleY("+c+")"}},Transform:{toString(a){if(a)return[l9.Translate.toString(a),l9.Scale.toString(a)].join(" ")}},Transition:{toString(a){let{property:b,duration:c,easing:d}=a;return b+" "+c+"ms "+d}}}),ma="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]",mb={display:"none"};function mc(a){let{id:b,value:c}=a;return C().createElement("div",{id:b,style:mb},c)}function md(a){let{id:b,announcement:c,ariaLiveType:d="assertive"}=a;return C().createElement("div",{id:b,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":d,"aria-atomic":!0},c)}let me=(0,B.createContext)(null),mf={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},mg={onDragStart(a){let{active:b}=a;return"Picked up draggable item "+b.id+"."},onDragOver(a){let{active:b,over:c}=a;return c?"Draggable item "+b.id+" was moved over droppable area "+c.id+".":"Draggable item "+b.id+" is no longer over a droppable area."},onDragEnd(a){let{active:b,over:c}=a;return c?"Draggable item "+b.id+" was dropped over droppable area "+c.id:"Draggable item "+b.id+" was dropped."},onDragCancel(a){let{active:b}=a;return"Dragging was cancelled. Draggable item "+b.id+" was dropped."}};function mh(a){var b;let c,{announcements:d=mg,container:e,hiddenTextDescribedById:f,screenReaderInstructions:g=mf}=a,{announce:h,announcement:i}=function(){let[a,b]=(0,B.useState)("");return{announce:(0,B.useCallback)(a=>{null!=a&&b(a)},[]),announcement:a}}(),j=l3("DndLiveRegion"),[k,l]=(0,B.useState)(!1);if((0,B.useEffect)(()=>{l(!0)},[]),b=(0,B.useMemo)(()=>({onDragStart(a){let{active:b}=a;h(d.onDragStart({active:b}))},onDragMove(a){let{active:b,over:c}=a;d.onDragMove&&h(d.onDragMove({active:b,over:c}))},onDragOver(a){let{active:b,over:c}=a;h(d.onDragOver({active:b,over:c}))},onDragEnd(a){let{active:b,over:c}=a;h(d.onDragEnd({active:b,over:c}))},onDragCancel(a){let{active:b,over:c}=a;h(d.onDragCancel({active:b,over:c}))}}),[h,d]),c=(0,B.useContext)(me),(0,B.useEffect)(()=>{if(!c)throw Error("useDndMonitor must be used within a children of <DndContext>");return c(b)},[b,c]),!k)return null;let m=C().createElement(C().Fragment,null,C().createElement(mc,{id:f,value:g.draggable}),C().createElement(md,{id:j,announcement:i}));return e?(0,lP.createPortal)(m,e):m}function mi(){}function mj(a,b){return(0,B.useMemo)(()=>({sensor:a,options:null!=b?b:{}}),[a,b])}function mk(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return(0,B.useMemo)(()=>[...b].filter(a=>null!=a),[...b])}(h=q||(q={})).DragStart="dragStart",h.DragMove="dragMove",h.DragEnd="dragEnd",h.DragCancel="dragCancel",h.DragOver="dragOver",h.RegisterDroppable="registerDroppable",h.SetDroppableDisabled="setDroppableDisabled",h.UnregisterDroppable="unregisterDroppable";let ml=Object.freeze({x:0,y:0});function mm(a,b){return Math.sqrt(Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2))}function mn(a,b){let{data:{value:c}}=a,{data:{value:d}}=b;return c-d}function mo(a,b){let{data:{value:c}}=a,{data:{value:d}}=b;return d-c}function mp(a){let{left:b,top:c,height:d,width:e}=a;return[{x:b,y:c},{x:b+e,y:c},{x:b,y:c+d},{x:b+e,y:c+d}]}function mq(a,b){if(!a||0===a.length)return null;let[c]=a;return b?c[b]:c}function mr(a,b,c){return void 0===b&&(b=a.left),void 0===c&&(c=a.top),{x:b+.5*a.width,y:c+.5*a.height}}let ms=a=>{let{collisionRect:b,droppableRects:c,droppableContainers:d}=a,e=mr(b,b.left,b.top),f=[];for(let a of d){let{id:b}=a,d=c.get(b);if(d){let c=mm(mr(d),e);f.push({id:b,data:{droppableContainer:a,value:c}})}}return f.sort(mn)},mt=a=>{let{collisionRect:b,droppableRects:c,droppableContainers:d}=a,e=[];for(let a of d){let{id:d}=a,f=c.get(d);if(f){let c=function(a,b){let c=Math.max(b.top,a.top),d=Math.max(b.left,a.left),e=Math.min(b.left+b.width,a.left+a.width),f=Math.min(b.top+b.height,a.top+a.height);if(d<e&&c<f){let g=b.width*b.height,h=a.width*a.height,i=(e-d)*(f-c);return Number((i/(g+h-i)).toFixed(4))}return 0}(f,b);c>0&&e.push({id:d,data:{droppableContainer:a,value:c}})}}return e.sort(mo)};function mu(a,b){return a&&b?{x:a.left-b.left,y:a.top-b.top}:ml}let mv=function(a){for(var b=arguments.length,c=Array(b>1?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];return c.reduce((a,b)=>({...a,top:a.top+ +b.y,bottom:a.bottom+ +b.y,left:a.left+ +b.x,right:a.right+ +b.x}),{...a})},mw={ignoreTransform:!1};function mx(a,b){void 0===b&&(b=mw);let c=a.getBoundingClientRect();if(b.ignoreTransform){let{transform:b,transformOrigin:d}=lT(a).getComputedStyle(a);b&&(c=function(a,b,c){let d=function(a){if(a.startsWith("matrix3d(")){let b=a.slice(9,-1).split(/, /);return{x:+b[12],y:+b[13],scaleX:+b[0],scaleY:+b[5]}}if(a.startsWith("matrix(")){let b=a.slice(7,-1).split(/, /);return{x:+b[4],y:+b[5],scaleX:+b[0],scaleY:+b[3]}}return null}(b);if(!d)return a;let{scaleX:e,scaleY:f,x:g,y:h}=d,i=a.left-g-(1-e)*parseFloat(c),j=a.top-h-(1-f)*parseFloat(c.slice(c.indexOf(" ")+1)),k=e?a.width/e:a.width,l=f?a.height/f:a.height;return{width:k,height:l,top:j,right:i+k,bottom:j+l,left:i}}(c,b,d))}let{top:d,left:e,width:f,height:g,bottom:h,right:i}=c;return{top:d,left:e,width:f,height:g,bottom:h,right:i}}function my(a){return mx(a,{ignoreTransform:!0})}function mz(a,b){let c=[];return a?function d(e){var f,g;let h;if(null!=b&&c.length>=b||!e)return c;if(lU(e)&&null!=e.scrollingElement&&!c.includes(e.scrollingElement))return c.push(e.scrollingElement),c;if(!lV(e)||lW(e)||c.includes(e))return c;let i=lT(a).getComputedStyle(e);return(e!==a&&(void 0===(f=i)&&(f=lT(e).getComputedStyle(e)),h=/(auto|scroll|overlay)/,["overflow","overflowX","overflowY"].some(a=>{let b=f[a];return"string"==typeof b&&h.test(b)}))&&c.push(e),void 0===(g=i)&&(g=lT(e).getComputedStyle(e)),"fixed"===g.position)?c:d(e.parentNode)}(a):c}function mA(a){let[b]=mz(a,1);return null!=b?b:null}function mB(a){return lQ&&a?lR(a)?a:lS(a)?lU(a)||a===lX(a).scrollingElement?window:lV(a)?a:null:null:null}function mC(a){return lR(a)?a.scrollX:a.scrollLeft}function mD(a){return lR(a)?a.scrollY:a.scrollTop}function mE(a){return{x:mC(a),y:mD(a)}}function mF(a){return!!lQ&&!!a&&a===document.scrollingElement}function mG(a){let b={x:0,y:0},c=mF(a)?{height:window.innerHeight,width:window.innerWidth}:{height:a.clientHeight,width:a.clientWidth},d={x:a.scrollWidth-c.width,y:a.scrollHeight-c.height},e=a.scrollTop<=b.y,f=a.scrollLeft<=b.x;return{isTop:e,isLeft:f,isBottom:a.scrollTop>=d.y,isRight:a.scrollLeft>=d.x,maxScroll:d,minScroll:b}}(i=r||(r={}))[i.Forward=1]="Forward",i[i.Backward=-1]="Backward";let mH={x:.2,y:.2};function mI(a){return a.reduce((a,b)=>l5(a,mE(b)),ml)}let mJ=[["x",["left","right"],function(a){return a.reduce((a,b)=>a+mC(b),0)}],["y",["top","bottom"],function(a){return a.reduce((a,b)=>a+mD(b),0)}]];class mK{constructor(a,b){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const c=mz(b),d=mI(c);for(const[b,e,f]of(this.rect={...a},this.width=a.width,this.height=a.height,mJ))for(const a of e)Object.defineProperty(this,a,{get:()=>{let e=f(c),g=d[b]-e;return this.rect[a]+g},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class mL{constructor(a){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(a=>{var b;return null==(b=this.target)?void 0:b.removeEventListener(...a)})},this.target=a}add(a,b,c){var d;null==(d=this.target)||d.addEventListener(a,b,c),this.listeners.push([a,b,c])}}function mM(a,b){let c=Math.abs(a.x),d=Math.abs(a.y);return"number"==typeof b?Math.sqrt(c**2+d**2)>b:"x"in b&&"y"in b?c>b.x&&d>b.y:"x"in b?c>b.x:"y"in b&&d>b.y}function mN(a){a.preventDefault()}function mO(a){a.stopPropagation()}(j=s||(s={})).Click="click",j.DragStart="dragstart",j.Keydown="keydown",j.ContextMenu="contextmenu",j.Resize="resize",j.SelectionChange="selectionchange",j.VisibilityChange="visibilitychange",(k=t||(t={})).Space="Space",k.Down="ArrowDown",k.Right="ArrowRight",k.Left="ArrowLeft",k.Up="ArrowUp",k.Esc="Escape",k.Enter="Enter",k.Tab="Tab";let mP={start:[t.Space,t.Enter],cancel:[t.Esc],end:[t.Space,t.Enter,t.Tab]},mQ=(a,b)=>{let{currentCoordinates:c}=b;switch(a.code){case t.Right:return{...c,x:c.x+25};case t.Left:return{...c,x:c.x-25};case t.Down:return{...c,y:c.y+25};case t.Up:return{...c,y:c.y-25}}};class mR{constructor(a){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=a;const{event:{target:b}}=a;this.props=a,this.listeners=new mL(lX(b)),this.windowListeners=new mL(lT(b)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(s.Resize,this.handleCancel),this.windowListeners.add(s.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(s.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:a,onStart:b}=this.props,c=a.node.current;c&&function(a,b){if(void 0===b&&(b=mx),!a)return;let{top:c,left:d,bottom:e,right:f}=b(a);mA(a)&&(e<=0||f<=0||c>=window.innerHeight||d>=window.innerWidth)&&a.scrollIntoView({block:"center",inline:"center"})}(c),b(ml)}handleKeyDown(a){if(l7(a)){let{active:b,context:c,options:d}=this.props,{keyboardCodes:e=mP,coordinateGetter:f=mQ,scrollBehavior:g="smooth"}=d,{code:h}=a;if(e.end.includes(h))return void this.handleEnd(a);if(e.cancel.includes(h))return void this.handleCancel(a);let{collisionRect:i}=c.current,j=i?{x:i.left,y:i.top}:ml;this.referenceCoordinates||(this.referenceCoordinates=j);let k=f(a,{active:b,context:c.current,currentCoordinates:j});if(k){let b=l6(k,j),d={x:0,y:0},{scrollableAncestors:e}=c.current;for(let c of e){let e=a.code,{isTop:f,isRight:h,isLeft:i,isBottom:j,maxScroll:l,minScroll:m}=mG(c),n=function(a){if(a===document.scrollingElement){let{innerWidth:a,innerHeight:b}=window;return{top:0,left:0,right:a,bottom:b,width:a,height:b}}let{top:b,left:c,right:d,bottom:e}=a.getBoundingClientRect();return{top:b,left:c,right:d,bottom:e,width:a.clientWidth,height:a.clientHeight}}(c),o={x:Math.min(e===t.Right?n.right-n.width/2:n.right,Math.max(e===t.Right?n.left:n.left+n.width/2,k.x)),y:Math.min(e===t.Down?n.bottom-n.height/2:n.bottom,Math.max(e===t.Down?n.top:n.top+n.height/2,k.y))},p=e===t.Right&&!h||e===t.Left&&!i,q=e===t.Down&&!j||e===t.Up&&!f;if(p&&o.x!==k.x){let a=c.scrollLeft+b.x,f=e===t.Right&&a<=l.x||e===t.Left&&a>=m.x;if(f&&!b.y)return void c.scrollTo({left:a,behavior:g});f?d.x=c.scrollLeft-a:d.x=e===t.Right?c.scrollLeft-l.x:c.scrollLeft-m.x,d.x&&c.scrollBy({left:-d.x,behavior:g});break}if(q&&o.y!==k.y){let a=c.scrollTop+b.y,f=e===t.Down&&a<=l.y||e===t.Up&&a>=m.y;if(f&&!b.x)return void c.scrollTo({top:a,behavior:g});f?d.y=c.scrollTop-a:d.y=e===t.Down?c.scrollTop-l.y:c.scrollTop-m.y,d.y&&c.scrollBy({top:-d.y,behavior:g});break}}this.handleMove(a,l5(l6(k,this.referenceCoordinates),d))}}}handleMove(a,b){let{onMove:c}=this.props;a.preventDefault(),c(b)}handleEnd(a){let{onEnd:b}=this.props;a.preventDefault(),this.detach(),b()}handleCancel(a){let{onCancel:b}=this.props;a.preventDefault(),this.detach(),b()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function mS(a){return!!(a&&"distance"in a)}function mT(a){return!!(a&&"delay"in a)}mR.activators=[{eventName:"onKeyDown",handler:(a,b,c)=>{let{keyboardCodes:d=mP,onActivation:e}=b,{active:f}=c,{code:g}=a.nativeEvent;if(d.start.includes(g)){let b=f.activatorNode.current;return(!b||a.target===b)&&(a.preventDefault(),null==e||e({event:a.nativeEvent}),!0)}return!1}}];class mU{constructor(a,b,c){var d;void 0===c&&(c=function(a){let{EventTarget:b}=lT(a);return a instanceof b?a:lX(a)}(a.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=a,this.events=b;const{event:e}=a,{target:f}=e;this.props=a,this.events=b,this.document=lX(f),this.documentListeners=new mL(this.document),this.listeners=new mL(c),this.windowListeners=new mL(lT(f)),this.initialCoordinates=null!=(d=l8(e))?d:ml,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:a,props:{options:{activationConstraint:b,bypassActivationConstraint:c}}}=this;if(this.listeners.add(a.move.name,this.handleMove,{passive:!1}),this.listeners.add(a.end.name,this.handleEnd),a.cancel&&this.listeners.add(a.cancel.name,this.handleCancel),this.windowListeners.add(s.Resize,this.handleCancel),this.windowListeners.add(s.DragStart,mN),this.windowListeners.add(s.VisibilityChange,this.handleCancel),this.windowListeners.add(s.ContextMenu,mN),this.documentListeners.add(s.Keydown,this.handleKeydown),b){if(null!=c&&c({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(mT(b)){this.timeoutId=setTimeout(this.handleStart,b.delay),this.handlePending(b);return}if(mS(b))return void this.handlePending(b)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(a,b){let{active:c,onPending:d}=this.props;d(c,a,this.initialCoordinates,b)}handleStart(){let{initialCoordinates:a}=this,{onStart:b}=this.props;a&&(this.activated=!0,this.documentListeners.add(s.Click,mO,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(s.SelectionChange,this.removeTextSelection),b(a))}handleMove(a){var b;let{activated:c,initialCoordinates:d,props:e}=this,{onMove:f,options:{activationConstraint:g}}=e;if(!d)return;let h=null!=(b=l8(a))?b:ml,i=l6(d,h);if(!c&&g){if(mS(g)){if(null!=g.tolerance&&mM(i,g.tolerance))return this.handleCancel();if(mM(i,g.distance))return this.handleStart()}return mT(g)&&mM(i,g.tolerance)?this.handleCancel():void this.handlePending(g,i)}a.cancelable&&a.preventDefault(),f(h)}handleEnd(){let{onAbort:a,onEnd:b}=this.props;this.detach(),this.activated||a(this.props.active),b()}handleCancel(){let{onAbort:a,onCancel:b}=this.props;this.detach(),this.activated||a(this.props.active),b()}handleKeydown(a){a.code===t.Esc&&this.handleCancel()}removeTextSelection(){var a;null==(a=this.document.getSelection())||a.removeAllRanges()}}let mV={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class mW extends mU{constructor(a){const{event:b}=a;super(a,mV,lX(b.target))}}mW.activators=[{eventName:"onPointerDown",handler:(a,b)=>{let{nativeEvent:c}=a,{onActivation:d}=b;return!!c.isPrimary&&0===c.button&&(null==d||d({event:c}),!0)}}];let mX={move:{name:"mousemove"},end:{name:"mouseup"}};(l=u||(u={}))[l.RightClick=2]="RightClick";class mY extends mU{constructor(a){super(a,mX,lX(a.event.target))}}mY.activators=[{eventName:"onMouseDown",handler:(a,b)=>{let{nativeEvent:c}=a,{onActivation:d}=b;return c.button!==u.RightClick&&(null==d||d({event:c}),!0)}}];let mZ={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class m$ extends mU{constructor(a){super(a,mZ)}static setup(){return window.addEventListener(mZ.move.name,a,{capture:!1,passive:!1}),function(){window.removeEventListener(mZ.move.name,a)};function a(){}}}m$.activators=[{eventName:"onTouchStart",handler:(a,b)=>{let{nativeEvent:c}=a,{onActivation:d}=b,{touches:e}=c;return!(e.length>1)&&(null==d||d({event:c}),!0)}}],(m=v||(v={}))[m.Pointer=0]="Pointer",m[m.DraggableRect=1]="DraggableRect",(n=w||(w={}))[n.TreeOrder=0]="TreeOrder",n[n.ReversedTreeOrder=1]="ReversedTreeOrder";let m_={x:{[r.Backward]:!1,[r.Forward]:!1},y:{[r.Backward]:!1,[r.Forward]:!1}};(o=x||(x={}))[o.Always=0]="Always",o[o.BeforeDragging=1]="BeforeDragging",o[o.WhileDragging=2]="WhileDragging",(y||(y={})).Optimized="optimized";let m0=new Map;function m1(a,b){return l_(c=>a?c||("function"==typeof b?b(a):a):null,[b,a])}function m2(a){let{callback:b,disabled:c}=a,d=lZ(b),e=(0,B.useMemo)(()=>{if(c||"u"<typeof window||void 0===window.ResizeObserver)return;let{ResizeObserver:a}=window;return new a(d)},[c]);return(0,B.useEffect)(()=>()=>null==e?void 0:e.disconnect(),[e]),e}function m3(a){return new mK(mx(a),a)}function m4(a,b,c){void 0===b&&(b=m3);let[d,e]=(0,B.useState)(null);function f(){e(d=>{if(!a)return null;if(!1===a.isConnected){var e;return null!=(e=null!=d?d:c)?e:null}let f=b(a);return JSON.stringify(d)===JSON.stringify(f)?d:f})}let g=function(a){let{callback:b,disabled:c}=a,d=lZ(b),e=(0,B.useMemo)(()=>{if(c||"u"<typeof window||void 0===window.MutationObserver)return;let{MutationObserver:a}=window;return new a(d)},[d,c]);return(0,B.useEffect)(()=>()=>null==e?void 0:e.disconnect(),[e]),e}({callback(b){if(a)for(let c of b){let{type:b,target:d}=c;if("childList"===b&&d instanceof HTMLElement&&d.contains(a)){f();break}}}}),h=m2({callback:f});return lY(()=>{f(),a?(null==h||h.observe(a),null==g||g.observe(document.body,{childList:!0,subtree:!0})):(null==h||h.disconnect(),null==g||g.disconnect())},[a]),d}let m5=[];function m6(a,b){void 0===b&&(b=[]);let c=(0,B.useRef)(null);return(0,B.useEffect)(()=>{c.current=null},b),(0,B.useEffect)(()=>{let b=a!==ml;b&&!c.current&&(c.current=a),!b&&c.current&&(c.current=null)},[a]),c.current?l6(a,c.current):ml}function m7(a){return(0,B.useMemo)(()=>{let b,c;return a?(b=a.innerWidth,{top:0,left:0,right:b,bottom:c=a.innerHeight,width:b,height:c}):null},[a])}let m8=[],m9=[{sensor:mW,options:{}},{sensor:mR,options:{}}],na={current:{}},nb={draggable:{measure:my},droppable:{measure:my,strategy:x.WhileDragging,frequency:y.Optimized},dragOverlay:{measure:mx}};class nc extends Map{get(a){var b;return null!=a&&null!=(b=super.get(a))?b:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(a=>{let{disabled:b}=a;return!b})}getNodeFor(a){var b,c;return null!=(b=null==(c=this.get(a))?void 0:c.node.current)?b:void 0}}let nd={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new nc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:mi},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:nb,measureDroppableContainers:mi,windowRect:null,measuringScheduled:!1},ne={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:mi,draggableNodes:new Map,over:null,measureDroppableContainers:mi},nf=(0,B.createContext)(ne),ng=(0,B.createContext)(nd);function nh(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new nc}}}function ni(a,b){switch(b.type){case q.DragStart:return{...a,draggable:{...a.draggable,initialCoordinates:b.initialCoordinates,active:b.active}};case q.DragMove:if(null==a.draggable.active)return a;return{...a,draggable:{...a.draggable,translate:{x:b.coordinates.x-a.draggable.initialCoordinates.x,y:b.coordinates.y-a.draggable.initialCoordinates.y}}};case q.DragEnd:case q.DragCancel:return{...a,draggable:{...a.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case q.RegisterDroppable:{let{element:c}=b,{id:d}=c,e=new nc(a.droppable.containers);return e.set(d,c),{...a,droppable:{...a.droppable,containers:e}}}case q.SetDroppableDisabled:{let{id:c,key:d,disabled:e}=b,f=a.droppable.containers.get(c);if(!f||d!==f.key)return a;let g=new nc(a.droppable.containers);return g.set(c,{...f,disabled:e}),{...a,droppable:{...a.droppable,containers:g}}}case q.UnregisterDroppable:{let{id:c,key:d}=b,e=a.droppable.containers.get(c);if(!e||d!==e.key)return a;let f=new nc(a.droppable.containers);return f.delete(c),{...a,droppable:{...a.droppable,containers:f}}}default:return a}}function nj(a){let{disabled:b}=a,{active:c,activatorEvent:d,draggableNodes:e}=(0,B.useContext)(nf),f=l1(d),g=l1(null==c?void 0:c.id);return(0,B.useEffect)(()=>{if(!b&&!d&&f&&null!=g){if(!l7(f)||document.activeElement===f.target)return;let a=e.get(g);if(!a)return;let{activatorNode:b,node:c}=a;(b.current||c.current)&&requestAnimationFrame(()=>{for(let a of[b.current,c.current]){if(!a)continue;let b=a.matches(ma)?a:a.querySelector(ma);if(b){b.focus();break}}})}},[d,b,e,g,f]),null}let nk=(0,B.createContext)({...ml,scaleX:1,scaleY:1});(p=z||(z={}))[p.Uninitialized=0]="Uninitialized",p[p.Initializing=1]="Initializing",p[p.Initialized=2]="Initialized";let nl=(0,B.memo)(function(a){var b,c,d,e,f,g,h,i;let j,k,l,m,n,o,p,s,{id:t,accessibility:u,autoScroll:y=!0,children:A,sensors:D=m9,collisionDetection:E=mt,measuring:F,modifiers:G,...H}=a,[I,J]=(0,B.useReducer)(ni,void 0,nh),[K,L]=function(){let[a]=(0,B.useState)(()=>new Set),b=(0,B.useCallback)(b=>(a.add(b),()=>a.delete(b)),[a]);return[(0,B.useCallback)(b=>{let{type:c,event:d}=b;a.forEach(a=>{var b;return null==(b=a[c])?void 0:b.call(a,d)})},[a]),b]}(),[M,N]=(0,B.useState)(z.Uninitialized),O=M===z.Initialized,{draggable:{active:P,nodes:Q,translate:R},droppable:{containers:S}}=I,T=null!=P?Q.get(P):null,U=(0,B.useRef)({initial:null,translated:null}),V=(0,B.useMemo)(()=>{var a;return null!=P?{id:P,data:null!=(a=null==T?void 0:T.data)?a:na,rect:U}:null},[P,T]),W=(0,B.useRef)(null),[X,Y]=(0,B.useState)(null),[Z,$]=(0,B.useState)(null),_=l$(H,Object.values(H)),aa=l3("DndDescribedBy",t),ab=(0,B.useMemo)(()=>S.getEnabled(),[S]),ac=(0,B.useMemo)(()=>({draggable:{...nb.draggable,...null==F?void 0:F.draggable},droppable:{...nb.droppable,...null==F?void 0:F.droppable},dragOverlay:{...nb.dragOverlay,...null==F?void 0:F.dragOverlay}}),[null==F?void 0:F.draggable,null==F?void 0:F.droppable,null==F?void 0:F.dragOverlay]),{droppableRects:ad,measureDroppableContainers:ae,measuringScheduled:af}=function(a,b){let{dragging:c,dependencies:d,config:e}=b,[f,g]=(0,B.useState)(null),{frequency:h,measure:i,strategy:j}=e,k=(0,B.useRef)(a),l=function(){switch(j){case x.Always:return!1;case x.BeforeDragging:return c;default:return!c}}(),m=l$(l),n=(0,B.useCallback)(function(a){void 0===a&&(a=[]),m.current||g(b=>null===b?a:b.concat(a.filter(a=>!b.includes(a))))},[m]),o=(0,B.useRef)(null),p=l_(b=>{if(l&&!c)return m0;if(!b||b===m0||k.current!==a||null!=f){let b=new Map;for(let c of a){if(!c)continue;if(f&&f.length>0&&!f.includes(c.id)&&c.rect.current){b.set(c.id,c.rect.current);continue}let a=c.node.current,d=a?new mK(i(a),a):null;c.rect.current=d,d&&b.set(c.id,d)}return b}return b},[a,f,c,l,i]);return(0,B.useEffect)(()=>{k.current=a},[a]),(0,B.useEffect)(()=>{l||n()},[c,l]),(0,B.useEffect)(()=>{f&&f.length>0&&g(null)},[JSON.stringify(f)]),(0,B.useEffect)(()=>{l||"number"!=typeof h||null!==o.current||(o.current=setTimeout(()=>{n(),o.current=null},h))},[h,l,n,...d]),{droppableRects:p,measureDroppableContainers:n,measuringScheduled:null!=f}}(ab,{dragging:O,dependencies:[R.x,R.y],config:ac.droppable}),ag=l_(a=>{var b;return null==P?null:null!=(b=null!=n?n:a)?b:null},[n=(m=null!=P?Q.get(P):void 0)?m.node.current:null,P]),ah=(0,B.useMemo)(()=>Z?l8(Z):null,[Z]),ai=(j=(null==X?void 0:X.autoScrollEnabled)===!1,k="object"==typeof y?!1===y.enabled:!1===y,l=O&&!j&&!k,"object"==typeof y?{...y,enabled:l}:{enabled:l}),aj=m1(ag,ac.draggable.measure);!function(a){let{activeNode:b,measure:c,initialRect:d,config:e=!0}=a,f=(0,B.useRef)(!1),{x:g,y:h}="boolean"==typeof e?{x:e,y:e}:e;lY(()=>{if(!g&&!h||!b){f.current=!1;return}if(f.current||!d)return;let a=null==b?void 0:b.node.current;if(!a||!1===a.isConnected)return;let e=mu(c(a),d);if(g||(e.x=0),h||(e.y=0),f.current=!0,Math.abs(e.x)>0||Math.abs(e.y)>0){let b=mA(a);b&&b.scrollBy({top:e.y,left:e.x})}},[b,g,h,d,c])}({activeNode:null!=P?Q.get(P):null,config:ai.layoutShiftCompensation,initialRect:aj,measure:ac.draggable.measure});let ak=m4(ag,ac.draggable.measure,aj),al=m4(ag?ag.parentElement:null),am=(0,B.useRef)({activatorEvent:null,active:null,activeNode:ag,collisionRect:null,collisions:null,droppableRects:ad,draggableNodes:Q,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),an=S.getNodeFor(null==(b=am.current.over)?void 0:b.id),ao=function(a){let{measure:b}=a,[c,d]=(0,B.useState)(null),e=m2({callback:(0,B.useCallback)(a=>{for(let{target:c}of a)if(lV(c)){d(a=>{let d=b(c);return a?{...a,width:d.width,height:d.height}:d});break}},[b])}),[f,g]=l0((0,B.useCallback)(a=>{let c=function(a){if(!a)return null;if(a.children.length>1)return a;let b=a.children[0];return lV(b)?b:a}(a);null==e||e.disconnect(),c&&(null==e||e.observe(c)),d(c?b(c):null)},[b,e]));return(0,B.useMemo)(()=>({nodeRef:f,rect:c,setRef:g}),[c,f,g])}({measure:ac.dragOverlay.measure}),ap=null!=(c=ao.nodeRef.current)?c:ag,aq=O?null!=(d=ao.rect)?d:ak:null,ar=!!(ao.nodeRef.current&&ao.rect),as=(o=m1(f=ar?null:ak),mu(f,o)),at=m7(ap?lT(ap):null),au=(g=O?null!=an?an:ag:null,p=(0,B.useRef)(g),s=l_(a=>g?a&&a!==m5&&g&&p.current&&g.parentNode===p.current.parentNode?a:mz(g):m5,[g]),(0,B.useEffect)(()=>{p.current=g},[g]),s),av=function(a,b){void 0===b&&(b=mx);let[c]=a,d=m7(c?lT(c):null),[e,f]=(0,B.useState)(m8);function g(){f(()=>a.length?a.map(a=>mF(a)?d:new mK(b(a),a)):m8)}let h=m2({callback:g});return lY(()=>{null==h||h.disconnect(),g(),a.forEach(a=>null==h?void 0:h.observe(a))},[a]),e}(au),aw=function(a,b){let{transform:c,...d}=b;return null!=a&&a.length?a.reduce((a,b)=>b({transform:a,...d}),c):c}(G,{transform:{x:R.x-as.x,y:R.y-as.y,scaleX:1,scaleY:1},activatorEvent:Z,active:V,activeNodeRect:ak,containerNodeRect:al,draggingNodeRect:aq,over:am.current.over,overlayNodeRect:ao.rect,scrollableAncestors:au,scrollableAncestorRects:av,windowRect:at}),ax=ah?l5(ah,R):null,ay=function(a){let[b,c]=(0,B.useState)(null),d=(0,B.useRef)(a),e=(0,B.useCallback)(a=>{let b=mB(a.target);b&&c(a=>a?(a.set(b,mE(b)),new Map(a)):null)},[]);return(0,B.useEffect)(()=>{let b=d.current;if(a!==b){f(b);let g=a.map(a=>{let b=mB(a);return b?(b.addEventListener("scroll",e,{passive:!0}),[b,mE(b)]):null}).filter(a=>null!=a);c(g.length?new Map(g):null),d.current=a}return()=>{f(a),f(b)};function f(a){a.forEach(a=>{let b=mB(a);null==b||b.removeEventListener("scroll",e)})}},[e,a]),(0,B.useMemo)(()=>a.length?b?Array.from(b.values()).reduce((a,b)=>l5(a,b),ml):mI(a):ml,[a,b])}(au),az=m6(ay),aA=m6(ay,[ak]),aB=l5(aw,az),aC=aq?mv(aq,aw):null,aD=V&&aC?E({active:V,collisionRect:aC,droppableRects:ad,droppableContainers:ab,pointerCoordinates:ax}):null,aE=mq(aD,"id"),[aF,aG]=(0,B.useState)(null),aH=(h=ar?aw:l5(aw,aA),i=null!=(e=null==aF?void 0:aF.rect)?e:null,{...h,scaleX:i&&ak?i.width/ak.width:1,scaleY:i&&ak?i.height/ak.height:1}),aI=(0,B.useRef)(null),aJ=(0,B.useCallback)((a,b)=>{let{sensor:c,options:d}=b;if(null==W.current)return;let e=Q.get(W.current);if(!e)return;let f=a.nativeEvent,g=new c({active:W.current,activeNode:e,event:f,options:d,context:am,onAbort(a){if(!Q.get(a))return;let{onDragAbort:b}=_.current,c={id:a};null==b||b(c),K({type:"onDragAbort",event:c})},onPending(a,b,c,d){if(!Q.get(a))return;let{onDragPending:e}=_.current,f={id:a,constraint:b,initialCoordinates:c,offset:d};null==e||e(f),K({type:"onDragPending",event:f})},onStart(a){let b=W.current;if(null==b)return;let c=Q.get(b);if(!c)return;let{onDragStart:d}=_.current,e={activatorEvent:f,active:{id:b,data:c.data,rect:U}};(0,lP.unstable_batchedUpdates)(()=>{null==d||d(e),N(z.Initializing),J({type:q.DragStart,initialCoordinates:a,active:b}),K({type:"onDragStart",event:e}),Y(aI.current),$(f)})},onMove(a){J({type:q.DragMove,coordinates:a})},onEnd:h(q.DragEnd),onCancel:h(q.DragCancel)});function h(a){return async function(){let{active:b,collisions:c,over:d,scrollAdjustedTranslate:e}=am.current,g=null;if(b&&e){let{cancelDrop:h}=_.current;g={activatorEvent:f,active:b,collisions:c,delta:e,over:d},a===q.DragEnd&&"function"==typeof h&&await Promise.resolve(h(g))&&(a=q.DragCancel)}W.current=null,(0,lP.unstable_batchedUpdates)(()=>{J({type:a}),N(z.Uninitialized),aG(null),Y(null),$(null),aI.current=null;let b=a===q.DragEnd?"onDragEnd":"onDragCancel";if(g){let a=_.current[b];null==a||a(g),K({type:b,event:g})}})}}aI.current=g},[Q]),aK=(0,B.useCallback)((a,b)=>(c,d)=>{let e=c.nativeEvent,f=Q.get(d);null!==W.current||!f||e.dndKit||e.defaultPrevented||!0===a(c,b.options,{active:f})&&(e.dndKit={capturedBy:b.sensor},W.current=d,aJ(c,b))},[Q,aJ]),aL=(0,B.useMemo)(()=>D.reduce((a,b)=>{let{sensor:c}=b;return[...a,...c.activators.map(a=>({eventName:a.eventName,handler:aK(a.handler,b)}))]},[]),[D,aK]);(0,B.useEffect)(()=>{if(!lQ)return;let a=D.map(a=>{let{sensor:b}=a;return null==b.setup?void 0:b.setup()});return()=>{for(let b of a)null==b||b()}},D.map(a=>{let{sensor:b}=a;return b})),lY(()=>{ak&&M===z.Initializing&&N(z.Initialized)},[ak,M]),(0,B.useEffect)(()=>{let{onDragMove:a}=_.current,{active:b,activatorEvent:c,collisions:d,over:e}=am.current;if(!b||!c)return;let f={active:b,activatorEvent:c,collisions:d,delta:{x:aB.x,y:aB.y},over:e};(0,lP.unstable_batchedUpdates)(()=>{null==a||a(f),K({type:"onDragMove",event:f})})},[aB.x,aB.y]),(0,B.useEffect)(()=>{let{active:a,activatorEvent:b,collisions:c,droppableContainers:d,scrollAdjustedTranslate:e}=am.current;if(!a||null==W.current||!b||!e)return;let{onDragOver:f}=_.current,g=d.get(aE),h=g&&g.rect.current?{id:g.id,rect:g.rect.current,data:g.data,disabled:g.disabled}:null,i={active:a,activatorEvent:b,collisions:c,delta:{x:e.x,y:e.y},over:h};(0,lP.unstable_batchedUpdates)(()=>{aG(h),null==f||f(i),K({type:"onDragOver",event:i})})},[aE]),lY(()=>{am.current={activatorEvent:Z,active:V,activeNode:ag,collisionRect:aC,collisions:aD,droppableRects:ad,draggableNodes:Q,draggingNode:ap,draggingNodeRect:aq,droppableContainers:S,over:aF,scrollableAncestors:au,scrollAdjustedTranslate:aB},U.current={initial:aq,translated:aC}},[V,ag,aD,aC,Q,ap,aq,ad,S,aF,au,aB]),function(a){let b,{acceleration:c,activator:d=v.Pointer,canScroll:e,draggingRect:f,enabled:g,interval:h=5,order:i=w.TreeOrder,pointerCoordinates:j,scrollableAncestors:k,scrollableAncestorRects:l,delta:m,threshold:n}=a,o=function(a){let{delta:b,disabled:c}=a,d=l1(b);return l_(a=>{if(c||!d||!a)return m_;let e={x:Math.sign(b.x-d.x),y:Math.sign(b.y-d.y)};return{x:{[r.Backward]:a.x[r.Backward]||-1===e.x,[r.Forward]:a.x[r.Forward]||1===e.x},y:{[r.Backward]:a.y[r.Backward]||-1===e.y,[r.Forward]:a.y[r.Forward]||1===e.y}}},[c,b,d])}({delta:m,disabled:!g}),[p,q]=(b=(0,B.useRef)(null),[(0,B.useCallback)((a,c)=>{b.current=setInterval(a,c)},[]),(0,B.useCallback)(()=>{null!==b.current&&(clearInterval(b.current),b.current=null)},[])]),s=(0,B.useRef)({x:0,y:0}),t=(0,B.useRef)({x:0,y:0}),u=(0,B.useMemo)(()=>{switch(d){case v.Pointer:return j?{top:j.y,bottom:j.y,left:j.x,right:j.x}:null;case v.DraggableRect:return f}},[d,f,j]),x=(0,B.useRef)(null),y=(0,B.useCallback)(()=>{let a=x.current;if(!a)return;let b=s.current.x*t.current.x,c=s.current.y*t.current.y;a.scrollBy(b,c)},[]),z=(0,B.useMemo)(()=>i===w.TreeOrder?[...k].reverse():k,[i,k]);(0,B.useEffect)(()=>{if(!g||!k.length||!u)return void q();for(let a of z){if((null==e?void 0:e(a))===!1)continue;let b=l[k.indexOf(a)];if(!b)continue;let{direction:d,speed:f}=function(a,b,c,d,e){let{top:f,left:g,right:h,bottom:i}=c;void 0===d&&(d=10),void 0===e&&(e=mH);let{isTop:j,isBottom:k,isLeft:l,isRight:m}=mG(a),n={x:0,y:0},o={x:0,y:0},p={height:b.height*e.y,width:b.width*e.x};return!j&&f<=b.top+p.height?(n.y=r.Backward,o.y=d*Math.abs((b.top+p.height-f)/p.height)):!k&&i>=b.bottom-p.height&&(n.y=r.Forward,o.y=d*Math.abs((b.bottom-p.height-i)/p.height)),!m&&h>=b.right-p.width?(n.x=r.Forward,o.x=d*Math.abs((b.right-p.width-h)/p.width)):!l&&g<=b.left+p.width&&(n.x=r.Backward,o.x=d*Math.abs((b.left+p.width-g)/p.width)),{direction:n,speed:o}}(a,b,u,c,n);for(let a of["x","y"])o[a][d[a]]||(f[a]=0,d[a]=0);if(f.x>0||f.y>0){q(),x.current=a,p(y,h),s.current=f,t.current=d;return}}s.current={x:0,y:0},t.current={x:0,y:0},q()},[c,y,e,q,g,h,JSON.stringify(u),JSON.stringify(o),p,k,z,l,JSON.stringify(n)])}({...ai,delta:R,draggingRect:aC,pointerCoordinates:ax,scrollableAncestors:au,scrollableAncestorRects:av});let aM=(0,B.useMemo)(()=>({active:V,activeNode:ag,activeNodeRect:ak,activatorEvent:Z,collisions:aD,containerNodeRect:al,dragOverlay:ao,draggableNodes:Q,droppableContainers:S,droppableRects:ad,over:aF,measureDroppableContainers:ae,scrollableAncestors:au,scrollableAncestorRects:av,measuringConfiguration:ac,measuringScheduled:af,windowRect:at}),[V,ag,ak,Z,aD,al,ao,Q,S,ad,aF,ae,au,av,ac,af,at]),aN=(0,B.useMemo)(()=>({activatorEvent:Z,activators:aL,active:V,activeNodeRect:ak,ariaDescribedById:{draggable:aa},dispatch:J,draggableNodes:Q,over:aF,measureDroppableContainers:ae}),[Z,aL,V,ak,J,aa,Q,aF,ae]);return C().createElement(me.Provider,{value:L},C().createElement(nf.Provider,{value:aN},C().createElement(ng.Provider,{value:aM},C().createElement(nk.Provider,{value:aH},A)),C().createElement(nj,{disabled:(null==u?void 0:u.restoreFocus)===!1})),C().createElement(mh,{...u,hiddenTextDescribedById:aa}))}),nm=(0,B.createContext)(null),nn="button",no={timeout:25};function np(a,b,c){let d=a.slice();return d.splice(c<0?d.length+c:c,0,d.splice(b,1)[0]),d}function nq(a){return null!==a&&a>=0}let nr=a=>{let{rects:b,activeIndex:c,overIndex:d,index:e}=a,f=np(b,d,c),g=b[e],h=f[e];return h&&g?{x:h.left-g.left,y:h.top-g.top,scaleX:h.width/g.width,scaleY:h.height/g.height}:null},ns={scaleX:1,scaleY:1},nt=a=>{var b,c,d,e;let f,g,h,{activeIndex:i,activeNodeRect:j,index:k,rects:l,overIndex:m}=a,n=null!=(b=l[i])?b:j;if(!n)return null;if(k===i){let a=l[m];return a?{x:0,y:i<m?a.top+a.height-(n.top+n.height):a.top-n.top,...ns}:null}let o=(c=l,d=k,e=i,f=c[d],g=c[d-1],h=c[d+1],f?e<d?g?f.top-(g.top+g.height):h?h.top-(f.top+f.height):0:h?h.top-(f.top+f.height):g?f.top-(g.top+g.height):0:0);return k>i&&k<=m?{x:0,y:-n.height-o,...ns}:k<i&&k>=m?{x:0,y:n.height+o,...ns}:{x:0,y:0,...ns}},nu="Sortable",nv=C().createContext({activeIndex:-1,containerId:nu,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:nr,disabled:{draggable:!1,droppable:!1}});function nw(a){let{children:b,id:c,items:d,strategy:e=nr,disabled:f=!1}=a,{active:g,dragOverlay:h,droppableRects:i,over:j,measureDroppableContainers:k}=(0,B.useContext)(ng),l=l3(nu,c),m=null!==h.rect,n=(0,B.useMemo)(()=>d.map(a=>"object"==typeof a&&"id"in a?a.id:a),[d]),o=null!=g,p=g?n.indexOf(g.id):-1,q=j?n.indexOf(j.id):-1,r=(0,B.useRef)(n),s=!function(a,b){if(a===b)return!0;if(a.length!==b.length)return!1;for(let c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}(n,r.current),t=-1!==q&&-1===p||s,u="boolean"==typeof f?{draggable:f,droppable:f}:f;lY(()=>{s&&o&&k(n)},[s,n,o,k]),(0,B.useEffect)(()=>{r.current=n},[n]);let v=(0,B.useMemo)(()=>({activeIndex:p,containerId:l,disabled:u,disableTransforms:t,items:n,overIndex:q,useDragOverlay:m,sortedRects:n.reduce((a,b,c)=>{let d=i.get(b);return d&&(a[c]=d),a},Array(n.length)),strategy:e}),[p,l,u.draggable,u.droppable,t,n,q,i,m,e]);return C().createElement(nv.Provider,{value:v},b)}let nx=a=>{let{id:b,items:c,activeIndex:d,overIndex:e}=a;return np(c,d,e).indexOf(b)},ny=a=>{let{containerId:b,isSorting:c,wasDragging:d,index:e,items:f,newIndex:g,previousItems:h,previousContainerId:i,transition:j}=a;return!!j&&!!d&&(h===f||e!==g)&&(!!c||g!==e&&b===i)},nz={duration:200,easing:"ease"},nA="transform",nB=l9.Transition.toString({property:nA,duration:0,easing:"linear"}),nC={roleDescription:"sortable"};function nD(a){var b,c,d,e;let{animateLayoutChanges:f=ny,attributes:g,disabled:h,data:i,getNewIndex:j=nx,id:k,strategy:l,resizeObserverConfig:m,transition:n=nz}=a,{items:o,containerId:p,activeIndex:r,disabled:s,disableTransforms:t,sortedRects:u,overIndex:v,useDragOverlay:w,strategy:x}=(0,B.useContext)(nv),y=(b=h,c=s,"boolean"==typeof b?{draggable:b,droppable:!1}:{draggable:null!=(d=null==b?void 0:b.draggable)?d:c.draggable,droppable:null!=(e=null==b?void 0:b.droppable)?e:c.droppable}),z=o.indexOf(k),A=(0,B.useMemo)(()=>({sortable:{containerId:p,index:z,items:o},...i}),[p,i,z,o]),C=(0,B.useMemo)(()=>o.slice(o.indexOf(k)),[o,k]),{rect:D,node:E,isOver:F,setNodeRef:G}=function(a){let{data:b,disabled:c=!1,id:d,resizeObserverConfig:e}=a,f=l3("Droppable"),{active:g,dispatch:h,over:i,measureDroppableContainers:j}=(0,B.useContext)(nf),k=(0,B.useRef)({disabled:c}),l=(0,B.useRef)(!1),m=(0,B.useRef)(null),n=(0,B.useRef)(null),{disabled:o,updateMeasurementsFor:p,timeout:r}={...no,...e},s=l$(null!=p?p:d),t=m2({callback:(0,B.useCallback)(()=>{if(!l.current){l.current=!0;return}null!=n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{j(Array.isArray(s.current)?s.current:[s.current]),n.current=null},r)},[r]),disabled:o||!g}),[u,v]=l0((0,B.useCallback)((a,b)=>{t&&(b&&(t.unobserve(b),l.current=!1),a&&t.observe(a))},[t])),w=l$(b);return(0,B.useEffect)(()=>{t&&u.current&&(t.disconnect(),l.current=!1,t.observe(u.current))},[u,t]),(0,B.useEffect)(()=>(h({type:q.RegisterDroppable,element:{id:d,key:f,disabled:c,node:u,rect:m,data:w}}),()=>h({type:q.UnregisterDroppable,key:f,id:d})),[d]),(0,B.useEffect)(()=>{c!==k.current.disabled&&(h({type:q.SetDroppableDisabled,id:d,key:f,disabled:c}),k.current.disabled=c)},[d,f,c,h]),{active:g,rect:m,isOver:(null==i?void 0:i.id)===d,node:u,over:i,setNodeRef:v}}({id:k,data:A,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...m}}),{active:H,activatorEvent:I,activeNodeRect:J,attributes:K,setNodeRef:L,listeners:M,isDragging:N,over:O,setActivatorNodeRef:P,transform:Q}=function(a){let{id:b,data:c,disabled:d=!1,attributes:e}=a,f=l3("Draggable"),{activators:g,activatorEvent:h,active:i,activeNodeRect:j,ariaDescribedById:k,draggableNodes:l,over:m}=(0,B.useContext)(nf),{role:n=nn,roleDescription:o="draggable",tabIndex:p=0}=null!=e?e:{},q=(null==i?void 0:i.id)===b,r=(0,B.useContext)(q?nk:nm),[s,t]=l0(),[u,v]=l0(),w=(0,B.useMemo)(()=>g.reduce((a,c)=>{let{eventName:d,handler:e}=c;return a[d]=a=>{e(a,b)},a},{}),[g,b]),x=l$(c);return lY(()=>(l.set(b,{id:b,key:f,node:s,activatorNode:u,data:x}),()=>{let a=l.get(b);a&&a.key===f&&l.delete(b)}),[l,b]),{active:i,activatorEvent:h,activeNodeRect:j,attributes:(0,B.useMemo)(()=>({role:n,tabIndex:p,"aria-disabled":d,"aria-pressed":!!q&&n===nn||void 0,"aria-roledescription":o,"aria-describedby":k.draggable}),[d,n,p,q,o,k.draggable]),isDragging:q,listeners:d?void 0:w,node:s,over:m,setNodeRef:t,setActivatorNodeRef:v,transform:r}}({id:k,data:A,attributes:{...nC,...g},disabled:y.draggable}),R=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return(0,B.useMemo)(()=>a=>{b.forEach(b=>b(a))},b)}(G,L),S=!!H,T=S&&!t&&nq(r)&&nq(v),U=!w&&N,V=U&&T?Q:null,W=T?null!=V?V:(null!=l?l:x)({rects:u,activeNodeRect:J,activeIndex:r,overIndex:v,index:z}):null,X=nq(r)&&nq(v)?j({id:k,items:o,activeIndex:r,overIndex:v}):z,Y=null==H?void 0:H.id,Z=(0,B.useRef)({activeId:Y,items:o,newIndex:X,containerId:p}),$=o!==Z.current.items,_=f({active:H,containerId:p,isDragging:N,isSorting:S,id:k,index:z,items:o,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:n,wasDragging:null!=Z.current.activeId}),aa=function(a){let{disabled:b,index:c,node:d,rect:e}=a,[f,g]=(0,B.useState)(null),h=(0,B.useRef)(c);return lY(()=>{if(!b&&c!==h.current&&d.current){let a=e.current;if(a){let b=mx(d.current,{ignoreTransform:!0}),c={x:a.left-b.left,y:a.top-b.top,scaleX:a.width/b.width,scaleY:a.height/b.height};(c.x||c.y)&&g(c)}}c!==h.current&&(h.current=c)},[b,c,d,e]),(0,B.useEffect)(()=>{f&&g(null)},[f]),f}({disabled:!_,index:z,node:E,rect:D});return(0,B.useEffect)(()=>{S&&Z.current.newIndex!==X&&(Z.current.newIndex=X),p!==Z.current.containerId&&(Z.current.containerId=p),o!==Z.current.items&&(Z.current.items=o)},[S,X,p,o]),(0,B.useEffect)(()=>{if(Y===Z.current.activeId)return;if(null!=Y&&null==Z.current.activeId){Z.current.activeId=Y;return}let a=setTimeout(()=>{Z.current.activeId=Y},50);return()=>clearTimeout(a)},[Y]),{active:H,activeIndex:r,attributes:K,data:A,rect:D,index:z,newIndex:X,items:o,isOver:F,isSorting:S,isDragging:N,listeners:M,node:E,overIndex:v,over:O,setNodeRef:R,setActivatorNodeRef:P,setDroppableNodeRef:G,setDraggableNodeRef:L,transform:null!=aa?aa:W,transition:aa||$&&Z.current.newIndex===z?nB:(!U||l7(I))&&n&&(S||_)?l9.Transition.toString({...n,property:nA}):void 0}}function nE(a){if(!a)return!1;let b=a.data.current;return!!b&&"sortable"in b&&"object"==typeof b.sortable&&"containerId"in b.sortable&&"items"in b.sortable&&"index"in b.sortable}let nF=[t.Down,t.Right,t.Up,t.Left],nG=(a,b)=>{let{context:{active:c,collisionRect:d,droppableRects:e,droppableContainers:f,over:g,scrollableAncestors:h}}=b;if(nF.includes(a.code)){if(a.preventDefault(),!c||!d)return;let b=[];f.getEnabled().forEach(c=>{if(!c||null!=c&&c.disabled)return;let f=e.get(c.id);if(f)switch(a.code){case t.Down:d.top<f.top&&b.push(c);break;case t.Up:d.top>f.top&&b.push(c);break;case t.Left:d.left>f.left&&b.push(c);break;case t.Right:d.left<f.left&&b.push(c)}});let k=(a=>{let{collisionRect:b,droppableRects:c,droppableContainers:d}=a,e=mp(b),f=[];for(let a of d){let{id:b}=a,d=c.get(b);if(d){let c=mp(d),g=Number((e.reduce((a,b,d)=>a+mm(c[d],b),0)/4).toFixed(4));f.push({id:b,data:{droppableContainer:a,value:g}})}}return f.sort(mn)})({active:c,collisionRect:d,droppableRects:e,droppableContainers:b,pointerCoordinates:null}),l=mq(k,"id");if(l===(null==g?void 0:g.id)&&k.length>1&&(l=k[1].id),null!=l){let a=f.get(c.id),b=f.get(l),g=b?e.get(b.id):null,k=null==b?void 0:b.node.current;if(k&&g&&a&&b){var i,j;let c=mz(k).some((a,b)=>h[b]!==a),e=nH(a,b),f=(i=a,j=b,!!nE(i)&&!!nE(j)&&!!nH(i,j)&&i.data.current.sortable.index<j.data.current.sortable.index),l=c||!e?{x:0,y:0}:{x:f?d.width-g.width:0,y:f?d.height-g.height:0},m={x:g.left,y:g.top};return l.x&&l.y?m:l6(m,l)}}}};function nH(a,b){return!!nE(a)&&!!nE(b)&&a.data.current.sortable.containerId===b.data.current.sortable.containerId}let nI=(0,S.A)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);var nJ=c(9913);let nK=(0,S.A)("circle-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]),nL=[{value:"#3b82f6",label:"presetColorBlue"},{value:"#0891b2",label:"presetColorCyan"},{value:"#16a34a",label:"presetColorGreen"},{value:"#b7791f",label:"presetColorAmber"},{value:"#ea580c",label:"presetColorOrange"},{value:"#dc2626",label:"presetColorRed"},{value:"#db2777",label:"presetColorPink"},{value:"#8b5cf6",label:"presetColorPurple"}];function nM(a){return nL.map(({value:b})=>({value:b,count:a.filter(a=>a.color?.toLowerCase()===b).length})).reduce((a,b)=>b.count<a.count?b:a).value}let nN=["OpenAI Chat Completions","OpenAI Responses","Anthropic Messages","Google Generative AI","Mistral Conversations","Azure OpenAI Responses","OpenAI Codex Responses","Amazon Bedrock","Google Vertex AI","Pi Messages"],nO=["openai-completions","openai-responses","anthropic-messages","google-generative-ai","mistral-conversations","azure-openai-responses","openai-codex-responses","bedrock-converse-stream","google-vertex","pi-messages"].map((a,b)=>({value:a,label:nN[b]})),nP=["openai","openrouter","together","deepseek","zai","qwen","chat-template","qwen-chat-template","string-thinking","ant-ling","baseten"];function nQ(a){return Object.entries(a).map(([a,b])=>`${a}: ${b}`).join("\n")}function nR({headers:a,onChange:b,placeholder:c}){let[d,e]=(0,B.useState)(null);return(0,A.jsx)(iE.T,{value:d??nQ(a),onFocus:()=>e(nQ(a)),onChange:a=>{let c=a.target.value;e(c),b(Object.fromEntries(c.split("\n").map(a=>a.trim()).filter(Boolean).map(a=>{let b=a.indexOf(":");return b>0?[a.slice(0,b).trim(),a.slice(b+1).trim()]:[a,""]})))},onBlur:()=>e(null),rows:4,placeholder:c,className:"font-mono"})}function nS(a){let b=Math.floor(a/1e3),c=a%1e3;return c?`${b}.${String(c).padStart(3,"0").replace(/0+$/,"")}`:String(b)}function nT(a){if(!/^\d+(?:\.\d{0,3})?$/.test(a))return null;let[b,c=""]=a.split("."),d=1e3*Number(b)+Number(c.padEnd(3,"0"));return Number.isSafeInteger(d)&&d>0?d:null}function nU({label:a,children:b,className:c}){return(0,A.jsxs)("label",{className:(0,W.cn)("grid gap-1 text-sm text-foreground",c),children:[(0,A.jsx)("span",{className:"font-medium",children:a}),b]})}let nV="__pi-desk_empty__";function nW({value:a,options:b,onChange:c,ariaLabel:d,placeholder:e,allowEmpty:f=!0,className:g}){let{t:h}=(0,Q.Bd)("settings"),i=e??h("useDefault"),j=a||(f?nV:b[0]?.value??null),k=!!a&&!b.some(b=>b.value===a);return(0,A.jsxs)(bS.l6,{value:j,onValueChange:a=>c(a===nV||null===a?"":a),children:[(0,A.jsx)(bS.bq,{"aria-label":d,className:(0,W.cn)("w-full",g),children:(0,A.jsx)(bS.yv,{children:b.find(b=>b.value===a)?.label??(a||i)})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[120]",children:[f?(0,A.jsx)(bS.eb,{value:nV,children:i}):null,k?(0,A.jsx)(bS.eb,{value:a,children:a}):null,b.map(a=>(0,A.jsx)(bS.eb,{value:a.value,children:a.label},a.value))]})]})}function nX({value:a,onChange:b,ariaLabel:c}){let{t:d}=(0,Q.Bd)("settings");return(0,A.jsx)(nW,{value:null===a?"":String(a),ariaLabel:c,options:[{value:"true",label:d("yes")},{value:"false",label:d("no")}],onChange:a=>b(""===a?null:"true"===a)})}let nY={off:"thinkingOff",minimal:"thinkingMinimal",low:"thinkingLow",medium:"thinkingMedium",high:"thinkingHigh",xhigh:"thinkingXhigh",max:"thinkingMax"};function nZ(a,b){return JSON.stringify([a,b])}function n$(a,b){return JSON.stringify([a.provider,a.modelId,a.thinkingLevel,b])}function n_(a){return a.map(a=>({value:nZ(a.provider,a.modelId),label:a.name||a.modelId,description:a.provider}))}function n0(a,b){return(a?.thinkingLevels??[]).map(a=>({value:a,label:b(nY[a])}))}function n1({id:a,preset:b,model:c,models:d,canMoveUp:e,canMoveDown:f,onChange:g,onDelete:h,onMoveUp:i,onMoveDown:j}){let{t:k}=(0,Q.Bd)("settings"),{attributes:l,listeners:m,setActivatorNodeRef:n,setNodeRef:o,transform:p,transition:q,isDragging:r}=nD({id:a}),s=p?`translate3d(${p.x}px, ${p.y}px, 0) scaleX(${p.scaleX??1}) scaleY(${p.scaleY??1})`:void 0,t=b.color?.toLowerCase()??"none",u=nL.find(a=>a.value===t),v=u?k(u.label):k(b.color?"presetColorCustom":"presetColorNone"),w=[{value:"none",color:null,label:k("presetColorNone")},...b.color&&!u?[{value:t,color:b.color,label:k("presetColorCustom")}]:[],...nL.map(a=>({value:a.value,color:a.value,label:k(a.label)}))];return(0,A.jsxs)("div",{ref:o,style:{transform:s,transition:q},className:(0,W.cn)("grid min-w-0 items-center gap-3 border-b bg-card py-3 @[48rem]/presets:grid-cols-[auto_minmax(0,1fr)_7.5rem_4rem_auto]",r&&"z-10 opacity-70 shadow-lg"),children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(U.$,{variant:"ghost",size:"icon-sm",ref:n,type:"button",title:k("presetDrag"),"aria-label":k("presetDrag"),className:"touch-none cursor-grab text-muted-foreground active:cursor-grabbing",...l,...m,children:(0,A.jsx)(nI,{className:"size-4"})}),(0,A.jsxs)("div",{className:"flex gap-2",children:[(0,A.jsx)(U.$,{variant:"ghost",size:"icon-sm",type:"button",title:k("presetMoveUp"),"aria-label":k("presetMoveUp"),disabled:!e,onClick:i,children:(0,A.jsx)(nJ.A,{className:"size-4"})}),(0,A.jsx)(U.$,{variant:"ghost",size:"icon-sm",type:"button",title:k("presetMoveDown"),"aria-label":k("presetMoveDown"),disabled:!f,onClick:j,children:(0,A.jsx)(cr.A,{className:"size-4"})})]})]}),(0,A.jsx)(nU,{label:k("modelsHeading"),children:(0,A.jsx)(km.b,{value:nZ(b.provider,b.modelId),options:n_(d),ariaLabel:k("presetModel"),searchPlaceholder:k("modelSearch"),onChange:a=>{let c=d.find(b=>nZ(b.provider,b.modelId)===a);c&&g({...b,provider:c.provider,modelId:c.modelId,thinkingLevel:c.thinkingLevels.includes(b.thinkingLevel)?b.thinkingLevel:c.thinkingLevels[0]})}})}),(0,A.jsx)(nU,{label:k("thinkingLevel"),children:(0,A.jsx)(nW,{value:b.thinkingLevel,options:n0(c,k),ariaLabel:k("presetThinking"),allowEmpty:!1,onChange:a=>g({...b,thinkingLevel:a})})}),(0,A.jsx)(nU,{label:k("presetColor"),children:(0,A.jsxs)(bS.l6,{value:t,onValueChange:a=>{null!==a&&g({...b,color:"none"===a?null:a})},children:[(0,A.jsx)(bS.bq,{"aria-label":k("presetColorLabel"),className:"w-16",children:(0,A.jsxs)(bS.yv,{children:[b.color?(0,A.jsx)("span",{"aria-hidden":"true",className:"size-4 shrink-0 rounded-full",style:{backgroundColor:b.color}}):(0,A.jsx)(nK,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),(0,A.jsx)("span",{className:"sr-only",children:v})]})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[120]",className:"w-40 min-w-40",align:"end",alignItemWithTrigger:!1,children:(0,A.jsx)(bS.s3,{className:"grid grid-cols-4 gap-1 p-2",children:w.map(a=>(0,A.jsx)(bS.eb,{value:a.value,label:a.label,"aria-label":a.label,className:"size-8 justify-center p-0 data-selected:bg-accent data-selected:ring-1 data-selected:ring-ring data-selected:ring-inset [&>span:first-child]:justify-center [&>span:last-child]:hidden",children:a.color?(0,A.jsx)("span",{"aria-hidden":"true",className:"size-4 shrink-0 self-center rounded-full",style:{backgroundColor:a.color}}):(0,A.jsx)(nK,{"aria-hidden":"true",className:"size-4 text-muted-foreground"})},a.value))})})]})}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm",title:k("presetDelete"),"aria-label":k("presetDelete"),onClick:h,children:(0,A.jsx)(bN,{})})]})}function n2({presets:a,models:b,onChange:c}){let{t:d}=(0,Q.Bd)("settings"),[e,f]=(0,B.useState)(()=>b[0]?nZ(b[0].provider,b[0].modelId):""),g=b.find(a=>nZ(a.provider,a.modelId)===e),[h,i]=(0,B.useState)(g?.thinkingLevels[0]??"off"),j=mk(mj(mW,{activationConstraint:{distance:6}}),mj(mR,{coordinateGetter:nG})),k=(0,B.useMemo)(()=>a.map(n$),[a]);return(0,A.jsxs)("div",{className:"@container/presets space-y-4 p-4 sm:p-6",children:[(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:d("presetDescription")}),(0,A.jsxs)("div",{className:"grid gap-3 border-b pb-4 @[32rem]/presets:grid-cols-[minmax(0,1fr)_7.5rem_auto]",children:[(0,A.jsx)(nU,{label:d("modelsHeading"),children:(0,A.jsx)(km.b,{value:e,options:n_(b),ariaLabel:d("presetModelNew"),searchPlaceholder:d("modelSearch"),disabled:0===b.length,onChange:a=>{f(a);let c=b.find(b=>nZ(b.provider,b.modelId)===a);c&&i(c.thinkingLevels[0])}})}),(0,A.jsx)(nU,{label:d("thinkingLevel"),children:(0,A.jsx)(nW,{value:h,options:n0(g,d),ariaLabel:d("presetThinkingNew"),allowEmpty:!1,onChange:a=>i(a)})}),(0,A.jsxs)(U.$,{type:"button",variant:"outline",className:"self-end justify-self-start",onClick:function(){let d=b.find(a=>nZ(a.provider,a.modelId)===e);if(!d)return;let f=d.thinkingLevels.includes(h)?h:d.thinkingLevels[0];a.some(a=>a.provider===d.provider&&a.modelId===d.modelId&&a.thinkingLevel===f)||c([...a,{provider:d.provider,modelId:d.modelId,thinkingLevel:f,color:nM(a)}])},disabled:!g,children:[(0,A.jsx)(am,{})," ",d("presetAdd")]})]}),0===a.length?(0,A.jsx)("p",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:d("presetEmpty")}):(0,A.jsx)(nl,{sensors:j,collisionDetection:ms,onDragEnd:function(b){if(!b.over||b.active.id===b.over.id)return;let d=k.indexOf(String(b.active.id)),e=k.indexOf(String(b.over.id));d>=0&&e>=0&&c(np(a,d,e))},children:(0,A.jsx)(nw,{items:k,strategy:nt,children:(0,A.jsx)("div",{className:"space-y-2",children:a.map((d,e)=>{let f=b.find(a=>a.provider===d.provider&&a.modelId===d.modelId);return(0,A.jsx)(n1,{id:k[e],preset:d,model:f,models:b,canMoveUp:e>0,canMoveDown:e<a.length-1,onChange:b=>c(a.map((a,c)=>c===e?b:a)),onDelete:()=>c(a.filter((a,b)=>b!==e)),onMoveUp:()=>c(np(a,e,e-1)),onMoveDown:()=>c(np(a,e,e+1))},k[e])})})})})]})}let n3=(0,S.A)("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]),n4=(0,S.A)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var n5=c(99451),n6=c(9860);function n7(a){return 100*!!a.official+10*!!a.defaults.cost}let n8=[["off","thinkingOff"],["minimal","thinkingMinimal"],["low","thinkingLow"],["medium","thinkingMedium"],["high","thinkingHigh"],["xhigh","thinkingXhigh"],["max","thinkingMax"]],n9=[["input","inputPrice"],["output","outputPrice"],["cacheRead","cacheReadPrice"],["cacheWrite","cacheWritePrice"]];function oa(a){return{input:String(a.cost?.input??""),output:String(a.cost?.output??""),cacheRead:String(a.cost?.cacheRead??""),cacheWrite:String(a.cost?.cacheWrite??"")}}function ob(a,b){return Object.values(a).some(a=>null===nT(a))||Object.values(b).some(a=>""!==a&&(!Number.isFinite(Number(a))||0>Number(a)))}function oc({biz:a,provider:b,model:c,onChange:d,onInputState:e}){let{t:f}=(0,Q.Bd)("settings"),g=(0,B.useId)(),[h,i]=(0,B.useState)({contextWindow:nS(c.contextWindow),maxTokens:nS(c.maxTokens)}),[j,k]=(0,B.useState)(()=>oa(c)),{searchText:l,setSearchText:m,catalogOpen:n,setCatalogOpen:o,loadingCatalog:p,candidates:q,visibleCandidates:r,showAllCandidates:s,setShowAllCandidates:t,selectedCandidateKey:u,setSelectedCandidateKey:v}=function(a){let{t:b}=(0,Q.Bd)("settings");(0,bK.G)(),(0,B.useRef)(0);let[c,d]=(0,B.useState)(a),[e,f]=(0,B.useState)([]),[g,h]=(0,B.useState)(!1),[i,j]=(0,B.useState)(null),[k,l]=(0,B.useState)(!1),[m,n]=(0,B.useState)(!1),o=(0,B.useMemo)(()=>{let a=new Map,b=e.filter(a=>"exact"===a.match);for(let c of b.length?b:e)for(let b of c.sources){let d=JSON.stringify([c.referenceId,b.modelId,b.defaults]),e=a.get(d);e?e.sources.push(b):a.set(d,{item:c,sources:[b]})}let d=c.trim().toLocaleLowerCase();return[...a.entries()].map(([a,b])=>{let c=[...b.sources].sort((a,b)=>n7(b)-n7(a)||a.providerName.localeCompare(b.providerName)),d=c[0];return{key:a,item:b.item,source:d,equivalentSourceCount:c.length,recommended:d.official}}).sort((a,b)=>("exact"===a.item.match?0:"similar"===a.item.match?1:2)-("exact"===b.item.match?0:"similar"===b.item.match?1:2)||Number(b.recommended)-Number(a.recommended)||Number(b.source.modelId.toLocaleLowerCase()===d)-Number(a.source.modelId.toLocaleLowerCase()===d)||a.source.providerName.localeCompare(b.source.providerName))},[e,c]);return{searchText:c,setSearchText:d,catalogOpen:g,setCatalogOpen:a=>{h(a),a||l(!1)},loadingCatalog:k,candidates:o,visibleCandidates:m?o:o.slice(0,6),showAllCandidates:m,setShowAllCandidates:n,selectedCandidateKey:i,setSelectedCandidateKey:j}}(c.modelId),w=new Map(c.thinkingLevels.map(a=>[a.level,a])),x=nO.find(a=>a.value===b.api)?.label??b.api;function y(a){d({...c,...a})}return(0,A.jsxs)("div",{className:"@container/model-editor space-y-6",children:[(0,A.jsxs)("div",{className:"grid max-w-[40rem] gap-3 @[32rem]/model-editor:grid-cols-2",children:[(0,A.jsxs)("div",{className:"grid gap-1 text-sm @[32rem]/model-editor:col-span-2",children:[(0,A.jsx)("label",{htmlFor:g,className:"font-medium",children:f("modelId")}),(0,A.jsx)(n6.uB,{shouldFilter:!1,loop:!0,className:"h-auto w-full overflow-visible rounded-none bg-transparent p-0 [&_[data-slot=command-input-wrapper]]:p-0 [&_[data-slot=input-group-addon]]:hidden",onKeyDown:a=>{"Escape"===a.key&&n&&(a.preventDefault(),a.stopPropagation(),o(!1))},children:(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)(n6.G7,{id:g,value:l,onValueChange:a=>{m(a),y({modelId:a}),v(null),t(!1),o(!0)},placeholder:f("modelIdSearch"),"aria-label":f("modelId"),"aria-autocomplete":"list",className:"pr-9"}),(0,A.jsxs)(cq.AM,{open:n,onOpenChange:a=>{o(a),a&&t(!1)},children:[(0,A.jsx)(cq.Wv,{render:(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm",title:f("chooseModel"),"aria-label":f("chooseModel"),"aria-busy":p,className:"absolute top-0.5 right-0.5 z-10",children:p?(0,A.jsx)(R.A,{className:"animate-spin"}):(0,A.jsx)(n5.A,{})})}),(0,A.jsx)(cq.hl,{align:"end",sideOffset:4,initialFocus:!1,finalFocus:!1,positionerClassName:"z-[120]",className:"w-[min(32rem,calc(100vw-2rem))] gap-0 p-0",children:(0,A.jsx)(n6.oI,{className:"max-h-[min(24rem,var(--available-height))] p-1",children:p&&0===q.length?(0,A.jsx)("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:f("matchingCatalog")}):0===q.length?(0,A.jsx)(n6.xL,{className:"py-6 text-sm",children:f("noCatalogMatches")}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(n6.L$,{className:"p-0",children:r.map(a=>(0,A.jsx)(n6.h_,{value:a.key,"data-checked":u===a.key?"true":void 0,className:"px-3 py-2",onSelect:()=>(function(a){let{item:b,source:f}=a,g={...c,modelId:f.modelId,name:b.name,...f.defaults};d(g),i({contextWindow:nS(g.contextWindow),maxTokens:nS(g.maxTokens)}),k(oa(g)),e({dirty:!1,invalid:!1}),m(f.modelId),v(a.key),t(!1),o(!1)})(a),children:(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("span",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,A.jsx)("span",{className:"break-all font-mono text-sm font-semibold",children:a.source.modelId}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:a.source.providerName})]}),(0,A.jsxs)("span",{className:"mt-1 block text-xs text-muted-foreground",children:[a.item.name," \xb7"," ",f("contextAndOutput",{context:`${nS(a.source.defaults.contextWindow)}K`,output:`${nS(a.source.defaults.maxTokens)}K`})]}),(0,A.jsx)("span",{className:"mt-1 block text-xs text-muted-foreground",children:a.source.defaults.cost?`${f("priceInput",{price:`$${a.source.defaults.cost.input}`})} \xb7 ${f("priceOutput",{price:`$${a.source.defaults.cost.output}`})}${f("perMillionTokens")}`:f("priceMissing")})]})},a.key))}),!s&&q.length>r.length?(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:()=>t(!0),children:f("moreConfigurations",{count:q.length-r.length})}):null]})})})]})]})}),c.modelId.trim()?null:(0,A.jsx)("span",{className:"text-xs text-destructive",children:f("modelIdRequired")})]}),(0,A.jsxs)(nU,{label:f("modelName"),className:"@[32rem]/model-editor:col-span-2",children:[(0,A.jsx)(bY.p,{value:c.name,onChange:a=>y({name:a.target.value})}),c.name.trim()?null:(0,A.jsx)("span",{className:"text-xs text-destructive",children:f("modelNameRequired")})]}),[["contextWindow","contextLength"],["maxTokens","maximumOutput"]].map(([a,b])=>{let c=null===nT(h[a]);return(0,A.jsxs)(nU,{label:f(b),children:[(0,A.jsxs)(j4.MG,{children:[(0,A.jsx)(j4.iV,{"aria-label":f(b),inputMode:"decimal",value:h[a],"aria-invalid":c,"aria-describedby":c?`${g}-${a}-error`:void 0,onChange:b=>{var c;let d,f,g;return c=b.target.value,i(d={...h,[a]:c}),e({dirty:f=ob(d,j),invalid:f}),void(null!==(g=nT(c))&&y({[a]:g}))}}),(0,A.jsx)(j4.Sq,{align:"inline-end",children:"K"})]}),c?(0,A.jsx)("span",{id:`${g}-${a}-error`,role:"alert",className:"text-xs text-destructive",children:f("capacityInvalid")}):null]},a)})]}),(0,A.jsxs)("section",{children:[(0,A.jsx)("p",{className:"text-sm font-semibold",children:f("capabilities")}),(0,A.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2 text-sm",children:[c.input.map(a=>(0,A.jsx)("span",{className:"rounded-md bg-muted px-2 py-1",children:f("text"===a?"textInput":"imageInput")},a)),c.reasoning?(0,A.jsx)("span",{className:"rounded-md bg-muted px-2 py-1",children:f("supportsThinking")}):null]})]}),(0,A.jsxs)("details",{className:"border-t pt-3",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-semibold",children:f("inputAndThinking")}),(0,A.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[["text","image"].map(a=>{let b=c.input.includes(a);return(0,A.jsxs)(U.$,{type:"button",size:"sm",variant:"outline","aria-pressed":b,onClick:()=>{b&&1===c.input.length||y({input:b?c.input.filter(b=>b!==a):[...c.input,a]})},children:[b?(0,A.jsx)(bs.A,{}):null,f("text"===a?"textInput":"imageInput")]},a)}),(0,A.jsxs)(U.$,{type:"button",size:"sm",variant:"outline","aria-pressed":c.reasoning,onClick:()=>y({reasoning:!c.reasoning,thinkingLevels:c.reasoning?[{level:"off",providerValue:null}]:[{level:"high",providerValue:null}]}),children:[c.reasoning?(0,A.jsx)(bs.A,{}):null,f("supportsThinking")]})]}),c.reasoning?(0,A.jsxs)("details",{className:"mt-4 border-t pt-3",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:f("thinkingMapping")}),(0,A.jsx)("div",{className:"mt-2 grid max-w-[40rem] gap-x-4 @[32rem]/model-editor:grid-cols-2",children:n8.map(([a,b])=>{let d=w.get(a);return(0,A.jsxs)("div",{className:"grid grid-cols-[6rem_minmax(0,1fr)] items-center gap-2 border-b py-2",children:[(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm","aria-pressed":!!d,className:"justify-start",onClick:()=>{let b=d?c.thinkingLevels.filter(b=>b.level!==a):[...c.thinkingLevels,{level:a,providerValue:"off"===a?null:a}];b.length&&y({thinkingLevels:b})},children:[d?(0,A.jsx)(bs.A,{}):null,f(b)]}),(0,A.jsx)(bY.p,{"aria-label":f("providerMapping",{level:f(b)}),disabled:!d||"off"===a,value:"off"===a?f("noMapping"):d?.providerValue??"",placeholder:a,onChange:b=>y({thinkingLevels:c.thinkingLevels.map(c=>c.level===a?{...c,providerValue:b.target.value||null}:c)})})]},a)})})]}):null]}),(0,A.jsxs)("details",{className:"border-t pt-3",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-semibold",children:f("price")}),(0,A.jsxs)("div",{className:"mt-3 grid max-w-[40rem] gap-3 @[32rem]/model-editor:grid-cols-2",children:[n9.map(([a,b])=>{let d=""!==j[a]&&(!Number.isFinite(Number(j[a]))||0>Number(j[a]));return(0,A.jsxs)(nU,{label:f(b),children:[(0,A.jsx)(bY.p,{inputMode:"decimal",value:j[a],"aria-invalid":d,onChange:b=>(function(a,b){let d={...j,[a]:b};k(d);let f=ob(h,d);if(e({dirty:f,invalid:f}),Object.values(d).every(a=>""===a))return void y({cost:null});let g=Number(b);Number.isFinite(g)&&!(g<0)&&y({cost:{input:c.cost?.input??0,output:c.cost?.output??0,cacheRead:c.cost?.cacheRead??0,cacheWrite:c.cost?.cacheWrite??0,[a]:g}})})(a,b.target.value)}),d?(0,A.jsx)("span",{role:"alert",className:"text-xs text-destructive",children:f("priceInvalid")}):null]},a)}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"sm",className:"justify-self-start",onClick:()=>{let a={input:"",output:"",cacheRead:"",cacheWrite:""};k(a),e({dirty:!0,invalid:ob(h,a)}),y({cost:null})},children:f("clearPrice")})]})]}),(0,A.jsxs)("details",{className:"border-t pt-3",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-semibold",children:f("advancedCompatibility")}),(0,A.jsxs)("div",{className:"mt-3 grid max-w-[40rem] gap-3 @[32rem]/model-editor:grid-cols-2",children:[(0,A.jsx)(nU,{label:f("apiOverride"),className:"@[32rem]/model-editor:col-span-2",children:(0,A.jsx)(nW,{value:c.api??"",ariaLabel:f("apiOverride"),options:nO,placeholder:x?f("inheritServiceValue",{value:x}):f("inheritService"),onChange:a=>y({api:a||null})})}),(0,A.jsx)(nU,{label:f("baseUrlOverride"),className:"@[32rem]/model-editor:col-span-2",children:(0,A.jsx)(bY.p,{value:c.baseUrl??"","aria-label":f("baseUrlOverride"),placeholder:b.baseUrl?f("inheritServiceValue",{value:b.baseUrl}):f("inheritService"),onChange:a=>y({baseUrl:a.target.value||null})})}),(0,A.jsx)(nU,{label:f("modelHeaders"),className:"@[32rem]/model-editor:col-span-2",children:(0,A.jsx)(nR,{headers:c.headers,onChange:a=>y({headers:a}),placeholder:f("headerPlaceholder")})}),(0,A.jsx)(nU,{label:f("developerRole"),children:(0,A.jsx)(nX,{value:c.compat?.supportsDeveloperRole??null,ariaLabel:f("developerRole"),onChange:a=>y({compat:{supportsDeveloperRole:a,thinkingFormat:c.compat?.thinkingFormat??null,requiresReasoningContentOnAssistantMessages:c.compat?.requiresReasoningContentOnAssistantMessages??null}})})}),(0,A.jsx)(nU,{label:"Thinking Format",children:(0,A.jsx)(nW,{value:c.compat?.thinkingFormat??"",ariaLabel:"Thinking Format",options:nP.map(a=>({value:a,label:a})),onChange:a=>y({compat:{supportsDeveloperRole:c.compat?.supportsDeveloperRole??null,thinkingFormat:a||null,requiresReasoningContentOnAssistantMessages:c.compat?.requiresReasoningContentOnAssistantMessages??null}})})}),(0,A.jsx)(nU,{label:f("replayReasoning"),children:(0,A.jsx)(nX,{value:c.compat?.requiresReasoningContentOnAssistantMessages??null,ariaLabel:f("replayReasoning"),onChange:a=>y({compat:{supportsDeveloperRole:c.compat?.supportsDeveloperRole??null,thinkingFormat:c.compat?.thinkingFormat??null,requiresReasoningContentOnAssistantMessages:a}})})})]})]})]})}var od=c(72175),oe=c(24811);function of({className:a,disabled:b,id:c,...d}){let{t:e}=(0,Q.Bd)("common"),[f,g]=B.useState(!1),h=e(f?"hideSecret":"revealSecret");return(0,A.jsxs)("div",{className:"relative min-w-0",children:[(0,A.jsx)(bY.p,{...d,id:c,disabled:b,type:"text",autoComplete:"off",autoCapitalize:"none",spellCheck:!1,className:(0,W.cn)("pr-9",!f&&"[-webkit-text-security:disc]",a)}),(0,A.jsx)("button",{type:"button",className:"absolute top-1/2 right-1 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50","aria-label":h,"aria-controls":c,"aria-pressed":f,title:h,disabled:b,onClick:()=>g(a=>!a),children:f?(0,A.jsx)(od.A,{className:"size-3.5"}):(0,A.jsx)(oe.A,{className:"size-3.5"})})]})}function og({provider:a,existingIds:b,isNew:c,onApply:d,onDelete:e,onClose:f,onDirtyChange:g}){let{t:h}=(0,Q.Bd)("settings"),{confirm:i,dialog:j}=kg(),[k,l]=(0,B.useState)(()=>structuredClone(a)),m=JSON.stringify(k)!==JSON.stringify(a),n=!k.provider.trim()||b.includes(k.provider.trim()),o=k.provider||h("providerUnnamed");function p(a){l(b=>({...b,...a}))}async function q(){(!m||await i({title:h("discardServiceTitle"),description:h("discardServiceDescription"),confirmLabel:h("discardModelConfirm")}))&&f()}async function r(){await i({title:h("providerDeleteTitle"),description:h("providerDeleteDescription",{name:o,count:a.models.length})})&&e()}return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(b7.YV,{open:!0,onOpenChange:a=>{a||q()},children:(0,A.jsxs)(b7.hA,{className:"max-w-[40rem]",initialFocus:!1,children:[(0,A.jsxs)(b7.Hl,{className:"border-b px-4 py-4 pr-12",children:[(0,A.jsx)(b7.YM,{children:h("serviceConnection")}),(0,A.jsx)(b7.uX,{children:h("serviceDraftScope",{count:a.models.length})})]}),(0,A.jsx)(b7._Y,{className:"max-h-[65dvh]",children:(0,A.jsxs)("div",{className:"space-y-5 p-4",children:[(0,A.jsxs)(nU,{label:h("serviceId"),children:[(0,A.jsx)(bY.p,{value:k.provider,"aria-label":h("serviceId"),autoComplete:"off",autoCapitalize:"none",spellCheck:!1,placeholder:h("providerIdExample"),"aria-invalid":n,onChange:a=>p({provider:a.target.value})}),n?(0,A.jsx)("span",{role:"alert",className:"text-xs text-destructive",children:h("serviceIdInvalid")}):null]}),(0,A.jsx)(nU,{label:h("serviceAddress"),children:(0,A.jsx)(bY.p,{value:k.baseUrl??"",placeholder:"https://api.example.com/v1",onChange:a=>p({baseUrl:a.target.value||null})})}),(0,A.jsx)(nU,{label:h("providerApiType"),children:(0,A.jsx)(nW,{value:k.api??"",ariaLabel:h("providerApiType"),options:nO,onChange:a=>p({api:a||null})})}),(0,A.jsx)(nU,{label:h("serviceKey"),children:(0,A.jsx)(of,{value:k.apiKey??"",onChange:a=>p({apiKey:a.target.value||null})})}),(0,A.jsxs)("details",{className:"border-t pt-3",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-semibold",children:h("providerAdvanced")}),(0,A.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,A.jsx)(nU,{label:h("providerAuthHeader"),children:(0,A.jsx)(nX,{value:k.authHeader,ariaLabel:h("providerAuthHeader"),onChange:a=>p({authHeader:a})})}),(0,A.jsx)(nU,{label:h("providerHeaders"),children:(0,A.jsx)(nR,{headers:k.headers,onChange:a=>p({headers:a}),placeholder:h("headerPlaceholder")})})]})]})]})}),(0,A.jsxs)(b7.vu,{children:[c?null:(0,A.jsxs)(U.$,{type:"button",variant:"ghost",className:"mr-auto text-destructive hover:text-destructive",onClick:r,children:[(0,A.jsx)(bN,{}),h("providerDelete")]}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",onClick:f,children:h("cancel",{ns:"common"})}),(0,A.jsx)(U.$,{type:"button",disabled:n||!m&&!c,onClick:()=>d(k),children:h("applyServiceDraft")})]})]})}),j]})}let oh=E.Ik({}).strict(),oi=E.Yj().trim().min(1).max(128),oj=E.Yj().max(32768),ok=E.Ik({url:oj,label:oj.optional()}).strict(),ol=E.Ik({provider:oi,name:oj,loggedIn:E.zM(),conflict:E.Yj().nullable()}).strict(),om=E.Ik({id:E.Yj().uuid(),type:E.k5(["text","secret","select","manual_code"]),message:oj,placeholder:oj.optional(),options:E.YO(E.Ik({id:oj,label:oj,description:oj.optional()}).strict()).optional()}).strict(),on=E.gM("type",[E.Ik({type:E.eu("auth_url"),url:oj,instructions:oj.optional()}).strict(),E.Ik({type:E.eu("device_code"),userCode:oj,verificationUri:oj}).strict(),E.Ik({type:E.eu("info"),message:oj,links:E.YO(ok).optional()}).strict(),E.Ik({type:E.eu("progress"),message:oj}).strict()]),oo=E.Ik({loginId:E.Yj().uuid(),provider:oi,status:E.k5(["running","completed","cancelled","error"]),notice:on.nullable(),prompt:om.nullable(),message:E.Yj().nullable()}).strict(),op=Object.freeze({list:(0,F.Vc)({path:"model-auth/list",inputSchema:oh,outputSchema:E.Ik({providers:E.YO(ol)}).strict()}),start:(0,F.Vc)({path:"model-auth/start",inputSchema:E.Ik({loginId:E.Yj().uuid(),provider:oi}).strict(),outputSchema:oh}),respond:(0,F.Vc)({path:"model-auth/respond",inputSchema:E.Ik({loginId:E.Yj().uuid(),promptId:E.Yj().uuid(),value:oj}).strict(),outputSchema:oh}),cancel:(0,F.Vc)({path:"model-auth/cancel",inputSchema:E.Ik({loginId:E.Yj().uuid()}).strict(),outputSchema:oh}),logout:(0,F.Vc)({path:"model-auth/logout",inputSchema:E.Ik({provider:oi}).strict(),outputSchema:oh}),state:(0,F._G)({path:"model-auth/state",bodySchema:oo})});function oq(a){try{let b=new URL(a);return"http:"===b.protocol||"https:"===b.protocol?b.href:null}catch{return null}}function or(a){let b=oq(a);b&&window.open(b,"_blank","noopener,noreferrer")}async function os(a){await navigator.clipboard.writeText(a)}function ot({prompt:a,submitting:b,onRespond:c}){let{t:d}=(0,Q.Bd)("settings"),[e,f]=(0,B.useState)(""),g="select"!==a.type||e.length>0;return(0,A.jsxs)("form",{className:"grid gap-3",onSubmit:d=>{d.preventDefault(),g&&!b&&c(a.id,e)},children:[(0,A.jsx)(nU,{label:a.message,children:"select"===a.type?(0,A.jsx)(nW,{value:e,ariaLabel:a.message,placeholder:a.placeholder??d("accountChooseOption"),options:(a.options??[]).map(a=>({value:a.id,label:a.description?`${a.label} — ${a.description}`:a.label})),onChange:f}):"secret"===a.type?(0,A.jsx)(of,{value:e,placeholder:a.placeholder,disabled:b,onChange:a=>f(a.target.value)}):(0,A.jsx)(bY.p,{value:e,placeholder:a.placeholder,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:b,onChange:a=>f(a.target.value)})}),(0,A.jsx)(U.$,{type:"submit",disabled:!g||b,className:"justify-self-end",children:d("accountContinue")})]})}function ou({notice:a,onCopy:b,onOpenUrl:c}){let{t:d}=(0,Q.Bd)("settings"),e="auth_url"===a.type?[{url:a.url}]:"device_code"===a.type?[{url:a.verificationUri}]:"info"===a.type?a.links??[]:[];return(0,A.jsxs)("div",{className:"space-y-3",children:["auth_url"===a.type&&a.instructions?(0,A.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:a.instructions}):null,"info"===a.type||"progress"===a.type?(0,A.jsx)("p",{className:"whitespace-pre-wrap text-sm",role:"status",children:a.message}):null,"device_code"===a.type?(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border p-3",children:[(0,A.jsx)("span",{className:"text-sm",children:d("accountDeviceCode")}),(0,A.jsx)("code",{className:"select-all break-all text-lg font-semibold",children:a.userCode}),(0,A.jsx)(U.$,{type:"button",size:"sm",variant:"outline",onClick:()=>void b(a.userCode),children:d("accountCopyCode")})]}):null,e.map((a,e)=>oq(a.url)?(0,A.jsxs)("div",{className:"space-y-2",children:[(0,A.jsx)("p",{className:"break-all text-sm text-muted-foreground",children:a.url}),(0,A.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"sm",onClick:()=>c(a.url),children:a.label??d("accountOpenLink")}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>void b(a.url),children:d("accountCopyLink")})]})]},`${e}:${a.url}`):(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:d("accountInvalidLink")},e))]})}function ov({open:a,connected:b,providers:c,state:d,loading:e,submitting:f,error:g,onClose:h,onStart:i,onRespond:j,onCopy:k,onOpenUrl:l,onRetry:m}){let{t:n}=(0,Q.Bd)("settings"),o=d?.status==="running";return(0,A.jsx)(b7.YV,{open:a,onOpenChange:a=>{a||h()},children:(0,A.jsxs)(b7.hA,{className:"max-w-lg",children:[(0,A.jsx)(b7.Hl,{className:"border-b p-4 pr-12",children:(0,A.jsx)(b7.YM,{children:d?c.find(a=>a.provider===d.provider)?.name??d.provider:n("accountLogin")})}),(0,A.jsx)(b7._Y,{className:"max-h-[65dvh]",children:(0,A.jsxs)("div",{className:"space-y-4 p-4",children:[g?(0,A.jsx)("p",{role:"alert",className:"whitespace-pre-wrap text-sm text-destructive",children:g}):null,d?.message?(0,A.jsx)("p",{role:"error"===d.status?"alert":"status",className:"whitespace-pre-wrap text-sm",children:d.message}):null,d&&"cancelled"!==d.status&&"error"!==d.status?null:e?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:n("accountLoadingProviders")}):(0,A.jsxs)("div",{className:"grid gap-2",children:[(0,A.jsx)("h3",{className:"text-sm font-semibold",children:n("accountChooseProvider")}),c.length?null:(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:n("accountNoProviders")}),c.map(a=>(0,A.jsxs)("div",{className:"grid gap-1",children:[(0,A.jsxs)(U.$,{type:"button",variant:"outline",className:"h-auto min-h-10 justify-between whitespace-normal text-left",disabled:!b||!!a.conflict,onClick:()=>void i(a.provider),children:[(0,A.jsx)("span",{children:a.name}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:a.loggedIn?n("accountRelogin"):n("accountLogin")})]}),a.conflict?(0,A.jsx)("p",{className:"text-sm text-destructive",children:a.conflict}):null]},a.provider))]}),o&&d.notice?(0,A.jsx)(ou,{notice:d.notice,onCopy:k,onOpenUrl:l}):null,o&&d.prompt?(0,A.jsx)(ot,{prompt:d.prompt,submitting:f||!b,onRespond:j},d.prompt.id):null,o&&!d.prompt?(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:n("accountWaiting")}):null,d?.status==="completed"?(0,A.jsx)("p",{role:"status",className:"text-sm",children:n("accountLoggedIn")}):null]})}),(0,A.jsxs)(b7.vu,{children:[g&&!o?(0,A.jsx)(U.$,{type:"button",variant:"outline",disabled:e,onClick:m,children:n("retry",{ns:"common"})}):null,(0,A.jsx)(U.$,{type:"button",variant:"ghost",onClick:h,children:n(o?"cancel":"close",{ns:"common"})})]})]})})}function ow({account:a,existingIds:b,onAdd:c,onClose:d}){let{t:e}=(0,Q.Bd)("settings"),[f,g]=(0,B.useState)(""),[h,i]=(0,B.useState)([]),j=a.models.filter(a=>`${a.name} ${a.modelId}`.toLocaleLowerCase().includes(f.toLocaleLowerCase()));return(0,A.jsx)(b7.YV,{open:!0,onOpenChange:a=>{a||d()},children:(0,A.jsxs)(b7.hA,{className:"max-w-xl",children:[(0,A.jsx)(b7.Hl,{className:"border-b p-4 pr-12",children:(0,A.jsx)(b7.YM,{children:e("modelAddToService",{name:a.name})})}),(0,A.jsx)("div",{className:"p-4 pb-2",children:(0,A.jsx)(bY.p,{value:f,"aria-label":e("accountModelSearch"),placeholder:e("accountModelSearch"),onChange:a=>g(a.target.value)})}),(0,A.jsx)(b7._Y,{className:"max-h-[55dvh]",children:(0,A.jsxs)("div",{className:"space-y-1 px-4 pb-4",children:[j.map(a=>{let c=b.includes(a.modelId);return(0,A.jsxs)("label",{className:"flex min-h-14 cursor-pointer items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent",children:[(0,A.jsx)("input",{type:"checkbox",className:"size-4 shrink-0 accent-primary",checked:c||h.includes(a.modelId),disabled:c,onChange:b=>i(c=>b.target.checked?[...c,a.modelId]:c.filter(b=>b!==a.modelId))}),(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsx)("span",{className:"block break-words text-sm font-medium",children:a.name}),(0,A.jsxs)("span",{className:"block break-all text-xs text-muted-foreground",children:[a.modelId," \xb7 ",nS(a.contextWindow)," K"]})]}),c?(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:e("accountModelAdded")}):null]},a.modelId)}),j.length?null:(0,A.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:e("accountNoModels")})]})}),(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",onClick:d,children:e("accountAddLater")}),(0,A.jsx)(U.$,{type:"button",disabled:!h.length,onClick:()=>c(h),children:e("accountAddSelected",{count:h.length})})]})]})})}let ox=[["input","inputPrice"],["output","outputPrice"],["cacheRead","cacheReadPrice"],["cacheWrite","cacheWritePrice"]];function oy({model:a,account:b,overrides:c,onChange:d,onInputState:e}){let{t:f}=(0,Q.Bd)("settings"),[g,h]=(0,B.useState)(()=>({contextWindow:void 0===c.contextWindow?"":nS(c.contextWindow),maxTokens:void 0===c.maxTokens?"":nS(c.maxTokens),...Object.fromEntries(ox.map(([a])=>[a,c.cost?.[a]===void 0?"":String(c.cost[a])]))})),i=a=>""!==a&&null===nT(a),j=a=>""!==a&&(!Number.isFinite(Number(a))||0>Number(a));function k(a,b){let f={...g,[a]:b};h(f);let k=i(f.contextWindow)||i(f.maxTokens)||ox.some(([a])=>j(f[a]));if(e({dirty:k,invalid:k}),"contextWindow"===a||"maxTokens"===a){if(i(b))return;let e={...c};""===b?delete e[a]:e[a]=nT(b),d(e)}else{if(ox.some(([a])=>j(f[a])))return;let a={...c};ox.every(([a])=>""===f[a])?delete a.cost:a.cost=Object.fromEntries(ox.filter(([a])=>""!==f[a]).map(([a])=>[a,Number(f[a])])),d(a)}}if(!a)return(0,A.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:f("accountModelUnavailable")});let l=a.cost?{...a.cost,...c.cost}:c.cost;return(0,A.jsxs)("div",{className:"max-w-[40rem] space-y-6",children:[(0,A.jsxs)("div",{className:"flex flex-wrap gap-2 text-sm text-muted-foreground",children:[(0,A.jsx)("span",{children:f(b?.loggedIn?"accountLoggedIn":"accountLoggedOut")}),b?.subscription?(0,A.jsx)("span",{className:"rounded-md bg-muted px-2",children:f("accountSubscription")}):null]}),(0,A.jsxs)("dl",{className:"grid gap-4 sm:grid-cols-2",children:[(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-sm text-muted-foreground",children:f("contextLength")}),(0,A.jsxs)("dd",{className:"mt-1 text-lg font-semibold",children:[nS(c.contextWindow??a.contextWindow)," K"]})]}),(0,A.jsxs)("div",{children:[(0,A.jsx)("dt",{className:"text-sm text-muted-foreground",children:f("maximumOutput")}),(0,A.jsxs)("dd",{className:"mt-1 text-lg font-semibold",children:[nS(c.maxTokens??a.maxTokens)," K"]})]}),(0,A.jsxs)("div",{className:"sm:col-span-2",children:[(0,A.jsx)("dt",{className:"text-sm text-muted-foreground",children:f("capabilities")}),(0,A.jsx)("dd",{className:"mt-1 text-sm",children:[...a.input.map(a=>f("image"===a?"imageInput":"textInput")),...a.reasoning?[f("supportsThinking")]:[]].join(" \xb7 ")})]})]}),(0,A.jsxs)("details",{className:"border-t pt-3",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-semibold",children:f("accountReferencePrice")}),(0,A.jsx)("div",{className:"mt-3 text-sm text-muted-foreground",children:l?ox.map(([a,b])=>(0,A.jsxs)("p",{children:[f(b),": ",void 0===l[a]?"—":`$${l[a]}`]},a)):f("priceMissing")})]}),(0,A.jsxs)("details",{className:"border-t pt-3",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-semibold",children:f("accountAdjustParameters")}),(0,A.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,A.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:["contextWindow","maxTokens"].map(b=>(0,A.jsxs)(nU,{label:`${f("contextWindow"===b?"contextLength":"maximumOutput")} (K)`,children:[(0,A.jsx)(bY.p,{value:g[b],placeholder:nS(a[b]),inputMode:"decimal","aria-invalid":i(g[b]),onChange:a=>k(b,a.target.value)}),i(g[b])?(0,A.jsx)("span",{className:"text-xs text-destructive",children:f("capacityInvalid")}):null]},b))}),(0,A.jsxs)("details",{children:[(0,A.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:f("price")}),(0,A.jsx)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:ox.map(([b,c])=>(0,A.jsxs)(nU,{label:f(c),children:[(0,A.jsx)(bY.p,{value:g[b],inputMode:"decimal",placeholder:String(a.cost?.[b]??""),"aria-invalid":j(g[b]),onChange:a=>k(b,a.target.value)}),j(g[b])?(0,A.jsx)("span",{className:"text-xs text-destructive",children:f("priceInvalid")}):null]},b))})]}),(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{h({contextWindow:"",maxTokens:"",input:"",output:"",cacheRead:"",cacheWrite:""}),d({}),e({dirty:!1,invalid:!1})},children:f("accountRestoreDefaults")})]})]})]})}var oz=c(79694);function oA({name:a,hasAccount:b,loggedIn:c,hasCustom:d,onCustomSettings:e,onLogin:f,onLogout:g}){let{t:h}=(0,Q.Bd)("settings"),[i,j]=(0,B.useState)(!1),k=(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":h("serviceSettingsNamed",{name:a}),onClick:b?void 0:e,children:(0,A.jsx)(oz.A,{})});function l(a){j(!1),a()}return b?(0,A.jsxs)(cq.AM,{open:i,onOpenChange:j,children:[(0,A.jsx)(cq.Wv,{render:k}),(0,A.jsxs)(cq.hl,{align:"end",positionerClassName:"z-[120]",className:"w-52 gap-1 p-1",children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>l(f),children:h(c?"accountRelogin":"accountLogin")}),c?(0,A.jsx)(U.$,{type:"button",variant:"ghost",className:"justify-start text-destructive",onClick:()=>l(g),children:h("accountLogout")}):null,d?(0,A.jsx)(U.$,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>l(e),children:h("accountCustomSettings")}):null]})]}):k}function oB({providerId:a,custom:b,account:c,accountModels:d,query:e,modelKeys:f,selectedCustomIndex:g,selectedAccountId:h,presets:i,onSelectCustom:j,onSelectAccount:k,onCustomSettings:l,onAddCustom:m,onAddAccount:n,onLogin:o,onLogout:p,onGroupRef:q,onRowRef:r}){let{t:s}=(0,Q.Bd)("settings"),t=(b?a:c?.name)||a||s("providerUnnamed"),u=d.filter(a=>!b?.models.some(b=>b.modelId===a.modelId)),v=[...(b?.models??[]).map((a,b)=>({key:f[b],modelId:a.modelId,name:a.name,model:a,selected:g===b,select:()=>j(b)})),...u.map(b=>{let d=c?.models.find(a=>a.modelId===b.modelId);return{key:`account:${a}:${b.modelId}`,modelId:b.modelId,name:d?.name??b.modelId,model:d?{...d,...b.overrides}:void 0,selected:h===b.modelId,select:()=>k(b.modelId)}})],w=v.filter(b=>`${a} ${t} ${c?.name??""} ${b.name} ${b.modelId}`.toLocaleLowerCase().includes(e.toLocaleLowerCase()));if(e&&!w.length&&!`${a} ${t} ${c?.name??""}`.toLocaleLowerCase().includes(e.toLocaleLowerCase()))return null;let x=!!c||d.length>0;return(0,A.jsxs)("section",{ref:q,className:"mb-3",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 text-foreground",children:[(0,A.jsx)(cb,{"aria-hidden":"true",className:"size-4 shrink-0"}),(0,A.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",title:c?.name,children:t}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:v.length}),(0,A.jsx)(oA,{name:t,hasAccount:x,loggedIn:c?.loggedIn??!1,hasCustom:!!b,onCustomSettings:l,onLogin:o,onLogout:p})]}),(0,A.jsxs)("div",{className:"space-y-1",children:[w.map(b=>(0,A.jsxs)("button",{ref:a=>r(b.key,a),type:"button","aria-current":b.selected?"true":void 0,className:(0,W.cn)("flex min-h-14 w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",b.selected&&"bg-accent text-accent-foreground"),onClick:b.select,children:[(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsx)("span",{className:"block truncate text-sm font-medium",children:b.name||b.modelId||s("modelUnnamed")}),(0,A.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:b.model?`${nS(b.model.contextWindow)} K \xb7 ${s(b.model.input.includes("image")?"imageInput":"textInput")}`:s("accountModelUnavailableShort")})]}),i.some(c=>c.provider===a&&c.modelId===b.modelId)?(0,A.jsx)(n4,{className:"size-4 shrink-0 text-muted-foreground"}):null]},b.key)),x?(0,A.jsxs)(U.$,{type:"button",variant:"ghost",size:"sm",className:"mt-1 w-full border border-dashed border-input","aria-label":s("modelAddToService",{name:c?.name??t}),onClick:n,children:[(0,A.jsx)(am,{}),s("modelAdd")]}):null,b?(0,A.jsxs)(U.$,{type:"button",variant:"ghost",size:"sm",className:"mt-1 w-full border border-dashed border-input","aria-label":s("modelAddToService",{name:t}),onClick:m,children:[(0,A.jsx)(am,{}),x?s("accountCustomModel"):null]}):null]})]})}let oC={off:"thinkingOff",minimal:"thinkingMinimal",low:"thinkingLow",medium:"thinkingMedium",high:"thinkingHigh",xhigh:"thinkingXhigh",max:"thinkingMax"};function oD({biz:a,connectionReady:b,providers:c,accounts:d,accountModels:e,onAccountModelsChange:f,onRefreshAccounts:g,savedModels:h,savedProviders:i,presets:j,resetVersion:k,onChange:l,onPresetsChange:m,onInputState:n,onServiceDirtyChange:o}){let{t:p}=(0,Q.Bd)("settings"),{confirm:q,dialog:r}=kg(),s=(0,bK.G)(),[t,u]=(0,B.useState)(null),[v,w]=(0,B.useState)(null),[x,y]=(0,B.useState)(!1),[z,C]=(0,B.useState)(()=>new Set),D=function(a,b){let{appSocket:c}=(0,bR.gM)(),d=(0,B.useMemo)(()=>({list:async()=>(await c.request(op.list,{})).providers,async start(a,b){await c.request(op.start,{loginId:a,provider:b})},async respond(a,b,d){await c.request(op.respond,{loginId:a,promptId:b,value:d})},async cancel(a){await c.request(op.cancel,{loginId:a})},async logout(a){await c.request(op.logout,{provider:a})},subscribe:a=>c.subscribe(op.state,a)}),[c]),{t:e}=(0,Q.Bd)("settings"),f=(0,bK.G)(),[g,h]=(0,B.useState)(!1),[i,j]=(0,B.useState)([]),[k,l]=(0,B.useState)(null),[m,n]=(0,B.useState)(!1),[o,p]=(0,B.useState)(!1),[q,r]=(0,B.useState)(null),[s,t]=(0,B.useState)(null),u=(0,B.useRef)(a),v=(0,B.useRef)(null),w=(0,B.useRef)(null),x=(0,B.useRef)(null),y=(0,B.useRef)(null),z=(0,B.useRef)(0),A=(0,B.useRef)(b);function C(){let a=v.current;v.current=null,w.current=null,x.current=null,y.current?.(),y.current=null,a?.status==="running"&&d.cancel(a.loginId).catch(a=>{console.warn("[Pi Desk][ModelAuth] 取消登录失败",{message:a instanceof Error?a.message:String(a)})})}function D(){z.current+=1,C(),h(!1)}async function E(){let a=v.current;if(!a||"completed"!==a.status||x.current)return;x.current=a.loginId,p(!0),t(null);let b=()=>v.current?.loginId===a.loginId;try{await A.current(a.provider,b),b()&&D()}catch(a){b()&&t(a instanceof Error?a.message:e("accountRefreshFailed"))}finally{b()&&(x.current=null,p(!1))}}async function F(a){if(!u.current)return void t(e("accountConnectionNotReady"));if(v.current?.status==="running")return;C();let b={loginId:crypto.randomUUID(),provider:a,status:"running",notice:null,prompt:null,message:null};v.current=b,l(b),t(null),r(null),y.current=d.subscribe(a=>{v.current?.loginId===a.loginId&&((v.current.prompt?.id!==a.prompt?.id||"running"!==a.status)&&(w.current=null,r(null)),v.current=a,l(a),t("error"!==a.status||a.message?null:e("accountLoginFailed")),"completed"===a.status&&E())});try{await d.start(b.loginId,a)}catch(a){if(v.current?.loginId!==b.loginId||"running"!==v.current.status)return;C(),l(null),t(a instanceof Error?a.message:e("accountLoginFailed"))}}async function G(a,b){let c=v.current;if(!u.current||!c||"running"!==c.status||c.prompt?.id!==a||w.current)return;let f={loginId:c.loginId,promptId:a};w.current=f,r(a),t(null);try{await d.respond(c.loginId,a,b)}catch(b){v.current?.loginId===c.loginId&&v.current.prompt?.id===a&&t(b instanceof Error?b.message:e("accountLoginFailed"))}finally{w.current===f&&(w.current=null,r(null))}}return{open:g,providers:i,state:k,loading:m||o,submitting:null!==q&&q===k?.prompt?.id,error:s,show:function(a){if(D(),l(null),t(null),r(null),p(!1),h(!0),!u.current){n(!1),t(e("accountConnectionNotReady"));return}n(!0);let b=++z.current;d.list().then(c=>{z.current===b&&(j(c),a&&c.some(b=>b.provider===a&&!b.conflict)&&F(a))}).catch(a=>{z.current===b&&t(a instanceof Error?a.message:e("accountLoginFailed"))}).finally(()=>{z.current===b&&n(!1)})},close:D,start:F,respond:G,finish:E,async logout(a){if(!u.current)throw Error(e("accountConnectionNotReady"));await d.logout(a)},async copy(a){try{await os(a),f.success(e("accountCopied"))}catch{f.error(e("accountCopyFailed"))}},openUrl:or}}(b,async(a,b)=>{await g(),b()&&w(a)}),E=function(a,b){let[c,d]=(0,B.useState)(()=>{let b=a.findIndex(a=>a.models.length>0);return b<0?null:{providerIndex:b,modelIndex:0}}),[e,f]=(0,B.useState)(!1),[g,h]=(0,B.useState)(""),[i,j]=(0,B.useState)(()=>a.map((a,b)=>a.models.map((a,c)=>`${b}:${c}`))),k=(0,B.useRef)(0),l=(0,B.useRef)(new Map(a.flatMap((a,b)=>a.models.map((c,d)=>[`${b}:${d}`,{provider:a.provider,modelId:c.modelId}])))),[m,n]=(0,B.useState)({}),[o,p]=(0,B.useState)(null),[q,r]=(0,B.useState)(!1);function s(a){n(b=>Object.fromEntries(Object.entries(b).filter(([b])=>!a.includes(b))))}function t(a,c=i){let d=[];a.forEach((a,b)=>{a.models.forEach((e,f)=>{let g=l.current.get(c[b][f]),h={provider:a.provider.trim(),modelId:e.modelId.trim()};g&&(g.provider!==h.provider||g.modelId!==h.modelId)&&d.push({from:g,to:h})})}),b(a,d)}function u(){p(null),r(!1)}return(0,B.useRef)(a),{selection:c,mobileDetail:e,query:g,setQuery:h,modelKeys:i,serviceIndex:o,newService:q,openService:a=>{p(a),r(null===a)},closeService:u,applyService:b=>{q?(t([...a,b],[...i,[]]),j(a=>[...a,[]])):t(a.map((a,c)=>c===o?b:a)),u()},deleteService:()=>{if(null===o)return;s(i[o]);let b=a.filter((a,b)=>b!==o);t(b,i.filter((a,b)=>b!==o)),j(a=>a.filter((a,b)=>b!==o)),d(a=>{if(!a||a.providerIndex===o){let a=b.findIndex(a=>a.models.length);return a<0?null:{providerIndex:a,modelIndex:0}}return a.providerIndex>o?{...a,providerIndex:a.providerIndex-1}:a}),f(!1),u()},addModel:b=>{let c=a[b],e=`new-${++k.current}`;t(a.map((a,c)=>c===b?{...a,models:[...a.models,{modelId:"",name:"",api:null,baseUrl:null,reasoning:!1,thinkingLevels:[{level:"off",providerValue:null}],input:["text"],contextWindow:128e3,maxTokens:16384,cost:null,headers:{},compat:null}]}:a),i.map((a,c)=>c===b?[...a,e]:a)),j(a=>a.map((a,c)=>c===b?[...a,e]:a)),d({providerIndex:b,modelIndex:c.models.length}),h(""),f(!0)},selectModel:(a,b)=>{d({providerIndex:a,modelIndex:b}),f(!0)},backToList:()=>{f(!1),h("")},updateModel:function(b,c,d){t(a.map((a,e)=>e===b?{...a,models:a.models.map((a,b)=>b===c?d:a)}:a))},deleteModel:(b,c)=>{s([i[b][c]]);let e=a.map((a,d)=>d===b?{...a,models:a.models.filter((a,b)=>b!==c)}:a);t(e,i.map((a,d)=>d===b?a.filter((a,b)=>b!==c):a)),j(a=>a.map((a,d)=>d===b?a.filter((a,b)=>b!==c):a)),d(a=>{if(!a||a.providerIndex!==b)return a;if(a.modelIndex===c){if(e[b].models.length)return{providerIndex:b,modelIndex:Math.min(c,e[b].models.length-1)};let a=e.findIndex(a=>a.models.length);return a<0?null:{providerIndex:a,modelIndex:0}}return a.modelIndex>c?{...a,modelIndex:a.modelIndex-1}:a}),f(!1)},updateInputState:(a,b)=>n(c=>({...c,[a]:b}))}}(c,l),{selection:F,mobileDetail:G,query:H,setQuery:I,modelKeys:J,serviceIndex:K,newService:L}=E,M=(0,B.useRef)(new Map),N=(0,B.useRef)(new Map),[O,P]=(0,B.useState)(!1),[R,S]=(0,B.useState)("off"),T=e.find(a=>a.provider===t?.provider&&a.modelId===t?.modelId)??(c.some(a=>a.models.length)?void 0:e[0]),V=d.find(a=>a.provider===T?.provider),X=V?.models.find(a=>a.modelId===T?.modelId),Y=!!T,$=!Y&&F?c[F.providerIndex]:null,_=!Y&&F?$?.models[F.modelIndex]:null,aa=Y?x:G&&!!_,ab=Y?X?.name??T?.modelId:_?.name||_?.modelId||p("modelUnnamed"),ac=T?.provider||$?.provider||p("providerUnnamed"),ad=d.find(a=>a.provider===v),ae=[...new Set([...c.map(a=>a.provider),...d.map(a=>a.provider),...e.map(a=>a.provider)])],af=a=>`account:${a.provider}:${a.modelId}`,ag=new Set(e.map(af)),ah=new Set([...z].filter(a=>ag.has(a)));T&&ah.add(af(T)),(ah.size!==z.size||T&&!z.has(af(T)))&&C(ah);let[ai,aj]=(0,B.useState)(()=>new Set),ak=F?J[F.providerIndex]?.[F.modelIndex]:void 0,al=new Set(J.flat()),an=new Set([...ai].filter(a=>al.has(a)));ak&&an.add(ak),(an.size!==ai.size||ak&&!ai.has(ak))&&aj(an);let ao=Y?h.find(a=>a.provider===T?.provider&&a.modelId===T.modelId):$&&_&&i.some(a=>a.provider===$.provider&&a.models.some(a=>a.modelId===_.modelId))?h.find(a=>a.provider===$.provider&&a.modelId===_.modelId):void 0;async function ap(){if(T){await q({title:p("accountRemoveTitle"),description:p("accountRemoveDescription",{name:ab})})&&(f(e.filter(a=>a!==T)),E.updateInputState(af(T),{dirty:!1,invalid:!1}),u(null),y(!1));return}F&&_&&await q({title:p("modelDeleteTitle"),description:p("modelDeleteDescription",{name:_.name||_.modelId||p("modelUnnamed")})})&&E.deleteModel(F.providerIndex,F.modelIndex)}async function aq(a){if(await q({title:p("accountLogoutTitle"),description:p("accountLogoutDescription",{name:d.find(b=>b.provider===a)?.name??a}),confirmLabel:p("accountLogout")}))try{await D.logout(a),await g()}catch(a){s.error(a instanceof Error?a.message:p("accountLogoutFailed"))}}return(0,A.jsxs)("section",{className:"@container/models h-full min-h-0 overflow-hidden bg-card",children:[(0,A.jsxs)("div",{className:"grid h-full min-h-0 grid-cols-1 @[48rem]/models:grid-cols-[15rem_minmax(0,1fr)]",children:[(0,A.jsxs)("aside",{"aria-label":p("providerList"),className:(0,W.cn)("min-h-0 min-w-0 flex-col bg-sidebar @[48rem]/models:flex @[48rem]/models:border-r",aa?"hidden":"flex"),children:[(0,A.jsx)("div",{className:"shrink-0 p-3",children:(0,A.jsx)(bY.p,{value:H,"aria-label":p("modelSearch"),placeholder:p("modelSearch"),onChange:a=>I(a.target.value)})}),(0,A.jsxs)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto px-2 pb-3",children:[ae.map(a=>{let b=c.findIndex(b=>b.provider===a);return(0,A.jsx)(oB,{providerId:a,custom:c[b],account:d.find(b=>b.provider===a),accountModels:e.filter(b=>b.provider===a),query:H,modelKeys:J[b]??[],selectedCustomIndex:Y||F?.providerIndex!==b?null:F.modelIndex,selectedAccountId:T?.provider===a?T.modelId:null,presets:j,onSelectCustom:a=>{u(null),E.selectModel(b,a)},onSelectAccount:b=>{u({provider:a,modelId:b}),y(!0),C(c=>new Set([...c,af({provider:a,modelId:b})]))},onCustomSettings:()=>E.openService(b),onAddCustom:()=>{u(null),E.addModel(b)},onAddAccount:()=>{let b;return b=d.find(b=>b.provider===a),void(b?.loggedIn?w(a):D.show(a))},onLogin:()=>D.show(a),onLogout:()=>void aq(a),onGroupRef:a=>{b<0||(a?M.current.set(b,a):M.current.delete(b))},onRowRef:(a,b)=>{b?N.current.set(a,b):N.current.delete(a)}},a)}),ae.length?null:(0,A.jsx)("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:p("providerEmpty")})]}),(0,A.jsxs)("div",{className:"flex shrink-0 gap-2 border-t p-3",children:[(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",onClick:()=>E.openService(null),children:[(0,A.jsx)(am,{}),p("accountCustomApi")]}),(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",onClick:()=>D.show(),children:[(0,A.jsx)(n3,{}),p("accountLogin")]})]})]}),(0,A.jsx)("section",{"aria-label":p("modelsHeading"),className:(0,W.cn)("min-h-0 min-w-0 flex-col @[48rem]/models:flex",aa?"flex":"hidden"),children:Y||_&&F?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 @[48rem]/models:hidden",children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":p("backModelList"),onClick:function(){if(T){y(!1),window.requestAnimationFrame(()=>{let a=N.current.get(af(T));a?.scrollIntoView({block:"nearest"}),a?.focus({preventScroll:!0})});return}E.backToList(),window.requestAnimationFrame(()=>{if(!F)return;let a=J[F.providerIndex]?.[F.modelIndex];M.current.get(F.providerIndex)?.scrollIntoView({block:"nearest"}),N.current.get(a)?.scrollIntoView({block:"nearest"}),N.current.get(a)?.focus({preventScroll:!0})})},children:(0,A.jsx)(Z.A,{})}),(0,A.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:V?.name??ac,children:V?.name??ac}),(0,A.jsx)(oA,{name:ac,hasAccount:d.some(a=>a.provider===ac)||e.some(a=>a.provider===ac),loggedIn:d.find(a=>a.provider===ac)?.loggedIn??!1,hasCustom:c.some(a=>a.provider===ac),onCustomSettings:()=>E.openService(c.findIndex(a=>a.provider===ac)),onLogin:()=>D.show(ac),onLogout:()=>void aq(ac)})]}),(0,A.jsxs)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto p-4 @[48rem]/models:p-6",children:[(0,A.jsxs)("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-2",children:[(0,A.jsx)("h3",{className:"min-w-0 break-all text-lg font-semibold",children:ab}),(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",disabled:!ao,title:ao?void 0:p("saveBeforePreset"),onClick:()=>{S(ao?.thinkingLevels[0]??"off"),P(!0)},children:[(0,A.jsx)(n4,{}),p("addModelPreset")]}),(0,A.jsxs)(d_.m_,{children:[(0,A.jsx)(d_.k$,{render:(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm",className:"text-destructive hover:text-destructive","aria-label":Y?`${p("accountRemove")} ${ab}`:p("modelDeleteNamed",{name:ab}),onClick:ap,children:(0,A.jsx)(bN,{})})}),(0,A.jsx)(d_.ZI,{children:p(Y?"accountRemove":"modelDelete")})]})]})]}),e.map(a=>{let b=af(a);if(!ah.has(b))return null;let c=d.find(b=>b.provider===a.provider);return(0,A.jsx)("div",{hidden:!Y||T!==a,children:(0,A.jsx)(oy,{account:c,model:c?.models.find(b=>b.modelId===a.modelId),overrides:a.overrides,onChange:b=>f(e.map(c=>c===a?{...a,overrides:b}:c)),onInputState:a=>E.updateInputState(b,a)})},`${b}:${k}`)}),c.flatMap((b,c)=>b.models.map((d,e)=>{let f=!Y&&F?.providerIndex===c&&F.modelIndex===e,g=J[c]?.[e];return an.has(g)?(0,A.jsx)("div",{hidden:!f,children:(0,A.jsx)(oc,{biz:a,provider:b,model:d,onChange:a=>E.updateModel(c,e,a),onInputState:a=>E.updateInputState(g,a)})},`${g}:${k}`):null}))]})]}):(0,A.jsxs)("div",{className:"flex flex-col items-center gap-3 p-6 text-sm text-muted-foreground",children:[(0,A.jsx)(ck,{className:"size-6"}),p("selectModelToEdit")]})})]}),(0,A.jsx)(ov,{open:D.open,connected:b,providers:D.providers,state:D.state,loading:D.loading,submitting:D.submitting,error:D.error,onClose:D.close,onStart:D.start,onRespond:D.respond,onCopy:D.copy,onOpenUrl:D.openUrl,onRetry:()=>D.state?.status==="completed"?void D.finish():D.show()}),ad?(0,A.jsx)(ow,{account:ad,existingIds:[...e.filter(a=>a.provider===ad.provider).map(a=>a.modelId),...c.filter(a=>a.provider===ad.provider).flatMap(a=>a.models.map(a=>a.modelId))],onAdd:function(a){if(!ad)return;let b=a.filter(a=>!e.some(b=>b.provider===ad.provider&&b.modelId===a)&&!c.some(b=>b.provider===ad.provider&&b.models.some(b=>b.modelId===a))).map(a=>({provider:ad.provider,modelId:a,overrides:{}}));f([...e,...b]),w(null)},onClose:()=>w(null)},ad.provider):null,L||null!==K?(0,A.jsx)(og,{provider:L?{provider:"",name:null,baseUrl:null,api:"openai-responses",apiKey:null,authHeader:null,headers:{},models:[]}:c[K],existingIds:c.filter((a,b)=>L||b!==K).map(a=>a.provider),isNew:L,onApply:E.applyService,onDelete:E.deleteService,onClose:E.closeService,onDirtyChange:o}):null,(0,A.jsx)(b7.YV,{open:O,onOpenChange:P,children:(0,A.jsxs)(b7.hA,{children:[(0,A.jsx)(b7.Hl,{className:"border-b px-4 py-4 pr-12",children:(0,A.jsx)(b7.YM,{children:p("addModelPreset")})}),(0,A.jsx)(b7._Y,{children:(0,A.jsx)("div",{className:"p-4",children:(0,A.jsx)(nU,{label:p("thinkingLevel"),children:(0,A.jsx)(nW,{value:R,allowEmpty:!1,ariaLabel:p("presetThinkingNew"),options:(ao?.thinkingLevels??[]).map(a=>({value:a,label:p(oC[a])})),onChange:a=>S(a)})})})}),(0,A.jsxs)(b7.vu,{children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",onClick:()=>P(!1),children:p("cancel",{ns:"common"})}),(0,A.jsx)(U.$,{type:"button",onClick:function(){ao&&(j.some(a=>a.provider===ao.provider&&a.modelId===ao.modelId&&a.thinkingLevel===R)||m([...j,{provider:ao.provider,modelId:ao.modelId,thinkingLevel:R,color:nM(j)}]),P(!1))},disabled:!ao,children:p("presetAdd")})]})]})}),r]})}let oE={off:"thinkingOff",minimal:"thinkingMinimal",low:"thinkingLow",medium:"thinkingMedium",high:"thinkingHigh",xhigh:"thinkingXhigh",max:"thinkingMax"};function oF(a,b){return JSON.stringify([a,b])}function oG(a){return a.replace(/[\\/]+$/,"").split(/[\\/]/).at(-1)||a}function oH({biz:a,presets:b,onDirtyChange:c}){let{t:d}=(0,Q.Bd)("settings"),e=function(a,b){let{t:c}=(0,Q.Bd)("settings"),d=(0,bK.G)(),{confirm:e,dialog:f}=kg(),[g,h]=(0,B.useState)([]),[i,j]=(0,B.useState)(""),[k,l]=(0,B.useState)([]),[m,n]=(0,B.useState)(null),[o,p]=(0,B.useState)(!1),[q,r]=(0,B.useState)(!0),[s,t]=(0,B.useState)(!1),[u,v]=(0,B.useState)(!1),[w,x]=(0,B.useState)(!1),[y,z]=(0,B.useState)(null),[A,C]=(0,B.useState)(null),[D,E]=(0,B.useState)(null),[F,G]=(0,B.useState)(0),[H,I]=(0,B.useState)(0),J=y===i&&null===D&&!s&&!u,K=(0,B.useRef)(!1);(0,B.useRef)("");let L=(0,B.useRef)(0),M=(0,B.useCallback)(a=>{K.current=a,b?.(a)},[b]);async function N(a){return!w&&(a===i||(!K.current||!!await e({title:c("discardModelTitle"),description:c("discardModelDescription"),confirmLabel:c("discardModelConfirm")}))&&(L.current+=1,v(!0),j(a),!0))}async function O(){if(i&&J&&!s&&!u&&!w&&(!o||m)){x(!0);try{await a.replaceProjectDefault({cwd:i,default:o?m:null}),lM({cwd:i,default:o?m:null,models:k}),M(!1),d.success(o?c("projectDefaultSaved"):c("projectDefaultGlobalSaved"))}catch(a){d.error(a instanceof Error?a.message:c("projectDefaultSaveFailed"))}finally{x(!1)}}}return{directories:g,cwd:i,loadedCwd:y,models:k,selection:m,fixed:o,directoriesLoading:q,projectLoading:s,projectRefreshing:u,saving:w,projectReady:J,directoriesError:A,projectError:D,dialog:f,selectProject:N,changeFixed:function(a){J&&!w&&(M(!0),p(a))},selectModel:function(a){J&&!w&&(M(!0),n({provider:a.provider,modelId:a.modelId,thinkingLevel:a.thinkingLevels[0]}))},selectThinking:function(a){if(!J||w)return;let b=k.find(a=>a.provider===m?.provider&&a.modelId===m.modelId),c=b?.thinkingLevels.find(b=>b===a);m&&c&&(M(!0),n({...m,thinkingLevel:c}))},applyPreset:function(a){J&&!w&&(M(!0),n({provider:a.provider,modelId:a.modelId,thinkingLevel:a.thinkingLevel}))},retryDirectories:function(){G(a=>a+1)},retryProject:function(){L.current+=1,v(!0),I(a=>a+1)},save:O}}(a,c),[f,g]=(0,B.useState)(""),[h,i]=(0,B.useState)(!1),j=e.models.find(a=>a.provider===e.selection?.provider&&a.modelId===e.selection.modelId),k=b.filter(a=>e.models.some(b=>b.provider===a.provider&&b.modelId===a.modelId&&b.thinkingLevels.includes(a.thinkingLevel))),l=e.directories.filter(a=>a.cwd.toLocaleLowerCase().includes(f.trim().toLocaleLowerCase())),m=e.models.map(a=>({value:oF(a.provider,a.modelId),label:a.name||a.modelId,description:a.provider})),n=!e.projectReady||e.saving,o=e.loadedCwd??e.cwd;async function p(a){await e.selectProject(a)&&i(!0)}return(0,A.jsxs)("section",{className:"@container/project-default h-full min-h-0 overflow-hidden bg-card",children:[(0,A.jsxs)("div",{className:"grid h-full min-h-0 grid-cols-1 @[48rem]/project-default:grid-cols-[18rem_minmax(0,1fr)]",children:[(0,A.jsxs)("aside",{"aria-label":d("projectList"),className:(0,W.cn)("min-h-0 min-w-0 flex-col bg-sidebar @[48rem]/project-default:flex @[48rem]/project-default:border-r",h&&e.cwd?"hidden":"flex"),children:[(0,A.jsxs)("div",{className:"shrink-0 space-y-3 p-3",children:[(0,A.jsx)("h3",{className:"text-sm font-semibold",children:d("projectList")}),(0,A.jsx)(bY.p,{value:f,"aria-label":d("projectSearch"),placeholder:d("projectSearch"),onChange:a=>g(a.target.value)})]}),(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto px-2 pb-3",children:e.directoriesLoading&&0===e.directories.length?(0,A.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-6 text-sm text-muted-foreground",children:[(0,A.jsx)(R.A,{"aria-hidden":"true",className:"size-4 animate-spin"}),d("projectLoading")]}):e.directoriesError?(0,A.jsxs)("div",{className:"space-y-3 px-3 py-6 text-sm",children:[(0,A.jsx)("p",{role:"alert",className:"break-words text-destructive",children:e.directoriesError}),(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"sm",onClick:e.retryDirectories,children:d("retry",{ns:"common"})})]}):0===l.length?(0,A.jsx)("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:d("projectEmpty")}):(0,A.jsx)("div",{className:"space-y-1",children:l.map(a=>{let b=a.cwd===e.cwd;return(0,A.jsx)(U.$,{type:"button",variant:"ghost","aria-current":b?"true":void 0,disabled:e.saving,className:(0,W.cn)("h-auto min-h-14 w-full items-start justify-start gap-2 whitespace-normal px-3 py-2 text-left",b&&"bg-accent text-accent-foreground ring-1 ring-border ring-inset"),onClick:()=>{p(a.cwd)},children:(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("span",{className:"flex items-start gap-2",children:[(0,A.jsx)("span",{className:"min-w-0 flex-1 break-all text-sm font-medium",children:oG(a.cwd)}),b?(0,A.jsx)(bs.A,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0"}):null]}),(0,A.jsx)("span",{className:"mt-1 block break-all text-xs font-normal text-muted-foreground",children:a.cwd}),(0,A.jsx)("span",{className:"mt-1 block text-xs font-normal text-muted-foreground",children:d("projectSessionCount",{count:a.sessionCount})})]})},a.cwd)})})})]}),(0,A.jsx)("section",{"aria-label":d("projectDefaultSource"),className:(0,W.cn)("min-h-0 min-w-0 flex-col @[48rem]/project-default:flex",h&&e.cwd?"flex":"hidden"),children:e.cwd?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"shrink-0 border-b px-4 py-2 @[48rem]/project-default:hidden",children:(0,A.jsxs)(U.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(!1),children:[(0,A.jsx)(Z.A,{"aria-hidden":"true"}),d("backProjectList")]})}),(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto p-4 @[48rem]/project-default:p-6",children:(0,A.jsxs)("div",{className:"max-w-[40rem] space-y-6",children:[(0,A.jsxs)("header",{className:"space-y-1",children:[(0,A.jsxs)("h3",{className:"flex items-center gap-2 text-lg font-semibold",children:[(0,A.jsx)("span",{className:"min-w-0 break-all",children:oG(o)}),(0,A.jsx)("span",{className:"inline-flex size-4 shrink-0",children:!e.projectReady&&!e.projectError&&(0,A.jsx)(R.A,{role:"status","aria-label":d("projectLoading"),className:"size-4 animate-spin text-muted-foreground"})})]}),(0,A.jsx)("p",{className:"break-all text-sm text-muted-foreground",children:o})]}),e.projectError?(0,A.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,A.jsx)("p",{role:"alert",className:"min-w-0 flex-1 break-words text-destructive",children:e.projectError}),(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"sm",onClick:e.retryProject,disabled:e.projectLoading||e.projectRefreshing,children:d("retry",{ns:"common"})})]}):null,null!==e.loadedCwd?(0,A.jsxs)("fieldset",{disabled:n,className:"min-w-0 space-y-6",children:[(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsx)("p",{className:"text-sm font-medium",children:d("projectDefaultSource")}),(0,A.jsx)(kx,{label:d("projectDefaultSource"),value:e.fixed?"fixed":"global",layout:"segmented",disabled:n,options:[{value:"global",label:d("projectFollowGlobal")},{value:"fixed",label:d("projectFixed")}],onChange:a=>e.changeFixed("fixed"===a)})]}),e.fixed?(0,A.jsxs)("div",{className:"space-y-3",children:[(0,A.jsx)(nU,{label:d("projectDefaultModel"),children:(0,A.jsx)(km.b,{value:e.selection?oF(e.selection.provider,e.selection.modelId):"",options:m,ariaLabel:d("projectDefaultModel"),searchPlaceholder:d("modelSearch"),disabled:n||0===e.models.length,onChange:function(a){let b=e.models.find(b=>oF(b.provider,b.modelId)===a);b&&e.selectModel(b)}})}),(0,A.jsx)(nU,{label:d("thinkingLevel"),children:(0,A.jsx)(nW,{value:e.selection?.thinkingLevel??"",options:(j?.thinkingLevels??[]).map(a=>({value:a,label:d(oE[a])})),ariaLabel:d("projectDefaultThinking"),allowEmpty:!1,onChange:e.selectThinking})}),k.length>0?(0,A.jsxs)("div",{children:[(0,A.jsx)("p",{className:"text-sm font-medium",children:d("fromPreset")}),(0,A.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:k.map((a,b)=>{let c=e.models.find(b=>b.provider===a.provider&&b.modelId===a.modelId);return(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"xs",disabled:n,className:"h-auto min-h-7 max-w-full whitespace-normal text-left",onClick:()=>e.applyPreset(a),children:[(0,A.jsx)("span",{className:"size-2 shrink-0 rounded-full bg-current",style:a.color?{color:a.color}:void 0}),(0,A.jsxs)("span",{className:"min-w-0 break-all",children:[c?.name||a.modelId," \xb7"," ",d(oE[a.thinkingLevel])]})]},`${a.provider}/${a.modelId}/${a.thinkingLevel}/${b}`)})})]}):null]}):null]}):null]})}),(0,A.jsx)("div",{className:"shrink-0 border-t px-4 py-3 @[48rem]/project-default:px-6",children:(0,A.jsxs)(U.$,{type:"button",onClick:e.save,disabled:!e.projectReady||n||e.fixed&&!e.selection,children:[e.saving?(0,A.jsx)(R.A,{"aria-hidden":"true",className:"animate-spin"}):(0,A.jsx)(bL,{"aria-hidden":"true"}),e.saving?d("savingModels"):d("saveProjectDefault")]})})]}):(0,A.jsxs)("div",{className:"flex items-center gap-2 p-6 text-sm text-muted-foreground",children:[(0,A.jsx)(ch.A,{"aria-hidden":"true",className:"size-6 shrink-0"}),d("selectProjectToConfigure")]})})]}),e.dialog]})}let oI=[{value:"providers",label:"modelProviders"},{value:"presets",label:"modelPresets"},{value:"project-default",label:"projectDefault"}];function oJ({loading:a,error:b,onRetry:c}){let{t:d}=(0,Q.Bd)("settings");return(0,A.jsx)("div",{className:"flex min-h-72 flex-col items-center justify-center gap-3 p-5 text-sm text-muted-foreground",children:a?(0,A.jsxs)("span",{className:"flex items-center gap-2",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"})," ",d("loadingModels")]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("p",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-destructive",children:b??d("modelsUnavailable")}),(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"sm",onClick:c,children:d("retry",{ns:"common"})})]})})}function oK({onBeforeLeaveChange:a,connectionReady:b=!1,initialTab:c}){let{t:d}=(0,Q.Bd)("settings"),{locale:e,timeZone:f}=(0,cy.i)(),[g,h]=(0,B.useState)(!1),{biz:i,tab:j,settings:k,providers:l,presets:m,accountModels:n,changeAccountModels:o,refreshAccounts:p,resetVersion:q,formDirty:r,formInvalid:s,serviceDirty:t,nativeOpen:u,nativeText:v,nativeError:w,nativeDirty:x,setNativeText:y,openNative:z,closeNative:C,saveNative:D,revertConfig:E,setInputState:F,setServiceDirty:G,loading:H,saving:I,refreshing:J,catalogUpdatedAt:K,loadError:L,dialog:M,setProjectDefaultDirty:N,changeProviders:O,changePresets:P,selectTab:S,retry:T,refreshCatalog:V,saveConfig:X}=function(a){let{t:b}=(0,Q.Bd)("settings"),{clientId:c}=(0,bR.gM)(),d=(0,bK.G)(),{confirm:e,dialog:f}=kg(),g=(0,B.useMemo)(()=>{let a;return a=null,{parseNativeConfig(a){let b=JSON.parse(a);return la.parse(b)},getSettings:()=>(a||(a=bX(c,"/api/model-settings/get",{},lm).finally(()=>{a=null})),a),previewSettings:a=>bX(c,"/api/model-settings/preview",lN(a),ls),async replaceSettings(a){await bX(c,"/api/model-settings/replace",lN(a),lr)},listCatalog:a=>bX(c,"/api/model-catalog/list",lt.parse(a),lx),async listDirectories(){let a=await bX(c,"/api/pi/directories/list",{forceRefresh:!1},lB.N$);return lI(a),a},async getProjectDefault(a){let b=await bX(c,"/api/project-model-default/get",{cwd:a},ly);return lM(b),b},async replaceProjectDefault(a){await bX(c,"/api/project-model-default/replace",lz.parse(a),lA)}}},[c]),[h,i]=(0,B.useState)(()=>a??"providers"),[j,k]=(0,B.useState)(null),[l,m]=(0,B.useState)([]),[n,o]=(0,B.useState)([]),[p,q]=(0,B.useState)([]),[r,s]=(0,B.useState)(!1),[t,u]=(0,B.useState)(!1),[v,w]=(0,B.useState)(!1),[x,y]=(0,B.useState)(!1),[z,A]=(0,B.useState)(!0),[C,D]=(0,B.useState)(!1),[E,F]=(0,B.useState)(!1),[G,H]=(0,B.useState)(null),[I,J]=(0,B.useState)(null),[K,L]=(0,B.useState)(0),[M,N]=(0,B.useState)(0),[O,P]=(0,B.useState)({dirty:!1,invalid:!1}),[R,S]=(0,B.useState)(!1),[T,U]=(0,B.useState)(!1),[V,W]=(0,B.useState)(""),[X,Y]=(0,B.useState)(null),Z=(0,B.useRef)(!1),$=(0,B.useRef)([]),_=j?JSON.stringify(j.nativeConfig,null,2):"",aa=T&&V!==_,ab=t||v||r||O.dirty,ac=(0,B.useCallback)(a=>{$.current=[],k(a),m(structuredClone(a.providers)),o(structuredClone(a.presets)),q(structuredClone(a.accountModels)),s(!1),u(!1),w(!1),P({dirty:!1,invalid:!1}),N(a=>a+1)},[]);async function ad(){F(!0);try{let a=await g.listCatalog({query:"",refresh:!0,page:{index:1,size:1}});H(a.updatedAt),await ag(),d.success("cached"===a.refreshResult?b("catalogCached"):"partial"===a.refreshResult?b("catalogPartial"):"unchanged"===a.refreshResult?b("catalogUnchanged"):b("catalogUpdated"))}catch(a){d.error(a instanceof Error?a.message:b("catalogRefreshFailed"))}finally{F(!1)}}async function ae(a,c=0){let{projectDefaults:d}=await g.previewSettings(a);if(d.length>0){let a=[b("replaceProjectDefaultsDescription"),...c>0?[b("removeInvalidPresets",{count:c})]:[]].join(" ");return e({title:b("replaceProjectDefaultsTitle"),description:a,content:(0,B.createElement)(k1,{projectDefaults:d}),confirmLabel:b("confirmAndSaveModels"),confirmVariant:"default"})}return 0===c||e({title:b("removeInvalidPresetsTitle"),description:b("removeInvalidPresets",{count:c}),confirmLabel:b("removeAndSave")})}async function af(){if(!Z.current&&!O.invalid&&!R&&!T){if(!j||!ab)return void d.success(b("modelsNoChanges"));Z.current=!0,D(!0);try{let a=new Set([...l.flatMap(a=>a.models.map(b=>`${a.provider}\u0000${b.modelId}`)),...p.map(a=>`${a.provider}\u0000${a.modelId}`)]),c=new Set([...j.providers.flatMap(a=>a.models.map(b=>`${a.provider}\u0000${b.modelId}`)),...j.accountModels.map(a=>`${a.provider}\u0000${a.modelId}`)]),e=n.filter(b=>{let d=`${b.provider}\u0000${b.modelId}`;return!c.has(d)||a.has(d)}),f=n.length-e.length,h={...t||O.dirty?{providers:l}:{},...r?{accountModels:p}:{},...v||f>0?{presets:e}:{},...$.current.length?{modelReplacements:$.current}:{}};if(!await ae(h,f))return;await g.replaceSettings(h),ac(await g.getSettings()),u(!1),w(!1),d.success(b("modelSaved"))}catch(a){d.error(a instanceof Error?a.message:b("modelSaveFailed"))}finally{Z.current=!1,D(!1)}}}async function ag(){let a=await g.getSettings();return k(b=>b?{...b,accounts:a.accounts,models:a.models,nativeConfig:a.nativeConfig}:a),a}async function ah(){!j||Z.current||R||await e({title:b("discardModelTitle"),description:b("discardModelDescription"),confirmLabel:b("discardModelConfirm")})&&ac(j)}async function ai(){Z.current||(!aa||await e({title:b("discardNativeTitle"),description:b("discardNativeDescription"),confirmLabel:b("discardModelConfirm")}))&&U(!1)}async function aj(){if(!Z.current&&T&&aa){Z.current=!0,D(!0),Y(null);try{let a={nativeConfig:g.parseNativeConfig(V)};if(!await ae(a))return;await g.replaceSettings(a),ac(await g.getSettings()),U(!1),d.success(b("modelSaved"))}catch(c){let a=c instanceof Error?c.message:b("modelSaveFailed");console.warn("[Pi Desk][ModelSettings] 保存 Pi 配置失败",{message:a}),Y(a)}finally{Z.current=!1,D(!1)}}}return{biz:g,tab:h,settings:j,providers:l,presets:n,accountModels:p,changeAccountModels:a=>{q(a),s(JSON.stringify(a)!==JSON.stringify(j?.accountModels))},refreshAccounts:ag,providersDirty:t,presetsDirty:v,loading:z,saving:C,refreshing:E,catalogUpdatedAt:G,loadError:I,resetVersion:M,formDirty:ab,formInvalid:O.invalid,serviceDirty:R,nativeOpen:T,nativeText:V,nativeError:X,nativeDirty:aa,setNativeText:W,openNative:function(){if(j&&!Z.current){if(ab||R||x)return void d.error(b("nativeProtectDraft"));W(_),Y(null),U(!0)}},closeNative:ai,saveNative:aj,revertConfig:ah,setInputState:P,setServiceDirty:S,dialog:f,setProjectDefaultDirty:y,changeProviders:(a,b)=>{$.current=b,m(a),u(JSON.stringify(a)!==JSON.stringify(j?.providers))},changePresets:a=>{o(a),w(JSON.stringify(a)!==JSON.stringify(j?.presets))},selectTab:a=>{if(a!==h&&!Z.current){if("project-default"===h&&x)return void e({title:b("discardModelTitle"),description:b("discardModelDescription"),confirmLabel:b("discardModelConfirm")}).then(b=>{b&&(y(!1),i(a))});i(a)}},retry:()=>L(a=>a+1),refreshCatalog:ad,saveConfig:af}}(c);return(0,A.jsxs)("div",{className:"@container/model-settings flex h-full min-h-0 flex-col",children:[(0,A.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b p-4",children:[(0,A.jsx)(kx,{label:d("models"),layout:"segmented",value:j,options:oI.map(a=>({...a,label:d(a.label)})),onChange:S}),(0,A.jsxs)("div",{className:"hidden gap-2 @[40rem]/model-settings:flex",children:[(0,A.jsxs)(U.$,{type:"button",variant:"ghost",size:"sm",disabled:!k||I,onClick:z,children:[(0,A.jsx)(k_,{}),d("nativeConfig")]}),(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",title:K?d("catalogUpdatedAt",{time:new Date(K).toLocaleString("en"===e?"en-US":"zh-CN",{timeZone:f,timeZoneName:"shortOffset",hourCycle:"h23"})}):d("catalogUnavailable"),onClick:V,disabled:J,children:[(0,A.jsx)(bO.A,{className:(0,W.cn)(J&&"animate-spin")}),J?d("refreshingCatalog"):d("refreshCatalog")]})]}),(0,A.jsxs)(cq.AM,{open:g,onOpenChange:h,children:[(0,A.jsx)(cq.Wv,{render:(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":d("modelMoreActions"),className:"shrink-0 @[40rem]/model-settings:hidden",children:(0,A.jsx)(an,{})})}),(0,A.jsxs)(cq.hl,{align:"end",positionerClassName:"z-[120]",className:"w-48 gap-1 p-1",children:[(0,A.jsxs)(U.$,{type:"button",variant:"ghost",className:"justify-start",disabled:!k||I,onClick:()=>{h(!1),z()},children:[(0,A.jsx)(k_,{}),d("nativeConfig")]}),(0,A.jsxs)(U.$,{type:"button",variant:"ghost",className:"justify-start",disabled:J,onClick:()=>{h(!1),V()},children:[(0,A.jsx)(bO.A,{}),d("refreshCatalog")]})]})]})]}),(0,A.jsxs)("div",{className:(0,W.cn)("pi-desk-chat-scrollbar min-h-0 flex-1","presets"===j?"overflow-y-auto":"overflow-hidden"),children:["project-default"===j?(0,A.jsx)(oH,{biz:i,presets:k?.presets??[],onDirtyChange:N}):k?null:(0,A.jsx)(oJ,{loading:H,error:L,onRetry:T}),k?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("fieldset",{disabled:I,className:(0,W.cn)("h-full min-h-0 min-w-0","providers"!==j&&"hidden"),children:(0,A.jsx)(oD,{biz:i,connectionReady:b,providers:l,accounts:k.accounts,accountModels:n,onAccountModelsChange:o,onRefreshAccounts:p,savedProviders:k.providers,savedModels:k.models,presets:m,resetVersion:q,onChange:O,onPresetsChange:P,onInputState:F,onServiceDirtyChange:G})}),(0,A.jsx)("fieldset",{disabled:I,className:(0,W.cn)("min-w-0","presets"!==j&&"hidden"),children:(0,A.jsx)(n2,{presets:m,models:k.models,onChange:P})})]}):null]}),"project-default"!==j&&k?(0,A.jsxs)("footer",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-t bg-card px-4 py-3",children:[(0,A.jsx)("span",{className:(0,W.cn)("text-xs text-muted-foreground",s&&"text-destructive"),role:"status",children:s?d("fixModelInputs"):r?d("modelDraftPending"):d("modelDraftClean")}),(0,A.jsxs)("div",{className:"flex gap-2",children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"sm",disabled:I||!r||t,onClick:E,children:d("revertModels")}),(0,A.jsxs)(U.$,{type:"button",size:"sm",onClick:X,disabled:I||!r||s||t,children:[I?(0,A.jsx)(R.A,{className:"animate-spin"}):(0,A.jsx)(bL,{}),I?d("savingModels"):d("saveModels")]})]})]}):null,(0,A.jsx)(lO,{open:u,text:v,error:w,saving:I,dirty:x,onChange:y,onClose:C,onSave:D}),M]})}function oL({render:a,input:b}){return a(b)}let oM=[{id:"appearance",label:"appearance",icon:jj},{id:"region",label:"region",icon:jk.A},{id:"habits",label:"habits",icon:jl},{id:"models",label:"models",icon:ci},{id:"mcp-settings",label:"mcpSettings",icon:ca},{id:"capability-modes",label:"capabilityModes",icon:b$.A},{id:"skills",label:"skills",icon:jm.A},{id:"plugins",label:"plugins",icon:ca},{id:"auth",label:"loginProtection",icon:bP},{id:"about",label:"about",icon:jn.A}];function oN(a,b){return`plugin:${a}:${b}`}function oO(){let{t:a}=(0,Q.Bd)("settings"),b=(0,cy.i)();return(0,A.jsxs)("section",{"aria-labelledby":"settings-about-title",className:"min-w-0 space-y-6",children:[(0,A.jsx)("h2",{id:"settings-about-title",className:"text-xl font-semibold",children:a("about")}),(0,A.jsxs)("div",{className:"flex items-center gap-3 rounded-xl bg-muted p-4",children:[(0,A.jsx)(jq.V,{size:48,className:"shrink-0"}),(0,A.jsxs)("div",{children:[(0,A.jsx)("p",{className:"text-sm font-semibold",children:"Pi Desk"}),(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:a("webDescription")})]})]}),(0,A.jsxs)("dl",{className:"divide-y border-y text-sm",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 py-3",children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:a("version")}),(0,A.jsxs)("dd",{className:"font-mono",children:["v",jo]})]}),(0,A.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 py-3",children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:a("versionUpdated")}),(0,A.jsx)("dd",{className:"tabular-nums",children:function(a,b,c,d){if(!a)return d;let e=new Date(a);return Number.isNaN(e.getTime())?d:new Intl.DateTimeFormat(b,{timeZone:c,year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(e)}(jp,"en"===b.locale?"en-US":"zh-CN",b.timeZone,a("common:unavailable"))})]})]})]})}function oP({open:a,connectionReady:b=!1,initialModelTab:c,workSessions:d,focusedCwd:e,pluginAttention:f,renderPluginManagement:g,renderMcpSettings:h,renderCapabilityModesSettings:i,renderPluginSettingsPage:j,onOpenChange:k,onBeforeReload:l}){let{t:m}=(0,Q.Bd)("settings"),n=(0,bJ.So)(),o=(0,B.useMemo)(()=>{let a=new Map;for(let{cwd:b,projectName:c}of d){let d=b.replaceAll("\\","/").replace(/\/+$/,""),e=/^[a-zA-Z]:\//.test(d)||d.startsWith("//")?d.toLowerCase():d;a.has(e)||a.set(e,{cwd:b,projectName:c})}return[...a.values()]},[d]),p=(0,B.useMemo)(()=>n.flatMap(a=>a.contributions.flatMap(b=>"settings-page"===b.kind?[{pluginName:a.pluginName,descriptor:b}]:[])),[n]),[q,r]=(0,B.useState)(()=>c?"models":"appearance"),[s,t]=(0,B.useState)(!1),[u,v]=(0,B.useState)(!1),w=(0,B.useRef)(null),x=(0,B.useRef)(!1),y=p.find(a=>oN(a.pluginName,a.descriptor.contributionName)===q),z=q.startsWith("plugin:")&&!y?"appearance":q,C=oM.find(a=>a.id===z),D=C?.icon,E=(0,B.useCallback)(async a=>{if(!x.current){x.current=!0,v(!0);try{let b=w.current;if(b&&!await b())return;w.current=null,a()}finally{x.current=!1,v(!1)}}},[]),F=(0,B.useCallback)(()=>{E(()=>k(!1))},[k,E]),G=(0,B.useCallback)(a=>{w.current=a},[]),H=a=>{a!==z&&E(()=>r(a))};return(0,A.jsx)(b7.YV,{open:a,onOpenChange:(a,b)=>{a?k(!0):"focus-out"!==b.reason&&F()},children:(0,A.jsxs)(b7.hA,{className:"h-[min(48rem,calc(100dvh-2rem))] max-w-6xl max-sm:h-[var(--pi-desk-content-height)] max-sm:max-h-[var(--pi-desk-content-height)] max-sm:w-dvw max-sm:max-w-none max-sm:rounded-none max-sm:border-0",finalFocus:!1,showCloseButton:!u,children:[(0,A.jsx)(b7.Hl,{className:"border-b px-4 py-3 pr-12",children:(0,A.jsx)(b7.YM,{children:m("title")})}),(0,A.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[(0,A.jsx)("div",{className:"shrink-0 border-b bg-sidebar p-3 sm:hidden",children:(0,A.jsxs)(bS.l6,{value:z,disabled:u,onValueChange:a=>{if("string"!=typeof a)return;let b=oM.find(b=>b.id===a);if(b)return void H(b.id);let c=p.find(b=>oN(b.pluginName,b.descriptor.contributionName)===a);c&&H(oN(c.pluginName,c.descriptor.contributionName))},children:[(0,A.jsx)(bS.bq,{"aria-label":m("category"),className:"w-full",children:(0,A.jsx)(bS.yv,{children:y?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(co,{icon:y.descriptor.icon,className:"size-4 shrink-0"}),(0,A.jsx)("span",{className:"truncate",children:y.descriptor.label})]}):C&&D?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(D,{className:"size-4 shrink-0"}),(0,A.jsx)("span",{className:"truncate",children:m(C.label)})]}):null})}),(0,A.jsxs)(bS.gC,{positionerClassName:"z-[120]",align:"start",children:[oM.map(a=>{let b=a.icon;return(0,A.jsxs)(bS.eb,{value:a.id,children:[(0,A.jsxs)("span",{className:"relative shrink-0",children:[(0,A.jsx)(b,{className:"size-4"}),"plugins"===a.id&&f?(0,A.jsx)("span",{"aria-hidden":"true",className:(0,W.cn)("absolute -right-1 -top-1 size-1.5 rounded-full","error"===f?"bg-destructive":"bg-primary")}):null]}),(0,A.jsx)("span",{children:m(a.label)})]},a.id)}),p.length>0?(0,A.jsxs)(bS.s3,{children:[(0,A.jsx)(bS.TR,{children:m("pluginSettings")}),p.map(a=>{let b=oN(a.pluginName,a.descriptor.contributionName);return(0,A.jsxs)(bS.eb,{value:b,children:[(0,A.jsx)(co,{icon:a.descriptor.icon,className:"size-4 shrink-0"}),(0,A.jsx)("span",{children:a.descriptor.label})]},b)})]}):null]})]})}),(0,A.jsxs)("nav",{"aria-label":m("category"),className:"pi-desk-chat-scrollbar hidden w-48 shrink-0 space-y-4 overflow-auto border-r bg-sidebar p-3 sm:block",children:[(0,A.jsx)("div",{className:"grid grid-cols-1 gap-1",children:oM.map(a=>{let b=a.icon,c=a.id===z;return(0,A.jsxs)(U.$,{variant:"ghost",disabled:u,"aria-current":c?"page":void 0,"aria-label":`${m("category")}:${m(a.label)}`,onClick:()=>H(a.id),className:(0,W.cn)("min-w-0 justify-start",c?"bg-accent text-accent-foreground hover:bg-accent":"text-muted-foreground"),children:[(0,A.jsxs)("span",{className:"relative shrink-0",children:[(0,A.jsx)(b,{className:"size-4"}),"plugins"===a.id&&f?(0,A.jsx)("span",{"aria-hidden":"true",className:(0,W.cn)("absolute -right-1 -top-1 size-1.5 rounded-full","error"===f?"bg-destructive":"bg-primary")}):null]}),(0,A.jsx)("span",{className:"truncate",children:m(a.label)})]},a.id)})}),p.length>0?(0,A.jsxs)(cs.Nt,{open:s||!!y,onOpenChange:t,className:"mt-2 border-t pt-2",children:[(0,A.jsxs)(cs.R6,{type:"button","aria-label":m("pluginSettings"),className:"flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1 text-sm font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[(0,A.jsx)("span",{className:"min-w-0 flex-1 text-left",children:m("pluginSettings")}),(0,A.jsx)("span",{className:"tabular-nums",children:p.length}),(0,A.jsx)(cr.A,{className:(0,W.cn)("size-3.5 transition-transform",s||y?"rotate-180":null)})]}),(0,A.jsx)(cs.Ke,{children:(0,A.jsx)("div",{className:"mt-1 grid grid-cols-1 gap-1",children:p.map(a=>{let b=oN(a.pluginName,a.descriptor.contributionName),c=b===z;return(0,A.jsxs)(U.$,{variant:"ghost",disabled:u,"aria-current":c?"page":void 0,onClick:()=>H(b),className:(0,W.cn)("min-w-0 justify-start",c?"bg-accent text-accent-foreground hover:bg-accent":"text-muted-foreground"),children:[(0,A.jsx)(co,{icon:a.descriptor.icon,className:"size-4 shrink-0"}),(0,A.jsx)("span",{className:"truncate",children:a.descriptor.label})]},b)})})})]}):null]}),y?(0,A.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,A.jsx)(oL,{render:j,input:{pluginName:y.pluginName,descriptor:y.descriptor,onClose:F,onBeforeLeaveChange:G}})}):"skills"===z?(0,A.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:a&&(0,A.jsx)(kb,{projects:o,focusedCwd:e,onBeforeLeaveChange:G})}):"mcp-settings"===z?(0,A.jsx)("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:a&&(0,A.jsx)(oL,{render:h,input:{onBeforeLeaveChange:G}})}):"capability-modes"===z?(0,A.jsx)("div",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:a&&(0,A.jsx)(oL,{render:i,input:{onBeforeLeaveChange:G}})}):"models"===z?(0,A.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:a&&(0,A.jsx)(oK,{connectionReady:b,initialTab:c,onBeforeLeaveChange:G})}):"plugins"===z?(0,A.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:g()}):(0,A.jsx)(b7._Y,{className:"min-w-0 max-h-none",children:(0,A.jsx)("div",{className:"p-4 sm:p-6",children:"appearance"===z?(0,A.jsx)(kL,{}):"habits"===z?(0,A.jsx)(k$,{}):"auth"===z?a&&(0,A.jsx)(kl,{}):"region"===z?(0,A.jsx)(ks,{canLeave:l}):(0,A.jsx)(oO,{})})})]})]})})}let oQ=E.Ik({cwd:E.Yj().trim().min(1).nullable()}).strict(),oR=E.g1(E.Yj(),E.Pq()),oS=E.g1(E.Yj().min(1).max(128),oR),oT=E.Ik({local:oS,inherited:oS,projectTrusted:E.zM().nullable(),diagnostics:E.YO(E.Ik({name:E.Yj().nullable(),message:E.Yj()}).strict())}).strict();oQ.extend({servers:oS}).strict(),oQ.extend({name:E.Yj().min(1).max(128)}).strict();let oU=E.Ik({output:E.Yj()}).strict(),oV=E.Ik({}).strict(),oW=["command","args","url","type","description","enabled","exposure"];function oX(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&Object.values(a).every(a=>"string"==typeof a)}function oY(a){return oX(a)?Object.entries(a).map(([a,b])=>({key:a,value:b})):[]}function oZ(a){return!("command"in a)&&!("url"in a)&&!("type"in a)}function o$(a,b){let c=b??{};return{originalName:a,name:a??"",transport:b&&oZ(b)?"inherit":"url"in c?"http":"stdio",command:"string"==typeof c.command?c.command:"",args:Array.isArray(c.args)?c.args.join("\n"):"",env:oY(c.env),headers:oY(c.headers),url:"string"==typeof c.url?c.url:"",description:"string"==typeof c.description?c.description:"",enabled:!1!==c.enabled,exposure:"string"==typeof c.exposure?c.exposure:"",advanced:JSON.stringify(Object.fromEntries(Object.entries(c).filter(([a,b])=>!oW.includes(a)&&!(["env","headers"].includes(a)&&oX(b)))),null,2)}}class o_ extends Error{constructor(a,b){super(b),this.field=a}}function o0(a){return"string"==typeof a.url?a.url:"string"==typeof a.command?a.command:"继承全局连接"}let o1={MCP:"MCP",服务列表:"Servers",配置服务:"Configure server",服务配置:"Server configuration",手动配置:"Configure manually","导入 JSON":"Import JSON",返回服务列表:"Back to servers",服务操作:"Server actions",恢复全局配置:"Restore global configuration",删除服务:"Delete server",继承全局:"Inherited from global",项目配置:"Project configuration","项目配置 \xb7 继承全局连接":"Project configuration \xb7 inherits global connection","连接参数沿用全局,仅保存本项目的启用和工具设置。":"Connection settings are inherited from global. Only enablement and tool settings are saved for this project.",环境变量:"Environment variables",请求头:"Request headers",名称:"Name",值:"Value",添加:"Add ",删除行:"Remove row",高级设置:"Advanced settings","其他配置(JSON)":"Other configuration (JSON)",保存并测试:"Save and test",连接测试结果:"Connection test result","正在测试连接…":"Testing connection…","已保存,正在测试连接…":"Saved. Testing connection…",连接测试通过:"Connection test passed",连接测试失败:"Connection test failed",查看详细输出:"View output","已保存,连接测试通过。":"Saved. Connection test passed.","已保存,连接测试失败。":"Saved. Connection test failed.","请填写名称,或删除空白行。":"Enter a name or remove the empty row.","名称不能重复。":"Names must be unique.","环境变量和请求头不能在表单与 JSON 中重复配置。":"Do not configure environment variables or request headers in both the form and JSON.","连接请求最多等待 10 秒;凭据命令可能延长检查时间。":"Connection requests wait up to 10 seconds; credential commands may extend the check.",配置范围:"Configuration scope",全局:"Global",当前项目:"Current project",手动添加:"Add manually","添加 JSON":"Add JSON","正在读取配置…":"Loading configuration…",重试:"Retry","添加第一个 MCP 服务":"Add your first MCP server","添加服务地址或本地程序。":"Add a server URL or a local program.",已启用:"Enabled",已停用:"Disabled",启用:"Enable",停用:"Disable",编辑:"Edit",为本项目配置:"Configure for this project",独立检查:"Check independently",删除:"Delete",来自全局:"Inherited from global",本项目:"This project",覆盖全局:"Overrides global","项目设置 \xb7 继承全局连接":"Project settings \xb7 inherits global connection",继承全局连接:"Inherit global connection","本项目尚未受信任,不能执行检查;仍可编辑和保存配置。":"This project is not trusted. Checking is disabled; editing and saving remain available.","配置启用不代表已连接。保存不会自动连接或重载会话。":"Enabled configuration does not mean connected. Saving does not connect or reload sessions.","正在检查…":"Checking…",检查输出:"Check output",检查完成:"Check completed",检查失败:"Check failed","检查连接已关闭,当前聊天会话状态未改变。":"The check connection is closed. Current chat session state is unchanged.",返回编辑:"Edit configuration",关闭结果:"Dismiss result",返回:"Back",添加服务:"Add server",编辑服务:"Edit server",保存范围:"Save scope",服务名称:"Server name",连接方式:"Transport",本地程序:"Local program","HTTP 地址":"HTTP URL",启动程序:"Command","参数(每行一个)":"Arguments (one per line)","服务说明(可选)":"Description (optional)",工具使用方式:"Tool exposure",沿用默认:"Use default",通过脚本调用:"Via scripts",按需发现:"On-demand discovery",直接使用:"Direct use",隐藏:"Hidden","高级配置(JSON)":"Advanced configuration (JSON)","继承全局连接,仅保存本项目启用与曝光设置,不复制全局凭据。":"Inherits the global connection. Only project enablement and exposure settings are saved; global credentials are not copied.","本项目的完整定义会整体替换同名全局配置。":"A complete project definition replaces the global configuration of the same name.","配置 JSON":"Configuration JSON","仅接受包含 mcpServers 的标准 JSON。":"Only standard JSON with mcpServers is accepted.",解析预览:"Preview",待保存服务:"Servers to save",新增:"New",替换已有配置:"Replace existing configuration","覆盖全局(仅本项目)":"Override global (this project only)",允许替换以上同名已有配置:"Allow replacing existing configuration with the same names","重新编辑 JSON":"Edit JSON again",取消:"Cancel",保存:"Save","保存中…":"Saving…","已保存。新会话使用新配置;已有会话需重载 Pi 配置。":"Saved. New sessions use the new configuration; existing sessions must reload Pi configuration.","放弃未保存的修改?":"Discard unsaved changes?","当前修改尚未保存。放弃后将保留已保存的配置。":"Your changes have not been saved. Discarding keeps the saved configuration.",放弃修改:"Discard changes",删除配置:"Delete configuration","删除本项目配置后,将恢复使用同名全局配置。":"Deleting this project configuration restores the global configuration of the same name.","此范围内的服务配置将被删除。":"The server configuration will be deleted from this scope.","请输入有效的 JSON。":"Enter valid JSON.","仅接受包含 mcpServers 的标准配置,不允许其他根级字段。":"Only a standard mcpServers object is accepted; other root fields are not allowed.","配置中至少需要一个服务。":"At least one server is required.","服务名称需要 1–128 个字符。":"Server names must contain 1–128 characters.","高级配置需要是 JSON 对象。":"Advanced configuration must be a JSON object.","连接、说明、启用和曝光字段请在上方表单中填写。":"Set connection, description, enablement and exposure in the fields above.","继承连接只允许启用、曝光和 toolExposure 设置。":"Inherited connections only allow enablement, exposure and toolExposure settings.","请输入启动程序。":"Enter a command.","请输入有效的 HTTP 或 HTTPS 地址。":"Enter a valid HTTP or HTTPS URL.","请明确勾选替换已有配置。":"Explicitly allow replacing existing configuration.","该名称已存在,请编辑已有服务或使用其他名称。":"This name already exists. Edit that server or choose another name.","请求失败,请重试。":"The request failed. Please retry."};function o2(){let{locale:a}=(0,cy.i)();return b=>"en"===a?o1[b]??b:b}function o3(a){return a instanceof Error?a.message:"请求失败,请重试。"}function o4({id:a,label:b,value:c,options:d,disabled:e,onChange:f}){return(0,A.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,A.jsx)("label",{id:`${a}-label`,htmlFor:a,className:"text-sm font-medium",children:b}),(0,A.jsxs)(bS.l6,{value:c,disabled:e,onValueChange:a=>{"string"==typeof a&&f(a)},children:[(0,A.jsx)(bS.bq,{id:a,"aria-labelledby":`${a}-label`,className:"w-full min-w-0 whitespace-normal [&_[data-slot=select-value]]:line-clamp-none [&_[data-slot=select-value]]:break-all",children:(0,A.jsx)(bS.yv,{children:d.find(a=>a.value===c)?.label??c})}),(0,A.jsx)(bS.gC,{positionerClassName:"z-[125]",align:"start",children:d.map(a=>(0,A.jsx)(bS.eb,{value:a.value,className:"[&_span]:whitespace-normal [&_span]:break-all",children:a.label},a.value))})]})]})}function o5({trigger:a,children:b}){return(0,A.jsxs)(bt,{children:[(0,A.jsx)(bv,{render:a}),(0,A.jsx)(bu,{children:(0,A.jsx)(aZ.y,{sideOffset:4,align:"end",className:"z-[125] outline-none",children:(0,A.jsx)(a$._,{className:bq.hD,children:b})})})]})}function o6({message:a,id:b}){let c=o2();return a?(0,A.jsx)("p",{id:b,role:"alert",className:"break-words text-sm text-destructive",children:c(a)}):null}function o7({rows:a,selectedName:b,pending:c,onSelect:d}){let e=o2();return(0,A.jsx)("ul",{"aria-label":e("服务列表"),className:"divide-y",children:a.map(a=>{let f="string"==typeof a.config.url?cl:T;return(0,A.jsx)("li",{children:(0,A.jsxs)("button",{type:"button","aria-label":`${e("配置服务")} \xb7 ${a.name}`,"aria-current":b===a.name?"true":void 0,disabled:c,onClick:()=>d(a),className:(0,W.cn)("flex w-full min-w-0 cursor-pointer items-center gap-3 p-4 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:cursor-default",b===a.name&&"bg-accent"),children:[(0,A.jsx)(f,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),(0,A.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,A.jsxs)("span",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[(0,A.jsx)("span",{className:"min-w-0 break-all text-sm font-medium",children:a.name}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:e(!1===a.config.enabled?"已停用":"已启用")})]}),(0,A.jsxs)("span",{className:"block text-xs text-muted-foreground",children:[e(a.source)," \xb7"," ",e("string"==typeof a.config.url?"HTTP 地址":"本地程序")]}),(0,A.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:o0(a.config)})]}),(0,A.jsx)(br.A,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"})]})},a.name)})})}function o8({id:a,label:b,rows:c,disabled:d,error:e,onChange:f}){let g=o2();return(0,A.jsxs)("fieldset",{className:"min-w-0 space-y-2",disabled:d,children:[(0,A.jsx)("legend",{className:"text-sm font-medium",children:b}),c.length>0&&(0,A.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1.5fr)_2rem] gap-2 text-xs text-muted-foreground","aria-hidden":"true",children:[(0,A.jsx)("span",{children:g("名称")}),(0,A.jsx)("span",{children:g("值")})]}),c.map((h,i)=>(0,A.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1.5fr)_2rem] gap-2",children:[(0,A.jsx)(bY.p,{"aria-label":`${b} \xb7 ${g("名称")} ${i+1}`,"aria-invalid":!!e,"aria-describedby":e?`${a}-error`:void 0,value:h.key,spellCheck:!1,className:"min-w-0 font-mono",onChange:a=>f(c.map((b,c)=>c===i?{...b,key:a.target.value}:b))}),(0,A.jsx)(bY.p,{"aria-label":`${b} \xb7 ${g("值")} ${i+1}`,value:h.value,spellCheck:!1,autoComplete:"off",className:"min-w-0 font-mono",onChange:a=>f(c.map((b,c)=>c===i?{...b,value:a.target.value}:b))}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon","aria-label":`${g("删除行")} \xb7 ${b} ${i+1}`,disabled:d,onClick:()=>f(c.filter((a,b)=>b!==i)),children:(0,A.jsx)(bN,{"aria-hidden":"true"})})]},i)),(0,A.jsx)(o6,{id:`${a}-error`,message:e}),(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",disabled:d,onClick:()=>f([...c,{key:"",value:""}]),children:[(0,A.jsx)(am,{"aria-hidden":"true"}),g("添加"),b]})]})}var o9=c(69391);function pa({check:a,onRetry:b,onDismiss:c}){let d=o2(),e=a.loading?R.A:a.error?ak.A:o9.A;return(0,A.jsxs)("section",{"aria-label":d("连接测试结果"),"aria-busy":a.loading,className:"space-y-2 border-b pb-4",children:[(0,A.jsxs)("p",{role:"status",className:"flex items-center gap-2 text-sm font-medium",children:[(0,A.jsx)(e,{"aria-hidden":"true",className:`size-4 shrink-0 ${a.loading?"motion-safe:animate-spin":a.error?"text-destructive":""}`}),d(a.loading?"已保存,正在测试连接…":a.error?"已保存,连接测试失败。":"已保存,连接测试通过。")]}),(0,A.jsx)(o6,{message:a.error}),a.loading?(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:d("连接请求最多等待 10 秒;凭据命令可能延长检查时间。")}):(0,A.jsxs)(A.Fragment,{children:[a.output&&(0,A.jsxs)("details",{className:"text-sm",children:[(0,A.jsx)("summary",{className:"w-fit cursor-pointer rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:d("查看详细输出")}),(0,A.jsx)("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-muted p-3 font-mono text-sm",children:a.output})]}),(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:d("检查连接已关闭,当前聊天会话状态未改变。")}),(0,A.jsxs)("div",{className:"flex gap-2",children:[a.error&&(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"sm",onClick:b,children:d("重试")}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"sm",onClick:c,children:d("关闭结果")})]})]})]})}function pb({editor:a,scopeLabel:b,project:c,projectTrusted:d,check:e,local:f,inherited:g,pending:h,saving:i,error:j,onDraft:k,onJson:l,onPreview:m,onOverwrite:n,onSave:o,onCancel:p,onRemove:q,onDismissCheck:r}){let s=o2(),t=(0,B.useId)(),u=(0,B.useRef)(null),[v,w]=(0,B.useState)(!1),x=a=>`${t}-${a}`,y="manual"===a.kind?a.draft:null,z="json"===a.kind&&a.preview?Object.keys(a.preview).filter(a=>Object.hasOwn(f,a)):[],C="json"===a.kind?"导入 JSON":y?.originalName?"服务配置":"添加服务",D=y?.originalName,E=!!(D&&Object.hasOwn(f,D)),F=!!(c&&D&&Object.hasOwn(g,D)),G=(a,b,c)=>(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsx)("label",{htmlFor:x(a),className:"text-sm font-medium",children:s(b)}),c,(0,A.jsx)(o6,{id:x(`${a}-error`),message:j?.field===a?j.message:null})]}),H=(a,b)=>G(a,b,(0,A.jsx)(bY.p,{id:x(a),value:y?.[a]??"",disabled:h||"name"===a&&!!y?.originalName,"aria-invalid":j?.field===a,"aria-describedby":j?.field===a?x(`${a}-error`):void 0,onChange:b=>k({[a]:b.target.value})}));return(0,A.jsxs)("form",{ref:u,"aria-label":s(C),className:"flex min-h-0 min-w-0 flex-1 flex-col",onSubmit:a=>{a.preventDefault(),o()},children:[(0,A.jsxs)("div",{className:"shrink-0 space-y-1 border-b p-4 sm:px-6",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon","aria-label":s("返回服务列表"),disabled:h,onClick:p,children:(0,A.jsx)(Z.A,{"aria-hidden":"true"})}),(0,A.jsx)("h3",{className:"min-w-0 flex-1 text-sm font-semibold",children:s(C)}),E&&D&&(0,A.jsx)(o5,{trigger:(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon","aria-label":s("服务操作"),disabled:h,children:(0,A.jsx)(an,{"aria-hidden":"true"})}),children:(0,A.jsx)(bz,{variant:F?"default":"destructive",onClick:()=>q(D),children:s(F?"恢复全局配置":"删除服务")})})]}),c&&(0,A.jsxs)("p",{className:"break-all text-xs text-muted-foreground",children:[s("保存范围"),":",b]})]}),(0,A.jsxs)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[y?(0,A.jsxs)("div",{className:"max-w-[40rem] space-y-4",children:[e&&(0,A.jsx)(pa,{check:e,onRetry:()=>o(!0),onDismiss:r}),H("name","服务名称"),"inherit"===y.transport?(0,A.jsxs)("div",{className:"space-y-1",children:[(0,A.jsx)("p",{className:"text-sm font-medium",children:s("继承全局连接")}),D&&g[D]&&(0,A.jsx)("p",{className:"break-all font-mono text-sm text-muted-foreground",children:o0(g[D])}),(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:s("连接参数沿用全局,仅保存本项目的启用和工具设置。")})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(o4,{id:x("transport"),label:s("连接方式"),value:y.transport,disabled:h,options:[{value:"stdio",label:s("本地程序")},{value:"http",label:s("HTTP 地址")}],onChange:a=>k({transport:"http"===a?"http":"stdio"})}),"stdio"===y.transport?(0,A.jsxs)(A.Fragment,{children:[H("command","启动程序"),G("args","参数(每行一个)",(0,A.jsx)(iE.T,{id:x("args"),className:"min-h-24 font-mono",value:y.args,disabled:h,onChange:a=>k({args:a.target.value})}))]}):H("url","HTTP 地址"),("stdio"===y.transport||j?.field==="env")&&(0,A.jsx)(o8,{id:x("env"),label:s("环境变量"),rows:y.env,disabled:h,error:j?.field==="env"?j.message:null,onChange:a=>k({env:a})}),("http"===y.transport||j?.field==="headers")&&(0,A.jsx)(o8,{id:x("headers"),label:s("请求头"),rows:y.headers,disabled:h,error:j?.field==="headers"?j.message:null,onChange:a=>k({headers:a})}),c&&(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:s("本项目的完整定义会整体替换同名全局配置。")})]}),(0,A.jsxs)("label",{className:"flex min-h-8 cursor-pointer items-center gap-2 text-sm",children:[(0,A.jsx)("input",{type:"checkbox",checked:y.enabled,disabled:h,onChange:a=>k({enabled:a.target.checked}),className:"size-4 shrink-0 accent-primary"}),s("已启用")]}),(0,A.jsxs)(cs.Nt,{open:v||j?.field==="advanced",onOpenChange:w,children:[(0,A.jsxs)(cs.R6,{type:"button",className:"group flex min-h-8 cursor-pointer items-center gap-2 rounded-lg px-2 text-sm font-medium outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[(0,A.jsx)(cr.A,{"aria-hidden":"true",className:"size-4 transition-transform group-data-panel-open:rotate-180"}),s("高级设置")]}),(0,A.jsxs)(cs.Ke,{className:"space-y-3 pt-3",children:["inherit"!==y.transport&&H("description","服务说明(可选)"),(0,A.jsx)(o4,{id:x("exposure"),label:s("工具使用方式"),value:y.exposure,disabled:h,options:[{value:"",label:s("沿用默认")},{value:"codemode",label:s("通过脚本调用")},{value:"deferred",label:s("按需发现")},{value:"direct",label:s("直接使用")},{value:"hidden",label:s("隐藏")},...["","codemode","deferred","direct","hidden"].includes(y.exposure)?[]:[{value:y.exposure,label:y.exposure}]],onChange:a=>k({exposure:a})}),(0,A.jsx)("label",{htmlFor:x("advanced"),className:"block text-sm font-medium",children:s("其他配置(JSON)")}),(0,A.jsx)(iE.T,{id:x("advanced"),onFocus:()=>w(!0),value:y.advanced,disabled:h,className:"min-h-40 font-mono",spellCheck:!1,"aria-invalid":j?.field==="advanced","aria-describedby":j?.field==="advanced"?x("advanced-error"):void 0,onChange:a=>k({advanced:a.target.value})}),(0,A.jsx)(o6,{id:x("advanced-error"),message:j?.field==="advanced"?j.message:null})]})]})]}):"json"===a.kind?(0,A.jsxs)("div",{className:"space-y-3",children:[G("json","配置 JSON",(0,A.jsx)(iE.T,{id:x("json"),value:a.text,disabled:h,"aria-invalid":j?.field==="json","aria-describedby":j?.field==="json"?x("json-error"):void 0,spellCheck:!1,className:"min-h-48 font-mono",placeholder:'{ "mcpServers": { "docs": { "url": "https://example.com/mcp" } } }',onChange:a=>l(a.target.value)})),(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:s("仅接受包含 mcpServers 的标准 JSON。")}),(0,A.jsx)(U.$,{type:"button",variant:"outline",onClick:m,disabled:h||!a.text.trim(),children:s("解析预览")}),a.preview&&(0,A.jsxs)("section",{"aria-label":s("待保存服务"),className:"space-y-3",children:[(0,A.jsx)("ul",{className:"divide-y border-y",children:Object.entries(a.preview).map(([a,b])=>(0,A.jsxs)("li",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 text-sm",children:[(0,A.jsx)("span",{className:"min-w-0 break-all font-medium",children:a}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:s(oZ(b)?"继承全局连接":"url"in b?"HTTP 地址":"本地程序")}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:s(Object.hasOwn(f,a)?"替换已有配置":Object.hasOwn(g,a)?"覆盖全局(仅本项目)":"新增")}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:s(!1===b.enabled?"已停用":"已启用")})]},a))}),z.length>0&&(0,A.jsxs)("label",{className:"flex min-h-8 cursor-pointer items-start gap-2 text-sm",children:[(0,A.jsx)("input",{type:"checkbox",checked:a.overwrite,disabled:h,className:"mt-1 size-4 shrink-0 accent-primary",onChange:a=>n(a.target.checked)}),(0,A.jsx)("span",{children:s("允许替换以上同名已有配置")})]})]})]}):null,(0,A.jsx)("div",{className:"mt-3",children:(0,A.jsx)(o6,{message:j?.field==="save"?j.message:null})})]}),(0,A.jsxs)("footer",{className:"flex shrink-0 flex-wrap justify-end gap-2 border-t bg-background px-4 py-3 sm:px-6",children:[(0,A.jsx)(U.$,{type:"button",variant:"outline",disabled:h,onClick:p,children:s("取消")}),y&&(0,A.jsx)(U.$,{type:"button",variant:"outline",disabled:h||!y.enabled||!1===d,onClick:()=>o(!0),children:s("保存并测试")}),(0,A.jsx)(U.$,{type:"submit",disabled:h||"json"===a.kind&&(!a.preview||z.length>0&&!a.overwrite),children:s(e?.loading?"正在测试连接…":i?"保存中…":"保存")})]})]})}function pc({pending:a,onAdd:b,onImport:c}){let d=o2();return(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 min-w-0 flex-1 overflow-y-auto px-4 py-6",children:(0,A.jsx)("div",{className:"grid min-h-full grid-rows-[1fr_auto_2fr]",children:(0,A.jsxs)("div",{className:"row-start-2 flex flex-col items-center gap-6 text-center",children:[(0,A.jsxs)("div",{"aria-hidden":"true",className:"relative h-28 w-60 shrink-0 text-muted-foreground",children:[(0,A.jsxs)("svg",{viewBox:"0 0 240 112",fill:"none",className:"absolute inset-0 size-full text-muted-foreground/40",children:[(0,A.jsx)("path",{d:"M44 76H64Q76 76 76 64V60Q76 56 92 56M148 56H164Q180 56 180 44Q180 40 196 40M120 12V28",stroke:"currentColor"}),(0,A.jsx)("circle",{cx:"120",cy:"8",r:"3",className:"fill-background stroke-current"}),(0,A.jsx)("circle",{cx:"64",cy:"76",r:"2",className:"fill-muted-foreground"}),(0,A.jsx)("circle",{cx:"180",cy:"44",r:"2",className:"fill-muted-foreground"})]}),(0,A.jsx)("div",{className:"absolute top-14 left-1 flex size-10 items-center justify-center rounded-xl border bg-muted/50",children:(0,A.jsx)(T,{className:"size-4"})}),(0,A.jsx)("div",{className:"absolute top-7 left-[92px] flex size-14 items-center justify-center rounded-xl border bg-background text-foreground",children:(0,A.jsx)(ca,{className:"size-6"})}),(0,A.jsx)("div",{className:"absolute top-5 right-1 flex size-10 items-center justify-center rounded-xl border bg-muted/50",children:(0,A.jsx)(cl,{className:"size-4"})})]}),(0,A.jsx)("h3",{className:"text-lg font-semibold",children:d("添加第一个 MCP 服务")}),(0,A.jsxs)("div",{className:"flex flex-wrap justify-center gap-2",children:[(0,A.jsxs)(U.$,{disabled:a,onClick:b,children:[(0,A.jsx)(am,{"aria-hidden":"true"}),d("添加服务")]}),(0,A.jsx)(U.$,{variant:"outline",disabled:a,onClick:c,children:d("导入 JSON")})]})]})})})}function pd({projects:a,focusedCwd:b,onBeforeLeaveChange:c}){let{clientId:d}=(0,bR.gM)(),e=function(a){let b=o2(),c=(0,B.useMemo)(()=>({getMcp:(b,c)=>bX(a,"/api/mcp-settings/get",{cwd:b},oT,{signal:c}),replaceMcp:(b,c)=>bX(a,"/api/mcp-settings/replace",b,oV,{signal:c}),deleteMcp:(b,c,d)=>bX(a,"/api/mcp-settings/del",{cwd:b,name:c},oV,{signal:d}),checkMcp:(b,c,d)=>bX(a,"/api/mcp-check/get",{cwd:b,name:c},oU,{signal:d})}),[a]),{confirm:d,dialog:e}=kg(),[f,g]=(0,B.useState)(null),[h,i]=(0,B.useState)(null),j=h?.data??null,k=h?h.cwd:f,[l,m]=(0,B.useState)(null),[n,o]=(0,B.useState)(!0),[p,q]=(0,B.useState)(!1),[r,s]=(0,B.useState)(null),[t,u]=(0,B.useState)(null),[v,w]=(0,B.useState)(null),[x,y]=(0,B.useState)(null),z=(0,B.useRef)(null),A=(0,B.useRef)(0),C=(0,B.useRef)(0),D=(0,B.useRef)(d),F=(0,B.useRef)(b),G=null!==h&&h.cwd===f&&!n&&!r,H=G&&(l?.kind==="manual"&&JSON.stringify(l.draft)!==l.initial||l?.kind==="json"&&!!l.text),I=(0,B.useCallback)(()=>{m(null),u(null)},[]),J=(0,B.useCallback)(async()=>!(p||x?.loading)&&(!H||await D.current({title:F.current("放弃未保存的修改?"),description:F.current("当前修改尚未保存。放弃后将保留已保存的配置。"),confirmLabel:F.current("放弃修改")})),[H,p,x?.loading]),K=(0,B.useCallback)(async(a,b,d=!1)=>{o(!0),s(null);try{let e=await c.getMcp(f,a);if(a.aborted||A.current!==b)return!1;return i({cwd:f,data:e}),d&&m(null),!0}catch(c){return a.aborted||A.current!==b||(console.warn("[Pi Desk][MCP] 读取配置失败",{cwd:f,message:o3(c)}),s(o3(c))),!1}finally{a.aborted||A.current!==b||o(!1)}},[c,f]),L=async a=>{await J()&&(I(),w(null),a())},M=async a=>{a!==f&&await J()&&(z.current?.abort(),u(null),w(null),y(null),s(null),o(!0),g(a))},N=(a,b)=>{let c=o$(a,b);u(null),w(null),y(null),m({kind:"manual",draft:c,initial:JSON.stringify(c)})},O=async(a,b)=>{let c=z.current?.signal;if(!c||!G||p||x?.loading)return!1;let d=A.current;q(!0),u(null),w(null);try{if(await a(c),c.aborted||A.current!==d)return!1;return b(),y(null),w("已保存。新会话使用新配置;已有会话需重载 Pi 配置。"),await K(c,d)}catch(a){return c.aborted||A.current!==d||u({field:a instanceof o_?a.field:"save",message:o3(a)}),!1}finally{c.aborted||A.current!==d||q(!1)}},P=async(a=!1)=>{if(!(!l||!j||!G||p||x?.loading)&&(!a||"manual"===l.kind&&l.draft.enabled&&!1!==j.projectTrusted))try{let b="manual"===l.kind?function(a,b){let c,d=a.name.trim();if(!d||d.length>128)throw new o_("name","服务名称需要 1–128 个字符。");try{c=oR.parse(JSON.parse(a.advanced))}catch{throw new o_("advanced","高级配置需要是 JSON 对象。")}if(oW.some(a=>a in c))throw new o_("advanced","连接、说明、启用和曝光字段请在上方表单中填写。");if("inherit"===a.transport&&Object.keys(c).some(a=>"toolExposure"!==a))throw new o_("advanced","继承连接只允许启用、曝光和 toolExposure 设置。");let e={...c,enabled:a.enabled};if(a.exposure&&(e.exposure=a.exposure),"inherit"!==a.transport){for(let d of(a.description&&(e.description=a.description),["env","headers"]))if(a[d].length>0||oX(b?.[d])){if(d in c)throw new o_("advanced","环境变量和请求头不能在表单与 JSON 中重复配置。");e[d]=function(a,b){let c=[],d=new Set;for(let e of a){if(!e.key.trim()&&!e.value)continue;if(!e.key.trim())throw new o_(b,"请填写名称,或删除空白行。");let a=e.key.trim(),f="headers"===b?a.toLowerCase():a;if(d.has(f))throw new o_(b,"名称不能重复。");d.add(f),c.push([a,e.value])}return Object.fromEntries(c)}(a[d],d)}}if("stdio"===a.transport){if(!a.command.trim())throw new o_("command","请输入启动程序。");e.command=a.command.trim(),e.args=Array.isArray(b?.args)&&b.args.join("\n")===a.args?b.args:a.args?a.args.split(/\r?\n/):[],(b?.type!==void 0||!b||"url"in b)&&(e.type="stdio")}else if("http"===a.transport){try{let b=new URL(a.url.trim());if(!["https:","http:"].includes(b.protocol))throw Error()}catch{throw new o_("url","请输入有效的 HTTP 或 HTTPS 地址。")}e.url=a.url.trim(),(b?.type!==void 0||!b||"command"in b)&&(e.type="http")}return{[d]:e}}(l.draft,l.draft.originalName?j.local[l.draft.originalName]:void 0):l.preview;if(!b)return;let d=Object.keys(b).filter(a=>Object.hasOwn(j.local,a));if("json"===l.kind&&d.length&&!l.overwrite)throw new o_("json","请明确勾选替换已有配置。");if("manual"===l.kind&&d.some(a=>a!==l.draft.originalName))throw new o_("name","该名称已存在,请编辑已有服务或使用其他名称。");if(await O(a=>c.replaceMcp({cwd:f,servers:b},a),()=>{if("json"===l.kind)m(null);else{let a=l.draft.name.trim(),c=o$(a,b[a]);m({kind:"manual",draft:c,initial:JSON.stringify(c)})}})&&a&&"manual"===l.kind){let a=await R(l.draft.name.trim());z.current?.signal.aborted||w(a?"已保存,连接测试通过。":"已保存,连接测试失败。")}}catch(a){u({field:a instanceof o_?a.field:"save",message:o3(a)})}},Q=async a=>{if(!j||!G||p||!Object.hasOwn(j.local,a))return;let b=null!==f&&Object.hasOwn(j.inherited,a);await D.current({title:`${F.current(b?"恢复全局配置":"删除服务")} \xb7 ${a}`,description:F.current(b?"删除本项目配置后,将恢复使用同名全局配置。":"此范围内的服务配置将被删除。"),confirmLabel:F.current(b?"恢复全局配置":"删除服务")})&&await O(b=>c.deleteMcp(f,a,b),()=>m(null))},R=async a=>{let b=z.current?.signal;if(!b||!j||!1===j.projectTrusted||x?.loading)return!1;let d=++C.current;y({name:a,loading:!0,output:null,error:null});try{let e=await c.checkMcp(f,a,b);return b.aborted||C.current!==d||y({name:a,loading:!1,output:e.output.slice(0,32768),error:null}),!0}catch(c){return b.aborted||C.current!==d||y({name:a,loading:!1,output:null,error:o3(c)}),!1}},S=j?[...new Set([...Object.keys(j.inherited),...Object.keys(j.local)])].map(a=>{let b=j.local[a],c=j.inherited[a],d=!!(b&&c&&oZ(b));return{name:a,config:d?{...c,...b}:b??c,local:b??null,source:null===k?"全局":b?d?"项目配置 \xb7 继承全局连接":"项目配置":"继承全局"}}):[];return{cwd:f,displayCwd:k,ready:G,mcp:j,editor:l,setEditor:m,loading:n,pending:p,loadError:r,error:t,notice:v,check:x,rows:S,dirty:H,dialog:e,retry:()=>{z.current&&K(z.current.signal,A.current,h?.cwd!==f)},navigate:L,setCwd:M,startManual:N,startInherited:(a,b)=>{N(a,{enabled:!1!==b.enabled})},updateDraft:a=>{m(b=>b?.kind==="manual"?{...b,draft:{...b.draft,...a}}:b),u(null),w(null),y(null)},updateJson:a=>{m({kind:"json",text:a,preview:null,overwrite:!1}),u(null)},previewJson:()=>{if(l?.kind==="json"&&j)try{let b=function(a){let b;try{b=JSON.parse(a)}catch{throw Error("请输入有效的 JSON。")}let c=E.Ik({mcpServers:oS}).strict().safeParse(b);if(!c.success)throw Error("仅接受包含 mcpServers 的标准配置,不允许其他根级字段。");if(0===Object.keys(c.data.mcpServers).length)throw Error("配置中至少需要一个服务。");return c.data.mcpServers}(l.text);var a=j.inherited;for(let[c,d]of Object.entries(b)){if(!c.trim()||c!==c.trim())throw new o_("json","服务名称不能为空或带有首尾空格。");if(oZ(d)){if(null===f||!Object.hasOwn(a,c)||Object.keys(d).some(a=>!["enabled","exposure","toolExposure"].includes(a)))throw new o_("json",`${c}:继承配置需要同名全局服务,且只允许启用和曝光设置。`)}else if("sse"===d.type)throw new o_("json",`${c}:不支持 SSE,请使用 HTTP 连接。`);else if("string"!=typeof d.command&&"string"!=typeof d.url)throw new o_("json",`${c}:请提供启动程序或服务地址。`)}m({...l,preview:b,overwrite:!1}),u(null)}catch(a){u({field:"json",message:o3(a)})}},saveEditor:P,remove:Q,dismissCheck:()=>{y(null)},beforeLeave:J}}(d),f=o2(),g=(0,B.useId)(),h=(0,B.useMemo)(()=>{let c=new Map;for(let b of a){let a=b.cwd.replaceAll("\\","/").replace(/\/+$/,""),d=/^[a-zA-Z]:\//.test(a)||a.startsWith("//")?a.toLowerCase():a;c.has(d)||c.set(d,b)}return[...c.values()].sort((a,c)=>Number(c.cwd===b)-Number(a.cwd===b))},[a,b]),i=null===e.displayCwd?f("全局"):`${h.find(a=>a.cwd===e.displayCwd)?.projectName??f("当前项目")} \xb7 ${e.displayCwd}`,j=!!(e.editor&&e.mcp),k=e.pending||!!e.check?.loading,l=k||!e.ready,m=e.editor?.kind==="manual"?e.editor.draft.originalName:null,n=()=>{e.navigate(()=>e.startManual(null))},o=()=>{e.navigate(()=>e.setEditor({kind:"json",text:"",preview:null,overwrite:!1}))};return(0,A.jsxs)("section",{"aria-label":"MCP",className:"@container/mcp flex h-full min-h-0 min-w-0 flex-col",children:[e.dialog,(0,A.jsxs)("header",{className:"grid shrink-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-b p-4 @min-[40rem]/mcp:grid-cols-[auto_minmax(0,1fr)_auto]",children:[(0,A.jsxs)("h2",{className:"flex items-center gap-2 text-xl font-semibold",children:["MCP",(0,A.jsx)("span",{className:"inline-flex size-4",children:e.loading&&(0,A.jsx)(R.A,{role:"status","aria-label":f("正在读取配置…"),className:"size-4 animate-spin text-muted-foreground"})})]}),(0,A.jsxs)("div",{className:"col-start-2 flex flex-wrap justify-end gap-2 @min-[40rem]/mcp:col-start-3 @min-[40rem]/mcp:self-end",children:[(0,A.jsxs)(U.$,{disabled:l,onClick:n,children:[(0,A.jsx)(am,{"aria-hidden":"true"}),f("添加服务")]}),(0,A.jsx)(U.$,{variant:"outline",disabled:l,onClick:o,children:f("导入 JSON")})]}),(0,A.jsx)("div",{className:"col-span-2 row-start-2 w-full @min-[40rem]/mcp:col-span-1 @min-[40rem]/mcp:col-start-2 @min-[40rem]/mcp:row-start-1 @min-[40rem]/mcp:max-w-80 @min-[40rem]/mcp:justify-self-end @min-[40rem]/mcp:[&_[data-slot=select-trigger]]:mb-0",children:(0,A.jsx)(o4,{id:`${g}-scope`,label:f("配置范围"),value:e.cwd??"",disabled:k,options:[{value:"",label:f("全局")},...h.map(a=>({value:a.cwd,label:`${a.projectName}${a.cwd===b?` \xb7 ${f("当前项目")}`:""}`}))],onChange:a=>{e.setCwd(a||null)}})})]}),e.notice&&!e.check&&(0,A.jsx)("p",{role:"status",className:"shrink-0 break-words border-b px-4 py-2 text-sm",children:f(e.notice)}),e.mcp?.projectTrusted===!1&&(0,A.jsx)("p",{className:"shrink-0 px-4 pt-3 text-sm text-muted-foreground",children:f("本项目尚未受信任,不能执行检查;仍可编辑和保存配置。")}),e.mcp&&e.mcp.diagnostics.length>0&&(0,A.jsx)("div",{className:"max-h-32 shrink-0 space-y-2 overflow-y-auto px-4 pt-3",children:e.mcp.diagnostics.map((a,b)=>(0,A.jsx)(o6,{message:`${a.name?`${a.name}:`:""}${a.message}`},b))}),e.loadError&&(0,A.jsxs)("div",{className:"space-y-3 p-4",children:[(0,A.jsx)(o6,{message:e.loadError}),(0,A.jsx)(U.$,{variant:"outline",onClick:e.retry,disabled:e.loading,children:f("重试")})]}),e.loading&&!e.mcp?(0,A.jsx)("p",{role:"status",className:"p-4 text-sm text-muted-foreground",children:f("正在读取配置…")}):e.mcp?(0,A.jsxs)("div",{"aria-busy":e.loading,className:"flex min-h-0 min-w-0 flex-1",children:[e.editor?.kind!=="json"&&e.rows.length>0&&(0,A.jsxs)("div",{className:(0,W.cn)("pi-desk-chat-scrollbar min-h-0 min-w-0 overflow-y-auto",j?"hidden @min-[48rem]/mcp:block @min-[48rem]/mcp:w-56 @min-[48rem]/mcp:shrink-0 @min-[48rem]/mcp:border-r":"flex-1"),children:[!j&&e.error&&(0,A.jsx)("div",{className:"p-4",children:(0,A.jsx)(o6,{message:e.error.message})}),(0,A.jsx)(o7,{rows:e.rows,selectedName:m,pending:l,onSelect:a=>{m!==a.name&&e.navigate(()=>a.local?e.startManual(a.name,a.local):e.startInherited(a.name,a.config))}})]}),e.editor?(0,A.jsx)(pb,{editor:e.editor,scopeLabel:i,project:null!==e.displayCwd,projectTrusted:e.mcp.projectTrusted,local:e.mcp.local,inherited:e.mcp.inherited,pending:l,saving:e.pending,error:e.error,check:e.check?.name===m?e.check:null,onDraft:e.updateDraft,onJson:e.updateJson,onPreview:e.previewJson,onOverwrite:a=>e.setEditor(b=>b?.kind==="json"?{...b,overwrite:a}:b),onSave:a=>void e.saveEditor(a),onCancel:()=>void e.navigate(()=>e.setEditor(null)),onRemove:a=>void e.remove(a),onDismissCheck:e.dismissCheck},"manual"===e.editor.kind?m??"new":"json"):0===e.rows.length?(0,A.jsx)(pc,{pending:l,onAdd:n,onImport:o}):null]}):null]})}var pe=c(3035),pf=c(4543),pg=c(59776);let ph=E.Yj().trim().min(1).max(200),pi=E.Yj().trim().min(1).max(100).nullable(),pj=E.Yj().trim().min(1).max(100).nullable(),pk=E.Yj().trim().min(1).max(200),pl=E.Ik({label:E.Yj().trim().min(1).max(64),value:E.Yj().trim().min(1).max(500)}).strict(),pm=E.Yj().trim().min(1).max(300).nullable(),pn=E.k5(["running","completed","failed","stopped","interrupted"]),po=E.Ik({taskId:ph,taskKind:pi,taskType:pj,title:pk,info:E.YO(pl).max(12),status:pn,activity:pm,startedAt:k3.k,endedAt:k3.k.nullable()}).strict().superRefine((a,b)=>{"running"===a.status&&null!==a.endedAt&&b.addIssue({code:"custom",message:"running task requires endedAt=null",path:["endedAt"]}),"running"!==a.status&&null===a.endedAt&&b.addIssue({code:"custom",message:"terminal task requires endedAt",path:["endedAt"]})}),pp=E.Ik({tasks:E.YO(po)}).strict().superRefine((a,b)=>{let c=new Set;for(let[d,e]of a.tasks.entries())c.has(e.taskId)&&b.addIssue({code:"custom",message:"taskId values must be unique",path:["tasks",d,"taskId"]}),c.add(e.taskId)}),pq=E.Ik({kind:E.eu("text"),text:E.Yj(),truncated:E.zM()}).strict(),pr=pf.RX.extend({kind:E.eu("conversation"),truncated:E.zM()}).strict(),ps=E.KC([E.ch(),pq,pr]),pt=E.Ik({taskId:ph,canInterrupt:E.zM(),body:ps}).strict(),pu=pg.mv,pv=E.KC([E.Ik({type:E.eu("snapshot"),snapshot:pt}).strict(),E.Ik({type:E.eu("text_append"),text:E.Yj().min(1)}).strict(),E.Ik({type:E.eu("conversation_event"),event:pu}).strict(),E.Ik({type:E.eu("unavailable")}).strict()]);E.Ik({source:pe.R,taskId:ph,entryId:jv.Rv}).strict().extend({imageIndex:E.ai().int().nonnegative()}).strict();let pw=E.Ik({source:pe.R,taskId:ph.nullable()}).strict(),px=E.Ik({snapshot:pt.nullable()}).strict(),py=E.Ik({source:pe.R,taskId:ph}).strict(),pz=E.Ik({}).strict(),pA=E.Ik({source:pe.R,taskId:ph,event:pv}).strict(),pB=Object.freeze({detailWatch:(0,F.Vc)({path:"task-center/detail-watch",inputSchema:pw,outputSchema:px}),interrupt:(0,F.Vc)({path:"task-center/interrupt",inputSchema:py,outputSchema:pz}),detailEvent:(0,F._G)({path:"task-center/detail-event",bodySchema:pA})}),pC=(0,S.A)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var pD=c(49028);let pE=(0,S.A)("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]),pF=(0,S.A)("rotate-ccw",[["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"}]]),pG=(0,S.A)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),pH={damping:.7,stiffness:.05,mass:1.25},pI=1e3/60,pJ=!1;globalThis.document?.addEventListener("mousedown",()=>{pJ=!0}),globalThis.document?.addEventListener("mouseup",()=>{pJ=!1}),globalThis.document?.addEventListener("click",()=>{pJ=!1});let pK=(a={})=>{let[b,c]=(0,B.useState)(!1),[d,e]=(0,B.useState)(!1!==a.initial),[f,g]=(0,B.useState)(!1),h=(0,B.useRef)(null);h.current=a;let i=(0,B.useCallback)(()=>{if(!pJ)return!1;let a=window.getSelection();if(!a||!a.rangeCount)return!1;let b=a.getRangeAt(0);return b.commonAncestorContainer.contains(q.current)||q.current?.contains(b.commonAncestorContainer)},[]),j=(0,B.useCallback)(a=>{l.isAtBottom=a,e(a)},[]),k=(0,B.useCallback)(a=>{l.escapedFromLock=a,c(a)},[]),l=(0,B.useMemo)(()=>{let c;return{escapedFromLock:b,isAtBottom:d,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return q.current?.scrollTop??0},set scrollTop(scrollTop){if(q.current){let{scrollBehavior:a}=getComputedStyle(q.current);"auto"!==a&&(q.current.style.scrollBehavior="auto"),q.current.scrollTop=scrollTop,l.ignoreScrollToTop=q.current.scrollTop,"auto"!==a&&(q.current.style.scrollBehavior=a)}},get targetScrollTop(){if(!q.current||!r.current)return 0;return q.current.scrollHeight-1-q.current.clientHeight},get calculatedTargetScrollTop(){if(!q.current||!r.current)return 0;let{targetScrollTop:b}=this;if(!a.targetScrollTop)return b;if(c?.targetScrollTop===b)return c.calculatedScrollTop;let d=Math.max(Math.min(a.targetScrollTop(b,{scrollElement:q.current,contentElement:r.current}),b),0);return c={targetScrollTop:b,calculatedScrollTop:d},requestAnimationFrame(()=>{c=void 0}),d},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),m=(0,B.useCallback)((a={})=>{let b;"string"==typeof a&&(a={animation:a}),a.preserveScrollPosition||j(!0);let c=Date.now()+(Number(a.wait)||0),d=pN(h.current,a.animation),{ignoreEscapes:e=!1}=a,f=l.calculatedTargetScrollTop;a.duration instanceof Promise?a.duration.finally(()=>{b=Date.now()}):b=c+(a.duration??0);let g=async()=>{let a=new Promise(requestAnimationFrame).then(()=>{if(!l.isAtBottom)return l.animation=void 0,!1;let{scrollTop:j}=l,k=performance.now(),n=(k-(l.lastTick??k))/pI;if(l.animation||(l.animation={behavior:d,promise:a,ignoreEscapes:e}),l.animation.behavior===d&&(l.lastTick=k),i()||c>Date.now())return g();if(j<Math.min(f,l.calculatedTargetScrollTop)){if(l.animation?.behavior===d){if("instant"===d)return l.scrollTop=l.calculatedTargetScrollTop,g();l.velocity=(d.damping*l.velocity+d.stiffness*l.scrollDifference)/d.mass,l.accumulated+=l.velocity*n,l.scrollTop+=l.accumulated,l.scrollTop!==j&&(l.accumulated=0)}return g()}return b>Date.now()?(f=l.calculatedTargetScrollTop,g()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop)?m({animation:pN(h.current,h.current.resize),ignoreEscapes:e,duration:Math.max(0,b-Date.now())||void 0}):l.isAtBottom});return a.then(a=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),a))};return(!0!==a.wait&&(l.animation=void 0),l.animation?.behavior===d)?l.animation.promise:g()},[j,i,l]),n=(0,B.useCallback)(()=>{k(!0),j(!1)},[k,j]),o=(0,B.useCallback)(({target:a})=>{if(a!==q.current)return;let{scrollTop:b,ignoreScrollToTop:c}=l,{lastScrollTop:d=b}=l;l.lastScrollTop=b,l.ignoreScrollToTop=void 0,c&&c>b&&(d=c),g(l.isNearBottom),setTimeout(()=>{if(l.resizeDifference||b===c)return;if(i()){k(!0),j(!1);return}let a=b>d,e=b<d;if(l.animation?.ignoreEscapes){l.scrollTop=d;return}e&&(k(!0),j(!1)),a&&k(!1),!l.escapedFromLock&&l.isNearBottom&&j(!0)},1)},[k,j,i,l]),p=(0,B.useCallback)(({target:a,deltaY:b})=>{let c=a;for(;!["scroll","auto"].includes(getComputedStyle(c).overflow);){if(!c.parentElement)return;c=c.parentElement}c===q.current&&b<0&&q.current.scrollHeight>q.current.clientHeight&&!l.animation?.ignoreEscapes&&(k(!0),j(!1))},[k,j,l]),q=pL(a=>{q.current?.removeEventListener("scroll",o),q.current?.removeEventListener("wheel",p),a?.addEventListener("scroll",o,{passive:!0}),a?.addEventListener("wheel",p,{passive:!0})},[]),r=pL(a=>{let b;l.resizeObserver?.disconnect(),l.resizeObserver=void 0,a&&(l.resizeObserver=new ResizeObserver(([a])=>{let{height:c}=a.contentRect,d=c-(b??c);if(l.resizeDifference=d,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),g(l.isNearBottom),d>=0){let a=pN(h.current,b?h.current.resize:h.current.initial);m({animation:a,wait:!0,preserveScrollPosition:!0,duration:"instant"===a?void 0:350})}else l.isNearBottom&&(k(!1),j(!0));b=c,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===d&&(l.resizeDifference=0)},1)})}),l.resizeObserver?.observe(a))},[]);return{contentRef:r,scrollRef:q,scrollToBottom:m,stopScroll:n,isAtBottom:d||f,isNearBottom:f,escapedFromLock:b,state:l}};function pL(a,b){let c=(0,B.useCallback)(b=>(c.current=b,a(b)),b);return c}let pM=new Map;function pN(...a){let b={...pH},c=!1;for(let d of a){if("instant"===d){c=!0;continue}"object"==typeof d&&(c=!1,b.damping=d.damping??b.damping,b.stiffness=d.stiffness??b.stiffness,b.mass=d.mass??b.mass)}let d=JSON.stringify(b);return pM.has(d)||pM.set(d,Object.freeze(b)),c?"instant":pM.get(d)}let pO=(0,B.createContext)(null),pP="u">typeof window?B.useLayoutEffect:B.useEffect;function pQ({instance:a,children:b,resize:c,initial:d,mass:e,damping:f,stiffness:g,targetScrollTop:h,contextRef:i,...j}){let k=(0,B.useRef)(null),l=pK({mass:e,damping:f,stiffness:g,resize:c,initial:d,targetScrollTop:B.useCallback((a,b)=>{let c=t?.targetScrollTop??h;return c?.(a,b)??a},[h])}),{scrollRef:m,contentRef:n,scrollToBottom:o,stopScroll:p,isAtBottom:q,escapedFromLock:r,state:s}=a??l,t=(0,B.useMemo)(()=>({scrollToBottom:o,stopScroll:p,scrollRef:m,isAtBottom:q,escapedFromLock:r,contentRef:n,state:s,get targetScrollTop(){return k.current},set targetScrollTop(targetScrollTop){k.current=targetScrollTop}}),[o,q,n,m,p,r,s]);return(0,B.useImperativeHandle)(i,()=>t,[t]),pP(()=>{m.current&&"visible"===getComputedStyle(m.current).overflow&&(m.current.style.overflow="auto")},[]),B.createElement(pO.Provider,{value:t},B.createElement("div",{...j},"function"==typeof b?b(t):b))}function pR(){let a=(0,B.useContext)(pO);if(!a)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return a}(pQ||(pQ={})).Content=function({children:a,scrollClassName:b,...c}){let d=pR();return B.createElement("div",{ref:d.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:b},B.createElement("div",{...c,ref:d.contentRef},"function"==typeof a?a(d):a))};let pS=({className:a,...b})=>(0,A.jsx)(pQ,{className:(0,W.cn)("relative flex-1 overflow-y-hidden",a),initial:"smooth",resize:"smooth",role:"log",...b}),pT=({className:a,...b})=>(0,A.jsx)(pQ.Content,{className:(0,W.cn)("flex flex-col gap-8 p-4",a),...b});var pU=c(81266);let pV=B.createContext(void 0);function pW(a){let b=B.useContext(pV);if(void 0===b&&!a)throw Error((0,aq.A)(50));return b}var pX=c(69434),pY=c(21574),pZ=c(56278);function p$(a,b,c,d){return{left:a,top:b,right:c,bottom:d,x:a,y:b,width:c-a,height:d-b}}function p_(a){let b,c=[],d=1/0,e=1/0,f=-1/0,g=-1/0;for(let h of Array.from(a).sort((a,b)=>a.top-b.top)){if(d=Math.min(d,h.left),e=Math.min(e,h.top),f=Math.max(f,h.right),g=Math.max(g,h.bottom),!b||h.top-b.top>b.height/2)c.push({left:h.left,top:h.top,right:h.right,bottom:h.bottom,width:h.width,height:h.height});else{let a=c[c.length-1];a.left=Math.min(a.left,h.left),a.right=Math.max(a.right,h.right),a.bottom=Math.max(a.bottom,h.bottom),a.width=a.right-a.left,a.height=a.bottom-a.top}b=h}return{lines:c,fallback:p$(d,e,f,g)}}function p0(a,b,c){return a.findIndex(a=>b>a.left-2&&b<a.right+2&&c>a.top-2&&c<a.bottom+2)}function p1(a){return p$(a.left,a.top,a.right,a.bottom)}function p2(a,b,c,d){let e=function(a,b,c){let{lines:d}=p_(a.getClientRects());if(d.length<2)return;let e=p0(d,b,c);return{x:b,y:c,lineIndex:-1===e?void 0:e,element:a}}(b,c,d);return a.current=e,e}let p3={...pY.ol,instantType:a=>a.instantType,adaptiveOrigin:a=>a.adaptiveOrigin,closeDelay:a=>a.closeDelay};class p4 extends pX.H{constructor(a,b,c){const d=new pZ.Z;super(function(a,b,c,d=!1){let e={...(0,pY.rJ)(),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...a};return e.floatingRootContext=(0,pY.OB)(b,c,d),e}(a,d,b,c),function(a){return{popupRef:B.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:a,inlineRectCoordsRef:{current:void 0}}}(d),p3)}setOpen=(a,b)=>{let{inlineRectCoordsRef:c}=this.context;(0,aQ.DU)(this,a,b,{onBeforeDispatch(){let d=b.event;a&&b.reason===aT.N7&&b.trigger&&"clientX"in d&&"clientY"in d&&c.current?.element!==b.trigger&&p2(c,b.trigger,d.clientX,d.clientY)}})}}function p5(a){let{open:b,defaultOpen:c=!1,onOpenChange:d,onOpenChangeComplete:e,actionsRef:f,handle:g,triggerId:h,defaultTriggerId:i=null,children:j}=a,k=(0,aQ.xp)((a,d)=>new p4({open:c,openProp:b,activeTriggerId:i,triggerIdProp:h},a,d));k.useControlledProp("openProp",b),k.useControlledProp("triggerIdProp",h),k.useContextCallback("onOpenChange",d),k.useContextCallback("onOpenChangeComplete",e);let l=k.useState("open"),m=k.useState("activeTriggerId"),n=k.useState("mounted"),o=k.useState("payload");(0,aQ.tr)(k,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:p}=(0,aQ.l$)(l,k,()=>{k.context.inlineRectCoordsRef.current=void 0});(0,av.g)(()=>{l&&null==m&&k.set("payload",void 0)},[k,m,l]),B.useImperativeHandle(f,()=>({unmount:p,close:()=>k.setOpen(!1,(0,bf.d)(aT.zJ))}),[p,k]);let q=l||n;return(0,A.jsxs)(pV.Provider,{value:k,children:[g&&(0,A.jsx)(aQ.Ae,{handle:g,store:k}),q&&(0,A.jsx)(p6,{store:k}),"function"==typeof j?j({payload:o}):j]})}function p6({store:a}){let b=a.useState("floatingRootContext"),c=(0,pU.s)(b);return(0,aQ.i6)(a,{activeTriggerProps:c.reference,inactiveTriggerProps:c.trigger,popupProps:c.floating}),null}let p7=(0,at.G1)(function(a){return pW(!0)?(0,A.jsx)(p5,{...a}):(0,A.jsx)(ax.P6,{children:(0,A.jsx)(p5,{...a})})}),p8=(0,at.nk)(function(a,b){let{render:c,className:d,delay:e,closeDelay:f,id:g,payload:h,handle:i,style:j,...k}=a,l=pW(!0),m=(0,aP.f)(i)??l;if(!m)throw Error((0,aq.A)(89));let n=(0,aS.e)(g),o=m.useState("isTriggerActive",n),p=m.useState("isOpenedByTrigger",n),q=m.useState("floatingRootContext"),r=m.context.inlineRectCoordsRef,s=B.useRef(null),t=e??600,u=f??300,{registerTrigger:v,isMountedByThisTrigger:w}=(0,aQ.L_)(n,s,m,{payload:h,closeDelay:u}),x=(0,ay.j)(q,{mouseOnly:!0,move:!1,handleClose:(0,az.i)(),delay:()=>({open:t,close:u}),triggerElementRef:s,isActiveTrigger:o,isClosing:()=>"ending"===m.select("transitionStatus")}),y=(0,aB.i)(q,{delay:t}),z=m.useState("triggerProps",w),A=function(a,b){function c(c){b||p2(a,c.currentTarget,c.clientX,c.clientY)}return{onFocus(){a.current=void 0},onMouseEnter:c,onMouseMove:c}}(r,p);return(0,aG.o)("a",a,{state:{open:p},ref:[b,v,s],props:[x,y.reference,z,A,{id:n},k],stateAttributesMapping:aF.qV})}),p9=B.createContext(void 0);var qa=c(97894);let qb=B.forwardRef(function(a,b){let{keepMounted:c=!1,...d}=a;return pW().useState("mounted")||c?(0,A.jsx)(p9.Provider,{value:c,children:(0,A.jsx)(qa.F,{ref:b,...d})}):null}),qc=B.createContext(void 0);var qd=c(65913),qe=c(91259);let qf=B.forwardRef(function(a,b){let{render:c,className:d,anchor:e,positionMethod:f="absolute",side:g="bottom",align:h="center",sideOffset:i=0,alignOffset:j=0,collisionBoundary:k="clipping-ancestors",collisionPadding:l=5,arrowPadding:m=5,sticky:n=!1,disableAnchorTracking:o=!1,collisionAvoidance:p=aV.Pe,style:q,...r}=a,s=pW(),t=function(){let a=B.useContext(p9);if(void 0===a)throw Error((0,aq.A)(48));return a}(),u=(0,ax.fI)(),v=s.useState("open"),w=s.useState("mounted"),x=s.useState("floatingRootContext"),y=s.useState("instantType"),z=s.useState("transitionStatus"),C=s.useState("adaptiveOrigin"),D=s.context.inlineRectCoordsRef,E=(0,qd.s)({anchor:e,floatingRootContext:x,positionMethod:f,mounted:w,side:g,sideOffset:i,align:h,alignOffset:j,arrowPadding:m,collisionBoundary:k,collisionPadding:l,sticky:n,disableAnchorTracking:o,keepMounted:t,nodeId:u,collisionAvoidance:p,adaptiveOrigin:C,inline:{name:"inline",async fn(a){let b=a.elements.reference;if("function"!=typeof b?.getClientRects)return{};let c="contextElement"in b&&b.contextElement?b.contextElement:(0,dP.vq)(b)?b:void 0,d=D.current,e=d?.element===b||d?.element===c?d:void 0,f=function(a,b,c){let{lines:d,fallback:e}=p_(a.getClientRects());if(d.length<2)return null;let f=c?.x,g=c?.y,h=b[0];if(c?.lineIndex!=null&&d[c.lineIndex])return p1(d[c.lineIndex]);if(null!=f&&null!=g){let a=p0(d,f,g);if(-1!==a)return p1(d[a])}if(2===d.length&&d[0].left>d[1].right&&null!=f&&null!=g)return e;if("t"===h||"b"===h){let a=d[0],b=d[d.length-1],c="t"===h?a:b;return p$(c.left,a.top,c.right,b.bottom)}let i="l"===h,j=d[0].left,k=d[0].right,l=i?1/0:-1/0,m=d[0],n=d[0];for(let a of d){j=Math.min(j,a.left),k=Math.max(k,a.right);let b=i?a.left:a.right;i&&b<l||!i&&b>l?(l=b,m=a,n=a):b===l&&(n=a)}return p$(j,m.top,k,n.bottom)}(b,a.placement,e);if(!f||"function"!=typeof a.platform.getElementRects)return{};let g=await a.platform.getElementRects({reference:{contextElement:c,getBoundingClientRect:()=>f},floating:a.elements.floating,strategy:a.strategy});return a.rects.reference.x===g.reference.x&&a.rects.reference.y===g.reference.y&&a.rects.reference.width===g.reference.width&&a.rects.reference.height===g.reference.height?{}:{reset:{rects:g}}}}}),F=E.update;(0,av.g)(()=>{v&&w&&F()},[v,w,F]);let G={open:v,side:E.side,align:E.align,anchorHidden:E.anchorHidden,instant:y},H=(0,qe.i)(a,G,{styles:E.positionerStyles,transitionStatus:z,props:r,refs:[b,s.useStateSetter("positionerElement")],hidden:!w,inert:!v});return(0,A.jsx)(qc.Provider,{value:E,children:(0,A.jsx)(ax.$c,{id:u,children:H})})});var qg=c(69833),qh=c(43598);let qi=B.forwardRef(function(a,b){let{className:c,render:d,style:e,...f}=a,g=pW(),{side:h,align:i}=function(){let a=B.useContext(qc);if(void 0===a)throw Error((0,aq.A)(49));return a}(),j=g.useState("open"),k=g.useState("instantType"),l=g.useState("transitionStatus"),m=g.useState("popupProps"),n=g.useState("floatingRootContext"),o=g.useState("closeDelay");return(0,bi.v)({open:j,ref:g.context.popupRef,onComplete(){j&&g.context.onOpenChangeComplete?.(!0)}}),(0,qh.a)(n,{closeDelay:o}),(0,aG.o)("div",a,{state:{open:j,side:h,align:i,instant:k,transitionStatus:l},ref:[b,g.context.popupRef,g.useStateSetter("popupElement")],props:[aQ.Ls,m,(0,qg.d)(l),f],stateAttributesMapping:aF.LM})});function qj({onOpenChange:a,...b}){let c=(0,B.useRef)(null);return(0,A.jsx)(p7,{"data-slot":"hover-card",...b,onOpenChange:(b,d)=>{if(a?.(b,d),d.isCanceled)return;if(b){c.current=d.trigger??null;return}let e=c.current;c.current=null,"escape-key"===d.reason&&e instanceof HTMLElement&&e.ownerDocument.activeElement===e&&e.blur()}})}function qk({...a}){return(0,A.jsx)(p8,{"data-slot":"hover-card-trigger",...a})}function ql({className:a,side:b="bottom",sideOffset:c=4,align:d="center",alignOffset:e=4,...f}){return(0,A.jsx)(qb,{"data-slot":"hover-card-portal",children:(0,A.jsx)(qf,{align:d,alignOffset:e,side:b,sideOffset:c,className:"isolate z-50",children:(0,A.jsx)(qi,{"data-slot":"hover-card-content",className:(0,W.cn)("z-50 w-80 max-w-[calc(100vw-2rem)] origin-(--transform-origin) rounded-lg border border-border bg-popover p-3 text-sm text-popover-foreground shadow-md outline-hidden duration-100 motion-reduce:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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",a),...f})})})}let qm=({className:a,...b})=>(0,A.jsx)(j4.Sq,{align:"block-end",className:(0,W.cn)("justify-between gap-1",a),...b}),qn=({className:a,...b})=>(0,A.jsx)("div",{className:(0,W.cn)("flex min-w-0 items-center gap-1",a),...b}),qo=({variant:a="ghost",className:b,size:c,tooltip:d,...e})=>{let f=c??(B.Children.count(e.children)>1?"sm":"icon-sm"),g=(0,A.jsx)(j4.Ik,{className:(0,W.cn)(b),size:f,type:"button",variant:a,...e});if(!d)return g;let h="string"==typeof d?d:d.content,i="string"==typeof d?void 0:d.shortcut,j="string"==typeof d?"top":d.side??"top";return(0,A.jsxs)(d_.m_,{children:[(0,A.jsx)(d_.k$,{render:g}),(0,A.jsxs)(d_.ZI,{side:j,children:[h,i&&(0,A.jsx)("span",{className:"ml-2 text-muted-foreground",children:i})]})]})},qp=E.Ik({input:E.g1(E.Yj(),E.Pq())}).strict(),qq=E.Ik({output:E.Yj()}).strict(),qr="pideskHelp",qs=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/,qt=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function qu(a){return/^[a-zA-Z0-9_./:@=+-]+$/.test(a)?a:JSON.stringify(a)}let qv=E.Ik({name:E.Yj(),scope:E.eu("global").optional(),source:E.Yj(),kind:E.k5(["package","extension"]),version:E.Yj().nullable(),status:E.k5(["ready","available","disabled","failed"]),updateTag:E.Yj().nullish(),availableVersion:E.Yj().nullish(),updateError:E.Yj().nullish(),operation:E.Ik({action:E.k5(["add","update","del","apply"]),phase:E.k5(["queued","checking","applying","waiting","failed"]),message:E.Yj().nullable()}).strict().nullish(),error:E.Ik({phase:E.k5(["package","entry","setup","resources","resolve","native"]),message:cx.qf}).strict().nullish()}).strict(),qw=E.Ik({plugins:E.YO(qv),restartRequired:E.zM(),loadError:cx.qf.nullish()}).strict(),qx=qv.extend({detail:E.g1(E.Yj(),E.Pq())}).strict(),qy=E.Ik({version:E.Yj(),environment:E.k5(["development","production"]),mode:E.k5(["basic","normal"]),cwd:E.Yj(),agentDir:E.Yj(),docsDirectory:E.Yj()}).strict(),qz=null,qA=new WeakMap,qB=new WeakMap,qC=new WeakMap;function qD(a){switch(a.fixed.type){case"user":{let b=pf.lJ.safeParse(a.summary);return{summary:{type:"user",...b.success?b.data:{text:"",images:[]},hasDetail:!1},detail:void 0}}case"assistant":{let b="pi-desk/assistant"===a.fixed.viewKey?pf.Er.safeParse(a.summary):null,c=b?.success?b.data:{text:"",errorMessage:null},d="pi-desk/assistant"===a.fixed.viewKey?pf.Rh.safeParse(a.detail):null;return{summary:{type:"assistant",text:c.text,model:"model"in c?c.model:null,errorMessage:c.errorMessage,status:a.fixed.status,usage:a.fixed.usage,hasDetail:a.fixed.hasDetail},detail:d?.success?{type:"assistant",...d.data}:void 0}}case"tool":{let b={name:a.fixed.viewKey,reasoning:null,inputPreview:null,activity:null},c={status:a.fixed.status,usage:a.fixed.usage,hasDetail:a.fixed.hasDetail};switch(a.fixed.viewKey){case"pi-desk/codemode":{let d=pf.UT.safeParse(a.summary),e=d.success?d.data:b,f=pf.ny.safeParse(a.detail);return{summary:{type:"tool",kind:"codemode",...e,...c},detail:f.success?{type:"tool",kind:"codemode",...f.data}:void 0}}case"pi-desk/pidesk":{let d=qp.safeParse(a.summary),e=d.success?d.data:{input:{}},f=qq.safeParse(a.detail);return{summary:{type:"tool",kind:"pidesk",...b,...e,...c},detail:f.success?{type:"tool",kind:"pidesk",output:f.data.output}:void 0}}case"pi-desk/bash-tool":{let d=pf.Qi.safeParse(a.summary),e=d.success?d.data:{...b,timing:null},f=pf.Ok.safeParse(a.detail);return{summary:{type:"tool",kind:"bash",...e,...c},detail:f.success?{type:"tool",kind:"bash",output:f.data.output}:void 0}}case"pi-desk/read":{let d=pf.Gx.safeParse(a.summary),e=d.success?d.data:{...b,path:null},f=pf.Xj.safeParse(a.detail);return{summary:{type:"tool",kind:"read",...e,...c},detail:f.success?{type:"tool",kind:"read",content:f.data.content}:void 0}}case"pi-desk/edit":{let d=pf.aV.safeParse(a.summary),e=d.success?d.data:{...b,path:null},f=pf.Rk.safeParse(a.detail);return{summary:{type:"tool",kind:"edit",...e,...c},detail:f.success?{type:"tool",kind:"edit",contentKind:f.data.kind,content:f.data.content}:void 0}}case"pi-desk/write":{let d=pf.bN.safeParse(a.summary),e=d.success?d.data:{...b,path:null},f=pf.O_.safeParse(a.detail);return{summary:{type:"tool",kind:"write",...e,...c},detail:f.success?{type:"tool",kind:"write",contentKind:f.data.kind,content:f.data.content}:void 0}}default:{let d=pf.Px.safeParse(a.summary),e=d.success?d.data:b,f=pf.Ok.safeParse(a.detail);return{summary:{type:"tool",kind:"generic",...e,...c},detail:f.success?{type:"tool",kind:"generic",output:f.data.output}:void 0}}}}case"bash":{let b=pf.ai.safeParse(a.summary),c=b.success?b.data:{command:a.fixed.viewKey},d=pf.bG.safeParse(a.detail);return{summary:{type:"bash",command:c.command,status:a.fixed.status,hasDetail:a.fixed.hasDetail},detail:d.success?{type:"bash",...d.data}:void 0}}case"custom":{if("pi-desk/compaction"===a.fixed.viewKey){let b=pf.sL.safeParse(a.detail);return{summary:{type:"compaction",hasDetail:a.fixed.hasDetail},detail:b.success?{type:"compaction",...b.data}:void 0}}let b=pf.Rt.safeParse(a.summary);return{summary:{type:"custom",text:(b.success?b.data:{text:""}).text,hasDetail:!1},detail:void 0}}}}function qE(a){return a.temporary||"status"in a.summary&&"running"===a.summary.status}function qF(a){return"assistant"===a.summary.type&&("error"===a.summary.status||!!a.summary.errorMessage||(a.detail?.type==="assistant"?a.detail.thinking.trim().length>0:a.summary.hasDetail))}function qG(a,b,c){if("compaction"===c.summary.type){qH(a,b),a.push({identity:c.identity,user:null,processItems:[],finalAssistant:null,compaction:c,running:qE(c),toolCount:0});return}"user"!==c.summary.type?b.body.push(c):(qH(a,b),b.user=c)}function qH(a,b){if(!b.user&&0===b.body.length)return;let c=b.user?.identity??b.body[0].identity;a.push(function(a,b,c){let d=function(a){for(let b=a.length-1;b>=0;b-=1){let c=a[b];if("custom"!==c.summary.type){if("assistant"!==c.summary.type)return -1;return c.summary.text.trim()||"pi-desk/assistant"!==c.viewKey?b:-1}}return -1}(c),e=d>=0?c[d]:null,f=[];for(let[a,b]of c.entries()){if(a!==d){("assistant"!==b.summary.type||"pi-desk/assistant"!==b.viewKey||b.summary.text.trim().length>0||qF(b))&&f.push({message:b,hideAssistantText:!1});continue}qF(b)&&f.push({message:b,hideAssistantText:!0})}return{identity:a,user:b,processItems:f,finalAssistant:e,compaction:null,running:c.some(qE),toolCount:c.filter(a=>"tool"===a.summary.type||"bash"===a.summary.type).length}}(c,b.user,b.body)),b.user=null,b.body=[]}function qI(a,b=!1){let c=function(a){let b=qC.get(a);if(b)return b;let c=[],d={user:null,body:[]},e=new Set,f=[],g=(a[0]?.location.index??0)>0;for(let b of a){if(e.has(b.location.entryId))continue;e.add(b.location.entryId);let a=function(a){let b=qA.get(a);if(b)return b;let c=qD(a),d={identity:`position:${a.location.index}`,position:a.location.index,viewKey:a.fixed.viewKey,snapshot:a,...c,temporary:!1,timestampMs:a.fixed.timestampMs,durable:a,tempId:null};return qA.set(a,d),d}(b);"compaction"===a.summary.type?(f=[],g=!1):"assistant"===b.fixed.type&&(f.push(a),"assistant"===a.summary.type&&null!==a.timestampMs&&(a.summary.text.trim()||"pi-desk/assistant"!==a.viewKey)&&(a={...a,usageCalls:f,usageIncomplete:g},f=[],g=!1)),qG(c,d,a)}let h={turns:c,user:d.user,body:d.body};return qC.set(a,h),h}(a.messages),d=[...c.turns],e={user:c.user,body:[...c.body]};for(let[b,c]of a.temporaryMessages.entries())qG(d,e,function(a,b){let c=qB.get(a);if(c?.position===b)return c.message;let d=qD(a),e={identity:`position:${b}`,position:b,viewKey:a.fixed.viewKey,snapshot:a,...d,temporary:!0,timestampMs:a.fixed.timestampMs,durable:null,tempId:a.location.tempId};return qB.set(a,{position:b,message:e}),e}(c,a.messages.length+b));qH(d,e);let f=d.at(-1);return b&&f&&!f.compaction&&(f.running=!0),d}function qJ(a){return a<1e3?String(a):a<1e6?`${(a/1e3).toFixed(1).replace(/\.0$/,"")}k`:`${(a/1e6).toFixed(1).replace(/\.0$/,"")}m`}function qK(a){return 0===a?"$0":a<1e-4?"<$0.0001":`$${a.toFixed(4).replace(/0+$/,"").replace(/\.$/,"")}`}function qL(a,b=Date.now(),c="en",d="UTC"){let e=new Date(a),f=new Date(b),g=function(a,b){if(qz?.locale===a&&qz.timeZone===b)return qz;let c="en"===a?"en-US":"zh-CN";return qz={locale:a,timeZone:b,compactTime:new Intl.DateTimeFormat(c,{timeZone:b,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),compactDateTime:new Intl.DateTimeFormat(c,{timeZone:b,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),fullDateTime:new Intl.DateTimeFormat(c,{timeZone:b,timeZoneName:"shortOffset",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}),dateKey:new Intl.DateTimeFormat("en-US",{timeZone:b,year:"numeric",month:"2-digit",day:"2-digit"})}}(c,d);return{compact:g.dateKey.format(e)===g.dateKey.format(f)?g.compactTime.format(e):g.compactDateTime.format(e),full:g.fullDateTime.format(e)}}function qM(a,b,c={}){}function qN(a){return a.querySelector("[data-chat-tail-space]")}function qO(a){for(let b of a.querySelectorAll("[data-chat-tail-space]"))qM("tail:clear:start",a),b.style.removeProperty("min-height"),delete b.dataset.chatTailSpace,delete b.dataset.chatTailAnchor,delete b.dataset.chatTailOffset,qM("tail:clear:end",a)}function qP({active:a=!0}){let{scrollRef:b,state:c}=pR();return null}function qQ(a){let b=[a.user,...a.processItems.map(a=>a.message),a.finalAssistant,a.compaction].filter(a=>null!==a),c=new Set;return b.filter(a=>!c.has(a.identity)&&(c.add(a.identity),!0))}function qR(a,b,c){let d=0;for(let e=b;e<c;e+=1)a[e]?.user&&(d+=1);return d}function qS(a,b){let c=Math.max(0,Math.min(a.length,b)),d=Math.min(2,qR(a,0,c)),e=c,f=0,g=0,h=0;for(;e>0;){let b=a[e-1],c=qQ(b).length,i=h<d;if(f>0&&!i&&(f>=30||g+c>200))break;e-=1,f+=1,g+=c,b.user&&(h+=1)}return e}function qT(a,b){let c=Math.max(0,Math.min(a.length,b)),d=Math.min(2,qR(a,c,a.length)),e=c,f=0,g=0,h=0;for(;e<a.length;){let b=a[e],c=qQ(b).length,i=h<d;if(f>0&&!i&&(f>=30||g+c>200))break;e+=1,f+=1,g+=c,b.user&&(h+=1)}return e}function qU(a){return{startIndex:qS(a,a.length),endIndex:a.length}}function qV(a,b){let c,d;if(0===a.length)return{startIndex:0,endIndex:0};if(!b)return qU(a);let e=(d=(c=b.lastIndexOf(":"))>0?b.slice(0,c):b,a.findIndex(a=>qQ(a).some(a=>a.identity===d)));if(e<0)return qU(a);let f=Math.min(a.length,e+1+10);return{startIndex:qS(a,f),endIndex:f}}function qW({active:a=!0,turns:b,focusTurnIdentity:c,initialAnchor:d,children:e}){let{scrollRef:f}=pR(),[g,h]=(0,B.useState)(()=>({...qV(b,d),turnCount:b.length,focusTurnIdentity:c}));a||g.focusTurnIdentity===c||h({...g,focusTurnIdentity:c});let i=(0,B.useRef)(null),j=(0,B.useRef)(!1),k=(0,B.useMemo)(()=>{if(0===b.length)return{startIndex:0,endIndex:0};if(a&&g.focusTurnIdentity!==c)return qU(b);if(0===g.turnCount&&0===g.endIndex)return qV(b,d);let e=g.endIndex>=g.turnCount;return{startIndex:Math.min(g.startIndex,b.length),endIndex:e?b.length:Math.max(g.startIndex,Math.min(g.endIndex,b.length))}},[a,c,d,b,g]),l=(0,B.useCallback)(a=>{h({...a,turnCount:b.length,focusTurnIdentity:c})},[c,b.length]),m=(0,B.useCallback)(()=>{let a=f.current,b=a?.querySelector("[data-chat-turn]");a&&b?.dataset.chatTurn&&(i.current={turnIdentity:b.dataset.chatTurn,offset:b.getBoundingClientRect().top-a.getBoundingClientRect().top})},[f]);(0,B.useCallback)(()=>{if(k.startIndex<=0||j.current)return;let a=qS(b,k.startIndex);if(a>=k.startIndex)return;m();let c=f.current;c&&qM("window:expand-earlier",c,{previousStartIndex:k.startIndex,nextStartIndex:a}),j.current=!0,l({...k,startIndex:a})},[m,l,k,f,b]),(0,B.useCallback)(()=>{if(k.endIndex>=b.length||j.current)return;let a=qT(b,k.endIndex);a<=k.endIndex||(j.current=!0,l({...k,endIndex:a}))},[l,k,b]);let n=(0,B.useCallback)(a=>{!Number.isSafeInteger(a)||a<0||a>=b.length||a>=k.startIndex&&a<k.endIndex||(a<k.startIndex?l({...k,startIndex:Math.min(a,qS(b,a+1))}):l({...k,endIndex:Math.max(a+1,qT(b,a))}))},[l,k,b]),o=(0,B.useCallback)(()=>{l(qU(b))},[l,b]),p=(0,B.useMemo)(()=>b.slice(k.startIndex,k.endIndex),[k.endIndex,k.startIndex,b]),q=(0,B.useMemo)(()=>({...k,visibleTurns:p,containsTail:k.endIndex>=b.length,revealTurn:n,resetToTail:o}),[k,o,n,b.length,p]);return(0,A.jsx)(A.Fragment,{children:e(q)})}let qX={canMoveUp:!1,canMoveDown:!1,hasNextMessage:!1};function qY(a,b,c,d){let e=0,f=a.length;for(;e<f;){let g=Math.floor((e+f)/2),h=a[g].getBoundingClientRect().top-b;(d?h>=c:h>c)?f=g:e=g+1}return e}function qZ(a){return a.user?`${a.user.identity}:user`:null}function q$(a,b,c){var d;let e,f,g=Array.from(a.querySelectorAll("[data-chat-user-message]")),h=a.getBoundingClientRect().top+12,i=qY(g,h,-2,!0),j=qY(g,h,2,!1),k=c.find(a=>a>=b.startIndex&&a<b.endIndex),l=c.findLast(a=>a>=b.startIndex&&a<b.endIndex),m=0===i?c.findLast(a=>a<(k??b.startIndex))??null:null,n=j>=g.length?c.find(a=>a>(l??b.endIndex-1))??null:null,o=a.scrollHeight-a.scrollTop-a.clientHeight,p=(f=qN(a))&&(e=(d=f).lastElementChild)instanceof HTMLElement?Math.max(0,d.getBoundingClientRect().bottom-e.getBoundingClientRect().bottom):0,q=b.containsTail&&o<=2;return qM("navigation:inspect",a,{containsTail:b.containsTail,tailSpacerHeight:p,atBottom:q,previousMessage:g[i-1]?.dataset.chatUserMessage??null,nextMessage:g[j]?.dataset.chatUserMessage??null,previousOutsideTurnIndex:m,nextOutsideTurnIndex:n}),{previousMessage:g[i-1]??null,nextMessage:g[j]??null,previousOutsideTurnIndex:m,nextOutsideTurnIndex:n,atBottom:q}}function q_({turns:a,window:b}){let{t:c}=(0,Q.Bd)("conversation"),{scrollRef:d,scrollToBottom:e,stopScroll:f}=pR(),g=(0,B.useMemo)(()=>a.flatMap((a,b)=>a.user?[b]:[]),[a]),[h,i]=(0,B.useState)(!1),[j,k]=(0,B.useState)(qX),[l,m]=(0,B.useState)(null),n=(0,B.useRef)(null),o=(0,B.useRef)(!1),p=(0,B.useRef)(!1),q=(0,B.useRef)(null),r=(0,B.useRef)(null),s=(0,B.useRef)(!1),t=(0,B.useRef)(null),u=(0,B.useRef)(!1),v=(0,B.useRef)(!1),w=(0,B.useCallback)(a=>{var c;let d,e=(d=!(c=q$(a,b,g)).atBottom,{canMoveUp:null!==c.previousMessage||null!==c.previousOutsideTurnIndex,canMoveDown:d,hasNextMessage:d&&(null!==c.nextMessage||null!==c.nextOutsideTurnIndex)});s.current&&(e.canMoveDown=!1),k(a=>a.canMoveUp===e.canMoveUp&&a.canMoveDown===e.canMoveDown&&a.hasNextMessage===e.hasNextMessage?a:e)},[b,g]),x=(0,B.useCallback)(a=>{null===r.current&&(r.current=window.requestAnimationFrame(()=>{r.current=null,w(a)}))},[w]),y=(0,B.useCallback)(()=>{null!==q.current&&(window.clearTimeout(q.current),q.current=null)},[]),z=(0,B.useCallback)(()=>{y(),p.current||(q.current=window.setTimeout(()=>{q.current=null,o.current=!1,i(!1),null!==r.current&&(window.cancelAnimationFrame(r.current),r.current=null)},2e3))},[y]);(0,B.useCallback)(()=>{null!==n.current&&window.clearTimeout(n.current),n.current=null,m(a=>a?.visible?{...a,visible:!1}:a)},[]);let C=(0,B.useCallback)(a=>{null!==n.current&&window.clearTimeout(n.current),m({index:a,visible:!0}),n.current=window.setTimeout(()=>{n.current=null,m(a=>a?.visible?{...a,visible:!1}:a)},2e3)},[]),D=(0,B.useCallback)(()=>{let a=d.current;a&&(o.current||k(qX),o.current=!0,i(!0),x(a),z())},[x,z,d]),E=(0,B.useCallback)((c,h)=>{let i=d.current;if(!i)return;D();let j=q$(i,b,g),l="up"===c?j.previousMessage:j.atBottom?null:j.nextMessage;if(l){let c=g.findIndex(b=>qZ(a[b])===l.dataset.chatScrollAnchor);c>=0&&C(c+1),s.current=!1,f(),function(a,b,c){let d,e,f,g,h,i;qM("position:start",a,{target:b.dataset.chatScrollAnchor??null,offset:12,addTailSpace:c});let j=c?(i=(h=a.querySelectorAll("[data-chat-turn]")).item(h.length-1),i?.hasAttribute("data-chat-logical-tail")?i:null):null;if(j&&qN(a)===j||qO(a),!j){a.scrollTop=Math.max(0,a.scrollTop+b.getBoundingClientRect().top-a.getBoundingClientRect().top-12),qM("position:end",a,{target:b.dataset.chatScrollAnchor??null,offset:12,addTailSpace:c});return}let{targetScrollTop:k,minHeight:l}=(d=a.getBoundingClientRect(),f=Math.max(0,(e=a.scrollTop)+b.getBoundingClientRect().top-d.top-12),g=e+j.getBoundingClientRect().top-d.top,{targetScrollTop:f,minHeight:Math.max(0,f+a.clientHeight-g-function(a){let b=a.parentElement;if(!b)return 0;let c=Number.parseFloat(getComputedStyle(b).paddingBottom);return Number.isFinite(c)?c:0}(j))}),m=`${Math.ceil(l)}px`;j.style.minHeight!==m&&(j.style.minHeight=m),j.hasAttribute("data-chat-tail-space")||(j.dataset.chatTailSpace="");let n=b.dataset.chatScrollAnchor;j.dataset.chatTailAnchor!==n&&(n?j.dataset.chatTailAnchor=n:delete j.dataset.chatTailAnchor),j.dataset.chatTailOffset!==String(12)&&(j.dataset.chatTailOffset=String(12)),a.scrollTop=k,qM("position:end",a,{target:b.dataset.chatScrollAnchor??null,offset:12,addTailSpace:c,minHeight:l})}(i,l,b.containsTail)}else{let d="up"===c?j.previousOutsideTurnIndex:j.nextOutsideTurnIndex;if(null!==d){let c=qZ(a[d]);c&&(C(g.indexOf(d)+1),s.current=!1,t.current={anchor:c},b.revealTurn(d))}else"down"===c&&(g.length>0&&C(g.length),h&&(h.disabled=!0),k(a=>a.canMoveDown?{...a,canMoveDown:!1}:a),j.atBottom||s.current||(qM("navigation:bottom:start",i,{containsTail:b.containsTail}),s.current=!0,qO(i),b.containsTail?Promise.resolve(e({animation:"instant"})).finally(()=>{s.current=!1,v.current&&o.current&&x(i)}):(u.current=!0,b.resetToTail())))}x(i)},[x,d,e,D,C,f,a,b,g]),F=h&&(j.canMoveUp||j.canMoveDown),G=c(j.hasNextMessage?"nextUserMessage":"bottom");return(0,A.jsxs)(A.Fragment,{children:[l&&g.length>0?(0,A.jsxs)("div",{role:"status","aria-hidden":!l.visible,"aria-label":`${c("userNavigation")} ${l.index} / ${g.length}`,className:`pointer-events-none absolute top-1/2 left-3 z-10 -translate-y-1/2 rounded-lg border bg-background/95 px-2 py-2 shadow-sm transition-opacity duration-150 motion-reduce:transition-none sm:left-4 ${l.visible?"opacity-100":"opacity-0"}`,children:[(0,A.jsxs)("div",{className:"text-center text-sm font-medium tabular-nums",children:[l.index," / ",g.length]}),(0,A.jsx)("div",{className:"relative mx-auto mt-2 h-28 w-0.5 rounded-full bg-border",children:(0,A.jsx)("span",{className:"absolute left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground",style:{top:`${(l.index-1)/Math.max(1,g.length-1)*100}%`}})})]}):null,F?(0,A.jsxs)(d$,{orientation:"vertical",className:"absolute right-3 bottom-4 z-10 rounded-lg shadow-sm sm:right-4","aria-label":c("userNavigation"),onMouseEnter:()=>{p.current=!0,y()},onMouseLeave:()=>{p.current=!1,o.current&&z()},children:[(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"icon",className:"size-10 bg-background/90 backdrop-blur dark:bg-background/90",disabled:!j.canMoveUp,"aria-label":c("previousUserMessage"),title:c("previousUserShort"),onClick:()=>E("up"),children:(0,A.jsx)($.A,{className:"size-4"})}),(0,A.jsx)(U.$,{type:"button",variant:"outline",size:"icon",className:"size-10 bg-background/90 backdrop-blur dark:bg-background/90",disabled:!j.canMoveDown,"aria-label":G,title:G,onClick:a=>E("down",a.currentTarget),children:(0,A.jsx)(_.A,{className:"size-4"})})]}):null]})}let q0=(0,B.createContext)({basic:!1});function q1({basic:a,onRecover:b,children:c}){let d=(0,B.useMemo)(()=>({basic:a,recover:b}),[a,b]);return(0,A.jsx)(q0.Provider,{value:d,children:c})}function q2(a){return{location:a.snapshot.location,fixed:a.snapshot.fixed,summary:a.snapshot.summary,...void 0===a.snapshot.detail?{}:{detail:a.snapshot.detail}}}class q3{constructor(a,b){this.listeners=new Set,this.pending=null,this.requestEpoch=0,this.disposed=!1,this.basic=!1,this.message=a,this.snapshot=q2(a),this.loader=b,this.detailLoaded=void 0!==this.snapshot.detail||!this.snapshot.fixed.hasDetail}getSnapshot(){return this.snapshot}subscribe(a){if(this.disposed)throw Error("Message Handle has been disposed");return this.listeners.add(a),()=>{this.listeners.delete(a)}}loadDetail(){if(this.detailLoaded)return Promise.resolve(this.snapshot.detail??null);if(!this.snapshot.fixed.hasDetail)return Promise.resolve(null);if(!("entryId"in this.snapshot.location))return Promise.reject(Error("Temporary Message 不能读取 canonical Detail"));if(this.pending)return this.pending;let a=this.requestEpoch,b=this.loader(this.message).then(b=>(this.disposed||a!==this.requestEpoch||(this.detailLoaded=!0,this.snapshot={...this.snapshot,...null===b?{}:{detail:b}},this.notify()),b)).finally(()=>{this.pending===b&&(this.pending=null)});return this.pending=b,b}replace(a,b,c){if(this.disposed)return;let d=q2(a);if(this.snapshot===d)return;let e=this.basic!==c||void 0!==this.snapshot.detail&&void 0===d.detail||this.snapshot.fixed.viewKey!==d.fixed.viewKey||"entryId"in this.snapshot.location&&"entryId"in d.location&&this.snapshot.location.entryId!==d.location.entryId;this.basic=c,this.message=a,this.loader=b,this.snapshot=d,e?(this.requestEpoch+=1,this.pending=null,this.detailLoaded=void 0!==d.detail||!d.fixed.hasDetail):void 0===d.detail&&d.fixed.hasDetail||(this.detailLoaded=!0),this.notify()}dispose(){this.disposed||(this.disposed=!0,this.listeners.clear(),this.requestEpoch+=1,this.pending=null)}notify(){for(let a of[...this.listeners])a()}}function q4({message:a,pluginName:b,contributionName:c,phase:d,error:e,handle:f,fallback:g,onRetry:h}){let{t:i}=(0,Q.Bd)("conversation"),[j,k]=(0,B.useState)(f.getSnapshot().detail),[l,m]=(0,B.useState)(!1),[n,o]=(0,B.useState)(null),p=(0,B.useContext)(q0),[q,r]=(0,B.useState)(!1),[s,t]=(0,B.useState)(!1);return e.name,e.message,e.stack,(0,A.jsxs)("div",{className:"space-y-2","data-message-id":a.identity,children:[g,(0,A.jsx)("div",{role:"alert",className:"rounded-lg border border-destructive/35 bg-muted/30 p-3 text-sm",children:(0,A.jsxs)("div",{className:"flex items-start gap-2",children:[(0,A.jsx)(cp.A,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)("p",{className:"font-medium text-destructive",children:i("viewFailed")}),"pi-desk/message-declaration-error"===a.viewKey&&"string"==typeof a.snapshot.summary.text&&a.snapshot.summary.text.length>0?(0,A.jsx)("p",{className:"mt-2 whitespace-pre-wrap break-words text-foreground",children:a.snapshot.summary.text}):null,(0,A.jsxs)(ct,{error:e,children:[(0,A.jsxs)("p",{className:"text-xs text-muted-foreground [overflow-wrap:anywhere]",children:[b??"Host"," \xb7 ",c??i("reservedView")," \xb7 ",a.viewKey," ","\xb7 ",d]}),(0,A.jsxs)("details",{className:"text-sm",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:i("publicSnapshot")}),(0,A.jsx)("pre",{className:"mt-2 max-h-48 overflow-auto rounded-md bg-background p-3 font-mono text-sm whitespace-pre-wrap [overflow-wrap:anywhere]",children:JSON.stringify(f.getSnapshot(),null,2)})]}),!a.temporary&&a.snapshot.fixed.hasDetail&&void 0===j?(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",disabled:l,onClick:()=>{m(!0),o(null),f.loadDetail().then(k,a=>{o(a instanceof Error?a.message:i("detailFailed"))}).finally(()=>m(!1))},children:[l?(0,A.jsx)(R.A,{className:"animate-spin"}):null,i("loadDetail")]}):null,n?(0,A.jsx)("p",{className:"text-sm text-destructive [overflow-wrap:anywhere]",children:n}):null,j?(0,A.jsx)("pre",{className:"max-h-48 overflow-auto rounded-md bg-background p-3 font-mono text-sm whitespace-pre-wrap [overflow-wrap:anywhere]",children:JSON.stringify(j,null,2)}):null]}),p.recover?(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",className:"mt-2 mr-2",disabled:q,onClick:()=>{r(!0),p.recover().catch(a=>o(a instanceof Error?a.message:String(a))).finally(()=>r(!1))},children:[q?(0,A.jsx)(R.A,{className:"animate-spin"}):null,i("useBasicPresentation")]}):null,h?(0,A.jsxs)(U.$,{type:"button",variant:"outline",size:"sm",className:"mt-2",disabled:s,onClick:()=>{t(!0),o(null),Promise.resolve().then(h).catch(a=>o(a instanceof Error?a.message:String(a))).finally(()=>t(!1))},children:[s?(0,A.jsx)(R.A,{className:"animate-spin"}):(0,A.jsx)(bO.A,{}),i("retry")]}):null]})]})})]})}function q5({message:a}){let{t:b}=(0,Q.Bd)("conversation");return(0,A.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3 text-sm","aria-busy":"true",children:[(0,A.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",role:"status",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"}),b("viewLoading")]}),(0,A.jsxs)("details",{className:"mt-2",children:[(0,A.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:b("messageContent")}),(0,A.jsx)("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap [overflow-wrap:anywhere]",children:JSON.stringify(a.snapshot.summary,null,2)})]})]})}function q6({message:a,loadDetail:b,defaultView:c}){let{t:d}=(0,Q.Bd)("conversation"),e=(0,bJ.t4)();(0,bJ.So)();let f=(0,B.useContext)(q0),g=(0,B.useRef)(null);(0,B.useRef)(null);let h=(0,B.useRef)(null),[i,j]=(0,B.useState)({status:"loading"}),[k]=(0,B.useState)(()=>new q3(a,b)),[l,m]=(0,B.useState)(0),n=e.getMessageViewResolution(a.viewKey),o=e.areEntriesInitialized(),p=!n&&e.isRefreshingEntries(),q=n?.status==="winner"?`${a.viewKey}\u0000${n.pluginName}\u0000${n.descriptor.contributionName}\u0000${n.descriptor.priority}`:n?.status==="conflict"?`${a.viewKey}\u0000${n.candidates.map(a=>`${a.pluginName}:${a.descriptor.contributionName}`).join(",")}`:a.viewKey,r=n?.status==="winner"?n.pluginName:null;n?.status==="winner"&&n.descriptor.contributionName;let s=r?e.getEntryState(r):null,t=s?.status==="ready"?s.runtime:s?.status,u=a.viewKey.startsWith("pi-desk/")&&"pi-desk/message-declaration-error"!==a.viewKey,v=(0,B.useMemo)(()=>({attempt:l,basic:f.basic,resolutionKey:q,winnerIdentity:t}),[l,f.basic,q,t]);if((0,B.useMemo)(()=>({kind:"message-view",message:{getSnapshot:()=>k.getSnapshot(),subscribe:a=>h.current!==v?()=>void 0:k.subscribe(()=>{if(h.current===v&&r&&e.getEntryState(r)===s)try{a()}catch(a){j({status:"error",error:a instanceof Error?a:Error(String(a)),phase:"update",generation:v})}}),loadDetail:async()=>{if(h.current!==v)throw Error("Message View 已释放");let a=await k.loadDetail();if(h.current!==v)throw Error("Message View 已释放");return a}},reportError(a){h.current===v&&r&&e.getEntryState(r)===s&&j({status:"error",error:a instanceof Error?a:Error(String(a)),phase:"report-error",generation:v})}}),[k,v,e,s,r]),f.basic)return(0,A.jsx)(A.Fragment,{children:c});if("pi-desk/message-declaration-error"===a.viewKey)return(0,A.jsx)(q4,{message:a,pluginName:"pi-desk",contributionName:"message-declaration-error",phase:"declaration",error:Error(d("declarationFailed")),handle:k});if(!o)return u?(0,A.jsx)(A.Fragment,{children:c}):(0,A.jsx)(q5,{message:a});if(n?.status==="conflict")return(0,A.jsx)(q4,{message:a,pluginName:null,contributionName:null,phase:"priority-conflict",error:Error(d("viewConflict")),handle:k,fallback:u?c:void 0});if(!n)return u?(0,A.jsx)(A.Fragment,{children:c}):p?(0,A.jsx)(q5,{message:a}):(0,A.jsx)(q4,{message:a,pluginName:null,contributionName:null,phase:"missing-view",error:Error(d("viewMissing",{viewKey:a.viewKey})),handle:k,onRetry:async()=>{await e.refreshEntries(),await Promise.all(e.getFailedEntries().map(({pluginName:a})=>e.retryEntry(a)))}});if("error"===i.status&&i.generation===v)return(0,A.jsx)(q4,{message:a,pluginName:n.pluginName,contributionName:n.descriptor.contributionName,phase:i.phase,error:i.error,handle:k,fallback:u?c:void 0,onRetry:()=>{let a=e.getContributionLoadState(n.pluginName,"message-view",n.descriptor.contributionName);(j({status:"loading"}),"failed"!==a.status)?m(a=>a+1):e.retryContribution(n.pluginName,"message-view",n.descriptor.contributionName).then(()=>m(a=>a+1),a=>{j({status:"error",error:a instanceof Error?a:Error(String(a)),phase:"load",generation:v})})}});let w="ready"===i.status&&i.generation===v;return(0,A.jsxs)("div",{className:"relative","data-message-id":a.identity,"aria-busy":!w,children:[w?null:u?c:(0,A.jsx)(q5,{message:a}),(0,A.jsx)("div",{ref:g,className:w?void 0:"pointer-events-none invisible absolute inset-x-0 top-0","data-pi-desk-plugin":n.pluginName,"data-pi-desk-kind":"message-view","data-pi-desk-contribution":n.descriptor.contributionName})]})}let q7=(0,S.A)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),q8=(0,S.A)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),q9=(0,S.A)("file-pen-line",[["path",{d:"M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z",key:"ukzhwg"}],["path",{d:"M14.487 7.858A1 1 0 0 1 14 7V2",key:"1klhew"}],["path",{d:"M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516",key:"rxaxab"}],["path",{d:"M8 18h1",key:"13wk12"}]]),ra=(0,S.A)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),rb=(0,S.A)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);var rc=c(14120),rd=c(72482);let re=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],rf=new Set([...re,"pathRotation"]),rg=(a,b,c)=>c>b?b:c<a?a:c,rh={test:a=>"number"==typeof a,parse:parseFloat,transform:a=>a},ri={...rh,transform:a=>rg(0,1,a)},rj={...rh,default:1},rk=a=>Math.round(1e5*a)/1e5,rl=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu,rm=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,rn=(a,b)=>c=>!!("string"==typeof c&&rm.test(c)&&c.startsWith(a)||b&&null!=c&&Object.prototype.hasOwnProperty.call(c,b)),ro=(a,b,c)=>d=>{if("string"!=typeof d)return d;let[e,f,g,h]=d.match(rl);return{[a]:parseFloat(e),[b]:parseFloat(f),[c]:parseFloat(g),alpha:void 0!==h?parseFloat(h):1}},rp={...rh,transform:a=>Math.round(rg(0,255,a))},rq={test:rn("rgb","red"),parse:ro("red","green","blue"),transform:({red:a,green:b,blue:c,alpha:d=1})=>"rgba("+rp.transform(a)+", "+rp.transform(b)+", "+rp.transform(c)+", "+rk(ri.transform(d))+")"},rr={test:rn("#"),parse:function(a){let b="",c="",d="",e="";return a.length>5?(b=a.substring(1,3),c=a.substring(3,5),d=a.substring(5,7),e=a.substring(7,9)):(b=a.substring(1,2),c=a.substring(2,3),d=a.substring(3,4),e=a.substring(4,5),b+=b,c+=c,d+=d,e+=e),{red:parseInt(b,16),green:parseInt(c,16),blue:parseInt(d,16),alpha:e?parseInt(e,16)/255:1}},transform:rq.transform},rs=a=>({test:b=>"string"==typeof b&&b.endsWith(a)&&1===b.split(" ").length,parse:parseFloat,transform:b=>`${b}${a}`}),rt=rs("deg"),ru=rs("%"),rv=rs("px"),rw=rs("vh"),rx=rs("vw"),ry={...ru,parse:a=>ru.parse(a)/100,transform:a=>ru.transform(100*a)},rz={test:rn("hsl","hue"),parse:ro("hue","saturation","lightness"),transform:({hue:a,saturation:b,lightness:c,alpha:d=1})=>"hsla("+Math.round(a)+", "+ru.transform(rk(b))+", "+ru.transform(rk(c))+", "+rk(ri.transform(d))+")"},rA={test:a=>rq.test(a)||rr.test(a)||rz.test(a),parse:a=>rq.test(a)?rq.parse(a):rz.test(a)?rz.parse(a):rr.parse(a),transform:a=>"string"==typeof a?a:a.hasOwnProperty("red")?rq.transform(a):rz.transform(a),getAnimatableNone:a=>{let b=rA.parse(a);return b.alpha=0,rA.transform(b)}},rB=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,rC="number",rD="color",rE=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function rF(a){let b=a.toString(),c=[],d={color:[],number:[],var:[]},e=[],f=0,g=b.replace(rE,a=>(rA.test(a)?(d.color.push(f),e.push(rD),c.push(rA.parse(a))):a.startsWith("var(")?(d.var.push(f),e.push("var"),c.push(a)):(d.number.push(f),e.push(rC),c.push(parseFloat(a))),++f,"${}")).split("${}");return{values:c,split:g,indexes:d,types:e}}function rG({split:a,types:b}){let c=a.length;return d=>{let e="";for(let f=0;f<c;f++)if(e+=a[f],void 0!==d[f]){let a=b[f];a===rC?e+=rk(d[f]):a===rD?e+=rA.transform(d[f]):e+=d[f]}return e}}let rH={test:function(a){return isNaN(a)&&"string"==typeof a&&(a.match(rl)?.length||0)+(a.match(rB)?.length||0)>0},parse:function(a){return rF(a).values},createTransformer:function(a){return rG(rF(a))},getAnimatableNone:function(a){let b=rF(a);return rG(b)(b.values.map((a,c)=>((a,b)=>"number"==typeof a?b?.trim().endsWith("/")?a:0:"number"==typeof a?0:rA.test(a)?rA.getAnimatableNone(a):a)(a,b.split[c])))}},rI=new Set(["brightness","contrast","saturate","opacity"]);function rJ(a){let[b,c]=a.slice(0,-1).split("(");if("drop-shadow"===b)return a;let[d]=c.match(rl)||[];if(!d)return a;let e=c.replace(d,""),f=+!!rI.has(b);return d!==c&&(f*=100),b+"("+f+e+")"}let rK=/\b([a-z-]*)\(.*?\)/gu,rL={...rH,getAnimatableNone:a=>{let b=a.match(rK);return b?b.map(rJ).join(" "):a}},rM={...rH,getAnimatableNone:a=>{let b=rH.parse(a);return rH.createTransformer(a)(b.map(a=>"number"==typeof a?0:"object"==typeof a?{...a,alpha:1}:a))}},rN={...rh,transform:Math.round},rO={borderWidth:rv,borderTopWidth:rv,borderRightWidth:rv,borderBottomWidth:rv,borderLeftWidth:rv,borderRadius:rv,borderTopLeftRadius:rv,borderTopRightRadius:rv,borderBottomRightRadius:rv,borderBottomLeftRadius:rv,width:rv,maxWidth:rv,height:rv,maxHeight:rv,top:rv,right:rv,bottom:rv,left:rv,inset:rv,insetBlock:rv,insetBlockStart:rv,insetBlockEnd:rv,insetInline:rv,insetInlineStart:rv,insetInlineEnd:rv,padding:rv,paddingTop:rv,paddingRight:rv,paddingBottom:rv,paddingLeft:rv,paddingBlock:rv,paddingBlockStart:rv,paddingBlockEnd:rv,paddingInline:rv,paddingInlineStart:rv,paddingInlineEnd:rv,margin:rv,marginTop:rv,marginRight:rv,marginBottom:rv,marginLeft:rv,marginBlock:rv,marginBlockStart:rv,marginBlockEnd:rv,marginInline:rv,marginInlineStart:rv,marginInlineEnd:rv,fontSize:rv,backgroundPositionX:rv,backgroundPositionY:rv,rotate:rt,pathRotation:rt,rotateX:rt,rotateY:rt,rotateZ:rt,scale:rj,scaleX:rj,scaleY:rj,scaleZ:rj,skew:rt,skewX:rt,skewY:rt,distance:rv,translateX:rv,translateY:rv,translateZ:rv,x:rv,y:rv,z:rv,perspective:rv,transformPerspective:rv,opacity:ri,originX:ry,originY:ry,originZ:rv,zIndex:rN,fillOpacity:ri,strokeOpacity:ri,numOctaves:rN},rP={...rO,color:rA,backgroundColor:rA,outlineColor:rA,fill:rA,stroke:rA,borderColor:rA,borderTopColor:rA,borderRightColor:rA,borderBottomColor:rA,borderLeftColor:rA,filter:rL,WebkitFilter:rL,mask:rM,WebkitMask:rM},rQ=a=>rP[a],rR=()=>({translate:0,scale:1,origin:0,originPoint:0}),rS=()=>({x:rR(),y:rR()}),rT=()=>({min:0,max:0}),rU=()=>({x:rT(),y:rT()}),rV=a=>!!(a&&a.getVelocity),rW=new Set(["width","height","top","left","right","bottom",...re]),rX=a=>b=>b.test(a),rY=[rh,rv,ru,rt,rx,rw,{test:a=>"auto"===a,parse:a=>a}],rZ=a=>rY.find(rX(a)),r$=()=>{},r_=()=>{},r0=a=>b=>"string"==typeof b&&b.startsWith(a),r1=r0("--"),r2=r0("var(--"),r3=a=>!!r2(a)&&r4.test(a.split("/*")[0].trim()),r4=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function r5(a){return"string"==typeof a&&a.split("/*")[0].includes("var(--")}let r6=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u,r7=a=>180*a/Math.PI,r8=a=>sa(r7(Math.atan2(a[1],a[0]))),r9={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:a=>(Math.abs(a[0])+Math.abs(a[3]))/2,rotate:r8,rotateZ:r8,skewX:a=>r7(Math.atan(a[1])),skewY:a=>r7(Math.atan(a[2])),skew:a=>(Math.abs(a[1])+Math.abs(a[2]))/2},sa=a=>((a%=360)<0&&(a+=360),a),sb=a=>Math.sqrt(a[0]*a[0]+a[1]*a[1]),sc=a=>Math.sqrt(a[4]*a[4]+a[5]*a[5]),sd={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:sb,scaleY:sc,scale:a=>(sb(a)+sc(a))/2,rotateX:a=>sa(r7(Math.atan2(a[6],a[5]))),rotateY:a=>sa(r7(Math.atan2(-a[2],a[0]))),rotateZ:r8,rotate:r8,skewX:a=>r7(Math.atan(a[4])),skewY:a=>r7(Math.atan(a[1])),skew:a=>(Math.abs(a[1])+Math.abs(a[4]))/2};function se(a){return+!!a.includes("scale")}function sf(a,b){let c,d;if(!a||"none"===a)return se(b);let e=a.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);if(e)c=sd,d=e;else{let b=a.match(/^matrix\(([-\d.e\s,]+)\)$/u);c=r9,d=b}if(!d)return se(b);let f=c[b],g=d[1].split(",").map(sg);return"function"==typeof f?f(g):g[f]}function sg(a){return parseFloat(a.trim())}let sh=a=>a===rh||a===rv,si=new Set(["x","y","z"]),sj=re.filter(a=>!si.has(a)),sk={width:({x:a},{paddingLeft:b="0",paddingRight:c="0",boxSizing:d})=>{let e=a.max-a.min;return"border-box"===d?e:e-parseFloat(b)-parseFloat(c)},height:({y:a},{paddingTop:b="0",paddingBottom:c="0",boxSizing:d})=>{let e=a.max-a.min;return"border-box"===d?e:e-parseFloat(b)-parseFloat(c)},top:(a,{top:b})=>parseFloat(b),left:(a,{left:b})=>parseFloat(b),bottom:({y:a},{top:b})=>parseFloat(b)+(a.max-a.min),right:({x:a},{left:b})=>parseFloat(b)+(a.max-a.min),x:(a,{transform:b})=>sf(b,"x"),y:(a,{transform:b})=>sf(b,"y")};sk.translateX=sk.x,sk.translateY=sk.y;let sl=a=>a,sm={},sn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function so(a,b){let c=!1,d=!0,e={delta:0,timestamp:0,isProcessing:!1},f=()=>c=!0,g=sn.reduce((a,b)=>(a[b]=function(a){let b=new Set,c=new Set,d=!1,e=!1,f=new WeakSet,g={delta:0,timestamp:0,isProcessing:!1};function h(b){f.has(b)&&(i.schedule(b),a()),b(g)}let i={schedule:(a,e=!1,g=!1)=>{let h=g&&d?b:c;return e&&f.add(a),h.add(a),a},cancel:a=>{c.delete(a),f.delete(a)},process:a=>{if(g=a,d){e=!0;return}d=!0;let f=b;b=c,c=f,b.forEach(h),b.clear(),d=!1,e&&(e=!1,i.process(a))}};return i}(f),a),{}),{setup:h,read:i,resolveKeyframes:j,preUpdate:k,update:l,preRender:m,render:n,postRender:o}=g,p=()=>{let f=sm.useManualTiming,g=f?e.timestamp:performance.now();c=!1,f||(e.delta=d?1e3/60:Math.max(Math.min(g-e.timestamp,40),1)),e.timestamp=g,e.isProcessing=!0,h.process(e),i.process(e),j.process(e),k.process(e),l.process(e),m.process(e),n.process(e),o.process(e),e.isProcessing=!1,c&&b&&(d=!1,a(p))};return{schedule:sn.reduce((b,f)=>{let h=g[f];return b[f]=(b,f=!1,g=!1)=>(!c&&(c=!0,d=!0,e.isProcessing||a(p)),h.schedule(b,f,g)),b},{}),cancel:a=>{for(let b=0;b<sn.length;b++)g[sn[b]].cancel(a)},state:e,steps:g}}let{schedule:sp,cancel:sq,state:sr,steps:ss}=so("u">typeof requestAnimationFrame?requestAnimationFrame:sl,!0),st=new Set,su=!1,sv=!1,sw=!1;function sx(){if(sv){let a=Array.from(st).filter(a=>a.needsMeasurement),b=new Set(a.map(a=>a.element)),c=new Map;b.forEach(a=>{let b,d=(b=[],sj.forEach(c=>{let d=a.getValue(c);void 0!==d&&(b.push([c,d.get()]),d.set(+!!c.startsWith("scale")))}),b);d.length&&(c.set(a,d),a.render())}),a.forEach(a=>a.measureInitialState()),b.forEach(a=>{a.render();let b=c.get(a);b&&b.forEach(([b,c])=>{a.getValue(b)?.set(c)})}),a.forEach(a=>a.measureEndState()),a.forEach(a=>{void 0!==a.suspendedScrollY&&window.scrollTo(0,a.suspendedScrollY)})}sv=!1,su=!1,st.forEach(a=>a.complete(sw)),st.clear()}function sy(){st.forEach(a=>{a.readKeyframes(),a.needsMeasurement&&(sv=!0)})}class sz{constructor(a,b,c,d,e,f=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...a],this.onComplete=b,this.name=c,this.motionValue=d,this.element=e,this.isAsync=f}scheduleResolve(){this.state="scheduled",this.isAsync?(st.add(this),su||(su=!0,sp.read(sy),sp.resolveKeyframes(sx))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:a,name:b,element:c,motionValue:d}=this;if(null===a[0]){let e=d?.get(),f=a[a.length-1];if(void 0!==e)a[0]=e;else if(c&&b){let d=c.readValue(b,f);null!=d&&(a[0]=d)}void 0===a[0]&&(a[0]=f),d&&void 0===e&&d.set(a[0])}for(let b=1;b<a.length;b++)a[b]??(a[b]=a[b-1])}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(a=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,a),st.delete(this)}cancel(){"scheduled"===this.state&&(st.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}let sA=new Set([rL,rM]);function sB(a,b){let c=rQ(a);return sA.has(c)||(c=rH),c.getAnimatableNone?c.getAnimatableNone(b):void 0}let sC=new Set(["auto","none","0"]);class sD extends sz{constructor(a,b,c,d,e){super(a,b,c,d,e,!0)}readKeyframes(){let{unresolvedKeyframes:a,element:b,name:c}=this;if(!b||!b.current)return;super.readKeyframes();for(let c=0;c<a.length;c++){let d=a[c];if("string"==typeof d&&r3(d=d.trim())){let e=function a(b,c,d=1){r_(`Max CSS variable fallback depth detected in property "${b}". This may indicate a circular fallback dependency.`);let[e,f]=function(a){let b=r6.exec(a);if(!b)return[,];let[,c,d,e]=b;return[`--${c??d}`,e]}(b);if(!e)return;let g=window.getComputedStyle(c).getPropertyValue(e);if(g){let a=g.trim();return/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(a)?parseFloat(a):a}return r3(f)?a(f,c,d+1):f}(d,b.current);void 0!==e&&(a[c]=e),c===a.length-1&&(this.finalKeyframe=d)}}if(this.resolveNoneKeyframes(),!rW.has(c)||2!==a.length)return;let[d,e]=a,f=rZ(d),g=rZ(e);if(r5(d)!==r5(e)&&sk[c]){this.needsMeasurement=!0;return}if(f!==g)if(sh(f)&&sh(g))for(let b=0;b<a.length;b++){let c=a[b];"string"==typeof c&&(a[b]=parseFloat(c))}else sk[c]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:a,name:b}=this,c=[];for(let b=0;b<a.length;b++)(null===a[b]||function(a){if("number"==typeof a)return 0===a;if(null===a)return!0;return"none"===a||"0"===a||/^0[^.\s]+$/u.test(a)}(a[b]))&&c.push(b);c.length&&function(a,b,c){let d,e=0;for(;e<a.length&&!d;){let b=a[e];"string"==typeof b&&!sC.has(b)&&rF(b).values.length&&(d=a[e]),e++}if(d&&c)for(let e of b)a[e]=sB(c,d)}(a,c,b)}measureInitialState(){let{element:a,unresolvedKeyframes:b,name:c}=this;if(!a||!a.current)return;"height"===c&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=sk[c](a.measureViewportBox(),window.getComputedStyle(a.current)),b[0]=this.measuredOrigin;let d=b[b.length-1];void 0!==d&&a.getValue(c,d).jump(d,!1)}measureEndState(){let{element:a,name:b,unresolvedKeyframes:c}=this;if(!a||!a.current)return;let d=a.getValue(b);d&&d.jump(this.measuredOrigin,!1);let e=c.length-1,f=c[e];c[e]=sk[b](a.measureViewportBox(),window.getComputedStyle(a.current)),null!==f&&void 0===this.finalKeyframe&&(this.finalKeyframe=f),this.removedTransforms?.length&&this.removedTransforms.forEach(([b,c])=>{a.getValue(b).set(c)}),this.resolveNoneKeyframes()}}let sE=a=>1e3*a;function sF(a,b){-1===a.indexOf(b)&&a.push(b)}function sG(a,b){let c=a.indexOf(b);c>-1&&a.splice(c,1)}class sH{constructor(){this.subscriptions=[]}add(a){return sF(this.subscriptions,a),()=>sG(this.subscriptions,a)}notify(a,b,c){let d=this.subscriptions.length;if(d)if(1===d)this.subscriptions[0](a,b,c);else for(let e=0;e<d;e++){let d=this.subscriptions[e];d&&d(a,b,c)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function sI(a,b,c){b.startsWith("--")?a.style.setProperty(b,c):a.style[b]=c}function sJ(a){let b;return()=>(void 0===b&&(b=a()),b)}let sK={};function sL(a,b){let c=sJ(a);return()=>sK[b]??c()}let sM=sL(()=>void 0!==window.ScrollTimeline,"scrollTimeline"),sN=a=>null!==a;function sO(a,{repeat:b,repeatType:c="loop"},d,e=1){let f=a.filter(sN),g=e<0||b&&"loop"!==c&&b%2==1?0:f.length-1;return g&&void 0!==d?d:f[g]}class sP{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(a=>{this.resolve=a})}notifyFinished(){this.resolve()}then(a,b){return this.finished.then(a,b)}}let sQ=a=>Array.isArray(a)&&"number"==typeof a[0],sR=sL(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(a){return!1}return!0},"linearEasing"),sS=(a,b,c=10)=>{let d="",e=Math.max(Math.round(b/c),2);for(let b=0;b<e;b++)d+=Math.round(1e4*a(b/(e-1)))/1e4+", ";return`linear(${d.substring(0,d.length-2)})`},sT=([a,b,c,d])=>`cubic-bezier(${a}, ${b}, ${c}, ${d})`,sU={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:sT([0,.65,.55,1]),circOut:sT([.55,0,1,.45]),backIn:sT([.31,.01,.66,-.59]),backOut:sT([.33,1.53,.69,.99])};function sV(a){return"function"==typeof a&&"applyToOptions"in a}class sW extends sP{constructor(a){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!a)return;const{element:b,name:c,keyframes:d,pseudoElement:e,allowFlatten:f=!1,finalKeyframe:g,onComplete:h}=a;this.isPseudoElement=!!e,this.allowFlatten=f,this.options=a,r_(a.type);const i=function({type:a,...b}){return sV(a)&&sR()?a.applyToOptions(b):(b.duration??(b.duration=300),b.ease??(b.ease="easeOut"),b)}(a);this.animation=function(a,b,c,{delay:d=0,duration:e=300,repeat:f=0,repeatType:g="loop",ease:h="easeOut",times:i}={},j){let k={[b]:c};i&&(k.offset=i);let l=function a(b,c){if(b)return"function"==typeof b?sR()?sS(b,c):"ease-out":sQ(b)?sT(b):Array.isArray(b)?b.map(b=>a(b,c)||sU.easeOut):sU[b]}(h,e);Array.isArray(l)&&(k.easing=l);let m={delay:d,duration:e,easing:Array.isArray(l)?"linear":l,fill:"both",iterations:f+1,direction:"reverse"===g?"alternate":"normal"};return j&&(m.pseudoElement=j),a.animate(k,m)}(b,c,d,i,e),!1===i.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!e){let a=sO(d,this.options,g,this.speed);this.updateMotionValue&&this.updateMotionValue(a),sI(b,c,a),this.animation.cancel()}h?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(a){}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:a}=this;"idle"!==a&&"finished"!==a&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let a=this.options?.element;!this.isPseudoElement&&a?.isConnected&&this.animation.commitStyles?.()}get duration(){return Number(this.animation.effect?.getComputedTiming?.().duration||0)/1e3}get iterationDuration(){let{delay:a=0}=this.options||{};return this.duration+a/1e3}get time(){return(Number(this.animation.currentTime)||0)/1e3}set time(a){let b=null!==this.finishedTime;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=sE(a),b&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(a){a<0&&(this.finishedTime=null),this.animation.playbackRate=a}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(a){this.manualStartTime=this.animation.startTime=a}attachTimeline({timeline:a,rangeStart:b,rangeEnd:c,observe:d}){return(this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,a&&sM())?(this.animation.timeline=a,b&&(this.animation.rangeStart=b),c&&(this.animation.rangeEnd=c),sl):d(this)}}let sX=new Set(["opacity","clipPath","filter","transform","backgroundColor"]),{schedule:sY}=so(queueMicrotask,!1);function sZ(){d=void 0}let s$={now:()=>(void 0===d&&s$.set(sr.isProcessing||sm.useManualTiming?sr.timestamp:performance.now()),d),set:a=>{d=a,queueMicrotask(sZ)}},s_=(a,b)=>b?1e3/b*a:0,s0;class s1{constructor(a,b={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=a=>{let b=s$.now();if(this.updatedAt!==b&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(a),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(a),this.owner=b.owner}setCurrent(a){this.current=a,this.updatedAt=s$.now(),null===this.canTrackVelocity&&void 0!==a&&(this.canTrackVelocity=!isNaN(parseFloat(this.current)))}setPrevFrameValue(a=this.current){this.prevFrameValue=a,this.prevUpdatedAt=this.updatedAt}onChange(a){return this.on("change",a)}on(a,b){this.events[a]||(this.events[a]=new sH);let c=this.events[a].add(b);return"change"===a?()=>{c(),sp.read(()=>{this.events.change.getSize()||this.stop()})}:c}clearListeners(){for(let a in this.events)this.events[a].clear()}attach(a,b){this.passiveEffect=a,this.stopPassiveEffect=b}set(a){this.passiveEffect?this.passiveEffect(a,this.updateAndNotify):this.updateAndNotify(a)}setWithVelocity(a,b,c){this.set(b),this.prev=void 0,this.prevFrameValue=a,this.prevUpdatedAt=this.updatedAt-c}jump(a,b=!0){this.updateAndNotify(a),this.prev=a,this.prevUpdatedAt=this.prevFrameValue=void 0,b&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(a){this.dependents||(this.dependents=new Set),this.dependents.add(a)}removeDependent(a){this.dependents&&this.dependents.delete(a)}get(){return s0&&s0.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let a=s$.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||a-this.updatedAt>30)return 0;let b=Math.min(this.updatedAt-this.prevUpdatedAt,30);return s_(parseFloat(this.current)-parseFloat(this.prevFrameValue),b)}start(a){return this.stop(),new Promise(b=>{this.hasAnimated=!0,this.animation=a(b),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function s2(a,b){return new s1(a,b)}let s3=[...rY,rA,rH],s4=new WeakMap;function s5(a){return null!==a&&"object"==typeof a&&"function"==typeof a.start}function s6(a){return"string"==typeof a||Array.isArray(a)}let s7=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],s8=["initial",...s7];function s9(a){return s5(a.animate)||s8.some(b=>s6(a[b]))}function ta(a){return!!(s9(a)||a.variants)}let tb={current:null},tc={current:!1},td="u">typeof window;function te(){if(tc.current=!0,td)if(window.matchMedia){let a=window.matchMedia("(prefers-reduced-motion)"),b=()=>tb.current=a.matches;a.addEventListener("change",b),b()}else tb.current=!1}function tf(a){let b=[{},{}];return a?.values.forEach((a,c)=>{b[0][c]=a.get(),b[1][c]=a.getVelocity()}),b}function tg(a,b,c,d){if("function"==typeof b){let[e,f]=tf(d);b=b(void 0!==c?c:a.custom,e,f)}if("string"==typeof b&&(b=a.variants&&a.variants[b]),"function"==typeof b){let[e,f]=tf(d);b=b(void 0!==c?c:a.custom,e,f)}return b}let th=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],ti={};class tj{scrapeMotionValuesFromProps(a,b,c){return{}}constructor({parent:a,props:b,presenceContext:c,reducedMotionConfig:d,skipAnimations:e,blockInitialAnimation:f,visualState:g},h={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=sz,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let a=s$.now();this.renderScheduledAt<a&&(this.renderScheduledAt=a,sp.render(this.render,!1,!0))};const{latestValues:i,renderState:j}=g;this.latestValues=i,this.baseTarget={...i},this.initialValues=b.initial?{...i}:{},this.renderState=j,this.parent=a,this.props=b,this.presenceContext=c,this.depth=a?a.depth+1:0,this.reducedMotionConfig=d,this.skipAnimationsConfig=e,this.options=h,this.blockInitialAnimation=!!f,this.isControllingVariants=s9(b),this.isVariantNode=ta(b),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(a&&a.current);const{willChange:k,...l}=this.scrapeMotionValuesFromProps(b,{},this);for(const a in l){const b=l[a];void 0!==i[a]&&rV(b)&&b.set(i[a])}}mount(a){if(this.hasBeenMounted)for(let a in this.initialValues)this.values.get(a)?.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=a,s4.set(a,this),this.projection&&!this.projection.instance&&this.projection.mount(a),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,b)=>this.bindToMotionValue(b,a)),"never"===this.reducedMotionConfig?this.shouldReduceMotion=!1:"always"===this.reducedMotionConfig?this.shouldReduceMotion=!0:(tc.current||te(),this.shouldReduceMotion=tb.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){for(let a in this.projection&&this.projection.unmount(),sq(this.notifyUpdate),sq(this.render),this.valueSubscriptions.forEach(a=>a()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this),this.events)this.events[a].clear();for(let a in this.features){let b=this.features[a];b&&(b.unmount(),b.isMounted=!1)}this.current=null}addChild(a){this.children.add(a),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(a)}removeChild(a){this.children.delete(a),this.enteringChildren&&this.enteringChildren.delete(a)}bindToMotionValue(a,b){let c;if(this.valueSubscriptions.has(a)&&this.valueSubscriptions.get(a)(),b.accelerate&&sX.has(a)&&this.current instanceof HTMLElement){let{factory:c,keyframes:d,times:e,ease:f,duration:g}=b.accelerate,h=new sW({element:this.current,name:a,keyframes:d,times:e,ease:f,duration:sE(g)}),i=c(h);this.valueSubscriptions.set(a,()=>{i(),h.cancel()});return}let d=rf.has(a);d&&this.onBindTransform&&this.onBindTransform();let e=b.on("change",b=>{this.latestValues[a]=b,this.props.onUpdate&&sp.preRender(this.notifyUpdate),d&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});"u">typeof window&&window.MotionCheckAppearSync&&(c=window.MotionCheckAppearSync(this,a,b)),this.valueSubscriptions.set(a,()=>{e(),c&&c()})}sortNodePosition(a){return this.current&&this.sortInstanceNodePosition&&this.type===a.type?this.sortInstanceNodePosition(this.current,a.current):0}updateFeatures(){let a="animation";for(a in ti){let b=ti[a];if(!b)continue;let{isEnabled:c,Feature:d}=b;if(!this.features[a]&&d&&c(this.props)&&(this.features[a]=new d(this)),this.features[a]){let b=this.features[a];b.isMounted?b.update():(b.mount(),b.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):rU()}getStaticValue(a){return this.latestValues[a]}setStaticValue(a,b){this.latestValues[a]=b}update(a,b){(a.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=a,this.prevPresenceContext=this.presenceContext,this.presenceContext=b;for(let b=0;b<th.length;b++){let c=th[b];this.propEventSubscriptions[c]&&(this.propEventSubscriptions[c](),delete this.propEventSubscriptions[c]);let d=a["on"+c];d&&(this.propEventSubscriptions[c]=this.on(c,d))}this.prevMotionValues=function(a,b,c){for(let d in b){let e=b[d],f=c[d];if(rV(e))a.addValue(d,e);else if(rV(f))a.addValue(d,s2(e,{owner:a}));else if(f!==e)if(a.hasValue(d)){let b=a.getValue(d);!0===b.liveStyle?b.jump(e):b.hasAnimated||b.set(e)}else{let b=a.getStaticValue(d);a.addValue(d,s2(void 0!==b?b:e,{owner:a}))}}for(let d in c)void 0===b[d]&&a.removeValue(d);return b}(this,this.scrapeMotionValuesFromProps(a,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(a){return this.props.variants?this.props.variants[a]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(a){let b=this.getClosestVariantNode();if(b)return b.variantChildren&&b.variantChildren.add(a),()=>b.variantChildren.delete(a)}addValue(a,b){let c=this.values.get(a);b!==c&&(c&&this.removeValue(a),this.bindToMotionValue(a,b),this.values.set(a,b),this.latestValues[a]=b.get())}removeValue(a){this.values.delete(a);let b=this.valueSubscriptions.get(a);b&&(b(),this.valueSubscriptions.delete(a)),delete this.latestValues[a],this.removeValueFromRenderState(a,this.renderState)}hasValue(a){return this.values.has(a)}getValue(a,b){if(this.props.values&&this.props.values[a])return this.props.values[a];let c=this.values.get(a);return void 0===c&&void 0!==b&&(c=s2(null===b?void 0:b,{owner:this}),this.addValue(a,c)),c}readValue(a,b){let c=void 0===this.latestValues[a]&&this.current?this.getBaseTargetFromProps(this.props,a)??this.readValueFromInstance(this.current,a,this.options):this.latestValues[a];if(null!=c){let d,e;if("string"==typeof c&&(d=c,/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(d)||(e=c,/^0[^.\s]+$/u.test(e))))c=parseFloat(c);else{let d;d=c,!s3.find(rX(d))&&rH.test(b)&&(c=sB(a,b))}this.setBaseTarget(a,rV(c)?c.get():c)}return rV(c)?c.get():c}setBaseTarget(a,b){this.baseTarget[a]=b}getBaseTarget(a){let b,{initial:c}=this.props;if("string"==typeof c||"object"==typeof c){let d=tg(this.props,c,this.presenceContext?.custom);d&&(b=d[a])}if(c&&void 0!==b)return b;let d=this.getBaseTargetFromProps(this.props,a);return void 0===d||rV(d)?void 0!==this.initialValues[a]&&void 0===b?void 0:this.baseTarget[a]:d}on(a,b){return this.events[a]||(this.events[a]=new sH),this.events[a].add(b)}notify(a,...b){this.events[a]&&this.events[a].notify(...b)}scheduleRenderMicrotask(){sY.render(this.render)}}class tk extends tj{constructor(){super(...arguments),this.KeyframeResolver=sD}sortInstanceNodePosition(a,b){return 2&a.compareDocumentPosition(b)?1:-1}getBaseTargetFromProps(a,b){let c=a.style;return c?c[b]:void 0}removeValueFromRenderState(a,{vars:b,style:c}){delete b[a],delete c[a]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:a}=this.props;rV(a)&&(this.childSubscription=a.on("change",a=>{this.current&&(this.current.textContent=`${a}`)}))}}function tl(a){return a.replace(/([A-Z])/g,a=>`-${a.toLowerCase()}`)}let tm=(a,b)=>b&&"number"==typeof a?b.transform(a):a,tn={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},to=re.length;function tp(a,b,c){let{style:d,vars:e,transformOrigin:f}=a,g=!1,h=!1;for(let a in b){let c=b[a];if(rf.has(a)){g=!0;continue}if(r1(a)){e[a]=c;continue}{let b=tm(c,rO[a]);a.startsWith("origin")?(h=!0,f[a]=b):d[a]=b}}if(!b.transform&&(g||c?d.transform=function(a,b,c){let d="",e=!0;for(let f=0;f<to;f++){let g=re[f],h=a[g];if(void 0===h)continue;let i=!0;if("number"==typeof h)i=h===+!!g.startsWith("scale");else{let a=parseFloat(h);i=g.startsWith("scale")?1===a:0===a}if(!i||c){let a=tm(h,rO[g]);if(!i){e=!1;let b=tn[g]||g;d+=`${b}(${a}) `}c&&(b[g]=a)}}let f=a.pathRotation;return f&&(e=!1,d+=`rotate(${tm(f,rO.pathRotation)}) `),d=d.trim(),c?d=c(b,e?"":d):e&&(d="none"),d}(b,a.transform,c):d.transform&&(d.transform="none")),h){let{originX:a="50%",originY:b="50%",originZ:c=0}=f;d.transformOrigin=`${a} ${b} ${c}`}}let tq={offset:"stroke-dashoffset",array:"stroke-dasharray"},tr={offset:"strokeDashoffset",array:"strokeDasharray"},ts=["transform","opacity","offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function tt(a,{attrX:b,attrY:c,attrScale:d,pathLength:e,pathSpacing:f=1,pathOffset:g=0,...h},i,j,k){if(tp(a,h,j),i){a.style.viewBox&&(a.attrs.viewBox=a.style.viewBox);return}a.attrs=a.style,a.style={};let{attrs:l,style:m}=a;for(let a of ts)void 0!==l[a]&&(m[a]=l[a],delete l[a]);(m.transform||l.transformOrigin)&&(m.transformOrigin=l.transformOrigin??"50% 50%",delete l.transformOrigin),m.transform&&(m.transformBox=k?.transformBox??"fill-box",delete l.transformBox),void 0!==b&&(l.x=b),void 0!==c&&(l.y=c),void 0!==d&&(l.scale=d),void 0!==e&&function(a,b,c=1,d=0,e=!0){a.pathLength=1;let f=e?tq:tr;a[f.offset]=`${-d}`,a[f.array]=`${b} ${c}`}(l,e,f,g,!1)}let tu=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),tv=a=>"string"==typeof a&&"svg"===a.toLowerCase();function tw(a,{style:b,vars:c},d,e){let f,g=a.style;for(f in b)g[f]=b[f];for(f in e?.applyProjectionStyles(g,d),c)g.setProperty(f,c[f])}let tx=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function ty(a,b){return b.max===b.min?0:a/(b.max-b.min)*100}let tz={correct:(a,b)=>{if(!b.target)return a;if("string"==typeof a)if(!rv.test(a))return a;else a=parseFloat(a);let c=ty(a,b.target.x),d=ty(a,b.target.y);return`${c}% ${d}%`}},tA=(a,b,c)=>a+(b-a)*c,tB={borderRadius:{...tz,applyTo:[...tx]},borderTopLeftRadius:tz,borderTopRightRadius:tz,borderBottomLeftRadius:tz,borderBottomRightRadius:tz,boxShadow:{correct:(a,{treeScale:b,projectionDelta:c})=>{let d=rH.parse(a);if(d.length>5)return a;let e=rH.createTransformer(a),f=+("number"!=typeof d[0]),g=c.x.scale*b.x,h=c.y.scale*b.y;d[0+f]/=g,d[1+f]/=h;let i=tA(g,h,.5);return"number"==typeof d[2+f]&&(d[2+f]/=i),"number"==typeof d[3+f]&&(d[3+f]/=i),e(d)}}};function tC(a,{layout:b,layoutId:c}){return rf.has(a)||a.startsWith("origin")||(b||void 0!==c)&&(!!tB[a]||"opacity"===a)}function tD(a,b,c){let d=a.style,e=b?.style,f={};if(!d)return f;for(let b in d)(rV(d[b])||e&&rV(e[b])||tC(b,a)||c?.getValue(b)?.liveStyle!==void 0)&&(f[b]=d[b]);return f}function tE(a,b,c){let d=tD(a,b,c);for(let c in a)(rV(a[c])||rV(b[c]))&&(d[-1!==re.indexOf(c)?"attr"+c.charAt(0).toUpperCase()+c.substring(1):c]=a[c]);return d}class tF extends tk{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=rU}getBaseTargetFromProps(a,b){return a[b]}readValueFromInstance(a,b){if(rf.has(b)){let a=rQ(b);return a&&a.default||0}if(ts.includes(b)){let c=getComputedStyle(a)[b];if("string"==typeof c&&c)return c.trim()}return b=tu.has(b)?b:tl(b),a.getAttribute(b)}scrapeMotionValuesFromProps(a,b,c){return tE(a,b,c)}build(a,b,c){tt(a,b,this.isSVGTag,c.transformTemplate,c.style)}renderInstance(a,b,c,d){for(let c in tw(a,b,void 0,d),b.attrs)a.setAttribute(tu.has(c)?c:tl(c),b.attrs[c])}mount(a){this.isSVGTag=tv(a.tagName),super.mount(a)}}function tG({top:a,left:b,right:c,bottom:d}){return{x:{min:b,max:c},y:{min:a,max:d}}}function tH(a){return void 0===a||1===a}function tI({scale:a,scaleX:b,scaleY:c}){return!tH(a)||!tH(b)||!tH(c)}function tJ(a){return tI(a)||tK(a)||a.z||a.rotate||a.rotateX||a.rotateY||a.skewX||a.skewY}function tK(a){var b,c;return(b=a.x)&&"0%"!==b||(c=a.y)&&"0%"!==c}function tL(a,b,c,d,e){return void 0!==e&&(a=d+e*(a-d)),d+c*(a-d)+b}function tM(a,b=0,c=1,d,e){a.min=tL(a.min,b,c,d,e),a.max=tL(a.max,b,c,d,e)}function tN(a,{x:b,y:c}){tM(a.x,b.translate,b.scale,b.originPoint),tM(a.y,c.translate,c.scale,c.originPoint)}function tO(a,b){a.min+=b,a.max+=b}function tP(a,b,c,d,e=.5){let f=tA(a.min,a.max,e);tM(a,b,c,f,d)}function tQ(a,b){return"string"==typeof a?parseFloat(a)/100*(b.max-b.min):a}function tR(a,b,c){let d=c??a;tP(a.x,tQ(b.x,d.x),b.scaleX,b.scale,b.originX),tP(a.y,tQ(b.y,d.y),b.scaleY,b.scale,b.originY)}function tS(a,b){return tG(function(a,b){if(!b)return a;let c=b({x:a.left,y:a.top}),d=b({x:a.right,y:a.bottom});return{top:c.y,left:c.x,bottom:d.y,right:d.x}}(a.getBoundingClientRect(),b))}class tT extends tk{constructor(){super(...arguments),this.type="html",this.renderInstance=tw}mount(a){r_(a.style),super.mount(a)}readValueFromInstance(a,b){if(rf.has(b))return this.projection?.isProjecting?se(b):((a,b)=>{let{transform:c="none"}=getComputedStyle(a);return sf(c,b)})(a,b);{let c=window.getComputedStyle(a),d=(r1(b)?c.getPropertyValue(b):c[b])||0;return"string"==typeof d?d.trim():d}}measureInstanceViewportBox(a,{transformPagePoint:b}){return tS(a,b)}build(a,b,c){tp(a,b,c.transformTemplate)}scrapeMotionValuesFromProps(a,b,c){return tD(a,b,c)}}let tU=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function tV(a){if("string"!=typeof a||a.includes("-"));else if(tU.indexOf(a)>-1||/[A-Z]/u.test(a))return!0;return!1}let tW=(0,B.createContext)({}),tX=(0,B.createContext)({transformPagePoint:a=>a,isStatic:!1,reducedMotion:"never"}),tY=(0,B.createContext)({});function tZ(a){return Array.isArray(a)?a.join(" "):a}let t$=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function t_(a,b,c){for(let d in b)rV(b[d])||tC(d,c)||(a[d]=b[d])}let t0=()=>({...t$(),attrs:{}}),t1=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function t2(a){return a.startsWith("while")||a.startsWith("drag")&&"draggable"!==a||a.startsWith("layout")||a.startsWith("onTap")||a.startsWith("onPan")||a.startsWith("onLayout")||t1.has(a)}function t3(a){return rV(a)?a.get():a}let t4=(0,B.createContext)(null);function t5(a){let b=(0,B.useRef)(null);return null===b.current&&(b.current=a()),b.current}let t6=a=>(b,c)=>{let d=(0,B.useContext)(tY),e=(0,B.useContext)(t4),f=()=>(function({scrapeMotionValuesFromProps:a,createRenderState:b},c,d,e){return{latestValues:function(a,b,c,d){let e={},f=d(a,{});for(let a in f)e[a]=t3(f[a]);let{initial:g,animate:h}=a,i=s9(a),j=ta(a);b&&j&&!i&&!1!==a.inherit&&(void 0===g&&(g=b.initial),void 0===h&&(h=b.animate));let k=!!c&&!1===c.initial,l=(k=k||!1===g)?h:g;if(l&&"boolean"!=typeof l&&!s5(l)){let b=Array.isArray(l)?l:[l];for(let c=0;c<b.length;c++){let d=tg(a,b[c]);if(d){let{transitionEnd:a,transition:b,...c}=d;for(let a in c){let b=c[a];if(Array.isArray(b)){let a=k?b.length-1:0;b=b[a]}null!==b&&(e[a]=b)}for(let b in a)e[b]=a[b]}}}return e}(c,d,e,a),renderState:b()}})(a,b,d,e);return c?f():t5(f)},t7=t6({scrapeMotionValuesFromProps:tD,createRenderState:t$}),t8=t6({scrapeMotionValuesFromProps:tE,createRenderState:t0}),t9={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},ua=!1,ub=Symbol.for("motionComponentSymbol");function uc(a,{forwardMotionProps:b=!1,type:c}={},d,e){d&&function(a){let b=(!function(){if(ua)return;let a={};for(let b in t9)a[b]={isEnabled:a=>t9[b].some(b=>!!a[b])};ti=a,ua=!0}(),ti);for(let c in a)b[c]={...b[c],...a[c]};ti=b}(d);let f=c?"svg"===c:tV(a),g=f?t8:t7;function h(c,d){var e;let h,i,j,k={...(0,B.useContext)(tX),...c,layoutId:function({layoutId:a}){let b=(0,B.useContext)(tW).id;return b&&void 0!==a?b+"-"+a:a}(c)},{isStatic:l,isValidProp:m}=k,n=function(a){let{initial:b,animate:c}=function(a,b){if(s9(a)){let{initial:b,animate:c}=a;return{initial:!1===b||s6(b)?b:void 0,animate:s6(c)?c:void 0}}return!1!==a.inherit?b:{}}(a,(0,B.useContext)(tY));return(0,B.useMemo)(()=>({initial:b,animate:c}),[tZ(b),tZ(c)])}(c),o=g(c,l);return(0,A.jsxs)(tY.Provider,{value:n,children:[h&&n.visualElement?(0,A.jsx)(h,{visualElement:n.visualElement,...k}):null,function(a,b,c,{latestValues:d},e,f=!1,g,h){let i=(g??tV(a)?function(a,b,c,d){let e=(0,B.useMemo)(()=>{let c=t0();return tt(c,b,tv(d),a.transformTemplate,a.style),{...c.attrs,style:{...c.style}}},[b]);if(a.style){let b={};t_(b,a.style,a),e.style={...b,...e.style}}return e}:function(a,b){let c,d,e={},f=(c=a.style||{},t_(d={},c,a),Object.assign(d,function({transformTemplate:a},b){return(0,B.useMemo)(()=>{let c=t$();return tp(c,b,a),Object.assign({},c.vars,c.style)},[b])}(a,b)),d);return a.drag&&!1!==a.dragListener&&(e.draggable=!1,f.userSelect=f.WebkitUserSelect=f.WebkitTouchCallout="none",f.touchAction=!0===a.drag?"none":`pan-${"x"===a.drag?"y":"x"}`),void 0===a.tabIndex&&(a.onTap||a.onTapStart||a.whileTap)&&(e.tabIndex=0),e.style=f,e})(b,d,e,a),j=function(a,b,c,d){let e={};for(let f in a)("values"!==f||"object"!=typeof a.values)&&!rV(a[f])&&((f.startsWith("on")?!t2(f):d?.(f)??!t2(f))||!0===c&&t2(f)||!b&&!t2(f)||a.draggable&&f.startsWith("onDrag"))&&(e[f]=a[f]);return e}(b,"string"==typeof a,f,h),k=a!==B.Fragment?{...j,...i,ref:c}:{},{children:l}=b,m=(0,B.useMemo)(()=>rV(l)?l.get():l,[l]);return(0,B.createElement)(a,{...k,children:m})}(a,c,(e=n.visualElement,i=(0,B.useRef)(d),(0,B.useInsertionEffect)(()=>{i.current=d}),j=(0,B.useRef)(null),(0,B.useCallback)(a=>{a&&o.onMount?.(a),e&&(a?e.mount(a):e.unmount());let b=i.current;if("function"==typeof b)if(a){let c=b(a);"function"==typeof c&&(j.current=c)}else j.current?(j.current(),j.current=null):b(a);else b&&(b.current=a)},[e])),o,l,b,f,m)]})}h.displayName=`motion.${"string"==typeof a?a:`create(${a.displayName??a.name??""})`}`;let i=(0,B.forwardRef)(h);return i[ub]=a,i}class ud{constructor(a){this.isMounted=!1,this.node=a}update(){}}function ue(a,b,c){let d=a.getProps();return tg(d,b,void 0!==c?c:d.custom,a)}function uf(a,b){if(a?.inherit&&b){let{inherit:c,...d}=a;return{...b,...d}}return a}function ug(a,b){let c=a?.[b]??a?.default??a;return c!==a?uf(c,a):c}let uh=a=>Array.isArray(a);function ui(a,b){let c=a.getValue("willChange");if(rV(c)&&c.add)return c.add(b);if(!c&&sm.WillChange){let c=new sm.WillChange("auto");a.addValue("willChange",c),c.add(b)}}let uj="data-"+tl("framerAppearId"),uk=(...a)=>a.reduce((a,b)=>c=>b(a(c)));function ul(a,b,c){return(c<0&&(c+=1),c>1&&(c-=1),c<1/6)?a+(b-a)*6*c:c<.5?b:c<2/3?a+(b-a)*(2/3-c)*6:a}function um(a,b){return c=>c>0?b:a}let un=(a,b,c)=>{let d=a*a,e=c*(b*b-d)+d;return e<0?0:Math.sqrt(e)},uo=[rr,rq,rz];function up(a){let b=uo.find(b=>b.test(a));if(r$(`'${a}' is not an animatable color. Use the equivalent color code instead.`),!b)return!1;let c=b.parse(a);return b===rz&&(c=function({hue:a,saturation:b,lightness:c,alpha:d}){a/=360,c/=100;let e=0,f=0,g=0;if(b/=100){let d=c<.5?c*(1+b):c+b-c*b,h=2*c-d;e=ul(h,d,a+1/3),f=ul(h,d,a),g=ul(h,d,a-1/3)}else e=f=g=c;return{red:Math.round(255*e),green:Math.round(255*f),blue:Math.round(255*g),alpha:d}}(c)),c}let uq=(a,b)=>{let c=up(a),d=up(b);if(!c||!d)return um(a,b);let e={...c};return a=>(e.red=un(c.red,d.red,a),e.green=un(c.green,d.green,a),e.blue=un(c.blue,d.blue,a),e.alpha=tA(c.alpha,d.alpha,a),rq.transform(e))},ur=new Set(["none","hidden"]);function us(a,b){return c=>tA(a,b,c)}function ut(a){return"number"==typeof a?us:"string"==typeof a?r3(a)?um:rA.test(a)?uq:uw:Array.isArray(a)?uu:"object"==typeof a?rA.test(a)?uq:uv:um}function uu(a,b){let c=[...a],d=c.length,e=a.map((a,c)=>ut(a)(a,b[c]));return a=>{for(let b=0;b<d;b++)c[b]=e[b](a);return c}}function uv(a,b){let c={...a,...b},d={};for(let e in c)void 0!==a[e]&&void 0!==b[e]&&(d[e]=ut(a[e])(a[e],b[e]));return a=>{for(let b in d)c[b]=d[b](a);return c}}let uw=(a,b)=>{let c=rH.createTransformer(b),d=rF(a),e=rF(b);if(!(d.indexes.var.length===e.indexes.var.length&&d.indexes.color.length===e.indexes.color.length&&d.indexes.number.length>=e.indexes.number.length))return r$(`Complex values '${a}' and '${b}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),um(a,b);if(ur.has(a)&&!e.values.length||ur.has(b)&&!d.values.length)return ur.has(a)?c=>c<=0?a:b:c=>c>=1?b:a;return uk(uu(function(a,b){let c=[],d={color:0,var:0,number:0};for(let e=0;e<b.values.length;e++){let f=b.types[e],g=a.indexes[f][d[f]],h=a.values[g]??0;c[e]=h,d[f]++}return c}(d,e),e.values),c)};function ux(a,b,c){return"number"==typeof a&&"number"==typeof b&&"number"==typeof c?tA(a,b,c):ut(a)(a,b)}let uy=a=>{let b=({timestamp:b})=>a(b);return{start:(a=!0)=>sp.update(b,a),stop:()=>sq(b),now:()=>sr.isProcessing?sr.timestamp:s$.now()}};function uz(a){let b=0,c=a.next(b);for(;!c.done&&b<2e4;)b+=50,c=a.next(b);return b>=2e4?1/0:b}let uA=.01,uB=2,uC=.005,uD=.5;function uE(a,b){return a*Math.sqrt(1-b*b)}let uF=["duration","bounce"],uG=["stiffness","damping","mass"];function uH(a,b){return b.some(b=>void 0!==a[b])}function uI(a=.3,b=.3){let c,d,e,f,g,h,i="object"!=typeof a?{visualDuration:a,keyframes:[0,1],bounce:b}:a,{restSpeed:j,restDelta:k}=i,l=i.keyframes[0],m=i.keyframes[i.keyframes.length-1],n={done:!1,value:l},{stiffness:o,damping:p,mass:q,duration:r,velocity:s,isResolvedFromDuration:t}=function(a){let b={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...a};if(!uH(a,uG)&&uH(a,uF))if(b.velocity=0,a.visualDuration){let c=2*Math.PI/(1.2*a.visualDuration),d=c*c,e=2*rg(.05,1,1-(a.bounce||0))*Math.sqrt(d);b={...b,mass:1,stiffness:d,damping:e}}else{let c=function({duration:a=800,bounce:b=.3,velocity:c=0,mass:d=1}){let e,f;r$(sE(10));let g=1-b;g=rg(.05,1,g),a=rg(.01,10,a/1e3),g<1?(e=b=>{let d=b*g,e=d*a;return .001-(d-c)/uE(b,g)*Math.exp(-e)},f=b=>{let d=b*g*a,f=Math.pow(g,2)*Math.pow(b,2)*a,h=Math.exp(-d),i=uE(Math.pow(b,2),g);return(d*c+c-f)*h*(-e(b)+.001>0?-1:1)/i}):(e=b=>-.001+Math.exp(-b*a)*((b-c)*a+1),f=b=>a*a*(c-b)*Math.exp(-b*a));let h=function(a,b,c){let d=c;for(let c=1;c<12;c++)d-=a(d)/b(d);return d}(e,f,5/a);if(a=sE(a),isNaN(h))return{stiffness:100,damping:10,duration:a};{let b=Math.pow(h,2)*d;return{stiffness:b,damping:2*g*Math.sqrt(d*b),duration:a}}}({...a,velocity:0});(b={...b,...c,mass:1}).isResolvedFromDuration=!0}return b}({...i,velocity:-((i.velocity||0)/1e3)}),u=s||0,v=p/(2*Math.sqrt(o*q)),w=m-l,x=Math.sqrt(o/q)/1e3,y=5>Math.abs(w);if(j||(j=y?uA:uB),k||(k=y?uC:uD),v<1)e=uE(x,v),f=(u+v*x*w)/e,c=a=>m-Math.exp(-v*x*a)*(f*Math.sin(e*a)+w*Math.cos(e*a)),g=v*x*f+w*e,h=v*x*w-f*e,d=a=>Math.exp(-v*x*a)*(g*Math.sin(e*a)+h*Math.cos(e*a));else if(1===v){c=a=>m-Math.exp(-x*a)*(w+(u+x*w)*a);let a=u+x*w;d=b=>Math.exp(-x*b)*(x*a*b-u)}else{let a=x*Math.sqrt(v*v-1);c=b=>{let c=Math.exp(-v*x*b),d=Math.min(a*b,300);return m-c*((u+v*x*w)*Math.sinh(d)+a*w*Math.cosh(d))/a};let b=(u+v*x*w)/a,e=v*x*b-w*a,f=v*x*w-b*a;d=b=>{let c=Math.exp(-v*x*b),d=Math.min(a*b,300);return c*(e*Math.sinh(d)+f*Math.cosh(d))}}let z={calculatedDuration:t&&r||null,velocity:a=>sE(d(a)),next:a=>{if(!t&&v<1){let b=Math.exp(-v*x*a),c=Math.sin(e*a),d=Math.cos(e*a),i=m-b*(f*c+w*d);return n.done=Math.abs(sE(b*(g*c+h*d)))<=j&&Math.abs(m-i)<=k,n.value=n.done?m:i,n}let b=c(a);return t?n.done=a>=r:n.done=Math.abs(sE(d(a)))<=j&&Math.abs(m-b)<=k,n.value=n.done?m:b,n},toString:()=>{let a=Math.min(uz(z),2e4),b=sS(b=>z.next(a*b).value,a,30);return a+"ms "+b},toTransition:()=>{}};return z}function uJ(a,b,c){let d=Math.max(b-5,0);return s_(c-a(d),b-d)}function uK({keyframes:a,velocity:b=0,power:c=.8,timeConstant:d=325,bounceDamping:e=10,bounceStiffness:f=500,modifyTarget:g,min:h,max:i,restDelta:j=.5,restSpeed:k}){let l,m,n=a[0],o={done:!1,value:n},p=c*b,q=n+p,r=void 0===g?q:g(q);r!==q&&(p=r-n);let s=a=>-p*Math.exp(-a/d),t=a=>r+s(a),u=a=>{let b=s(a),c=t(a);o.done=Math.abs(b)<=j,o.value=o.done?r:c},v=a=>{let b;if(b=o.value,void 0!==h&&b<h||void 0!==i&&b>i){var c;l=a,m=uI({keyframes:[o.value,(c=o.value,void 0===h?i:void 0===i||Math.abs(h-c)<Math.abs(i-c)?h:i)],velocity:uJ(t,a,o.value),damping:e,stiffness:f,restDelta:j,restSpeed:k})}};return v(0),{calculatedDuration:null,next:a=>{let b=!1;return(m||void 0!==l||(b=!0,u(a),v(a)),void 0!==l&&a>=l)?m.next(a-l):(b||u(a),o)}}}uI.applyToOptions=a=>{let b=function(a,b=100,c){let d=c({...a,keyframes:[0,b]}),e=Math.min(uz(d),2e4);return{type:"keyframes",ease:a=>d.next(e*a).value/b,duration:e/1e3}}(a,100,uI);return a.ease=b.ease,a.duration=sE(b.duration),a.type="keyframes",a};let uL=(a,b,c)=>(((1-3*c+3*b)*a+(3*c-6*b))*a+3*b)*a;function uM(a,b,c,d){return a===b&&c===d?sl:e=>0===e||1===e?e:uL(function(a,b,c,d,e){let f,g,h=0;do(f=uL(g=b+(c-b)/2,d,e)-a)>0?c=g:b=g;while(Math.abs(f)>1e-7&&++h<12);return g}(e,0,1,a,c),b,d)}let uN=uM(.42,0,1,1),uO=uM(0,0,.58,1),uP=uM(.42,0,.58,1),uQ=a=>b=>b<=.5?a(2*b)/2:(2-a(2*(1-b)))/2,uR=a=>b=>1-a(1-b),uS=uM(.33,1.53,.69,.99),uT=uR(uS),uU=uQ(uT),uV=a=>a>=1?1:(a*=2)<1?.5*uT(a):.5*(2-Math.pow(2,-10*(a-1))),uW=a=>1-Math.sin(Math.acos(a)),uX=uR(uW),uY=uQ(uW),uZ={linear:sl,easeIn:uN,easeInOut:uP,easeOut:uO,circIn:uW,circInOut:uY,circOut:uX,backIn:uT,backInOut:uU,backOut:uS,anticipate:uV},u$=a=>{if(sQ(a)){r_(a.length);let[b,c,d,e]=a;return uM(b,c,d,e)}return"string"==typeof a?(r_(uZ[a],`Invalid easing type '${a}'`),uZ[a]):a},u_=(a,b,c)=>{let d=b-a;return d?(c-a)/d:1};function u0({duration:a=300,keyframes:b,times:c,ease:d="easeInOut"}){var e;let f,g=Array.isArray(d)&&"number"!=typeof d[0]?d.map(u$):u$(d),h={done:!1,value:b[0]},i=function(a,b,{clamp:c=!0,ease:d,mixer:e}={}){let f=a.length;if(r_(b.length),1===f)return()=>b[0];if(2===f&&b[0]===b[1])return()=>b[1];let g=a[0]===a[1];a[0]>a[f-1]&&(a=[...a].reverse(),b=[...b].reverse());let h=function(a,b,c){let d=[],e=c||sm.mix||ux,f=a.length-1;for(let c=0;c<f;c++){let f=e(a[c],a[c+1]);b&&(f=uk(Array.isArray(b)?b[c]||sl:b,f)),d.push(f)}return d}(b,d,e),i=h.length,j=c=>{if(g&&c<a[0])return b[0];let d=0;if(i>1)for(;d<a.length-2&&!(c<a[d+1]);d++);let e=u_(a[d],a[d+1],c);return h[d](e)};return c?b=>j(rg(a[0],a[f-1],b)):j}((e=c&&c.length===b.length?c:(!function(a,b){let c=a[a.length-1];for(let d=1;d<=b;d++){let e=u_(0,b,d);a.push(tA(c,1,e))}}(f=[0],b.length-1),f),e.map(b=>b*a)),b,{ease:Array.isArray(g)?g:b.map(()=>g||uP).splice(0,b.length-1)});return{calculatedDuration:a,next:b=>(h.value=i(b),h.done=b>=a,h)}}let u1={decay:uK,inertia:uK,tween:u0,keyframes:u0,spring:uI};function u2(a){"string"==typeof a.type&&(a.type=u1[a.type])}let u3=a=>a/100;class u4 extends sP{constructor(a){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:a}=this.options;a&&a.updatedAt!==s$.now()&&this.tick(s$.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},this.options=a,this.initAnimation(),this.play(),!1===a.autoplay&&this.pause()}initAnimation(){let{options:a}=this;u2(a);let{type:b=u0,repeat:c=0,repeatDelay:d=0,repeatType:e,velocity:f=0}=a,{keyframes:g}=a,h=b||u0;h!==u0&&"number"!=typeof g[0]&&(this.mixKeyframes=uk(u3,ux(g[0],g[1])),g=[0,100]);let i=h({...a,keyframes:g});"mirror"===e&&(this.mirroredGenerator=h({...a,keyframes:[...g].reverse(),velocity:-f})),null===i.calculatedDuration&&(i.calculatedDuration=uz(i));let{calculatedDuration:j}=i;this.calculatedDuration=j,this.resolvedDuration=j+d,this.totalDuration=this.resolvedDuration*(c+1)-d,this.generator=i}updateTime(a){let b=Math.round(a-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=b}tick(a,b=!1){let c,{generator:d,totalDuration:e,mixKeyframes:f,mirroredGenerator:g,resolvedDuration:h,calculatedDuration:i}=this;if(null===this.startTime)return d.next(0);let{delay:j=0,keyframes:k,repeat:l,repeatType:m,repeatDelay:n,type:o,onUpdate:p,finalKeyframe:q}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,a):this.speed<0&&(this.startTime=Math.min(a-e/this.speed,this.startTime)),b?this.currentTime=a:this.updateTime(a);let r=this.currentTime-j*(this.playbackSpeed>=0?1:-1),s=this.playbackSpeed>=0?r<0:r>e;this.currentTime=Math.max(r,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=e);let t=this.currentTime,u=d;if(l){let a=Math.min(this.currentTime,e)/h,b=Math.floor(a),c=a%1;!c&&a>=1&&(c=1),1===c&&b--,(b=Math.min(b,l+1))%2&&("reverse"===m?(c=1-c,n&&(c-=n/h)):"mirror"===m&&(u=g)),t=rg(0,1,c)*h}s?(this.delayState.value=k[0],c=this.delayState):c=u.next(t),f&&!s&&(c.value=f(c.value));let{done:v}=c;s||null===i||(v=this.playbackSpeed>=0?this.currentTime>=e:this.currentTime<=0);let w=null===this.holdTime&&("finished"===this.state||"running"===this.state&&v);return w&&o!==uK&&(c.value=sO(k,this.options,q,this.speed)),p&&p(c.value),w&&this.finish(),c}then(a,b){return this.finished.then(a,b)}get duration(){return this.calculatedDuration/1e3}get iterationDuration(){let{delay:a=0}=this.options||{};return this.duration+a/1e3}get time(){return this.currentTime/1e3}set time(a){a=sE(a),this.currentTime=a,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=a:this.driver&&(this.startTime=this.driver.now()-a/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=a,this.tick(a))}getGeneratorVelocity(){let a=this.currentTime;if(a<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(a);let b=this.generator.next(a).value;return uJ(a=>this.generator.next(a).value,a,b)}get speed(){return this.playbackSpeed}set speed(a){let b=this.playbackSpeed!==a;b&&this.driver&&this.updateTime(s$.now()),this.playbackSpeed=a,b&&this.driver&&(this.time=this.currentTime/1e3)}play(){if(this.isStopped)return;let{driver:a=uy,startTime:b}=this.options;this.driver||(this.driver=a(a=>this.tick(a))),this.options.onPlay?.();let c=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=c):null!==this.holdTime?this.startTime=c-this.holdTime:this.startTime||(this.startTime=b??c),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(s$.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(a){return this.startTime=0,this.tick(a,!0)}attachTimeline(a){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),a.observe(this)}}let u5={anticipate:uV,backInOut:uU,circInOut:uY};class u6 extends sW{constructor(a){!function(a){"string"==typeof a.ease&&a.ease in u5&&(a.ease=u5[a.ease])}(a),u2(a),super(a),void 0!==a.startTime&&!1!==a.autoplay&&(this.startTime=a.startTime),this.options=a}updateMotionValue(a){let{motionValue:b,onUpdate:c,onComplete:d,element:e,...f}=this.options;if(!b)return;if(void 0!==a)return void b.set(a);let g=new u4({...f,autoplay:!1}),h=Math.max(10,s$.now()-this.startTime),i=rg(0,10,h-10),j=g.sample(h).value,{name:k}=this.options;e&&k&&sI(e,k,j),b.setWithVelocity(g.sample(Math.max(0,h-i)).value,j,i),g.stop()}}let u7=(a,b)=>"zIndex"!==b&&!!("number"==typeof a||Array.isArray(a)||"string"==typeof a&&(rH.test(a)||"0"===a)&&!a.startsWith("url("));function u8(a){a.duration=0,a.type="keyframes"}let u9=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/,va=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),vb=sJ(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class vc extends sP{constructor({autoplay:a=!0,delay:b=0,type:c="keyframes",repeat:d=0,repeatDelay:e=0,repeatType:f="loop",keyframes:g,name:h,motionValue:i,element:j,...k}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=s$.now();const l={autoplay:a,delay:b,type:c,repeat:d,repeatDelay:e,repeatType:f,name:h,motionValue:i,element:j,...k},m=j?.KeyframeResolver||sz;this.keyframeResolver=new m(g,(a,b,c)=>this.onKeyframesResolved(a,b,l,!c),h,i,j),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(a,b,c,d){let e;this.keyframeResolver=void 0;let{name:f,type:g,velocity:h,delay:i,isHandoff:j,onUpdate:k}=c;this.resolvedAt=s$.now();let l=!0;!function(a,b,c,d){let e=a[0];if(null===e)return!1;if("display"===b||"visibility"===b)return!0;let f=a[a.length-1],g=u7(e,b),h=u7(f,b);return r$(`You are trying to animate ${b} from "${e}" to "${f}". "${g?f:e}" is not an animatable value.`),!!g&&!!h&&(function(a){let b=a[0];if(1===a.length)return!0;for(let c=0;c<a.length;c++)if(a[c]!==b)return!0}(a)||("spring"===c||sV(c))&&d)}(a,f,g,h)&&(l=!1,(sm.instantAnimations||!i)&&k?.(sO(a,c,b)),a[0]=a[a.length-1],u8(c),c.repeat=0);let m={startTime:d?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:b,...c,keyframes:a},n=l&&!j&&function(a){let{motionValue:b,name:c,repeatDelay:d,repeatType:e,damping:f,type:g,keyframes:h}=a,i=b?.owner?.current;if(!(i instanceof HTMLElement)&&!(i instanceof SVGElement))return!1;let{onUpdate:j,transformTemplate:k}=b.owner.getProps();return vb()&&c&&(sX.has(c)||va.has(c)&&function(a){for(let b=0;b<a.length;b++)if("string"==typeof a[b]&&u9.test(a[b]))return!0;return!1}(h))&&("transform"!==c||!k)&&!j&&!d&&"mirror"!==e&&0!==f&&"inertia"!==g}(m),o=m.motionValue?.owner?.current;if(n)try{e=new u6({...m,element:o})}catch{e=new u4(m)}else e=new u4(m);e.finished.then(()=>{this.notifyFinished()}).catch(sl),this.pendingTimeline&&(this.stopTimeline=e.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=e}get finished(){return this._animation?this.animation.finished:this._finished}then(a,b){return this.finished.finally(a).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),sw=!0,sy(),sx(),sw=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(a){this.animation.time=a}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(a){this.animation.speed=a}get startTime(){return this.animation.startTime}attachTimeline(a){return this._animation?this.stopTimeline=this.animation.attachTimeline(a):this.pendingTimeline=a,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}let vd={type:"spring",stiffness:500,damping:25,restSpeed:10},ve={type:"keyframes",duration:.8},vf={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},vg=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]),vh=(a,b,c,d={},e,f)=>g=>{let h=ug(d,a)||{},i=h.delay||d.delay||0,{elapsed:j=0}=d;j-=sE(i);let k={keyframes:Array.isArray(c)?c:[null,c],ease:"easeOut",velocity:b.getVelocity(),...h,delay:-j,onUpdate:a=>{b.set(a),h.onUpdate&&h.onUpdate(a)},onComplete:()=>{g(),h.onComplete&&h.onComplete()},name:a,motionValue:b,element:f?void 0:e};!function(a){for(let b in a)if(!vg.has(b))return!0;return!1}(h)&&Object.assign(k,((a,{keyframes:b})=>b.length>2?ve:rf.has(a)?a.startsWith("scale")?{type:"spring",stiffness:550,damping:0===b[1]?2*Math.sqrt(550):30,restSpeed:10}:vd:vf)(a,k)),k.duration&&(k.duration=sE(k.duration)),k.repeatDelay&&(k.repeatDelay=sE(k.repeatDelay)),void 0!==k.from&&(k.keyframes[0]=k.from);let l=!1;if(!1!==k.type&&(0!==k.duration||k.repeatDelay)||(u8(k),0===k.delay&&(l=!0)),(sm.instantAnimations||sm.skipAnimations||e?.shouldSkipAnimations||h.skipAnimations)&&(l=!0,u8(k),k.delay=0),k.allowFlatten=!h.type&&!h.ease,l&&!f&&void 0!==b.get()){let a=sO(k.keyframes,h);if(void 0!==a)return void sp.update(()=>{k.onUpdate(a),k.onComplete()})}return h.isSync?new u4(k):new vc(k)};function vi(a,b,{delay:c=0,transitionOverride:d,type:e}={}){let{transition:f,transitionEnd:g,...h}=b,i=a.getDefaultTransition();f=f?uf(f,i):i;let j=f?.reduceMotion,k=f?.skipAnimations;d&&(f=d);let l=[],m=e&&a.animationState&&a.animationState.getState()[e],n=f?.path;for(let b in n&&n.animateVisualElement(a,h,f,c,l),h){let d=a.getValue(b,a.latestValues[b]??null),e=h[b];if(void 0===e||m&&function({protectedKeys:a,needsAnimating:b},c){let d=a.hasOwnProperty(c)&&!0!==b[c];return b[c]=!1,d}(m,b))continue;let g={delay:c,...ug(f||{},b)};k&&(g.skipAnimations=!0);let i=d.get();if(void 0!==i&&!d.isAnimating()&&!Array.isArray(e)&&e===i&&!g.velocity){sp.update(()=>d.set(e));continue}let n=!1;if(window.MotionHandoffAnimation){let c=a.props[uj];if(c){let a=window.MotionHandoffAnimation(c,b,sp);null!==a&&(g.startTime=a,n=!0)}}ui(a,b);let o=j??a.shouldReduceMotion;d.start(vh(b,d,e,o&&rW.has(b)?{type:!1}:g,a,n));let p=d.animation;p&&l.push(p)}if(g){let b=()=>sp.update(()=>{g&&function(a,b){let{transitionEnd:c={},transition:d={},...e}=ue(a,b)||{};for(let b in e={...e,...c}){var f;let c=uh(f=e[b])?f[f.length-1]||0:f;a.hasValue(b)?a.getValue(b).set(c):a.addValue(b,s2(c))}}(a,g)});l.length?Promise.all(l).then(b):b()}return l}function vj(a,b,c,d=0,e=1){let f=Array.from(a).sort((a,b)=>a.sortNodePosition(b)).indexOf(b),g=a.size,h=(g-1)*d;return"function"==typeof c?c(f,g):1===e?f*d:h-f*d}function vk(a,b,c={}){let d=ue(a,b,"exit"===c.type?a.presenceContext?.custom:void 0),{transition:e=a.getDefaultTransition()||{}}=d||{};c.transitionOverride&&(e=c.transitionOverride);let f=d?()=>Promise.all(vi(a,d,c)):()=>Promise.resolve(),g=a.variantChildren&&a.variantChildren.size?(d=0)=>{let{delayChildren:f=0,staggerChildren:g,staggerDirection:h}=e;return function(a,b,c=0,d=0,e=0,f=1,g){let h=[];for(let i of a.variantChildren)i.notify("AnimationStart",b),h.push(vk(i,b,{...g,delay:c+("function"==typeof d?0:d)+vj(a.variantChildren,i,d,e,f)}).then(()=>i.notify("AnimationComplete",b)));return Promise.all(h)}(a,b,d,f,g,h,c)}:()=>Promise.resolve(),{when:h}=e;if(!h)return Promise.all([f(),g(c.delay)]);{let[a,b]="beforeChildren"===h?[f,g]:[g,f];return a().then(()=>b())}}let vl=s8.length;function vm(a,b){if(!Array.isArray(b))return!1;let c=b.length;if(c!==a.length)return!1;for(let d=0;d<c;d++)if(b[d]!==a[d])return!1;return!0}let vn=[...s7].reverse(),vo=s7.length;function vp(a=!1){return{isActive:a,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function vq(){return{animate:vp(!0),whileInView:vp(),whileHover:vp(),whileTap:vp(),whileDrag:vp(),whileFocus:vp(),exit:vp()}}class vr extends ud{constructor(a){super(a),a.animationState||(a.animationState=function(a){let b=b=>Promise.all(b.map(({animation:b,options:c})=>(function(a,b,c={}){let d;if(a.notify("AnimationStart",b),Array.isArray(b))d=Promise.all(b.map(b=>vk(a,b,c)));else if("string"==typeof b)d=vk(a,b,c);else{let e="function"==typeof b?ue(a,b,c.custom):b;d=Promise.all(vi(a,e,c))}return d.then(()=>{a.notify("AnimationComplete",b)})})(a,b,c))),c=vq(),d=!0,e=!1,f=b=>(c,d)=>{let e=ue(a,d,"exit"===b?a.presenceContext?.custom:void 0);if(e){let{transition:a,transitionEnd:b,...d}=e;c={...c,...d,...b}}return c};function g(g){let{props:h}=a,i=function a(b){if(!b)return;if(!b.isControllingVariants){let c=b.parent&&a(b.parent)||{};return void 0!==b.props.initial&&(c.initial=b.props.initial),c}let c={};for(let a=0;a<vl;a++){let d=s8[a],e=b.props[d];(s6(e)||!1===e)&&(c[d]=e)}return c}(a.parent)||{},j=[],k=new Set,l={},m=1/0;for(let b=0;b<vo;b++){var n,o;let p=vn[b],q=c[p],r=void 0!==h[p]?h[p]:i[p],s=s6(r),t=p===g?q.isActive:null;!1===t&&(m=b);let u=r===i[p]&&r!==h[p]&&s;if(u&&(d||e)&&a.manuallyAnimateOnMount&&(u=!1),q.protectedKeys={...l},!q.isActive&&null===t||!r&&!q.prevProp||s5(r)||"boolean"==typeof r)continue;if("exit"===p&&q.isActive&&!0!==t){q.prevResolvedValues&&(l={...l,...q.prevResolvedValues});continue}let v=(n=q.prevProp,"string"==typeof(o=r)?o!==n:!!Array.isArray(o)&&!vm(o,n)),w=v||p===g&&q.isActive&&!u&&s||b>m&&s,x=!1,y=Array.isArray(r)?r:[r],z=y.reduce(f(p),{});!1===t&&(z={});let{prevResolvedValues:A={}}=q,B={...A,...z},C=b=>{w=!0,k.has(b)&&(x=!0,k.delete(b)),q.needsAnimating[b]=!0;let c=a.getValue(b);c&&(c.liveStyle=!1)};for(let a in B){let b=z[a],c=A[a];if(!l.hasOwnProperty(a))(uh(b)&&uh(c)?!vm(b,c)||v:b!==c)?null!=b?C(a):k.add(a):void 0!==b&&k.has(a)?C(a):q.protectedKeys[a]=!0}q.prevProp=r,q.prevResolvedValues=z,q.isActive&&(l={...l,...z}),(d||e)&&a.blockInitialAnimation&&(w=!1);let D=u&&v,E=!D||x;w&&E&&j.push(...y.map(b=>{let c={type:p};if("string"==typeof b&&(d||e)&&!D&&a.manuallyAnimateOnMount&&a.parent){let{parent:d}=a,e=ue(d,b);if(d.enteringChildren&&e){let{delayChildren:b}=e.transition||{};c.delay=vj(d.enteringChildren,a,b)}}return{animation:b,options:c}}))}if(k.size){let b={};if("boolean"!=typeof h.initial){let c=ue(a,Array.isArray(h.initial)?h.initial[0]:h.initial);c&&c.transition&&(b.transition=c.transition)}k.forEach(c=>{let d=a.getBaseTarget(c),e=a.getValue(c);e&&(e.liveStyle=!0),b[c]=d??null}),j.push({animation:b})}let p=!!j.length;return d&&(!1===h.initial||h.initial===h.animate)&&!a.manuallyAnimateOnMount&&(p=!1),d=!1,e=!1,p?b(j):Promise.resolve()}return{animateChanges:g,setActive:function(b,d){if(c[b].isActive===d)return Promise.resolve();a.variantChildren?.forEach(a=>a.animationState?.setActive(b,d)),c[b].isActive=d;let e=g(b);for(let a in c)c[a].protectedKeys={};return e},setAnimateFunction:function(c){b=c(a)},getState:()=>c,reset:()=>{c=vq(),e=!0}}}(a))}updateAnimationControlsSubscription(){let{animate:a}=this.node.getProps();s5(a)&&(this.unmountControls=a.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:a}=this.node.getProps(),{animate:b}=this.node.prevProps||{};a!==b&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let vs=0;class vt extends ud{constructor(){super(...arguments),this.id=vs++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:a,onExitComplete:b}=this.node.presenceContext,{isPresent:c}=this.node.prevPresenceContext||{};if(!this.node.animationState||a===c)return;if(a&&!1===c){if(this.isExitComplete){let{initial:a,custom:b}=this.node.getProps();if("string"==typeof a||"object"==typeof a&&null!==a&&!Array.isArray(a)){let c=ue(this.node,a,b);if(c){let{transition:a,transitionEnd:b,...d}=c;for(let a in d)this.node.getValue(a)?.jump(d[a])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}let d=this.node.animationState.setActive("exit",!a);b&&!a&&d.then(()=>{this.isExitComplete=!0,b(this.id)})}mount(){let{register:a,onExitComplete:b}=this.node.presenceContext||{};b&&b(this.id),a&&(this.unmount=a(this.id))}unmount(){}}let vu={x:!1,y:!1};function vv(a){return[a("x"),a("y")]}function vw(a){return a.max-a.min}function vx(a,b,c,d=.5){a.origin=d,a.originPoint=tA(b.min,b.max,a.origin),a.scale=vw(c)/vw(b),a.translate=tA(c.min,c.max,a.origin)-a.originPoint,(a.scale>=.9999&&a.scale<=1.0001||isNaN(a.scale))&&(a.scale=1),(a.translate>=-.01&&a.translate<=.01||isNaN(a.translate))&&(a.translate=0)}function vy(a,b,c,d){vx(a.x,b.x,c.x,d?d.originX:void 0),vx(a.y,b.y,c.y,d?d.originY:void 0)}function vz(a,b,c,d=0){a.min=(d?tA(c.min,c.max,d):c.min)+b.min,a.max=a.min+vw(b)}function vA(a,b,c,d=0){let e=d?tA(c.min,c.max,d):c.min;a.min=b.min-e,a.max=a.min+vw(b)}function vB(a,b,c,d){vA(a.x,b.x,c.x,d?.x),vA(a.y,b.y,c.y,d?.y)}let vC=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]),vD=new Set(["INPUT","SELECT","TEXTAREA"]);function vE(a,b,c,d={passive:!0}){return a.addEventListener(b,c,d),()=>a.removeEventListener(b,c,d)}let vF=a=>"object"==typeof a&&null!==a;function vG(a){return vF(a)&&"ownerSVGElement"in a}function vH(a,b,c){if(null==a)return[];if(a instanceof EventTarget)return[a];if("string"==typeof a){let d=document;b&&(d=b.current);let e=c?.[a]??d.querySelectorAll(a);return e?Array.from(e):[]}return Array.from(a).filter(a=>null!=a)}let vI=new WeakMap,vJ=(a,b,c)=>(d,e)=>e&&e[0]?e[0][a+"Size"]:vG(d)&&"getBBox"in d?d.getBBox()[b]:d[c],vK=vJ("inline","width","offsetWidth"),vL=vJ("block","height","offsetHeight");function vM({target:a,borderBoxSize:b}){vI.get(a)?.forEach(c=>{c(a,{get width(){return vK(a,b)},get height(){return vL(a,b)}})})}function vN(a){a.forEach(vM)}let vO=new Set;function vP(a,b){let c;return"function"==typeof a?(vO.add(a),f||(f=()=>{let a={get width(){return window.innerWidth},get height(){return window.innerHeight}};vO.forEach(b=>b(a))},window.addEventListener("resize",f)),()=>{vO.delete(a),vO.size||"function"!=typeof f||(window.removeEventListener("resize",f),f=void 0)}):(!e&&"u">typeof ResizeObserver&&(e=new ResizeObserver(vN)),(c=vH(a)).forEach(a=>{let c=vI.get(a);c||(c=new Set,vI.set(a,c)),c.add(b),e?.observe(a)}),()=>{c.forEach(a=>{let c=vI.get(a);c?.delete(b),c?.size||e?.unobserve(a)})})}let vQ=a=>"mouse"===a.pointerType?"number"!=typeof a.button||a.button<=0:!1!==a.isPrimary;function vR(a){return{point:{x:a.pageX,y:a.pageY}}}function vS(a,b,c,d){return vE(a,b,a=>vQ(a)&&c(a,vR(a)),d)}let vT=({current:a})=>a?a.ownerDocument.defaultView:null;function vU(a){return a&&"object"==typeof a&&Object.prototype.hasOwnProperty.call(a,"current")}let vV=(a,b)=>Math.abs(a-b),vW=new Set(["auto","scroll"]);class vX{constructor(a,b,{transformPagePoint:c,contextWindow:d=window,dragSnapToOrigin:e=!1,distanceThreshold:f=3,element:g}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=a=>{this.handleScroll(a.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{var a,b;if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=vY(this.lastRawMoveEventInfo,this.transformPagePoint));let c=v$(this.lastMoveEventInfo,this.history),d=null!==this.startEvent,e=(a=c.offset,b={x:0,y:0},Math.sqrt(vV(a.x,b.x)**2+vV(a.y,b.y)**2)>=this.distanceThreshold);if(!d&&!e)return;let{point:f}=c,{timestamp:g}=sr;this.history.push({...f,timestamp:g});let{onStart:h,onMove:i}=this.handlers;d||(h&&h(this.lastMoveEvent,c),this.startEvent=this.lastMoveEvent),i&&i(this.lastMoveEvent,c)},this.handlePointerMove=(a,b)=>{this.lastMoveEvent=a,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=vY(b,this.transformPagePoint),sp.update(this.updatePoint,!0)},this.handlePointerUp=(a,b)=>{this.end();let{onEnd:c,onSessionEnd:d,resumeAnimation:e}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&e&&e(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let f=v$("pointercancel"===a.type?this.lastMoveEventInfo:vY(b,this.transformPagePoint),this.history);this.startEvent&&c&&c(a,f),d&&d(a,f)},!vQ(a))return;this.dragSnapToOrigin=e,this.handlers=b,this.transformPagePoint=c,this.distanceThreshold=f,this.contextWindow=d||window;const h=vY(vR(a),this.transformPagePoint),{point:i}=h,{timestamp:j}=sr;this.history=[{...i,timestamp:j}];const{onSessionStart:k}=b;k&&k(a,v$(h,this.history));const l={passive:!0,capture:!0};this.removeListeners=uk(vS(this.contextWindow,"pointermove",this.handlePointerMove,l),vS(this.contextWindow,"pointerup",this.handlePointerUp,l),vS(this.contextWindow,"pointercancel",this.handlePointerUp,l)),g&&this.startScrollTracking(g)}startScrollTracking(a){let b=a.parentElement;for(;b;){let a=getComputedStyle(b);(vW.has(a.overflowX)||vW.has(a.overflowY))&&this.scrollPositions.set(b,{x:b.scrollLeft,y:b.scrollTop}),b=b.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(a){let b=this.scrollPositions.get(a);if(!b)return;let c=a===window,d=c?{x:window.scrollX,y:window.scrollY}:{x:a.scrollLeft,y:a.scrollTop},e={x:d.x-b.x,y:d.y-b.y};(0!==e.x||0!==e.y)&&(c?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=e.x,this.lastMoveEventInfo.point.y+=e.y):this.history.length>0&&(this.history[0].x-=e.x,this.history[0].y-=e.y),this.scrollPositions.set(a,d),sp.update(this.updatePoint,!0))}updateHandlers(a){this.handlers=a}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),sq(this.updatePoint)}}function vY(a,b){return b?{point:b(a.point)}:a}function vZ(a,b){return{x:a.x-b.x,y:a.y-b.y}}function v$({point:a},b){return{point:a,delta:vZ(a,v_(b)),offset:vZ(a,b[0]),velocity:function(a){if(a.length<2)return{x:0,y:0};let b=a.length-1,c=null,d=v_(a);for(;b>=0&&(c=a[b],!(d.timestamp-c.timestamp>sE(.1)));)b--;if(!c)return{x:0,y:0};c===a[0]&&a.length>2&&d.timestamp-c.timestamp>2*sE(.1)&&(c=a[1]);let e=(d.timestamp-c.timestamp)/1e3;if(0===e)return{x:0,y:0};let f={x:(d.x-c.x)/e,y:(d.y-c.y)/e};return f.x===1/0&&(f.x=0),f.y===1/0&&(f.y=0),f}(b)}}function v_(a){return a[a.length-1]}function v0(a,b,c){return{min:void 0!==b?a.min+b:void 0,max:void 0!==c?a.max+c-(a.max-a.min):void 0}}function v1(a,b){let c=b.min-a.min,d=b.max-a.max;return b.max-b.min<a.max-a.min&&([c,d]=[d,c]),{min:c,max:d}}function v2(a,b,c){return{min:v3(a,b),max:v3(a,c)}}function v3(a,b){return"number"==typeof a?a:a[b]||0}let v4=new WeakMap;class v5{constructor(a){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=rU(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=a}start(a,{snapToCursor:b=!1,distanceThreshold:c}={}){let{presenceContext:d}=this.visualElement;if(d&&!1===d.isPresent)return;let e=a=>{b&&this.snapToCursor(vR(a).point),this.stopAnimation()},f=(a,b)=>{let{drag:c,dragPropagation:d,onDragStart:e}=this.getProps();if(c&&!d&&(this.openDragLock&&this.openDragLock(),this.openDragLock=function(a){if("x"===a||"y"===a)if(vu[a])return null;else return vu[a]=!0,()=>{vu[a]=!1};return vu.x||vu.y?null:(vu.x=vu.y=!0,()=>{vu.x=vu.y=!1})}(c),!this.openDragLock))return;this.latestPointerEvent=a,this.latestPanInfo=b,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vv(a=>{let b=this.getAxisMotionValue(a).get()||0;if(ru.test(b)){let{projection:c}=this.visualElement;if(c&&c.layout){let d=c.layout.layoutBox[a];d&&(b=vw(d)*(parseFloat(b)/100))}}this.originPoint[a]=b}),e&&sp.update(()=>e(a,b),!1,!0),ui(this.visualElement,"transform");let{animationState:f}=this.visualElement;f&&f.setActive("whileDrag",!0)},g=(a,b)=>{this.latestPointerEvent=a,this.latestPanInfo=b;let{dragPropagation:c,dragDirectionLock:d,onDirectionLock:e,onDrag:f}=this.getProps();if(!c&&!this.openDragLock)return;let{offset:g}=b;if(d&&null===this.currentDirection){this.currentDirection=function(a,b=10){let c=null;return Math.abs(a.y)>b?c="y":Math.abs(a.x)>b&&(c="x"),c}(g),null!==this.currentDirection&&e&&e(this.currentDirection);return}this.updateAxis("x",b.point,g),this.updateAxis("y",b.point,g),this.visualElement.render(),f&&sp.update(()=>f(a,b),!1,!0)},h=(a,b)=>{this.latestPointerEvent=a,this.latestPanInfo=b,this.stop(a,b),this.latestPointerEvent=null,this.latestPanInfo=null},i=()=>{let{dragSnapToOrigin:a}=this.getProps();(a||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:j}=this.getProps();this.panSession=new vX(a,{onSessionStart:e,onStart:f,onMove:g,onSessionEnd:h,resumeAnimation:i},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:j,distanceThreshold:c,contextWindow:vT(this.visualElement),element:this.visualElement.current})}stop(a,b){let c=a||this.latestPointerEvent,d=b||this.latestPanInfo,e=this.isDragging;if(this.cancel(),!e||!d||!c)return;let{velocity:f}=d;this.startAnimation(f);let{onDragEnd:g}=this.getProps();g&&sp.postRender(()=>g(c,d))}cancel(){this.isDragging=!1;let{projection:a,animationState:b}=this.visualElement;a&&(a.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:c}=this.getProps();!c&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),b&&b.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(a,b,c){let{drag:d}=this.getProps();if(!c||!v7(a,d,this.currentDirection))return;let e=this.getAxisMotionValue(a),f=this.originPoint[a]+c[a];this.constraints&&this.constraints[a]&&(f=function(a,{min:b,max:c},d){return void 0!==b&&a<b?a=d?tA(b,a,d.min):Math.max(a,b):void 0!==c&&a>c&&(a=d?tA(c,a,d.max):Math.min(a,c)),a}(f,this.constraints[a],this.elastic[a])),e.set(f)}resolveConstraints(){let{dragConstraints:a,dragElastic:b}=this.getProps(),c=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,d=this.constraints;a&&vU(a)?this.constraints||(this.constraints=this.resolveRefConstraints()):a&&c?this.constraints=function(a,{top:b,left:c,bottom:d,right:e}){return{x:v0(a.x,c,e),y:v0(a.y,b,d)}}(c.layoutBox,a):this.constraints=!1,this.elastic=function(a=.35){return!1===a?a=0:!0===a&&(a=.35),{x:v2(a,"left","right"),y:v2(a,"top","bottom")}}(b),d!==this.constraints&&!vU(a)&&c&&this.constraints&&!this.hasMutatedConstraints&&vv(a=>{var b,d;let e;!1!==this.constraints&&this.getAxisMotionValue(a)&&(this.constraints[a]=(b=c.layoutBox[a],d=this.constraints[a],e={},void 0!==d.min&&(e.min=d.min-b.min),void 0!==d.max&&(e.max=d.max-b.min),e))})}resolveRefConstraints(){var a;let{dragConstraints:b,onMeasureDragConstraints:c}=this.getProps();if(!b||!vU(b))return!1;let d=b.current;r_();let{projection:e}=this.visualElement;if(!e||!e.layout)return!1;e.root&&(e.root.scroll=void 0,e.root.updateScroll());let f=function(a,b,c){let d=tS(a,c),{scroll:e}=b;return e&&(tO(d.x,e.offset.x),tO(d.y,e.offset.y)),d}(d,e.root,this.visualElement.getTransformPagePoint()),g=(a=e.layout.layoutBox,{x:v1(a.x,f.x),y:v1(a.y,f.y)});if(c){let a=c(function({x:a,y:b}){return{top:b.min,right:a.max,bottom:b.max,left:a.min}}(g));this.hasMutatedConstraints=!!a,a&&(g=tG(a))}return g}startAnimation(a){let{drag:b,dragMomentum:c,dragElastic:d,dragTransition:e,dragSnapToOrigin:f,onDragTransitionEnd:g}=this.getProps(),h=this.constraints||{};return Promise.all(vv(g=>{if(!v7(g,b,this.currentDirection))return;let i=h&&h[g]||{};(!0===f||f===g)&&(i={min:0,max:0});let j={type:"inertia",velocity:c?a[g]:0,bounceStiffness:d?200:1e6,bounceDamping:d?40:1e7,timeConstant:750,restDelta:1,restSpeed:10,...e,...i};return this.startAxisValueAnimation(g,j)})).then(g)}startAxisValueAnimation(a,b){let c=this.getAxisMotionValue(a);return ui(this.visualElement,a),c.start(vh(a,c,0,b,this.visualElement,!1))}stopAnimation(){vv(a=>this.getAxisMotionValue(a).stop())}getAxisMotionValue(a){let b=`_drag${a.toUpperCase()}`;return this.visualElement.getProps()[b]||this.visualElement.getValue(a,this.visualElement.latestValues[a]??0)}snapToCursor(a){vv(b=>{let{drag:c}=this.getProps();if(!v7(b,c,this.currentDirection))return;let{projection:d}=this.visualElement,e=this.getAxisMotionValue(b);if(d&&d.layout){let{min:c,max:f}=d.layout.layoutBox[b],g=e.get()||0;e.set(a[b]-tA(c,f,.5)+g)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:a,dragConstraints:b}=this.getProps(),{projection:c}=this.visualElement;if(!vU(b)||!c||!this.constraints)return;this.stopAnimation();let d={x:0,y:0};vv(a=>{let b=this.getAxisMotionValue(a);if(b&&!1!==this.constraints){var c,e;let f,g,h,i=b.get();d[a]=(c={min:i,max:i},e=this.constraints[a],f=.5,g=vw(c),(h=vw(e))>g?f=u_(e.min,e.max-g,c.min):g>h&&(f=u_(c.min,c.max-h,e.min)),rg(0,1,f))}});let{transformTemplate:e}=this.visualElement.getProps();this.visualElement.current.style.transform=e?e({},""):"none",c.root&&c.root.updateScroll(),c.updateLayout(),this.constraints=!1,this.resolveConstraints(),vv(b=>{if(!v7(b,a,null))return;let c=this.getAxisMotionValue(b),{min:e,max:f}=this.constraints[b];c.set(tA(e,f,d[b]))}),this.visualElement.render()}addListeners(){let a;if(!this.visualElement.current)return;v4.set(this.visualElement,this);let b=this.visualElement.current,c=vS(b,"pointerdown",a=>{let{drag:c,dragListener:d=!0}=this.getProps(),e=a.target,f=e!==b&&(vD.has(e.tagName)||!0===e.isContentEditable);c&&d&&!f&&this.start(a)}),d=()=>{var c,d,e;let f,g,{dragConstraints:h}=this.getProps();vU(h)&&h.current&&(this.constraints=this.resolveRefConstraints(),a||(c=b,d=h.current,f=vP(c,v6(e=()=>this.scalePositionWithinConstraints())),g=vP(d,v6(e)),a=()=>{f(),g()}))},{projection:e}=this.visualElement,f=e.addEventListener("measure",d);e&&!e.layout&&(e.root&&e.root.updateScroll(),e.updateLayout()),sp.read(d);let g=vE(window,"resize",()=>this.scalePositionWithinConstraints()),h=e.addEventListener("didUpdate",({delta:a,hasLayoutChanged:b})=>{this.isDragging&&b&&(vv(b=>{let c=this.getAxisMotionValue(b);c&&(this.originPoint[b]+=a[b].translate,c.set(c.get()+a[b].translate))}),this.visualElement.render())});return()=>{g(),c(),f(),h&&h(),a&&a()}}getProps(){let a=this.visualElement.getProps(),{drag:b=!1,dragDirectionLock:c=!1,dragPropagation:d=!1,dragConstraints:e=!1,dragElastic:f=.35,dragMomentum:g=!0}=a;return{...a,drag:b,dragDirectionLock:c,dragPropagation:d,dragConstraints:e,dragElastic:f,dragMomentum:g}}}function v6(a){let b=!0;return()=>{if(b){b=!1;return}a()}}function v7(a,b,c){return(!0===b||b===a)&&(null===c||c===a)}class v8 extends ud{constructor(a){super(a),this.removeGroupControls=sl,this.removeListeners=sl,this.controls=new v5(a)}mount(){let{dragControls:a}=this.node.getProps();a&&(this.removeGroupControls=a.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||sl}update(){let{dragControls:a}=this.node.getProps(),{dragControls:b}=this.node.prevProps||{};a!==b&&(this.removeGroupControls(),a&&(this.removeGroupControls=a.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}let v9=a=>(b,c)=>{a&&sp.update(()=>a(b,c),!1,!0)};class wa extends ud{constructor(){super(...arguments),this.removePointerDownListener=sl}onPointerDown(a){this.session=new vX(a,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:vT(this.node)})}createPanHandlers(){let{onPanSessionStart:a,onPanStart:b,onPan:c,onPanEnd:d}=this.node.getProps();return{onSessionStart:v9(a),onStart:v9(b),onMove:v9(c),onEnd:(a,b)=>{delete this.session,d&&sp.postRender(()=>d(a,b))}}}mount(){this.removePointerDownListener=vS(this.node.current,"pointerdown",a=>this.onPointerDown(a))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let wb={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function wc(a=!0){let b=(0,B.useContext)(t4);if(null===b)return[!0,null];let{isPresent:c,onExitComplete:d,register:e}=b,f=(0,B.useId)(),g=(0,B.useCallback)(()=>a&&d&&d(f),[f,d,a]);return!c&&d?[!1,g]:[!0]}function wd(){var a;return null===(a=(0,B.useContext)(t4))||a.isPresent}let we=(0,B.createContext)({}),wf=!1;class wg extends B.Component{componentDidMount(){let{visualElement:a,layoutGroup:b,switchLayoutGroup:c,layoutId:d}=this.props,{projection:e}=a;e&&(b.group&&b.group.add(e),c&&c.register&&d&&c.register(e),wf&&e.root.didUpdate(),e.addEventListener("animationComplete",()=>{this.safeToRemove()}),e.setOptions({...e.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),wb.hasEverUpdated=!0}getSnapshotBeforeUpdate(a){let{layoutDependency:b,visualElement:c,drag:d,isPresent:e}=this.props,{projection:f}=c;return f&&(f.isPresent=e,a.layoutDependency!==b&&f.setOptions({...f.options,layoutDependency:b}),wf=!0,d||a.layoutDependency!==b||void 0===b||a.isPresent!==e?f.willUpdate():this.safeToRemove(),a.isPresent!==e&&(e?f.promote():f.relegate()||sp.postRender(()=>{let a=f.getStack();a&&a.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{visualElement:a,layoutAnchor:b}=this.props,{projection:c}=a;c&&(c.options.layoutAnchor=b,c.root.didUpdate(),sY.postRender(()=>{!c.currentAnimation&&c.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:a,layoutGroup:b,switchLayoutGroup:c}=this.props,{projection:d}=a;wf=!0,d&&(d.scheduleCheckAfterUnmount(),b&&b.group&&b.group.remove(d),c&&c.deregister&&c.deregister(d))}safeToRemove(){let{safeToRemove:a}=this.props;a&&a()}render(){return null}}function wh(a){let[b,c]=wc(),d=(0,B.useContext)(tW);return(0,A.jsx)(wg,{...a,layoutGroup:d,switchLayoutGroup:(0,B.useContext)(we),isPresent:b,safeToRemove:c})}let wi=tx.length,wj=a=>"string"==typeof a?parseFloat(a):a,wk=a=>"number"==typeof a||rv.test(a);function wl(a,b){return void 0!==a[b]?a[b]:a.borderRadius}let wm=wo(0,.5,uX),wn=wo(.5,.95,sl);function wo(a,b,c){return d=>d<a?0:d>b?1:c(u_(a,b,d))}function wp(a,b){a.min=b.min,a.max=b.max}function wq(a,b){wp(a.x,b.x),wp(a.y,b.y)}function wr(a,b){a.translate=b.translate,a.scale=b.scale,a.originPoint=b.originPoint,a.origin=b.origin}function ws(a,b,c,d,e){return a-=b,a=d+1/c*(a-d),void 0!==e&&(a=d+1/e*(a-d)),a}function wt(a,b,[c,d,e],f,g){!function(a,b=0,c=1,d=.5,e,f=a,g=a){if(ru.test(b)&&(b=parseFloat(b),b=tA(g.min,g.max,b/100)-g.min),"number"!=typeof b)return;let h=tA(f.min,f.max,d);a===f&&(h-=b),a.min=ws(a.min,b,c,h,e),a.max=ws(a.max,b,c,h,e)}(a,b[c],b[d],b[e],b.scale,f,g)}let wu=["x","scaleX","originX"],wv=["y","scaleY","originY"];function ww(a,b,c,d){wt(a.x,b,wu,c?c.x:void 0,d?d.x:void 0),wt(a.y,b,wv,c?c.y:void 0,d?d.y:void 0)}function wx(a){return 0===a.translate&&1===a.scale}function wy(a){return wx(a.x)&&wx(a.y)}function wz(a,b){return a.min===b.min&&a.max===b.max}function wA(a,b){return Math.round(a.min)===Math.round(b.min)&&Math.round(a.max)===Math.round(b.max)}function wB(a,b){return wA(a.x,b.x)&&wA(a.y,b.y)}function wC(a){return vw(a.x)/vw(a.y)}function wD(a,b){return a.translate===b.translate&&a.scale===b.scale&&a.originPoint===b.originPoint}class wE{constructor(){this.members=[]}add(a){sF(this.members,a);for(let b=this.members.length-1;b>=0;b--){let c=this.members[b];if(c===a||c===this.lead||c===this.prevLead)continue;let d=c.instance;d&&!1!==d.isConnected||c.snapshot||(sG(this.members,c),c.unmount())}a.scheduleRender()}remove(a){if(sG(this.members,a),a===this.prevLead&&(this.prevLead=void 0),a===this.lead){let a=this.members[this.members.length-1];a&&this.promote(a)}}relegate(a){for(let b=this.members.indexOf(a)-1;b>=0;b--){let a=this.members[b];if(!1!==a.isPresent&&a.instance?.isConnected!==!1)return this.promote(a),!0}return!1}promote(a,b){let c=this.lead;if(a!==c&&(this.prevLead=c,this.lead=a,a.show(),c)){c.updateSnapshot(),a.scheduleRender();let{layoutDependency:d}=c.options,{layoutDependency:e}=a.options;(void 0===d||d!==e)&&(a.resumeFrom=c,b&&(c.preserveOpacity=!0),c.snapshot&&(a.snapshot=c.snapshot,a.snapshot.latestValues=c.animationValues||c.latestValues),a.root?.isUpdating&&(a.isLayoutDirty=!0)),!1===a.options.crossfade&&c.hide()}}exitAnimationComplete(){this.members.forEach(a=>{a.options.onExitComplete?.(),a.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(a=>a.instance&&a.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}let wF=(a,b)=>a.depth-b.depth;class wG{constructor(){this.children=[],this.isDirty=!1}add(a){sF(this.children,a),this.isDirty=!0}remove(a){sG(this.children,a),this.isDirty=!0}forEach(a){this.isDirty&&this.children.sort(wF),this.isDirty=!1,this.children.forEach(a)}}let wH=["","X","Y","Z"],wI=0;function wJ(a,b,c,d){let{latestValues:e}=b;e[a]&&(c[a]=e[a],b.setStaticValue(a,0),d&&(d[a]=0))}function wK({attachResizeListener:a,defaultParent:b,measureScroll:c,checkIsScrollRoot:d,resetTransform:e}){return class{constructor(a={},c=b?.()){this.id=wI++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(wN),this.nodes.forEach(wW),this.nodes.forEach(wX),this.nodes.forEach(wO)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=c?c.root||c:this,this.path=c?[...c.path,c]:[],this.parent=c,this.depth=c?c.depth+1:0;for(let a=0;a<this.path.length;a++)this.path[a].shouldResetTransform=!0;this.root===this&&(this.nodes=new wG)}addEventListener(a,b){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new sH),this.eventHandlers.get(a).add(b)}notifyListeners(a,...b){let c=this.eventHandlers.get(a);c&&c.notify(...b)}hasListeners(a){return this.eventHandlers.has(a)}mount(b){if(this.instance)return;this.isSVG=vG(b)&&!(vG(b)&&"svg"===b.tagName),this.instance=b;let{layoutId:c,layout:d,visualElement:e}=this.options;if(e&&!e.current&&e.mount(b),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(d||c)&&(this.isLayoutDirty=!0),a){let c,d=0,e=()=>this.root.updateBlockedByResize=!1;sp.read(()=>{d=window.innerWidth}),a(b,()=>{let a=window.innerWidth;if(a!==d){let b,f;d=a,this.root.updateBlockedByResize=!0,c&&c(),b=s$.now(),f=({timestamp:a})=>{let c=a-b;c>=250&&(sq(f),e())},sp.setup(f,!0),c=()=>sq(f),wb.hasAnimatedSinceResize&&(wb.hasAnimatedSinceResize=!1,this.nodes.forEach(wV))}})}c&&this.root.registerSharedNode(c,this),!1!==this.options.animate&&e&&(c||d)&&this.addEventListener("didUpdate",({delta:a,hasLayoutChanged:b,hasRelativeLayoutChanged:c,layout:d})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let f=this.options.transition||e.getDefaultTransition()||w1,{onLayoutAnimationStart:g,onLayoutAnimationComplete:h}=e.getProps(),i=!this.targetLayout||!wB(this.targetLayout,d),j=!b&&c;if(this.options.layoutRoot||this.resumeFrom||j||b&&(i||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let b={...ug(f,"layout"),onPlay:g,onComplete:h};(e.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(a,j,b.path)}else b||wV(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=d})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),sq(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){!this.isUpdateBlocked()&&(this.isUpdating=!0,this.nodes&&this.nodes.forEach(wY),this.animationId++)}getTransformTemplate(){let{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&function a(b){if(b.hasCheckedOptimisedAppear=!0,b.root===b)return;let{visualElement:c}=b.options;if(!c)return;let d=c.props[uj];if(window.MotionHasOptimisedAnimation(d,"transform")){let{layout:a,layoutId:c}=b.options;window.MotionCancelOptimisedAnimation(d,"transform",sp,!(a||c))}let{parent:e}=b;e&&!e.hasCheckedOptimisedAppear&&a(e)}(this),this.root.isUpdating||this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let a=0;a<this.path.length;a++){let b=this.path[a];b.shouldResetTransform=!0,("string"==typeof b.latestValues.x||"string"==typeof b.latestValues.y)&&(b.isLayoutDirty=!0),b.updateScroll("snapshot"),b.options.layoutRoot&&b.willUpdate(!1)}let{layoutId:b,layout:c}=this.options;if(void 0===b&&!c)return;let d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let a=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),a&&this.nodes.forEach(wR),this.nodes.forEach(wQ);return}if(this.animationId<=this.animationCommitId)return void this.nodes.forEach(wS);this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(wT),this.nodes.forEach(wU),this.nodes.forEach(wL),this.nodes.forEach(wM)):this.nodes.forEach(wS),this.clearAllSnapshots();let a=s$.now();sr.delta=rg(0,1e3/60,a-sr.timestamp),sr.timestamp=a,sr.isProcessing=!0,ss.update.process(sr),ss.preRender.process(sr),ss.render.process(sr),sr.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,sY.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(wP),this.sharedNodes.forEach(wZ)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,sp.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){sp.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||vw(this.snapshot.measuredBox.x)||vw(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let a=0;a<this.path.length;a++)this.path[a].updateScroll();let a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=rU()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:b}=this.options;b&&b.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let b=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(b=!1),b&&this.instance){let b=d(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:b,offset:c(this.instance),wasRoot:this.scroll?this.scroll.isRoot:b}}}resetTransform(){if(!e)return;let a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,b=this.projectionDelta&&!wy(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,f=d!==this.prevTransformTemplateValue;a&&this.instance&&(b||tJ(this.latestValues)||f)&&(e(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){var b;let c=this.measurePageBox(),d=this.removeElementScroll(c);return a&&(d=this.removeTransform(d)),w4((b=d).x),w4(b.y),{animationId:this.root.animationId,measuredBox:c,layoutBox:d,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:a}=this.options;if(!a)return rU();let b=a.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(w6))){let{scroll:a}=this.root;a&&(tO(b.x,a.offset.x),tO(b.y,a.offset.y))}return b}removeElementScroll(a){let b=rU();if(wq(b,a),this.scroll?.wasRoot)return b;for(let c=0;c<this.path.length;c++){let d=this.path[c],{scroll:e,options:f}=d;d!==this.root&&e&&f.layoutScroll&&(e.wasRoot&&wq(b,a),tO(b.x,e.offset.x),tO(b.y,e.offset.y))}return b}applyTransform(a,b=!1,c){let d=c||rU();wq(d,a);for(let a=0;a<this.path.length;a++){let c=this.path[a];!b&&c.options.layoutScroll&&c.scroll&&c!==c.root&&(tO(d.x,-c.scroll.offset.x),tO(d.y,-c.scroll.offset.y)),tJ(c.latestValues)&&tR(d,c.latestValues,c.layout?.layoutBox)}return tJ(this.latestValues)&&tR(d,this.latestValues,this.layout?.layoutBox),d}removeTransform(a){let b=rU();wq(b,a);for(let a=0;a<this.path.length;a++){let c,d=this.path[a];tJ(d.latestValues)&&(d.instance&&(tI(d.latestValues)&&d.updateSnapshot(),wq(c=rU(),d.measurePageBox())),ww(b,d.latestValues,d.snapshot?.layoutBox,c))}return tJ(this.latestValues)&&ww(b,this.latestValues),b}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:void 0===a.crossfade||a.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==sr.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){let b=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=b.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=b.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=b.isSharedProjectionDirty);let c=!!this.resumingFrom||this!==b;if(!(a||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:d,layoutId:e}=this.options;if(!this.layout||!(d||e))return;this.resolvedRelativeTargetAt=sr.timestamp;let f=this.getClosestProjectingParent();if(f&&this.linkedParentVersion!==f.layoutVersion&&!f.options.layoutRoot&&this.removeRelativeTarget(),this.targetDelta||this.relativeTarget||(!1!==this.options.layoutAnchor&&f&&f.layout?this.createRelativeTarget(f,this.layout.layoutBox,f.layout.layoutBox):this.removeRelativeTarget()),this.relativeTarget||this.targetDelta){if(this.target||(this.target=rU(),this.targetWithTransforms=rU()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target){var g,h,i,j;this.forceRelativeParentToResolveTarget(),g=this.target,h=this.relativeTarget,i=this.relativeParent.target,j=this.options.layoutAnchor||void 0,vz(g.x,h.x,i.x,j?.x),vz(g.y,h.y,i.y,j?.y)}else this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):wq(this.target,this.layout.layoutBox),tN(this.target,this.targetDelta)):wq(this.target,this.layout.layoutBox);this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,!1!==this.options.layoutAnchor&&f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&1!==this.animationProgress?this.createRelativeTarget(f,this.target,f.target):this.relativeParent=this.relativeTarget=void 0)}}getClosestProjectingParent(){if(!(!this.parent||tI(this.parent.latestValues)||tK(this.parent.latestValues)))if(this.parent.isProjecting())return this.parent;else return this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,b,c){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=rU(),this.relativeTargetOrigin=rU(),vB(this.relativeTargetOrigin,b,c,this.options.layoutAnchor||void 0),wq(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let a=this.getLead(),b=!!this.resumingFrom||this!==a,c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),b&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===sr.timestamp&&(c=!1),c)return;let{layout:d,layoutId:e}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||e))return;wq(this.layoutCorrected,this.layout.layoutBox);let f=this.treeScale.x,g=this.treeScale.y;!function(a,b,c,d=!1){let e,f,g=c.length;if(g){b.x=b.y=1;for(let h=0;h<g;h++){f=(e=c[h]).projectionDelta;let{visualElement:g}=e.options;(!g||!g.props.style||"contents"!==g.props.style.display)&&(d&&e.options.layoutScroll&&e.scroll&&e!==e.root&&(tO(a.x,-e.scroll.offset.x),tO(a.y,-e.scroll.offset.y)),f&&(b.x*=f.x.scale,b.y*=f.y.scale,tN(a,f)),d&&tJ(e.latestValues)&&tR(a,e.latestValues,e.layout?.layoutBox))}b.x<1.0000000000001&&b.x>.999999999999&&(b.x=1),b.y<1.0000000000001&&b.y>.999999999999&&(b.y=1)}}(this.layoutCorrected,this.treeScale,this.path,b),a.layout&&!a.target&&(1!==this.treeScale.x||1!==this.treeScale.y)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=rU());let{target:h}=a;if(!h){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}this.projectionDelta&&this.prevProjectionDelta?(wr(this.prevProjectionDelta.x,this.projectionDelta.x),wr(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),vy(this.projectionDelta,this.layoutCorrected,h,this.latestValues),this.treeScale.x===f&&this.treeScale.y===g&&wD(this.projectionDelta.x,this.prevProjectionDelta.x)&&wD(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",h))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){if(this.options.visualElement?.scheduleRender(),a){let a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=rS(),this.projectionDelta=rS(),this.projectionDeltaWithTransform=rS()}setAnimationOrigin(a,b=!1,c){let d,e=this.snapshot,f=e?e.latestValues:{},g={...this.latestValues},h=rS();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!b;let i=rU(),j=(e?e.source:void 0)!==(this.layout?this.layout.source:void 0),k=this.getStack(),l=!k||k.members.length<=1,m=!!(j&&!l&&!0===this.options.crossfade&&!this.path.some(w0));this.animationProgress=0;let n=c?.interpolateProjection(a);this.mixTargetDelta=b=>{let c=b/1e3,e=n?.(c);if(e?(h.x.translate=e.x,h.x.scale=tA(a.x.scale,1,c),h.x.origin=a.x.origin,h.x.originPoint=a.x.originPoint,h.y.translate=e.y,h.y.scale=tA(a.y.scale,1,c),h.y.origin=a.y.origin,h.y.originPoint=a.y.originPoint):(w$(h.x,a.x,c),w$(h.y,a.y,c)),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout){var k,o,p,q,r,s;vB(i,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),p=this.relativeTarget,q=this.relativeTargetOrigin,r=i,s=c,w_(p.x,q.x,r.x,s),w_(p.y,q.y,r.y,s),d&&(k=this.relativeTarget,o=d,wz(k.x,o.x)&&wz(k.y,o.y))&&(this.isProjectionDirty=!1),d||(d=rU()),wq(d,this.relativeTarget)}j&&(this.animationValues=g,function(a,b,c,d,e,f){e?(a.opacity=tA(0,c.opacity??1,wm(d)),a.opacityExit=tA(b.opacity??1,0,wn(d))):f&&(a.opacity=tA(b.opacity??1,c.opacity??1,d));for(let e=0;e<wi;e++){let f=tx[e],g=wl(b,f),h=wl(c,f);(void 0!==g||void 0!==h)&&(g||(g=0),h||(h=0),0===g||0===h||wk(g)===wk(h)?(a[f]=Math.max(tA(wj(g),wj(h),d),0),(ru.test(h)||ru.test(g))&&(a[f]+="%")):a[f]=h)}(b.rotate||c.rotate)&&(a.rotate=tA(b.rotate||0,c.rotate||0,d))}(g,f,this.latestValues,c,m,l)),e&&void 0!==e.rotate&&(this.animationValues||(this.animationValues=g),this.animationValues.pathRotation=e.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=c},this.mixTargetDelta(1e3*!!this.options.layoutRoot)}startAnimation(a){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(sq(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=sp.update(()=>{var b,c,d;let e;wb.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=s2(0)),this.motionValue.jump(0,!1),this.currentAnimation=(b=this.motionValue,c=[0,1e3],d={...a,velocity:0,isSync:!0,onUpdate:b=>{this.mixTargetDelta(b),a.onUpdate&&a.onUpdate(b)},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}},(e=rV(b)?b:s2(b)).start(vh("",e,c,d)),e.animation),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let a=this.getLead(),{targetWithTransforms:b,target:c,layout:d,latestValues:e}=a;if(b&&c&&d){if(this!==a&&this.layout&&d&&w5(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||rU();let b=vw(this.layout.layoutBox.x);c.x.min=a.target.x.min,c.x.max=c.x.min+b;let d=vw(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+d}wq(b,c),tR(b,e),vy(this.projectionDeltaWithTransform,this.layoutCorrected,b,e)}}registerSharedNode(a,b){this.sharedNodes.has(a)||this.sharedNodes.set(a,new wE),this.sharedNodes.get(a).add(b);let c=b.options.initialPromotionConfig;b.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(b):void 0})}isLead(){let a=this.getStack();return!a||a.lead===this}getLead(){let{layoutId:a}=this.options;return a&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:a}=this.options;return a?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:b,preserveFollowOpacity:c}={}){let d=this.getStack();d&&d.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),b&&this.setOptions({transition:b})}relegate(){let a=this.getStack();return!!a&&a.relegate(this)}resetSkewAndRotation(){let{visualElement:a}=this.options;if(!a)return;let b=!1,{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(b=!0),!b)return;let d={};c.z&&wJ("z",a,d,this.animationValues);for(let b=0;b<wH.length;b++)wJ(`rotate${wH[b]}`,a,d,this.animationValues),wJ(`skew${wH[b]}`,a,d,this.animationValues);for(let b in a.render(),d)a.setStaticValue(b,d[b]),this.animationValues&&(this.animationValues[b]=d[b]);a.scheduleRender()}applyProjectionStyles(a,b){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}let c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=t3(b?.pointerEvents)||"",a.transform=c?c(this.latestValues,""):"none";return}let d=this.getLead();if(!this.projectionDelta||!this.layout||!d.target){this.options.layoutId&&(a.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,a.pointerEvents=t3(b?.pointerEvents)||""),this.hasProjected&&!tJ(this.latestValues)&&(a.transform=c?c({},""):"none",this.hasProjected=!1);return}a.visibility="";let e=d.animationValues||d.latestValues;this.applyTransformsToTarget();let f=function(a,b,c){let d="",e=a.x.translate/b.x,f=a.y.translate/b.y,g=c?.z||0;if((e||f||g)&&(d=`translate3d(${e}px, ${f}px, ${g}px) `),(1!==b.x||1!==b.y)&&(d+=`scale(${1/b.x}, ${1/b.y}) `),c){let{transformPerspective:a,rotate:b,pathRotation:e,rotateX:f,rotateY:g,skewX:h,skewY:i}=c;a&&(d=`perspective(${a}px) ${d}`),b&&(d+=`rotate(${b}deg) `),e&&(d+=`rotate(${e}deg) `),f&&(d+=`rotateX(${f}deg) `),g&&(d+=`rotateY(${g}deg) `),h&&(d+=`skewX(${h}deg) `),i&&(d+=`skewY(${i}deg) `)}let h=a.x.scale*b.x,i=a.y.scale*b.y;return(1!==h||1!==i)&&(d+=`scale(${h}, ${i})`),d||"none"}(this.projectionDeltaWithTransform,this.treeScale,e);c&&(f=c(e,f)),a.transform=f;let{x:g,y:h}=this.projectionDelta;for(let b in a.transformOrigin=`${100*g.origin}% ${100*h.origin}% 0`,d.animationValues?a.opacity=d===this?e.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:e.opacityExit:a.opacity=d===this?void 0!==e.opacity?e.opacity:"":void 0!==e.opacityExit?e.opacityExit:0,tB){if(void 0===e[b])continue;let{correct:c,applyTo:g,isCSSVariable:h}=tB[b],i="none"===f?e[b]:c(e[b],d);if(g){let b=g.length;for(let c=0;c<b;c++)a[g[c]]=i}else h?this.options.visualElement.renderState.vars[b]=i:a[b]=i}this.options.layoutId&&(a.pointerEvents=d===this?t3(b?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>a.currentAnimation?.stop()),this.root.nodes.forEach(wQ),this.root.sharedNodes.clear()}}}function wL(a){a.updateLayout()}function wM(a){let b=a.resumeFrom?.snapshot||a.snapshot;if(a.isLead()&&a.layout&&b&&a.hasListeners("didUpdate")){let{layoutBox:c,measuredBox:d}=a.layout,{animationType:e}=a.options,f=b.source!==a.layout.source;if("size"===e)vv(a=>{let d=f?b.measuredBox[a]:b.layoutBox[a],e=vw(d);d.min=c[a].min,d.max=d.min+e});else if("x"===e||"y"===e){let a="x"===e?"y":"x";wp(f?b.measuredBox[a]:b.layoutBox[a],c[a])}else w5(e,b.layoutBox,c)&&vv(d=>{let e=f?b.measuredBox[d]:b.layoutBox[d],g=vw(c[d]);e.max=e.min+g,a.relativeTarget&&!a.currentAnimation&&(a.isProjectionDirty=!0,a.relativeTarget[d].max=a.relativeTarget[d].min+g)});let g=rS();vy(g,c,b.layoutBox);let h=rS();f?vy(h,a.applyTransform(d,!0),b.measuredBox):vy(h,c,b.layoutBox);let i=!wy(g),j=!1;if(!a.resumeFrom){let d=a.getClosestProjectingParent();if(d&&!d.resumeFrom){let{snapshot:e,layout:f}=d;if(e&&f){let g=a.options.layoutAnchor||void 0,h=rU();vB(h,b.layoutBox,e.layoutBox,g);let i=rU();vB(i,c,f.layoutBox,g),wB(h,i)||(j=!0),d.options.layoutRoot&&(a.relativeTarget=i,a.relativeTargetOrigin=h,a.relativeParent=d)}}}a.notifyListeners("didUpdate",{layout:c,snapshot:b,delta:h,layoutDelta:g,hasLayoutChanged:i,hasRelativeLayoutChanged:j})}else if(a.isLead()){let{onExitComplete:b}=a.options;b&&b()}a.options.transition=void 0}function wN(a){a.parent&&(a.isProjecting()||(a.isProjectionDirty=a.parent.isProjectionDirty),a.isSharedProjectionDirty||(a.isSharedProjectionDirty=!!(a.isProjectionDirty||a.parent.isProjectionDirty||a.parent.isSharedProjectionDirty)),a.isTransformDirty||(a.isTransformDirty=a.parent.isTransformDirty))}function wO(a){a.isProjectionDirty=a.isSharedProjectionDirty=a.isTransformDirty=!1}function wP(a){a.clearSnapshot()}function wQ(a){a.clearMeasurements()}function wR(a){a.isLayoutDirty=!0,a.updateLayout()}function wS(a){a.isLayoutDirty=!1}function wT(a){a.isAnimationBlocked&&a.layout&&!a.isLayoutDirty&&(a.snapshot=a.layout,a.isLayoutDirty=!0)}function wU(a){let{visualElement:b}=a.options;b&&b.getProps().onBeforeLayoutMeasure&&b.notify("BeforeLayoutMeasure"),a.resetTransform()}function wV(a){a.finishAnimation(),a.targetDelta=a.relativeTarget=a.target=void 0,a.isProjectionDirty=!0}function wW(a){a.resolveTargetDelta()}function wX(a){a.calcProjection()}function wY(a){a.resetSkewAndRotation()}function wZ(a){a.removeLeadSnapshot()}function w$(a,b,c){a.translate=tA(b.translate,0,c),a.scale=tA(b.scale,1,c),a.origin=b.origin,a.originPoint=b.originPoint}function w_(a,b,c,d){a.min=tA(b.min,c.min,d),a.max=tA(b.max,c.max,d)}function w0(a){return a.animationValues&&void 0!==a.animationValues.opacityExit}let w1={duration:.45,ease:[.4,0,.1,1]},w2=a=>"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(a),w3=w2("applewebkit/")&&!w2("chrome/")?Math.round:sl;function w4(a){a.min=w3(a.min),a.max=w3(a.max)}function w5(a,b,c){return"position"===a||"preserve-aspect"===a&&!(.2>=Math.abs(wC(b)-wC(c)))}function w6(a){return a!==a.root&&a.scroll?.wasRoot}let w7=wK({attachResizeListener:(a,b)=>vE(a,"resize",b),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),w8={current:void 0},w9=wK({measureScroll:a=>({x:a.scrollLeft,y:a.scrollTop}),defaultParent:()=>{if(!w8.current){let a=new w7({});a.mount(window),a.setOptions({layoutScroll:!0}),w8.current=a}return w8.current},resetTransform:(a,b)=>{a.style.transform=void 0!==b?b:"none"},checkIsScrollRoot:a=>"fixed"===window.getComputedStyle(a).position});function xa(a,b){let c=vH(a),d=new AbortController;return[c,{passive:!0,...b,signal:d.signal},()=>d.abort()]}function xb(a,b,c){let{props:d}=a;a.animationState&&d.whileHover&&a.animationState.setActive("whileHover","Start"===c);let e=d["onHover"+c];e&&sp.postRender(()=>e(b,vR(b)))}class xc extends ud{mount(){let{current:a}=this.node;a&&(this.unmount=function(a,b,c={}){let[d,e,f]=xa(a,c);return d.forEach(a=>{let c,d=!1,f=!1,g=b=>{c&&(c(b),c=void 0),a.removeEventListener("pointerleave",i)},h=a=>{d=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),f&&(f=!1,g(a))},i=a=>{if("touch"!==a.pointerType){if(d){f=!0;return}g(a)}};a.addEventListener("pointerenter",d=>{if("touch"===d.pointerType||vu.x||vu.y)return;f=!1;let g=b(a,d);"function"==typeof g&&(c=g,a.addEventListener("pointerleave",i,e))},e),a.addEventListener("pointerdown",()=>{d=!0,window.addEventListener("pointerup",h,e),window.addEventListener("pointercancel",h,e)},e)}),f}(a,(a,b)=>(xb(this.node,b,"Start"),a=>xb(this.node,a,"End"))))}unmount(){}}class xd extends ud{constructor(){super(...arguments),this.isActive=!1}onFocus(){let a=!1;try{a=this.node.current.matches(":focus-visible")}catch(b){a=!0}a&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=uk(vE(this.node.current,"focus",()=>this.onFocus()),vE(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function xe(a){return vF(a)&&"offsetHeight"in a&&!("ownerSVGElement"in a)}let xf=(a,b)=>!!b&&(a===b||xf(a,b.parentElement)),xg=new WeakSet;function xh(a){return b=>{"Enter"===b.key&&a(b)}}function xi(a,b){a.dispatchEvent(new PointerEvent("pointer"+b,{isPrimary:!0,bubbles:!0}))}function xj(a){return vQ(a)&&!(vu.x||vu.y)}let xk=new WeakSet;function xl(a,b,c){let{props:d}=a;if(a.current instanceof HTMLButtonElement&&a.current.disabled)return;a.animationState&&d.whileTap&&a.animationState.setActive("whileTap","Start"===c);let e=d["onTap"+("End"===c?"":c)];e&&sp.postRender(()=>e(b,vR(b)))}class xm extends ud{mount(){let{current:a}=this.node;if(!a)return;let{globalTapTarget:b,propagate:c}=this.node.props;this.unmount=function(a,b,c={}){let[d,e,f]=xa(a,c),g=a=>{let d=a.currentTarget;if(!xj(a)||xk.has(a))return;xg.add(d),c.stopPropagation&&xk.add(a);let f=b(d,a),g={...e,capture:!0},h=(a,b)=>{window.removeEventListener("pointerup",i,g),window.removeEventListener("pointercancel",j,g),xg.has(d)&&xg.delete(d),xj(a)&&"function"==typeof f&&f(a,{success:b})},i=a=>{h(a,d===window||d===document||c.useGlobalTarget||xf(d,a.target))},j=a=>{h(a,!1)};window.addEventListener("pointerup",i,g),window.addEventListener("pointercancel",j,g)};return d.forEach(a=>{((c.useGlobalTarget?window:a).addEventListener("pointerdown",g,e),xe(a))&&(a.addEventListener("focus",a=>((a,b)=>{let c=a.currentTarget;if(!c)return;let d=xh(()=>{if(xg.has(c))return;xi(c,"down");let a=xh(()=>{xi(c,"up")});c.addEventListener("keyup",a,b),c.addEventListener("blur",()=>xi(c,"cancel"),b)});c.addEventListener("keydown",d,b),c.addEventListener("blur",()=>c.removeEventListener("keydown",d),b)})(a,e)),vC.has(a.tagName)||!0===a.isContentEditable||a.hasAttribute("tabindex")||(a.tabIndex=0))}),f}(a,(a,b)=>(xl(this.node,b,"Start"),(a,{success:b})=>xl(this.node,a,b?"End":"Cancel")),{useGlobalTarget:b,stopPropagation:c?.tap===!1})}unmount(){}}let xn=new WeakMap,xo=new WeakMap,xp=a=>{let b=xn.get(a.target);b&&b(a)},xq=a=>{a.forEach(xp)},xr={some:0,all:1};class xs extends ud{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var a;let b;this.stopObserver?.();let{viewport:c={}}=this.node.getProps(),{root:d,margin:e,amount:f="some",once:g}=c,h={root:d?d.current:void 0,rootMargin:e,threshold:"number"==typeof f?f:xr[f]},i=a=>{let{isIntersecting:b}=a;if(this.isInView===b||(this.isInView=b,g&&!b&&this.hasEnteredView))return;b&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",b);let{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),e=b?c:d;e&&e(a)};this.stopObserver=(a=this.node.current,b=function({root:a,...b}){let c=a||document;xo.has(c)||xo.set(c,{});let d=xo.get(c),e=JSON.stringify(b);return d[e]||(d[e]=new IntersectionObserver(xq,{root:a,...b})),d[e]}(h),xn.set(a,i),b.observe(a),()=>{xn.delete(a),b.unobserve(a)})}mount(){this.startObserver()}update(){if("u"<typeof IntersectionObserver)return;let{props:a,prevProps:b}=this.node;["amount","margin","root"].some(function({viewport:a={}},{viewport:b={}}={}){return c=>a[c]!==b[c]}(a,b))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}let xt=function(a,b){if("u"<typeof Proxy)return uc;let c=new Map,d=(c,d)=>uc(c,d,a,b);return new Proxy((a,b)=>d(a,b),{get:(e,f)=>"create"===f?d:(c.has(f)||c.set(f,uc(f,void 0,a,b)),c.get(f))})}({animation:{Feature:vr},exit:{Feature:vt},inView:{Feature:xs},tap:{Feature:xm},focus:{Feature:xd},hover:{Feature:xc},pan:{Feature:wa},drag:{Feature:v8,ProjectionNode:w9,MeasureLayout:wh},layout:{ProjectionNode:w9,MeasureLayout:wh}},(a,b)=>b.isSVG??tV(a)?new tF(b):new tT(b,{allowProjection:a!==B.Fragment})),xu=new Map,xv=(0,B.memo)(({children:a,as:b="p",className:c,duration:d=2,spread:e=2})=>{let f,g=((f=xu.get(b))||(f=xt.create(b),xu.set(b,f)),f),h=(0,B.useMemo)(()=>(a?.length??0)*e,[a,e]);return(0,A.jsx)(g,{animate:{backgroundPosition:"0% center"},className:(0,W.cn)("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",c),initial:{backgroundPosition:"100% center"},style:{"--spread":`${h}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{duration:d,ease:"linear",repeat:1/0},children:a})}),xw=(0,B.createContext)(null),xx=(0,B.memo)(({className:a,isStreaming:b=!1,open:c,defaultOpen:d,onOpenChange:e,duration:f,children:g,...h})=>{let i=d??b,j=!1===d,[k,l]=(0,rd.i)({defaultProp:i,onChange:e,prop:c}),[m,n]=(0,rd.i)({defaultProp:void 0,prop:f}),o=(0,B.useRef)(b),[p,q]=(0,B.useState)(!1),r=(0,B.useRef)(null);(0,B.useEffect)(()=>{b?(o.current=!0,null===r.current&&(r.current=Date.now())):null!==r.current&&(n(Math.ceil((Date.now()-r.current)/1e3)),r.current=null)},[b,n]),(0,B.useEffect)(()=>{!b||k||j||l(!0)},[b,k,l,j]),(0,B.useEffect)(()=>{if(o.current&&!b&&k&&!p){let a=setTimeout(()=>{l(!1),q(!0)},1e3);return()=>clearTimeout(a)}},[b,k,l,p]);let s=(0,B.useCallback)(a=>{l(a)},[l]),t=(0,B.useMemo)(()=>({duration:m,isOpen:k,isStreaming:b,setIsOpen:l}),[m,k,b,l]);return(0,A.jsx)(xw.Provider,{value:t,children:(0,A.jsx)(cs.Nt,{className:(0,W.cn)("not-prose mb-4",a),onOpenChange:s,open:k,...h,children:g})})}),xy=(a,b)=>a||0===b?(0,A.jsx)(xv,{duration:1,children:"Thinking..."}):void 0===b?(0,A.jsx)("p",{children:"Thought for a few seconds"}):(0,A.jsxs)("p",{children:["Thought for ",b," seconds"]}),xz=(0,B.memo)(({className:a,children:b,getThinkingMessage:c=xy,...d})=>{let{isStreaming:e,isOpen:f,duration:g}=(()=>{let a=(0,B.useContext)(xw);if(!a)throw Error("Reasoning components must be used within Reasoning");return a})();return(0,A.jsx)(cs.R6,{className:(0,W.cn)("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",a),...d,children:b??(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(q7,{className:"size-4"}),c(e,g),(0,A.jsx)(cr.A,{className:(0,W.cn)("size-4 transition-transform",f?"rotate-180":"rotate-0")})]})})}),xA={cjk:d0.h,code:d1.a,math:eI,mermaid:is},xB=(0,B.memo)(({className:a,children:b,...c})=>(0,A.jsx)(cs.Ke,{className:(0,W.cn)("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",a),...c,children:(0,A.jsx)(it.jH,{plugins:xA,children:b})}));xx.displayName="Reasoning",xz.displayName="ReasoningTrigger",xB.displayName="ReasoningContent";var xC=c(10588),xD=c.n(xC);function xE({messages:a,incomplete:b,children:c}){let{t:d}=(0,Q.Bd)("conversation"),[e,f]=(0,B.useState)(!1),[g,h]=(0,B.useState)(!1),i=(0,B.useRef)(null),j=(0,B.useRef)(!1);return(0,A.jsxs)(cq.AM,{open:e,onOpenChange:(a,b)=>{if(!a&&"trigger-press"===b.reason&&j.current){j.current=!1,b.cancel();return}a&&"trigger-hover"===b.reason&&g||!a&&"trigger-hover"===b.reason&&(!j.current||i.current?.contains(document.activeElement))?b.cancel():(a?j.current="trigger-hover"===b.reason:"trigger-hover"!==b.reason&&(j.current=!1,h(!0)),f(a))},children:[(0,A.jsx)(cq.Wv,{openOnHover:!g,delay:250,closeDelay:180,onPointerLeave:()=>h(!1),className:"min-w-0 cursor-pointer rounded-sm text-left text-xs text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:c}),(0,A.jsxs)(cq.hl,{ref:i,align:"start",side:"top",initialFocus:()=>!j.current,className:(0,W.cn)(xD().panel,"w-[30rem] gap-0 p-2"),children:[(0,A.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b px-1 pb-1",children:[(0,A.jsx)(cq.eO,{className:"min-w-0 flex-1 text-xs font-medium text-muted-foreground",children:d(b?"calls.loadedTitle":"calls.title")}),(0,A.jsx)("button",{type:"button","aria-label":d("calls.close"),className:"flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{j.current=!1,h(!0),f(!1)},children:(0,A.jsx)(al.A,{className:"size-3.5"})})]}),e?(0,A.jsx)("div",{className:"min-h-0 overflow-y-auto overscroll-contain",children:(0,A.jsxs)("div",{className:xD().table,children:[(0,A.jsxs)("div",{className:(0,W.cn)(xD().row,"text-muted-foreground"),children:[(0,A.jsx)("span",{children:d("calls.model")}),(0,A.jsx)("span",{children:d("calls.input")}),(0,A.jsx)("span",{children:d("calls.output")}),(0,A.jsx)("span",{children:d("calls.cached")}),(0,A.jsx)("span",{children:d("calls.cost")})]}),a.map(a=>{let b=a.snapshot.fixed;if("assistant"!==b.type)return null;let c="assistant"===a.summary.type?a.summary.model:null,e=b.usage;return(0,A.jsxs)("div",{className:xD().row,children:[(0,A.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[(0,A.jsxs)("span",{className:"min-w-0 truncate",title:c?`${c.modelId} \xb7 ${c.provider}`:void 0,children:[c?.modelId||d("calls.unknownModel"),c?.provider?(0,A.jsxs)("span",{className:"text-muted-foreground",children:[" \xb7 ",c.provider]}):null]}),"error"===b.status||"aborted"===b.status?(0,A.jsx)("span",{className:"shrink-0 text-destructive",children:d(`calls.${b.status}`)}):null]}),(0,A.jsx)("span",{children:qJ(e.inputTokens)}),(0,A.jsx)("span",{children:qJ(e.outputTokens)}),(0,A.jsx)("span",{children:qJ(e.cacheReadTokens)}),(0,A.jsx)("span",{children:qK(e.costUsd)})]},a.durable.location.entryId)})]})}):null]})]})}function xF({nestedCalls:a}){let{t:b}=(0,Q.Bd)("conversation");return(0,A.jsxs)("section",{className:"border-t px-3 py-3 text-sm",children:[(0,A.jsx)("h4",{className:"mb-2 font-medium",children:b(a.complete?"nestedCalls":"nestedCallsIncomplete")}),(0,A.jsx)("ol",{className:"max-h-[min(24rem,45dvh)] space-y-2 overflow-auto",children:a.calls.map((a,c)=>(0,A.jsxs)("li",{className:"border-b pb-2 last:border-0 last:pb-0",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[(0,A.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground",children:c+1}),(0,A.jsx)("span",{className:"min-w-0 break-words font-mono font-medium",children:a.name}),(0,A.jsx)("span",{className:"error"===a.status?"text-xs text-destructive":"text-xs text-muted-foreground",children:b(`nestedStatus.${a.status}`)}),void 0===a.durationMs?null:(0,A.jsxs)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:[a.durationMs," ms"]})]}),a.arguments?(0,A.jsxs)("details",{className:"mt-1",children:[(0,A.jsx)("summary",{className:"min-h-7 cursor-pointer text-xs text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring",children:b("nestedArguments")}),(0,A.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words py-2 font-mono text-sm",children:JSON.stringify(a.arguments,null,2)})]}):null,void 0===a.argumentsBytes?null:(0,A.jsx)("p",{className:"mt-1 text-xs tabular-nums text-muted-foreground",children:b("nestedArgumentsBytes",{count:a.argumentsBytes})}),a.error?(0,A.jsx)("p",{className:"mt-1 whitespace-pre-wrap break-words text-destructive",children:a.error}):null]},c))})]})}function xG({plugin:a}){let{t:b}=(0,Q.Bd)("conversation"),{locale:c}=(0,cy.i)();return(0,A.jsxs)("div",{className:"min-w-0 space-y-1 py-2 first:pt-0 last:pb-0",role:"listitem",children:[(0,A.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[(0,A.jsx)("span",{className:"min-w-0 font-medium [overflow-wrap:anywhere]",children:a.name}),(0,A.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:a.version??b("pidesk.unknownVersion")}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:b(`pidesk.status.${a.status}`)})]}),(0,A.jsxs)("p",{className:"text-xs text-muted-foreground [overflow-wrap:anywhere]",children:[b(`pidesk.kind.${a.kind}`)," \xb7 ",(0,A.jsx)("span",{className:"font-mono",children:a.source})]}),a.updateTag||a.availableVersion?(0,A.jsxs)("p",{className:"flex flex-wrap gap-x-3 text-xs text-muted-foreground [overflow-wrap:anywhere]",children:[a.updateTag?(0,A.jsx)("span",{children:b("pidesk.updateChannel",{tag:a.updateTag})}):null,a.availableVersion?(0,A.jsx)("span",{children:b("pidesk.targetVersion",{version:a.availableVersion})}):null]}):null,a.updateError?(0,A.jsx)("p",{className:"text-destructive [overflow-wrap:anywhere]",children:a.updateError}):null,a.operation?(0,A.jsxs)("p",{className:"[overflow-wrap:anywhere]",children:[b(`pidesk.action.${a.operation.action}`)," \xb7 ",b(`pidesk.phase.${a.operation.phase}`),a.operation.message?` \xb7 ${a.operation.message}`:""]}):null,a.error?(0,A.jsxs)("p",{className:"text-destructive [overflow-wrap:anywhere]",children:[b(`pidesk.errorPhase.${a.error.phase}`)," \xb7 ",(0,cx.fD)(a.error.message,c)]}):null]})}function xH({result:a}){let{t:b}=(0,Q.Bd)("conversation"),{locale:c}=(0,cy.i)();return"info"===a.kind?(0,A.jsx)("dl",{className:"grid grid-cols-[max-content_minmax(0,1fr)] gap-x-4 gap-y-2",children:Object.entries(a.data).map(([a,c])=>(0,A.jsxs)("div",{className:"contents",children:[(0,A.jsx)("dt",{className:"text-muted-foreground",children:b(`pidesk.info.${a}`)}),(0,A.jsx)("dd",{className:"min-w-0 [overflow-wrap:anywhere]",children:"environment"===a?b(`pidesk.environment.${c}`):"mode"===a?b(`pidesk.mode.${c}`):(0,A.jsx)("span",{className:"font-mono",children:c})})]},a))}):"plugin"===a.kind?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{role:"list",children:(0,A.jsx)(xG,{plugin:a.data})}),(0,A.jsx)("p",{className:"mt-3 mb-2 font-medium",children:b("pidesk.pluginDetail")}),(0,A.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono leading-relaxed",children:JSON.stringify(a.data.detail,null,2)})]}):(0,A.jsxs)(A.Fragment,{children:[a.data.restartRequired?(0,A.jsx)("p",{className:"mb-2",children:b("pidesk.restartRequired")}):null,a.data.loadError?(0,A.jsx)("p",{className:"mb-2 text-destructive [overflow-wrap:anywhere]",children:(0,cx.fD)(a.data.loadError,c)}):null,a.data.plugins.length>0?(0,A.jsx)("div",{className:"divide-y divide-border",role:"list",children:a.data.plugins.map((a,b)=>(0,A.jsx)(xG,{plugin:a},`${a.source}:${b}`))}):(0,A.jsx)("p",{className:"text-muted-foreground",children:b("pidesk.noPlugins")})]})}function xI({identity:a,command:b,output:c,expandable:d,open:e,loading:f,error:g,onOpenChange:h,commandAction:i,outputAction:j}){let{t:k}=(0,Q.Bd)("conversation"),l=b.label?[k(b.label),b.name,b.version].filter(Boolean).join(" \xb7 "):b.command,m=null===c?null:function(a,b){let c;if(!["pideskListPlugins","pideskShowPlugin","pideskInfo"].includes(a??""))return null;try{c=JSON.parse(b)}catch{return null}switch(a){case"pideskListPlugins":{let a=qw.safeParse(c);return a.success?{kind:"plugins",data:a.data}:null}case"pideskShowPlugin":{let a=qx.safeParse(c);return a.success?{kind:"plugin",data:a.data}:null}case"pideskInfo":{let a=qy.safeParse(c);return a.success?{kind:"info",data:a.data}:null}default:return null}}(b.label,c);return(0,A.jsxs)(cs.Nt,{open:d&&e,onOpenChange:h,className:"w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card text-sm leading-relaxed","data-message-id":a,"data-chat-scroll-anchor":`${a}:tool`,children:[(0,A.jsxs)(cs.R6,{disabled:!d,"aria-label":d?k(e?"collapseTool":"expandTool",{name:l}):l,className:(0,W.cn)("flex min-h-9 w-full min-w-0 items-center gap-2 px-3 py-1.5 text-left",d&&"cursor-pointer hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),children:[(0,A.jsx)(kt,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,A.jsx)("span",{className:(0,W.cn)("min-w-0 flex-1 truncate font-medium",!b.label&&"font-mono"),title:l,children:l}),d?(0,A.jsx)(cr.A,{className:(0,W.cn)("size-4 shrink-0 text-muted-foreground transition-transform",e&&"rotate-180"),"aria-hidden":"true"}):null]}),(0,A.jsx)(cs.Ke,{className:"h-[var(--collapsible-panel-height)] overflow-hidden transition-[height,opacity] duration-200 ease-out data-starting-style:h-0 data-starting-style:opacity-0 data-ending-style:h-0 data-ending-style:opacity-0 motion-reduce:transition-none",children:(0,A.jsxs)("div",{className:"border-t",children:[(0,A.jsxs)("section",{className:"border-b px-3 py-2","aria-label":k("pidesk.command"),children:[(0,A.jsxs)("div",{className:"mb-1 flex min-h-7 items-center justify-between gap-2",children:[(0,A.jsx)("h4",{className:"font-medium text-muted-foreground",children:k("pidesk.command")}),i]}),(0,A.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono leading-relaxed",children:b.command})]}),(0,A.jsxs)("section",{"aria-label":k("pidesk.output"),children:[(0,A.jsxs)("div",{className:"flex min-h-9 items-center justify-between gap-2 px-3 pt-2",children:[(0,A.jsx)("h4",{className:"font-medium text-muted-foreground",children:k("pidesk.output")}),j]}),(0,A.jsx)("div",{className:"max-h-[min(24rem,50dvh)] overflow-auto px-3 pt-1 pb-3",role:"region","aria-label":k("pidesk.output"),tabIndex:0,children:f?(0,A.jsx)("p",{className:"text-muted-foreground",children:k("loadingResult")}):g?(0,A.jsx)("p",{className:"text-destructive [overflow-wrap:anywhere]",children:g}):c?m?(0,A.jsx)(xH,{result:m}):(0,A.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono leading-relaxed",children:c}):(0,A.jsx)("p",{className:"text-muted-foreground",children:k("pidesk.empty")})})]})]})})]})}var xJ=c(11113),xK=c.n(xJ);let xL="max-h-[min(20rem,45dvh)] overflow-auto [scrollbar-gutter:stable]",xM=(0,B.createContext)(()=>void 0),xN=(0,B.createContext)(null),xO=(0,B.createContext)(null),xP="h-[var(--collapsible-panel-height)] overflow-hidden transition-[height,opacity] duration-200 ease-out data-starting-style:h-0 data-starting-style:opacity-0 data-ending-style:h-0 data-ending-style:opacity-0 motion-reduce:transition-none";function xQ({children:a}){let{isAtBottom:b,stopScroll:c}=pR(),d=(0,B.useRef)(b),e=(0,B.useRef)(c),f=(0,B.useCallback)(()=>{d.current&&e.current()},[]);return(0,A.jsx)(xM.Provider,{value:f,children:a})}function xR(a,b){let{t:c}=(0,Q.Bd)("conversation"),[d,e]=(0,B.useState)(!1),[f,g]=(0,B.useState)(null),h=(0,B.useCallback)(async()=>{if(!a.temporary&&a.durable&&a.snapshot.fixed.hasDetail&&void 0===a.detail&&!d){e(!0),g(null);try{await b(a)}catch(a){g(a instanceof Error?a.message:c("detailFailed"))}finally{e(!1)}}},[d,a,b,c]);return{loading:d,error:f,load:h}}function xS(a,b){let[c,d]=(0,B.useState)(!1),e=(0,B.useContext)(xM),{loading:f,error:g,load:h}=xR(a,b),i=!a.temporary&&(a.summary.hasDetail||"tool"===a.summary.type&&!!a.summary.images?.length);return{open:c,expandable:i,loading:f,error:g,handleOpenChange:a=>{i&&(a&&(e(),h()),d(a))}}}function xT({timestampMs:a}){let{locale:b,timeZone:c}=(0,cy.i)(),d=qL(a,void 0,b,c);return(0,A.jsx)("time",{dateTime:new Date(a).toISOString(),title:d.full,className:"shrink-0",children:d.compact})}function xU({text:a,copyLabel:b,alwaysVisible:c=!1}){let{t:d}=(0,Q.Bd)("conversation"),e=(0,bK.G)(),[f,g]=(0,B.useState)(!1),h=(0,B.useRef)(null),i=(0,B.useCallback)(async()=>{let b=!1;try{b=await (0,cZ.x)(a)}catch{b=!1}b?(g(!0),null!==h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{h.current=null,g(!1)},1500)):e.error(d("messageCopyFailed"))},[a,e,d]);if(!a.trim())return null;let j=f?d("copied"):b??d("copyMessage");return(0,A.jsx)(iw,{tooltip:j,label:j,size:"icon-sm",className:(0,W.cn)(!c&&xK().messageCopyAction,"text-muted-foreground"),onClick:()=>void i(),children:f?(0,A.jsx)(bs.A,{className:"size-3.5"}):(0,A.jsx)(bM.A,{className:"size-3.5"})})}function xV({usage:a,compactOnly:b=!1}){let{t:c}=(0,Q.Bd)("conversation"),d=qJ(a.inputTokens),e=qJ(a.outputTokens),f=qJ(a.cacheReadTokens),g=qK(a.costUsd),h=c("usage",{input:d,output:e,cached:f,cost:g}),i=`${d}/${e}/${f}/${g}`;return b?(0,A.jsx)("span",{className:"shrink-0 font-mono text-xs tabular-nums text-muted-foreground",title:h,"aria-label":h,children:i}):(0,A.jsxs)("span",{className:"min-w-0",children:[(0,A.jsx)("span",{className:xK().usageLabeled,children:h}),(0,A.jsx)("span",{className:xK().usageCompact,children:i})]})}function xW({message:a}){if("assistant"!==a.summary.type||null===a.timestampMs)return null;let b="running"!==a.summary.status?a.summary.text:null;return(0,A.jsxs)(iz,{className:(0,W.cn)(xK().usageToolbar,"mt-1 flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground"),children:[a.usageCalls?.length?(0,A.jsx)(xE,{messages:a.usageCalls,incomplete:a.usageIncomplete??!1,children:(0,A.jsx)(xV,{usage:a.summary.usage})},a.durable.location.entryId):(0,A.jsx)(xV,{usage:a.summary.usage}),(0,A.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[null===b?null:(0,A.jsx)(xU,{text:b}),null===a.timestampMs?null:(0,A.jsx)(xT,{timestampMs:a.timestampMs})]})]})}function xX({message:a,onAcquireImage:b}){let{t:c}=(0,Q.Bd)("conversation"),d="user"===a.summary.type||"tool"===a.summary.type?a.summary.images??[]:[],e=d.length;(0,B.useRef)(a);let[f,g]=(0,B.useState)(()=>Array.from({length:e},()=>({status:"loading"}))),[h,i]=(0,B.useState)(null),[j,k]=(0,B.useState)(0);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"mb-2 grid grid-cols-2 gap-2 sm:grid-cols-3",children:d.map((a,b)=>{let e=f[b];return e?.status==="error"?(0,A.jsxs)("button",{type:"button",className:"flex aspect-square min-h-20 cursor-pointer flex-col items-center justify-center gap-2 rounded-md border bg-muted px-2 text-center text-xs text-muted-foreground hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{i(null),g(a=>a.map(a=>"error"===a.status?{status:"loading"}:a)),k(a=>a+1)},children:[(0,A.jsx)("span",{children:c("imageUnavailable")}),(0,A.jsx)("span",{className:"text-sm font-medium text-foreground",children:c("retry",{ns:"common"})})]},`${b}:${a.width}:${a.height}`):e?.status!=="ready"?(0,A.jsx)("div",{className:"grid aspect-square min-h-20 place-items-center rounded-md border bg-muted px-2 text-center text-xs text-muted-foreground",children:c("imageLoading")},`${b}:${a.width}:${a.height}`):(0,A.jsx)("button",{type:"button",className:"group block aspect-square w-full cursor-zoom-in overflow-hidden rounded-md border bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{let a,e;return a=[],e=-1,void(f.forEach((f,g)=>{if("ready"!==f.status)return;g===b&&(e=a.length);let h=d[g];a.push({src:f.url,alt:c("chatImage",{count:g+1}),width:h.width,height:h.height})}),e>=0&&i({slides:a,index:e}))},"aria-label":c("previewImageNumber",{count:b+1}),children:(0,A.jsx)("img",{src:e.url,alt:c("chatImage",{count:b+1}),className:"aspect-square size-full object-cover transition-transform duration-200 group-hover:scale-[1.02] motion-reduce:transition-none"})},`${b}:${a.width}:${a.height}`)})}),h?(0,A.jsx)(j$.k,{mode:"modal",open:!0,slides:h.slides,index:h.index,ariaLabel:c("chatImagePreview"),onClose:()=>i(null),onIndexChange:a=>i(b=>b?{...b,index:a}:b)}):null]})}function xY({text:a}){let{t:b}=(0,Q.Bd)("conversation"),c=(0,B.useRef)(null),[d,e]=(0,B.useState)(!1),[f,g]=(0,B.useState)(null),h=(0,B.useContext)(xM),i=(0,B.useCallback)(()=>{d||h(),e(a=>!a)},[h,d]);return(0,A.jsxs)("div",{className:"min-w-0",children:[(0,A.jsxs)("div",{className:(0,W.cn)("relative",!d&&!1!==f&&xK().userTextCollapsed),children:[(0,A.jsx)("p",{ref:c,className:"whitespace-pre-wrap break-words",children:a}),f&&!d?(0,A.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-secondary to-transparent","aria-hidden":"true"}):null]}),f?(0,A.jsxs)("button",{type:"button","aria-expanded":d,onClick:i,className:"-mb-1 ml-auto mt-1 flex min-h-7 cursor-pointer items-center gap-1 rounded-md px-1 text-xs font-medium text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[b(d?"collapse":"expand"),(0,A.jsx)(cr.A,{className:(0,W.cn)("size-3.5 transition-transform",d&&"rotate-180"),"aria-hidden":"true"})]}):null]})}function xZ({message:a,onAcquireImage:b,onResend:c,resendDisabled:d}){let{t:e}=(0,Q.Bd)("conversation");if("user"!==a.summary.type)throw Error("UserMessage requires a user summary");return(0,A.jsxs)(iu,{from:"user","data-message-id":a.identity,"data-chat-scroll-anchor":`${a.identity}:user`,"data-chat-user-message":"",className:(0,W.cn)(xK().copyableMessage,"max-w-[92%] sm:max-w-[84%]"),children:[(0,A.jsxs)(iv,{className:(0,W.cn)(xK().userText,"group-[.is-user]:px-3 group-[.is-user]:py-2"),children:[a.summary.images.length>0?(0,A.jsx)(xX,{message:a,onAcquireImage:b},`${a.tempId}:${a.durable?.location.entryId??"temporary"}`):null,a.summary.text?(0,A.jsx)(xY,{text:a.summary.text}):null]}),null===a.timestampMs?null:(0,A.jsxs)(iz,{className:"mt-0 justify-end gap-1 text-xs text-muted-foreground",children:[a.durable&&c?(0,A.jsx)(iw,{tooltip:e("resendMessage"),label:e("resendMessage"),size:"icon-sm",className:(0,W.cn)(xK().messageCopyAction,"text-muted-foreground"),disabled:d,onClick:()=>c(a.durable.location.entryId),children:(0,A.jsx)(pF,{className:"size-3.5"})}):null,(0,A.jsx)(xU,{text:a.summary.text}),(0,A.jsx)(xT,{timestampMs:a.timestampMs})]})]})}function x$({message:a,text:b}){let c=a.temporary&&"assistant"===a.summary.type&&"running"===a.summary.status;return(0,A.jsxs)(iu,{from:"assistant","data-message-id":a.identity,"data-chat-scroll-anchor":`${a.identity}:text`,className:(0,W.cn)(xK().copyableMessage,"max-w-full gap-1"),children:[(0,A.jsx)(iv,{className:"w-full",children:(0,A.jsx)(kI,{isAnimating:c,mode:c?"streaming":"static",children:b})}),(0,A.jsx)(xW,{message:a})]})}function x_(){let{t:a}=(0,Q.Bd)("conversation");return(0,A.jsxs)("div",{role:"status",className:(0,W.cn)(xK().detailText,"flex min-h-9 w-full items-center gap-2 py-1 text-muted-foreground"),children:[(0,A.jsx)(q7,{className:"size-4","aria-hidden":"true"}),(0,A.jsx)(xv,{as:"span",duration:1,children:a("thinking")})]})}function x0({content:a,streaming:b}){let{t:c}=(0,Q.Bd)("conversation"),{scrollRef:d,contentRef:e}=pK({initial:!!b&&"instant",resize:"instant"}),f=a.length>5e3,g=a.slice(-5e3);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{ref:d,className:"max-h-56 overflow-y-auto pb-2 pr-2 [scrollbar-gutter:stable] sm:max-h-72",children:(0,A.jsx)("div",{ref:e,children:(0,A.jsx)(kI,{isAnimating:b,mode:b?"streaming":"static",children:g},f?a.length:void 0)})}),f?(0,A.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:c("thinkingTruncated",{count:5e3})}),(0,A.jsx)(xU,{text:a,copyLabel:c("copyThinking"),alwaysVisible:!0})]}):null]})}function x1({message:a,detailLoad:b}){let{t:c}=(0,Q.Bd)("conversation");if("assistant"!==a.summary.type)return null;let{loading:d,error:e,load:f}=b,g=void 0!==a.detail,h=a.detail?.type==="assistant"?a.detail:null,i=h?.thinking??"",j=i.trim().length>0,k=j&&a.temporary&&"running"===a.summary.status&&0===a.summary.text.trim().length;if(!(j||!g&&a.summary.hasDetail))return null;let l=i||(d?c("thinkingLoading"):e??c("thinkingUnavailable"));return(0,A.jsxs)(xx,{className:"mb-0 w-full",isStreaming:k,onOpenChange:a=>{a&&f()},children:[(0,A.jsx)(xz,{className:(0,W.cn)(xK().detailText,"min-h-9 justify-start py-1"),getThinkingMessage:a=>a?(0,A.jsx)(xv,{as:"span",duration:1,children:c("thinking")}):(0,A.jsx)("span",{children:c("thinkingProcess")})}),(0,A.jsx)(cs.Ke,{className:(0,W.cn)(xP,"text-sm leading-6 text-muted-foreground outline-none"),children:(0,A.jsx)("div",{className:"pt-2",children:(0,A.jsx)("div",{className:"border-l pl-4",children:(0,A.jsx)(x0,{content:l,streaming:k})})})})]})}function x2({message:a}){let{t:b}=(0,Q.Bd)("conversation"),{locale:c}=(0,cy.i)();if("assistant"!==a.summary.type)return null;let d=function(a,b){let c=a?.trim();if(!c)return null;switch(c.toLowerCase()){case"terminated":return kB.W[b].streamInterrupted;case"request timed out":case"request timed out.":return kB.W[b].requestTimedOut;default:return a}}(a.summary.errorMessage,c)??("error"===a.summary.status?b("modelFailed"):null);return d?(0,A.jsx)("pre",{className:(0,W.cn)(xK().toolOutput,"whitespace-pre-wrap break-words rounded-lg border border-destructive/40 bg-muted p-3 font-sans text-destructive"),children:d}):null}function x3({item:a,onLoadDetail:b}){let{message:c,hideAssistantText:d}=a,e=xR(c,b);if("assistant"!==c.summary.type)throw Error("AssistantProcessItem requires an assistant summary");return(0,A.jsxs)("div",{className:"space-y-2","data-message-id":c.identity,"data-chat-scroll-anchor":`${c.identity}:process`,children:[(0,A.jsx)(x1,{message:c,detailLoad:e}),d||!c.summary.text.trim()?null:(0,A.jsx)(x$,{message:c,text:c.summary.text}),(0,A.jsx)(x2,{message:c})]})}function x4({name:a,filePath:b,className:c}){let d=a.toLowerCase().split(".").at(-1)??a.toLowerCase(),e={className:c};switch(d){case"read":return b?(0,A.jsx)(rc.s,{path:b,...e}):(0,A.jsx)(j2.A,{...e});case"write":return(0,A.jsx)(q8,{...e});case"edit":return(0,A.jsx)(q9,{...e});case"bash":return(0,A.jsx)(T,{...e});case"grep":case"find":return(0,A.jsx)(bZ.A,{...e});case"ls":return(0,A.jsx)(ch.A,{...e});case"agent":case"agent_resume":return(0,A.jsx)(ci,{...e});default:return(0,A.jsx)(cj,{...e})}}function x5(a){let b=a.replaceAll("\\","/");return"/"===b||/^[A-Za-z]:\/$/.test(b)?b:b.replace(/\/+$/,"")}function x6({status:a,timing:b}){let c=b&&"startedAtMs"in b?b.startedAtMs:null,d=b&&"durationMs"in b?b.durationMs:null,[e,f]=(0,B.useState)(()=>Date.now()),g=d??(null===c?null:Math.max(0,e-c));return null===g?null:(0,A.jsx)(A.Fragment,{children:function(a){let b=Math.max(0,Math.floor(a/1e3)),c=b%60,d=Math.floor(b/60);if(0===d)return`${c}s`;let e=d%60,f=Math.floor(d/60);return 0===f?`${e}m ${c}s`:`${f}h ${e}m ${c}s`}(g)})}function x7({message:a,onLoadDetail:b,previewPath:c,onPreviewFile:d,renderDetail:e}){let{t:f}=(0,Q.Bd)("conversation");if("tool"!==a.summary.type&&"bash"!==a.summary.type)throw Error("ToolCardShell requires a tool or bash summary");let g=(0,B.useContext)(xN),h=(0,B.useContext)(xO),i=!a.temporary&&"tool"===a.summary.type&&!!a.summary.images?.length,{open:j,expandable:k,loading:l,error:m,handleOpenChange:n}=xS(a,b),{name:o,reasoning:p,inputPreview:q,activity:r,usage:s}="tool"===a.summary.type?{name:a.summary.name,reasoning:a.summary.reasoning,inputPreview:a.summary.inputPreview,activity:a.summary.activity,usage:a.summary.usage}:{name:"bash",reasoning:null,inputPreview:a.summary.command,activity:null,usage:null},t="tool"===a.summary.type&&"bash"===a.summary.kind?a.summary:null,u="error"===a.summary.status,v=!a.temporary&&null!==c&&void 0!==d,w=c?function(a,b){let{compactPath:c,fullPath:d}=function(a,b){let c=x5(a);if(!b)return{compactPath:c,fullPath:c};let d=x5(b);if(!(c.startsWith("/")||/^[A-Za-z]:\//.test(c))){let a=c.replace(/^(?:\.\/)+/,""),b=d.endsWith("/")?d:`${d}/`;return{compactPath:a,fullPath:`${b}${a}`}}let e=d.endsWith("/")?d:`${d}/`,f=/^[A-Za-z]:\//.test(c)&&/^[A-Za-z]:\//.test(d),g=f?c.toLowerCase():c,h=f?e.toLowerCase():e;return g.startsWith(h)?{compactPath:c.slice(e.length),fullPath:c}:{compactPath:c,fullPath:c}}(a,b),e=c.match(/^[A-Za-z]:\//)?.[0]??null??(c.startsWith("/")?"/":""),f=c.slice(e.length).split("/").filter(Boolean),g=f.pop()??c,h=g.lastIndexOf("."),i=f.length>2?`…/${f.slice(-2).join("/")}`:`${e}${f.join("/")}`;return{fileStem:h>0?g.slice(0,h):g,fileExtension:h>0?g.slice(h):"",directory:i||null,fullPath:d}}(c,g):null;return(0,A.jsxs)(cs.Nt,{open:k&&j,onOpenChange:n,className:(0,W.cn)(xK().detailText,"w-full overflow-hidden rounded-lg border bg-muted/45 dark:bg-card",u?"border-destructive":"border-border"),"data-message-id":a.identity,"data-chat-scroll-anchor":`${a.identity}:tool`,children:[(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsxs)(cs.R6,{disabled:!k,className:(0,W.cn)("relative grid min-h-14 w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 px-3 py-1.5 text-left",k&&"cursor-pointer hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"),"aria-label":f(k?j?"collapseTool":"expandTool":"tool",{name:o}),children:[(0,A.jsx)(x4,{name:o,filePath:c,className:"col-start-1 row-start-1 size-4 text-muted-foreground"}),(0,A.jsxs)("span",{className:"col-start-2 row-start-1 flex min-h-7 min-w-0 items-center gap-2",children:[(0,A.jsx)("span",{className:"shrink-0 font-mono font-medium",children:o}),p?(0,A.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:p}):null,s?(0,A.jsx)(xV,{usage:s,compactOnly:!0}):null]}),(0,A.jsxs)("span",{className:"col-start-3 row-start-1 flex min-h-7 items-center justify-end gap-2",children:[v?(0,A.jsx)("span",{className:"size-7","aria-hidden":"true"}):null,k?(0,A.jsx)("span",{className:"flex size-7 items-center justify-center","aria-hidden":"true",children:(0,A.jsx)(cr.A,{"data-tool-disclosure":"",className:(0,W.cn)("size-4 text-muted-foreground transition-transform",j&&"rotate-180")})}):null]}),w?(0,A.jsxs)("span",{className:(0,W.cn)(xK().toolFilePath,"col-start-2 row-start-2 flex min-w-0 items-baseline overflow-hidden font-mono text-xs"),title:w.fullPath,children:[(0,A.jsxs)("span",{className:"flex min-w-0 max-w-full shrink-0 items-baseline text-foreground",children:[(0,A.jsx)("span",{className:"min-w-0 truncate",children:w.fileStem}),(0,A.jsx)("span",{className:"shrink-0",children:w.fileExtension})]}),w.directory?(0,A.jsxs)("span",{className:(0,W.cn)(xK().toolFileDirectory,"min-w-0 truncate text-muted-foreground"),children:["\xa0\xb7\xa0",w.directory]}):null]}):q?(0,A.jsx)("span",{className:"col-start-2 row-start-2 truncate font-mono text-xs text-muted-foreground",children:q}):null,t?.timing?(0,A.jsx)("span",{className:"col-start-3 row-start-2 text-right font-mono text-xs tabular-nums whitespace-nowrap text-muted-foreground",children:(0,A.jsx)(x6,{status:t.status,timing:t.timing})}):r?(0,A.jsx)("span",{className:"col-start-3 row-start-2 max-w-36 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",title:r,children:r}):null]}),v?(0,A.jsx)("button",{type:"button",title:f("previewFile"),"aria-label":f("previewFilePath",{path:c}),onClick:()=>d(c),className:(0,W.cn)("absolute top-1.5 flex size-7 cursor-pointer items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",k?"right-12":"right-3"),children:(0,A.jsx)(ra,{className:"size-4","aria-hidden":"true"})}):null]}),(0,A.jsx)(cs.Ke,{className:xP,children:(0,A.jsxs)("div",{className:"border-t",children:[w?(0,A.jsx)("p",{className:"border-b px-3 py-2 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]",children:w.fullPath}):null,j&&i&&h?(0,A.jsx)("div",{className:"px-3 pt-3",children:(0,A.jsx)(xX,{message:a,onAcquireImage:h})}):null,e({loading:l,error:m})]})})]})}function x8({children:a,destructive:b=!1}){return(0,A.jsx)("p",{className:(0,W.cn)(xK().detailText,"px-3 py-3",b?"text-destructive":"text-muted-foreground"),children:a})}function x9({message:a,loading:b,error:c}){let{t:d}=(0,Q.Bd)("conversation"),e=a.detail?.type==="bash"||a.detail?.type==="tool"&&("generic"===a.detail.kind||"bash"===a.detail.kind||"codemode"===a.detail.kind)?a.detail:null,f=e?.output??"";return b?(0,A.jsx)(x8,{children:d("loadingResult")}):c?(0,A.jsx)(x8,{destructive:!0,children:c}):f?(0,A.jsx)("pre",{role:"region","aria-label":d("toolOutput"),tabIndex:0,className:(0,W.cn)(xL,xK().toolOutput,"whitespace-pre-wrap break-words px-3 py-3 font-mono"),children:f}):"tool"===a.summary.type&&a.summary.images?.length?(0,A.jsx)(A.Fragment,{}):(0,A.jsx)(x8,{children:d("emptyResult")})}function ya({message:a,loading:b,error:c}){let{t:d}=(0,Q.Bd)("conversation"),e=a.detail?.type==="tool"&&"read"===a.detail.kind?a.detail:null;return b?(0,A.jsx)(x8,{children:d("loadingRead")}):c?(0,A.jsx)(x8,{destructive:!0,children:c}):e?e.content?(0,A.jsx)("pre",{role:"region","aria-label":d("readContent"),tabIndex:0,className:(0,W.cn)(xL,xK().toolOutput,xK().toolCode,"px-3 py-3 font-mono"),children:e.content}):(0,A.jsx)(x8,{children:d("readEmpty")}):"tool"===a.summary.type&&a.summary.images?.length?(0,A.jsx)(A.Fragment,{}):(0,A.jsx)(x8,{children:d("readUnavailable")})}function yb({content:a}){let{t:b}=(0,Q.Bd)("conversation");return(0,A.jsx)("div",{role:"region","aria-label":b("editDiff"),tabIndex:0,className:(0,W.cn)(xL,xK().toolOutput,"font-mono"),children:a.split("\n").map((a,b)=>{let c=a.startsWith("+")?"bg-emerald-500/10 text-emerald-800 dark:text-emerald-200":a.startsWith("-")?"bg-red-500/10 text-red-800 dark:text-red-200":a.trimEnd().endsWith("...")?"bg-muted/40 text-muted-foreground":"text-foreground";return(0,A.jsx)("span",{className:(0,W.cn)(xK().toolCode,xK().toolCodeLine,"block px-3",c),children:a||" "},b)})})}function yc({message:a,loading:b,error:c}){let{t:d}=(0,Q.Bd)("conversation"),e=a.detail?.type==="tool"&&"edit"===a.detail.kind?a.detail:null;return b?(0,A.jsx)(x8,{children:d("loadingDiff")}):c?(0,A.jsx)(x8,{destructive:!0,children:c}):e?"diff"===e.contentKind?(0,A.jsx)(yb,{content:e.content}):(0,A.jsx)("pre",{role:"region","aria-label":d("editResult"),tabIndex:0,className:(0,W.cn)(xL,xK().toolOutput,"whitespace-pre-wrap break-words px-3 py-3 font-mono","tool"===a.summary.type&&"error"===a.summary.status&&"text-destructive"),children:e.content}):(0,A.jsx)(x8,{children:d("diffUnavailable")})}function yd({message:a,loading:b,error:c}){let{t:d}=(0,Q.Bd)("conversation"),e=a.detail?.type==="tool"&&"write"===a.detail.kind?a.detail:null;return b?(0,A.jsx)(x8,{children:d("loadingWrite")}):c?(0,A.jsx)(x8,{destructive:!0,children:c}):e?"content"!==e.contentKind||e.content?(0,A.jsx)("pre",{role:"region","aria-label":d("content"===e.contentKind?"writeContent":"writeResult"),tabIndex:0,className:(0,W.cn)(xL,xK().toolOutput,"px-3 py-3 font-mono","content"===e.contentKind?xK().toolCode:"whitespace-pre-wrap break-words","output"===e.contentKind&&"tool"===a.summary.type&&"error"===a.summary.status&&"text-destructive"),children:e.content}):(0,A.jsx)(x8,{children:d("writeEmpty")}):(0,A.jsx)(x8,{children:d("writeUnavailable")})}function ye({message:a,onLoadDetail:b}){let{t:c}=(0,Q.Bd)("conversation"),{open:d,expandable:e,loading:f,error:g,handleOpenChange:h}=xS(a,b);if("tool"!==a.summary.type||"pidesk"!==a.summary.kind)throw Error("PiDeskToolView requires a pidesk summary");let i=function(a){let b=a.args,c={command:0===Object.keys(a).length?"pidesk":`pidesk ${JSON.stringify(a)}`,label:null,name:null,version:null};if(1!==Object.keys(a).length||!Array.isArray(b)||b.length>32||!b.every(a=>"string"==typeof a))return c;c.command=["pidesk",...b.map(qu)].join(" ");let d=b.some(a=>/\s/.test(a))?"":b.join(" ");if(0===b.length||["--help","-h","plugins","session","plugins --help","plugins -h","session --help","session -h"].includes(d))return{...c,label:qr};if("--version"===d)return{...c,label:"pideskVersion"};if("info"===d)return{...c,label:"pideskInfo"};if("session reload"===d)return{...c,label:"pideskReload"};if(3===b.length&&["--help","-h"].includes(b[2])&&("plugins"===b[0]&&["list","show","install","remove"].includes(b[1])||"session"===b[0]&&"reload"===b[1]))return{...c,label:qr};let e=b[1];if("plugins"!==b[0]||!e||!["list","show","install","remove"].includes(e))return c;let f=null,g=[],h=null,i=null,j=!1;for(let a=2;a<b.length;a+=1){let d=b[a];if("--scope"===d&&null===f&&"global"===b[a+1])f=b[++a];else if("--version"===d&&"install"===e&&null===h&&qt.test(b[a+1]??""))h=b[++a];else if("--tag"===d&&["list","install"].includes(e)&&null===i&&(b[a+1]?.length??0)<=128&&/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(b[a+1]??""))i=b[++a];else if("--check-updates"!==d||"list"!==e||j)if(!("list"!==e&&("show"!==e||0===g.length)&&"node_modules"!==d&&qs.test(d)))return c;else g.push(d);else j=!0}if(null!==i&&null!==h||"list"!==e&&(0===g.length||null===f))return c;let k=g.length>0?g.join("、"):null;switch(e){case"list":return{...c,label:"pideskListPlugins"};case"show":return{...c,label:"pideskShowPlugin",name:k};case"install":return{...c,label:"pideskInstallPlugin",name:k,version:h};case"remove":return{...c,label:"pideskRemovePlugin",name:k};default:return c}}(a.summary.input),j=a.detail?.type==="tool"&&"pidesk"===a.detail.kind?a.detail.output:null;return(0,A.jsx)(xI,{identity:a.identity,command:i,output:j,expandable:e,open:d,loading:f,error:g,onOpenChange:h,commandAction:(0,A.jsx)(xU,{text:i.command,copyLabel:c("pidesk.copyCommand"),alwaysVisible:!0}),outputAction:j?(0,A.jsx)(xU,{text:j,copyLabel:c("pidesk.copyOutput"),alwaysVisible:!0}):null})}function yf({message:a,onLoadDetail:b}){return(0,A.jsx)(x7,{message:a,onLoadDetail:b,previewPath:null,renderDetail:b=>(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(x9,{message:a,...b}),a.detail?.type==="tool"&&"codemode"===a.detail.kind&&a.detail.nestedCalls?(0,A.jsx)(xF,{nestedCalls:a.detail.nestedCalls}):null]})})}function yg({message:a,onLoadDetail:b}){return(0,A.jsx)(yf,{message:a,onLoadDetail:b})}function yh({message:a,onLoadDetail:b,onPreviewFile:c}){if("tool"!==a.summary.type||"read"!==a.summary.kind)throw Error("ReadToolView requires a read summary");return(0,A.jsx)(x7,{message:a,onLoadDetail:b,previewPath:a.summary.path,onPreviewFile:c,renderDetail:b=>(0,A.jsx)(ya,{message:a,...b})})}function yi({message:a,onLoadDetail:b,onPreviewFile:c}){if("tool"!==a.summary.type||"edit"!==a.summary.kind)throw Error("EditToolView requires an edit summary");return(0,A.jsx)(x7,{message:a,onLoadDetail:b,previewPath:a.summary.path,onPreviewFile:c,renderDetail:b=>(0,A.jsx)(yc,{message:a,...b})})}function yj({message:a,onLoadDetail:b,onPreviewFile:c}){if("tool"!==a.summary.type||"write"!==a.summary.kind)throw Error("WriteToolView requires a write summary");return(0,A.jsx)(x7,{message:a,onLoadDetail:b,previewPath:a.summary.path,onPreviewFile:c,renderDetail:b=>(0,A.jsx)(yd,{message:a,...b})})}function yk({message:a}){let{t:b}=(0,Q.Bd)("conversation");if("custom"!==a.summary.type)throw Error("CustomMessage requires a custom summary");return(0,A.jsx)("div",{"data-message-id":a.identity,"data-chat-scroll-anchor":`${a.identity}:custom`,className:(0,W.cn)(xK().toolOutput,"rounded-lg border-l-2 bg-muted px-3 py-2 text-muted-foreground"),children:a.summary.text||b("emptyMessage")})}function yl({message:a,onLoadDetail:b}){let{t:c}=(0,Q.Bd)("conversation");if("compaction"!==a.summary.type)throw Error("CompactionMessage requires a compaction summary");let{open:d,expandable:e,loading:f,error:g,handleOpenChange:h}=xS(a,b),i=a.detail?.type==="compaction"?a.detail:null;return(0,A.jsxs)(cs.Nt,{open:e&&d,onOpenChange:h,className:"w-full py-1","data-message-id":a.identity,"data-chat-scroll-anchor":`${a.identity}:compaction`,children:[(0,A.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,A.jsx)("span",{className:"h-px min-w-3 flex-1 bg-border/70","aria-hidden":"true"}),(0,A.jsxs)(cs.R6,{disabled:!e,"aria-label":e?`${c(d?"collapse":"expand")} ${c("compactionSummary")}`:c(a.temporary?"compactionRunning":"compactionComplete"),className:(0,W.cn)("inline-flex min-h-8 max-w-full items-center gap-2 rounded-full border border-border/70 bg-muted/30 px-3 py-1.5 text-xs font-medium text-muted-foreground outline-none transition-colors",e?"hover:bg-muted/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring":"cursor-default"),children:[a.temporary?(0,A.jsx)(R.A,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,A.jsx)(rb,{className:"size-3.5","aria-hidden":"true"}),(0,A.jsx)("span",{children:c(a.temporary?"compactionRunning":"compactionComplete")}),e?(0,A.jsx)(cr.A,{className:(0,W.cn)("size-3.5 transition-transform",d&&"rotate-180"),"aria-hidden":"true"}):null]}),(0,A.jsx)("span",{className:"h-px min-w-3 flex-1 bg-border/70","aria-hidden":"true"})]}),(0,A.jsx)(cs.Ke,{className:xP,children:(0,A.jsx)("div",{className:"pt-2",children:(0,A.jsx)("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3 sm:px-4",children:(0,A.jsx)("div",{role:"region","aria-label":c("compactionSummaryContent"),tabIndex:0,className:"max-h-80 overflow-y-auto pr-2 [scrollbar-gutter:stable]",children:f?(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:c("compactionLoading")}):g?(0,A.jsx)("p",{className:"text-sm text-destructive",children:g}):i?.text?(0,A.jsx)(kI,{isAnimating:!1,mode:"static",children:i.text}):(0,A.jsx)("p",{className:"text-sm text-muted-foreground",children:c("compactionUnavailable")})})})})})]})}let ym=(0,B.memo)(function({item:a,onLoadDetail:b,onAcquireImage:c,onPreviewFile:d}){let e=(()=>{switch(a.message.summary.type){case"assistant":return(0,A.jsx)(x3,{item:a,onLoadDetail:b});case"tool":switch(a.message.summary.kind){case"pidesk":return(0,A.jsx)(ye,{message:a.message,onLoadDetail:b});case"read":return(0,A.jsx)(yh,{message:a.message,onLoadDetail:b,onPreviewFile:d});case"edit":return(0,A.jsx)(yi,{message:a.message,onLoadDetail:b,onPreviewFile:d});case"write":return(0,A.jsx)(yj,{message:a.message,onLoadDetail:b,onPreviewFile:d});case"bash":case"codemode":case"generic":return(0,A.jsx)(yf,{message:a.message,onLoadDetail:b})}case"bash":return(0,A.jsx)(yg,{message:a.message,onLoadDetail:b});case"custom":return(0,A.jsx)(yk,{message:a.message});case"compaction":return(0,A.jsx)(yl,{message:a.message,onLoadDetail:b});case"user":return(0,A.jsx)(xZ,{message:a.message,onAcquireImage:c})}})();return(0,A.jsx)(q6,{message:a.message,loadDetail:b,defaultView:e})},(a,b)=>a.onLoadDetail===b.onLoadDetail&&a.onAcquireImage===b.onAcquireImage&&a.onPreviewFile===b.onPreviewFile&&a.item.hideAssistantText===b.item.hideAssistantText&&yp(a.item.message,b.item.message));function yn({items:a,onLoadDetail:b,onAcquireImage:c,onPreviewFile:d}){let{scrollRef:e}=pR(),f=(0,B.useRef)(null),g=(0,B.useRef)(null);(0,B.useRef)(a.length);let h=(0,B.useRef)(null),[i,j]=(0,B.useState)(()=>Math.min(64,a.length)),k=Math.max(0,a.length-i),l=k>0;return(0,B.useCallback)(()=>{if(!l)return;let b=e.current,c=f.current?.querySelector("[data-chat-process-item]");b&&c?.dataset.chatProcessItem&&(h.current={identity:c.dataset.chatProcessItem,offset:c.getBoundingClientRect().top-b.getBoundingClientRect().top}),j(b=>Math.min(a.length,b+64))},[l,a.length,e]),(0,A.jsxs)("div",{ref:f,children:[l?(0,A.jsx)("div",{ref:g,className:"h-px","data-chat-process-history":!0,"aria-hidden":"true"}):null,a.slice(k).map((e,f)=>{let g=k+f,h=a[g-1],i=h?.message.summary.type==="assistant"&&!h.hideAssistantText&&!!h.message.summary.text.trim();return(0,A.jsx)("div",{"data-chat-process-item":e.message.identity,className:g>0?i?"mt-5":"mt-2":void 0,children:(0,A.jsx)(ym,{item:e,onLoadDetail:b,onAcquireImage:c,onPreviewFile:d})},e.message.identity)})]})}let yo=(0,B.memo)(function({turn:a,onLoadDetail:b,onAcquireImage:c,onPreviewFile:d}){let{t:e}=(0,Q.Bd)("conversation"),[f,g]=(0,B.useState)(!1),h=(0,B.useContext)(xM),i=(0,bJ.t4)();(0,bJ.So)();let j=a.processItems.filter(a=>!a.hideAssistantText||"pi-desk/assistant"===a.message.viewKey&&null===i.getMessageViewResolution(a.message.viewKey)),k=a.running||f,l=(0,B.useCallback)(b=>{a.running||(b&&h(),g(b))},[h,a.running]);return 0===j.length?null:(0,A.jsxs)(cs.Nt,{open:k,onOpenChange:l,className:"w-full",children:[(0,A.jsxs)(cs.R6,{className:(0,W.cn)(xK().detailText,"flex min-h-9 w-full cursor-pointer items-center gap-2 py-1 text-left text-muted-foreground hover:text-foreground"),children:[(0,A.jsxs)("span",{className:"flex-1",children:[e("processGroup"),a.toolCount>0?` \xb7 ${e("toolCalls",{count:a.toolCount})}`:""]}),(0,A.jsx)(cr.A,{className:(0,W.cn)("size-4 transition-transform",k&&"rotate-180")})]}),(0,A.jsx)(cs.Ke,{className:xP,children:(0,A.jsx)("div",{className:"pt-2",children:(0,A.jsx)(yn,{items:j,onLoadDetail:b,onAcquireImage:c,onPreviewFile:d})})})]})},(a,b)=>a.onLoadDetail===b.onLoadDetail&&a.onAcquireImage===b.onAcquireImage&&a.onPreviewFile===b.onPreviewFile&&a.turn.running===b.turn.running&&a.turn.toolCount===b.turn.toolCount&&yq(a.turn.processItems,b.turn.processItems));function yp(a,b){return a===b||!!a&&!!b&&a.identity===b.identity&&(a.durable||b.durable?a.durable===b.durable&&a.usageIncomplete===b.usageIncomplete&&(a.usageCalls?.length??0)===(b.usageCalls?.length??0)&&(a.usageCalls??[]).every((a,c)=>a.durable===b.usageCalls?.[c]?.durable):a.tempId===b.tempId&&a.summary===b.summary&&a.detail===b.detail&&a.timestampMs===b.timestampMs)}function yq(a,b){return a===b||a.length===b.length&&a.every((a,c)=>{let d=b[c];return void 0!==d&&a.hideAssistantText===d.hideAssistantText&&yp(a.message,d.message)})}let yr=(0,B.memo)(function({message:a,onLoadDetail:b,onAcquireImage:c,onResend:d,resendDisabled:e}){return(0,A.jsx)(q6,{message:a,loadDetail:b,defaultView:(0,A.jsx)(xZ,{message:a,onAcquireImage:c,onResend:d,resendDisabled:e})})},(a,b)=>a.onLoadDetail===b.onLoadDetail&&a.onAcquireImage===b.onAcquireImage&&a.onResend===b.onResend&&a.resendDisabled===b.resendDisabled&&yp(a.message,b.message)),ys=(0,B.memo)(function({message:a,onLoadDetail:b}){return"assistant"!==a.summary.type?null:(0,A.jsx)(q6,{message:a,loadDetail:b,defaultView:(0,A.jsx)(x$,{message:a,text:a.summary.text})})},(a,b)=>a.onLoadDetail===b.onLoadDetail&&yp(a.message,b.message)),yt=(0,B.memo)(function({turn:a,cwd:b,logicalTail:c=!1,onLoadDetail:d,onAcquireImage:e,onPreviewFile:f,onResend:g,resendDisabled:h}){if(a.compaction)return(0,A.jsx)("section",{className:(0,W.cn)(!a.running&&"pi-desk-chat-turn-contained"),"data-chat-turn":a.identity,"data-chat-logical-tail":c?"":void 0,children:(0,A.jsx)(q6,{message:a.compaction,loadDetail:d,defaultView:(0,A.jsx)(yl,{message:a.compaction,onLoadDetail:d})})});let i=a.running&&0===a.processItems.length&&null===a.finalAssistant;return(0,A.jsxs)("section",{className:(0,W.cn)("space-y-3",!a.running&&"pi-desk-chat-turn-contained"),"data-chat-turn":a.identity,"data-chat-logical-tail":c?"":void 0,children:[a.user?(0,A.jsx)(yr,{message:a.user,onLoadDetail:d,onAcquireImage:e,onResend:g,resendDisabled:h}):null,(0,A.jsx)(xO.Provider,{value:e,children:(0,A.jsx)(xN.Provider,{value:b,children:(0,A.jsx)(yo,{turn:a,onLoadDetail:d,onAcquireImage:e,onPreviewFile:f})})}),i?(0,A.jsx)(x_,{}):null,a.finalAssistant?(0,A.jsx)(ys,{message:a.finalAssistant,onLoadDetail:d}):null]})},(a,b)=>{var c,d;return a.cwd===b.cwd&&a.logicalTail===b.logicalTail&&a.onResend===b.onResend&&a.resendDisabled===b.resendDisabled&&a.onAcquireImage===b.onAcquireImage&&a.onLoadDetail===b.onLoadDetail&&a.onPreviewFile===b.onPreviewFile&&((c=a.turn)===(d=b.turn)||c.identity===d.identity&&c.running===d.running&&c.toolCount===d.toolCount&&yp(c.user,d.user)&&yp(c.finalAssistant,d.finalAssistant)&&yp(c.compaction,d.compaction)&&yq(c.processItems,d.processItems))});yt.displayName="L3ConversationTurnView";let yu={running:"statusRunning",completed:"statusCompleted",failed:"statusFailed",stopped:"statusStopped",interrupted:"statusInterrupted"};function yv(a,b){let c=Math.max(0,Math.round(((a.endedAt??Date.now())-a.startedAt)/1e3));if(c<60)return b("seconds",c);let d=Math.floor(c/60);if(d<60)return b("minutes",d);let e=Math.floor(d/60);return`${b("hours",e)}${d%60?` ${b("minutes",d%60)}`:""}`}function yw(a){return[a.taskKind,a.taskType].filter(a=>!!a).join(" / ")}function yx(a){switch(a){case"running":return(0,A.jsx)(R.A,{className:"size-4 animate-spin text-foreground"});case"completed":return(0,A.jsx)(o9.A,{className:"size-4 text-status-success"});case"failed":return(0,A.jsx)(pC,{className:"size-4 text-destructive"});case"interrupted":return(0,A.jsx)(pD.A,{className:"size-4 text-status-warning"});case"stopped":return(0,A.jsx)(pE,{className:"size-4 text-muted-foreground"})}}function yy({info:a}){let{t:b}=(0,Q.Bd)("taskCenter"),c=(0,bK.G)(),[d,e]=(0,B.useState)(null);if(0===a.length)return null;let f=(a,d)=>{(0,cZ.x)(a.value).then(f=>{f?e(d):c.error(b("copyFailed",{name:a.label}))})};return(0,A.jsx)("div",{"data-task-info-scroll":"",className:"max-h-32 overflow-y-auto pr-1 [scrollbar-gutter:stable]",children:(0,A.jsx)("dl",{className:"flex flex-wrap gap-2",children:a.map((a,c)=>{let e=`${a.label}:${c}:${a.value}`,g=d===e;return(0,A.jsxs)("div",{role:"button",tabIndex:0,"aria-label":b(g?"copied":"copy",{name:a.label}),title:g?b("copiedShort"):b("clickToCopy",{name:a.label}),className:(0,W.cn)("flex min-h-8 min-w-0 max-w-full cursor-pointer items-start gap-2 rounded-md px-2 py-1 text-sm outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",g&&"bg-muted"),onClick:()=>f(a,e),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),f(a,e))},children:[(0,A.jsx)("dt",{className:"shrink-0 pt-0.5 font-medium text-muted-foreground",children:a.label}),(0,A.jsx)("dd",{className:"min-w-0 flex-1 break-words text-foreground",children:a.value}),(0,A.jsx)("span",{className:"shrink-0 pt-0.5 text-muted-foreground","aria-hidden":"true",children:g?(0,A.jsx)(bs.A,{className:"size-3.5 text-status-success"}):(0,A.jsx)(bM.A,{className:"size-3.5"})})]},`${a.label}:${c}`)})})})}function yz({snapshot:a,running:b,runtime:c,cwd:d}){let{t:e}=(0,Q.Bd)("taskCenter"),f=(0,B.useMemo)(()=>qI(a,b),[b,a]),g=f.findLast(a=>null!==a.user)??null;return(0,A.jsx)(pS,{className:"h-full min-h-0",initial:"instant",resize:"instant","aria-label":e("conversationDetails"),children:(0,A.jsx)(qW,{turns:f,focusTurnIdentity:g?.identity??null,initialAnchor:null,children:a=>(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(qP,{}),(0,A.jsx)(xQ,{children:(0,A.jsxs)(pT,{scrollClassName:"pi-desk-chat-scrollbar",className:"mx-auto min-h-full w-full max-w-3xl gap-6 px-4 pt-3 pb-6 sm:px-6",children:[f.length>0?a.visibleTurns.map((b,e)=>{let g=a.startIndex+e;return(0,A.jsx)(yt,{turn:b,cwd:d,logicalTail:a.containsTail&&g===f.length-1,onLoadDetail:c.loadMessageDetail,onAcquireImage:c.acquireImage},b.identity)}):(0,A.jsx)("div",{className:"grid min-h-48 place-items-center text-sm text-muted-foreground",children:e("noMessages")}),(0,A.jsx)("div",{className:"h-4 shrink-0","aria-hidden":"true"})]})}),(0,A.jsx)(q_,{turns:f,window:a})]})})})}function yA({task:a,runtime:b,cwd:c}){let{t:d}=(0,Q.Bd)("taskCenter"),e=(0,B.useSyncExternalStore)(b.subscribe,b.getState,b.getState),f=a?e.details[a.taskId]:void 0,[g,h]=(0,B.useState)(!1),[i,j]=(0,B.useState)(!1),[k,l]=(0,B.useState)(null),m=async()=>{if(!g)return void h(!0);j(!0),l(null);try{await b.interruptSelected(),h(!1)}catch(a){l(a instanceof Error?a.message:d("interruptFailed"))}finally{j(!1)}};if(!a)return(0,A.jsx)("div",{className:"grid h-full min-h-0 place-items-center px-6 text-center text-sm text-muted-foreground",children:d("selectTask")});let n=yw(a);return(0,A.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,A.jsx)("header",{className:"shrink-0 border-b px-4 py-3 lg:pr-16",children:(0,A.jsxs)("div",{className:"flex items-start gap-3",children:[(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,A.jsx)("span",{className:"mt-0.5 shrink-0",children:yx(a.status)}),(0,A.jsx)("h3",{className:"min-w-0 break-words text-sm font-semibold",children:n?`${n} \xb7 ${a.title}`:a.title})]}),(0,A.jsxs)("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[(0,A.jsx)("span",{className:(0,W.cn)("rounded-md px-1.5 py-0.5 font-medium",function(a){switch(a){case"running":return"bg-muted text-foreground";case"completed":return"bg-muted text-status-success";case"failed":return"bg-muted text-destructive";case"interrupted":return"bg-muted text-status-warning";case"stopped":return"bg-muted text-muted-foreground"}}(a.status)),children:d(yu[a.status])}),(0,A.jsx)("span",{className:"text-muted-foreground",children:yv(a,(a,b)=>d(a,{count:b}))}),a.activity?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground/60",children:"\xb7"}),(0,A.jsx)("span",{className:"min-w-0 break-words text-muted-foreground",children:a.activity})]}):null]})]}),f?.canInterrupt?(0,A.jsxs)(U.$,{className:"shrink-0",type:"button",size:"sm",variant:g?"destructive":"outline",disabled:i,onClick:()=>void m(),children:[i?(0,A.jsx)(R.A,{className:"animate-spin"}):(0,A.jsx)(pE,{}),g?d("confirmInterrupt"):d("interrupt")]}):null]})}),k?(0,A.jsx)("p",{role:"alert",className:"shrink-0 border-b bg-muted px-4 py-2 text-sm text-destructive",children:k}):null,a.info.length>0?(0,A.jsx)("div",{className:"shrink-0 border-b px-4 py-2",children:(0,A.jsx)(yy,{info:a.info})}):null,(0,A.jsxs)("div",{className:"relative min-h-0 flex-1",children:[f?.body?.kind==="conversation"?(0,A.jsx)(yz,{snapshot:f.body,running:"running"===a.status,runtime:b,cwd:c}):f?.body?.kind==="text"?(0,A.jsx)("div",{className:"h-full overflow-auto p-4 sm:p-5",children:(0,A.jsx)("pre",{className:(0,W.cn)("whitespace-pre-wrap break-words font-mono text-sm leading-[1.6]"),children:f.body.text||d("waitingOutput")})}):f?(0,A.jsx)("div",{className:"h-full overflow-auto p-4 sm:p-5",children:(0,A.jsx)("div",{className:"grid min-h-48 place-items-center px-2 text-center text-sm text-muted-foreground",children:d("noDetails")})}):(0,A.jsx)("div",{className:"h-full overflow-auto p-4 sm:p-5",children:(0,A.jsx)("div",{className:"grid min-h-48 place-items-center px-2 text-center text-sm text-muted-foreground",children:e.error?(0,A.jsxs)("div",{className:"space-y-3",children:[(0,A.jsx)("p",{className:"text-destructive",children:e.error}),(0,A.jsxs)(U.$,{type:"button",size:"sm",variant:"outline",onClick:()=>b.selectTask(a.taskId),children:[(0,A.jsx)(pF,{}),d("retry")]})]}):(0,A.jsxs)("div",{className:"flex items-center gap-2",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"}),d("loadingDetail")]})})}),e.refreshing?(0,A.jsxs)("div",{className:"pointer-events-none absolute right-3 top-3 flex items-center gap-2 rounded-md border bg-popover px-2 py-1 text-xs text-muted-foreground",children:[(0,A.jsx)(R.A,{className:"size-3 animate-spin"}),d("refreshing")]}):null]})]})}function yB({source:a,tasks:b,runtime:c,cwd:d}){var e;let{t:f}=(0,Q.Bd)("taskCenter"),{locale:g,timeZone:h}=(0,cy.i)(),i=(0,B.useCallback)(()=>{let a=c.getState();return JSON.stringify([a.open,a.source?.workId??null,a.source?.sessionId??null,a.source?.branchId??null,a.selectedTaskId])},[c]);(0,B.useSyncExternalStore)(c.subscribe,i,i);let j=c.getState(),[k,l]=(0,B.useState)(!1),m=b.find(a=>a.taskId===j.selectedTaskId)??null,n=k&&null!==j.selectedTaskId,o=j.open&&(e=j.source,null!==e&&e.workId===a.workId&&e.sessionId===a.sessionId&&e.branchId===a.branchId);return(0,A.jsx)(b7.YV,{open:o,onOpenChange:a=>{a||c.close()},children:(0,A.jsxs)(b7.hA,{"aria-label":f("title"),showCloseButton:!1,className:"h-[calc(100dvh-2rem)] max-w-[70rem] flex-row bg-background max-lg:h-[var(--pi-desk-content-height)] max-lg:max-h-[var(--pi-desk-content-height)] max-lg:w-dvw max-lg:max-w-none max-lg:rounded-none max-lg:border-0",children:[(0,A.jsxs)("div",{className:(0,W.cn)("flex min-w-0 flex-1 flex-col border-r bg-sidebar lg:max-w-80",n&&"hidden lg:flex"),children:[(0,A.jsxs)("header",{className:"flex min-h-14 items-center gap-3 border-b px-4 py-3",children:[(0,A.jsx)(pG,{className:"size-5 text-muted-foreground"}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)(b7.YM,{children:f("title")}),(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:f("recordCount",{count:b.length})})]}),(0,A.jsx)(U.$,{className:"lg:hidden",type:"button",variant:"ghost",size:"icon","aria-label":f("close"),onClick:()=>c.close(),children:(0,A.jsx)(al.A,{})})]}),(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto p-2",children:b.length>0?(0,A.jsx)("div",{className:"space-y-1",children:b.map(a=>{let b=yw(a),d=yv(a,(a,b)=>f(a,{count:b})),e=qL(a.startedAt,void 0,g,h);return(0,A.jsxs)("button",{type:"button","aria-current":a.taskId===j.selectedTaskId?"true":void 0,onClick:()=>{var b;return b=a.taskId,void(c.selectTask(b),l(!0))},className:(0,W.cn)("grid min-h-14 w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-2 rounded-lg px-3 py-3 text-left outline-none transition-colors hover:bg-foreground/8 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",a.taskId===j.selectedTaskId&&"bg-accent text-accent-foreground hover:bg-accent"),children:[(0,A.jsx)("span",{className:"mt-0.5 shrink-0",children:yx(a.status)}),(0,A.jsxs)("span",{className:"min-w-0",children:[(0,A.jsxs)("span",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-3",children:[(0,A.jsx)("span",{className:"truncate text-sm font-medium",children:a.title}),(0,A.jsxs)("span",{className:"whitespace-nowrap text-xs tabular-nums text-muted-foreground","aria-label":f("runningTime",{duration:d,time:e.full}),children:[d,(0,A.jsx)("span",{className:"mx-1 text-muted-foreground/50","aria-hidden":"true",children:"\xb7"}),(0,A.jsx)("time",{dateTime:new Date(a.startedAt).toISOString(),children:e.compact})]})]}),b?(0,A.jsx)("span",{className:"mt-1 block truncate text-xs text-muted-foreground",children:b}):null]}),(0,A.jsx)(br.A,{className:"mt-1 size-4 shrink-0 text-muted-foreground lg:hidden"})]},a.taskId)})}):(0,A.jsx)("div",{className:"grid min-h-48 place-items-center text-sm text-muted-foreground",children:f("noTasks")})})]}),(0,A.jsx)("div",{className:(0,W.cn)("min-w-0 flex-1",!n&&"hidden lg:block"),children:(0,A.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,A.jsxs)("div",{className:"flex min-h-12 items-center gap-2 border-b bg-muted/10 px-3 lg:hidden",children:[(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon","aria-label":f("back"),onClick:()=>l(!1),children:(0,A.jsx)(Z.A,{})}),(0,A.jsx)("span",{className:"min-w-0 flex-1 truncate text-center text-xs text-muted-foreground",children:m?.title??f("detail")}),(0,A.jsx)(U.$,{type:"button",variant:"ghost",size:"icon","aria-label":f("close"),onClick:()=>c.close(),children:(0,A.jsx)(al.A,{})})]}),(0,A.jsx)("div",{className:"min-h-0 flex-1",children:(0,A.jsx)(yA,{task:m,runtime:c,cwd:d},m?.taskId??"no-task")})]})}),(0,A.jsx)(U.$,{className:"absolute right-4 top-3 z-10 hidden lg:inline-flex",type:"button",variant:"ghost",size:"icon","aria-label":f("close"),onClick:()=>c.close(),children:(0,A.jsx)(al.A,{})})]})})}function yC({source:a,cwd:b,tasks:c,runtime:d,variant:e}){let{t:f}=(0,Q.Bd)("taskCenter"),g=c.filter(a=>"running"===a.status),h=g[0],i=()=>{d.open(a,(c.find(a=>"running"===a.status)??c[0]??null)?.taskId??null)};return"footer"===e?c.length>0?(0,A.jsx)(qo,{tooltip:f("title"),"aria-label":f("open"),onClick:i,children:(0,A.jsx)(pG,{className:"size-4"})}):(0,A.jsx)(A.Fragment,{}):"menu"===e?(0,A.jsxs)(bz,{onClick:i,children:[(0,A.jsx)(pG,{className:"size-4"}),f("title")]}):(0,A.jsxs)(A.Fragment,{children:[h?(0,A.jsxs)("button",{type:"button",className:"mb-2 flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-md border bg-muted px-2.5 text-left text-sm text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",onClick:i,"aria-label":`${f("open")}, ${f("runningCount",{count:g.length})}`,children:[(0,A.jsx)(R.A,{className:"size-3.5 shrink-0 animate-spin text-foreground"}),(0,A.jsx)("span",{className:"shrink-0 font-medium text-foreground",children:f("runningCount",{count:g.length})}),(0,A.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[h.title,h.activity?` \xb7 ${h.activity}`:""]}),(0,A.jsx)(br.A,{className:"size-3.5 shrink-0"})]}):null,(0,A.jsx)(yB,{source:a,tasks:c,runtime:d,cwd:b})]})}function yD({source:a,cwd:b,pluginState:c,runtime:d,variant:e}){let f=(0,B.useMemo)(()=>{let a=pp.safeParse(c);return a.success?a.data.tasks:[]},[c]);return(0,A.jsx)(yC,{source:a,cwd:b,tasks:f,runtime:d,variant:e})}var yE=c(43115),yF=c(50146);function yG(a){return`${a.location.index}:${a.location.entryId}`}let yH={user:["viewKey","hasDetail"],assistant:["viewKey","status","hasDetail","usage"],tool:["viewKey","status","hasDetail","usage"],bash:["viewKey","status","hasDetail"],custom:["viewKey","hasDetail"]};function yI(a,b,c){if(!b)return a;let d={...a,...b};return"summary"===c?pf.Hf.parse(d):pf.D8.parse(d)}function yJ(a,b){if(Array.isArray(a.parent)){if("number"!=typeof a.key)throw Error("Increment array key is invalid");a.parent[a.key]=b;return}if("string"!=typeof a.key)throw Error("Increment object key is invalid");a.parent[a.key]=b}function yK(a,b,c){let d=structuredClone(a),e=function(a,b){if(0===b.length)throw Error("Increment cannot append to the message layer root");let c=a;for(let a of b.slice(0,-1)){if("number"==typeof a){if(!Array.isArray(c)||a>=c.length)throw Error(`Increment array path does not exist: ${a}`);c=c[a];continue}if(!c||"object"!=typeof c||Array.isArray(c))throw Error(`Increment object path does not exist: ${a}`);if(!Object.hasOwn(c,a))throw Error(`Increment object field does not exist: ${a}`);c=c[a]}let d=b.at(-1);if("number"==typeof d){if(!Array.isArray(c)||d>=c.length)throw Error(`Increment array target does not exist: ${d}`);return{parent:c,key:d,value:c[d]}}if(!c||"object"!=typeof c||Array.isArray(c))throw Error(`Increment object target does not exist: ${d}`);if(!Object.hasOwn(c,d))throw Error(`Increment target does not exist: ${d}`);return{parent:c,key:d,value:c[d]}}(d,b);if("string"==typeof c){if("string"!=typeof e.value)throw Error("Increment target is not a string");return yJ(e,`${e.value}${c}`),pf.Hf.parse(d)}if(!Array.isArray(e.value))throw Error("Increment target is not an array");return yJ(e,[...e.value,...c]),pf.Hf.parse(d)}function yL(a,b,c){let d=new Map(a.messages.filter(a=>void 0!==a.detail).map(a=>[yG(a),a]));return{messages:b.map(a=>{let b=d.get(yG(a));return a.fixed.hasDetail&&b&&b.fixed.type===a.fixed.type&&b.fixed.viewKey===a.fixed.viewKey&&void 0!==b.detail?pf.mj.parse({...a,detail:b.detail}):a}),temporaryMessages:[...c]}}function yM(a,b){if("message_start"===b.type){if(a.temporaryMessages.some(a=>a.location.tempId===b.snapshot.location.tempId))throw Error(`Temporary conversation message already exists: ${b.snapshot.location.tempId}`);return{...a,temporaryMessages:[...a.temporaryMessages,b.snapshot]}}let c=a.temporaryMessages.findIndex(a=>a.location.tempId===b.location.tempId);if(c<0)throw Error(`Temporary conversation message was not found: ${b.location.tempId}`);if("message_update"===b.type){let d=[...a.temporaryMessages];return d[c]=function(a,b){var c,d;if(a.location.tempId!==b.location.tempId)throw Error(`Conversation update tempId mismatch: ${b.location.tempId}`);let e=(c=a.fixed,(d=b.fixed)?(!function(a,b,c){let d=Object.keys(a).filter(a=>!b.includes(a));if(d.length>0)throw Error(`${c} patch contains fields invalid for the current message: ${d}`)}(d,yH[c.type],`${c.type} fixed`),pf.q5.parse({...c,...d})):c),f=yI(a.summary,b.summary,"summary"),g=a.detail;if(void 0!==b.detail||Object.keys(b.increments??{}).some(a=>"detail"===(0,yF.U)(a).root)){if(b.fixed?.hasDetail===!1)throw Error("Realtime detail cannot be updated while explicitly clearing hasDetail");e.hasDetail||(e=pf.q5.parse({...e,hasDetail:!0}))}for(let[a,c]of(b.detail&&(g=yI(g??{},b.detail,"detail")),Object.entries(b.increments??{}))){let b=(0,yF.U)(a);"summary"===b.root?f=yK(f,b.segments,c):g=yK(g??{},b.segments,c)}return e.hasDetail||(g=void 0),pf.s4.parse({location:a.location,fixed:e,summary:f,...void 0===g?{}:{detail:g}})}(d[c],b),{...a,temporaryMessages:d}}if("message_discard"===b.type)return{...a,temporaryMessages:a.temporaryMessages.filter(a=>a.location.tempId!==b.location.tempId)};if(b.durable.index!==a.messages.length)throw Error(`Conversation commit index is not continuous: expected ${a.messages.length}, received ${b.durable.index}`);if(a.messages.some(a=>a.location.entryId===b.durable.entryId))throw Error(`Conversation commit entryId already exists: ${b.durable.entryId}`);let{detail:d,fixed:e,...f}=a.temporaryMessages[c],g=pf.mj.parse({...f,location:b.durable,fixed:{...e,timestampMs:b.fixed.timestampMs},...e.hasDetail&&void 0!==d?{detail:d}:{}});return{messages:[...a.messages,g],temporaryMessages:a.temporaryMessages.filter(a=>a.location.tempId!==b.location.tempId)}}function yN(a,b){let c=a.messages.findIndex(a=>a.location.index===b.index&&a.location.entryId===b.entryId);if(c<0)throw Error(`Conversation detail target was not found: ${b.index}/${b.entryId}`);let d=a.messages[c];if(null!==b.detail&&!d.fixed.hasDetail)throw Error("Message without hasDetail cannot accept detail");let e=[...a.messages];return e[c]=pf.mj.parse({...d,...null===b.detail?{detail:void 0}:{detail:b.detail}}),{...a,messages:e}}function yO(a,b){return a.taskId!==b.taskId||a.body?.kind!=="conversation"||b.body?.kind!=="conversation"?b:pt.parse({...b,body:{kind:"conversation",truncated:b.body.truncated,...yL(a.body,b.body.messages,b.body.temporaryMessages)}})}var yP=c(28661);function yQ(a){return(0,bW.B)({msg:yE.U["zh-CN"][a],i18n:{key:`taskCenter:${a}`}})}let yR=Object.freeze({open:!1,source:null,selectedTaskId:null,details:{},loading:!1,refreshing:!1,error:null});function yS(a,b){return a===b||null!==a&&null!==b&&a.workId===b.workId&&a.sessionId===b.sessionId&&a.branchId===b.branchId}var yT=c(94283),yU=c(17983);let yV=jw.rh,yW=jw.eC,yX=E.Ik({workId:yT.eW,cwd:yT.ik}).strict(),yY=yX.extend({path:yV}).strict(),yZ=yX.extend(jw.Nu.shape).strict(),y$=yU.Ot.request.safeExtend({workId:yT.eW});yU.Ot.response;let y_=jw.p$,y0=yX.extend({path:yW,imagePreviewMode:y_}).strict();var y1=c(74349),y2=c.n(y1);function y3({mobile:a,open:b,sidebar:c,children:d,onClose:e}){let{t:f}=(0,Q.Bd)("workbench"),g=(0,X.fk)(),h=(0,B.useRef)(288);return a?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button","aria-label":f("closeSessionMenu"),"aria-hidden":!b,tabIndex:b?0:-1,onClick:e,className:(0,W.cn)(y2().backdrop,"fixed inset-0 z-40 bg-black/35",b?"opacity-100":"pointer-events-none opacity-0")}),(0,A.jsx)("div",{"data-testid":"mobile-work-session-drawer","data-open":b,"aria-hidden":!b||void 0,inert:!b||void 0,className:(0,W.cn)(y2().drawer,"fixed inset-y-0 left-0 z-50 flex w-[min(86vw,320px)] flex-col border-r bg-sidebar shadow-2xl",!b&&"pointer-events-none"),children:c}),(0,A.jsx)("div",{className:"flex min-h-0 min-w-0 flex-1",inert:b||void 0,children:d})]}):(0,A.jsxs)(V.HK,{orientation:"horizontal",disableCursor:!0,className:(0,W.cn)(y2().panelGroup,"pi-desk-workbench-resize-group min-h-0 min-w-0 flex-1"),onLayoutChanged:(a,c)=>{if(!c.isUserInteraction||!b)return;let d=g.current?.getSize().inPixels;void 0!==d&&(h.current=d)},children:[(0,A.jsx)(V.wV,{id:"work-session-sidebar",panelRef:g,defaultSize:288,minSize:224*!!b,maxSize:480*!!b,disabled:!b,"aria-hidden":!b||void 0,inert:!b||void 0,className:"flex h-full min-h-0 min-w-0 !overflow-hidden bg-sidebar",children:(0,A.jsx)("div",{className:"flex h-full w-full min-w-[224px] flex-col border-r",children:c})}),(0,A.jsx)(V.WM,{withHandle:!0,"aria-label":f("resizeSessionList"),"aria-hidden":!b||void 0,disabled:!b,className:(0,W.cn)("cursor-col-resize",!b&&"w-0 pointer-events-none opacity-0")}),(0,A.jsx)(V.wV,{id:"work-session-content",minSize:360,className:"flex h-full min-h-0 min-w-0 !overflow-hidden",children:d})]})}let y4=E.Ik({application:E.eu("Pi Desk"),status:E.eu("ready"),version:E.Yj().trim().min(1).nullable().default(null),boundaries:E.Ik({client:E.eu("isolated"),server:E.eu("isolated"),common:E.eu("shared")}),layers:E.PV([E.eu("L1 Entry"),E.eu("L2 Biz"),E.eu("L3 Modules"),E.eu("L4 Foundation")])});var y5=c(18513),y6=c(10905),y7=c(62598);y7.Gm.extend({query:E.Yj().trim().min(1).max(120)});let y8=E.Ik({sessions:E.YO(E.Ik({workId:yT.eW,matches:E.YO(y7.Jk).min(1).max(4)}).strict())}).strict();var y9=c(8579),za=c(38974);function zb(a){let b=a.replaceAll("\\","/").replace(/\/+$/,"")||"/";return/^[a-z]:/i.test(b)||b.startsWith("//")?b.toLowerCase():b}E.Ik({directories:E.YO(E.Yj().min(1).max(4096)).max(32),defaultDirectory:E.Yj().min(1).max(4096).nullable()}).strict();var zc=c(92494),zd=c(38273);function ze(a,b){return(0,bW.B)({msg:zd.R["zh-CN"][a],i18n:{key:`workbench:${a}`,...b?{params:b}:{}}})}function zf(a){let{workId:b,sessionId:c,branchId:d}=a.source;return JSON.stringify([b,c,d,a.cwd])}function zg(a,b,c){return`${zf(a)}\u0000${c}\u0000${b}`}class zh{peek(a,b,c){let d=this.images.get(zg(a,b,c));return!d||0===d.references&&Date.now()-d.unusedAt>=6e4?null:d.url}get(a,b,c){this.trim();let d=zg(a,b,c),e=this.images.get(d);return e?this.acquire(d,e):null}store(a,b,c,d){if(this.disposed||!this.validSources.has(zf(a)))throw Error("工作会话来源已变化");let e=zg(a,b,c),f=this.images.get(e);if(f)return this.acquire(e,f);let g={url:URL.createObjectURL(d),size:d.size,references:0,unusedAt:Date.now()};return this.images.set(e,g),this.acquire(e,g)}invalidate(a,b,c){this.remove(zg(a,b,c))}reconcileWorkSessions(a){for(let b of(this.validSources=new Set(a.map(a=>zf({source:a,cwd:a.cwd}))),this.images.keys()))this.validSources.has(b.split("\0")[0])||this.remove(b);this.trim()}dispose(){for(let a of(this.disposed=!0,this.images.keys()))this.remove(a);this.validSources.clear()}acquire(a,b){b.references+=1,this.images.delete(a),this.images.set(a,b),this.trim();let c=!1;return{url:b.url,release:()=>{c||(c=!0,b.references-=1,0===b.references&&(b.unusedAt=Date.now()),this.trim())}}}remove(a){let b=this.images.get(a);b&&(URL.revokeObjectURL(b.url),this.images.delete(a))}trim(){let a=Date.now(),b=[...this.images.values()].reduce((a,b)=>a+b.size,0);for(let[c,d]of this.images)!(d.references>0)&&(a-d.unusedAt<6e4&&b<=0x4000000&&this.images.size<=64||(this.remove(c),b-=d.size))}constructor(){this.images=new Map,this.validSources=new Set,this.disposed=!1}}class zi{constructor(a,b,c=()=>void 0){this.biz=a,this.gitBiz=b,this.onNotice=c,this.standaloneImages=new zh,this.listeners=new Set,this.workspaces=new Map,this.sources=new Map,this.previewDirectories=new Map,this.expandedWorkId=null,this.revision=0,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getWorkspace(a){let b=a?this.workspaces.get(a):null;return b?{...b.files.state,cwd:b.files.cwd,windowOpen:b.windowOpen,chatWidthPercent:b.chatWidthPercent,activePane:b.activePane}:null}getFileRuntime(a){return this.workspaceFor(a).files}getExpandedWorkId(){return this.expandedWorkId}getDirectories(a){return this.previewDirectories.get(a)?.directories??[]}getDirectory(a){let b=this.previewDirectories.get(a);if(!b)throw Error(ze("sourceChanged"));return b.selectedDirectory}applyPreviewDirectories(a,b){let c=this.sources.get(a.workId);if(!c||c.sessionId!==a.sessionId||c.branchId!==a.branchId)return;let d=this.previewDirectories.get(a.workId),e=new Map([[zb(c.cwd),c.cwd]]);for(let a of b.directories){let b=zb(a);e.has(b)||e.set(b,a)}let f=b.defaultDirectory?e.get(zb(b.defaultDirectory))??null:null,g=(d.defaultDirectory?zb(d.defaultDirectory):null)!==(f?zb(f):null)?f??c.cwd:e.get(zb(d.selectedDirectory))??c.cwd,h=[...e.values()];if(d.defaultDirectory===f&&d.selectedDirectory===g&&d.directories.length===h.length&&d.directories.every((a,b)=>a===h[b]))return;this.previewDirectories.set(a.workId,{directories:h,defaultDirectory:f,selectedDirectory:g});let i=this.workspaces.get(a.workId);if(i){for(let[a,b]of i.roots)e.has(a)||(b.unsubscribe(),b.files.dispose(),i.roots.delete(a));this.switchFiles(a.workId,i)}this.publish()}selectDirectory(a,b){let c=this.previewDirectories.get(a);if(!c)throw Error(ze("sourceChanged"));let d=c.directories.find(a=>zb(a)===zb(b));if(!d)throw Error(ze("sourceChanged"));if(c.selectedDirectory===d)return;c.selectedDirectory=d;let e=this.workspaces.get(a);e&&this.switchFiles(a,e),this.publish()}reconcileWorkSessions(a){this.standaloneImages.reconcileWorkSessions(a);let b=new Map(a.map(({workId:a,cwd:b,sessionId:c,branchId:d})=>[a,{workId:a,cwd:b,sessionId:c,branchId:d}])),c=!1;for(let[a,d]of this.sources){let e=b.get(a);if(e?.cwd===d.cwd&&e.sessionId===d.sessionId&&e.branchId===d.branchId)continue;let f=this.workspaces.get(a);f&&(this.disposeLayout(f),this.workspaces.delete(a)),this.previewDirectories.delete(a),c=!0,this.expandedWorkId===a&&(this.expandedWorkId=null)}for(let[a,c]of(this.sources.clear(),b))this.sources.set(a,c),this.previewDirectories.has(a)||this.previewDirectories.set(a,{directories:[c.cwd],defaultDirectory:null,selectedDirectory:c.cwd});c&&this.publish()}ensureRoot(a){return this.getFileRuntime(a).ensureRoot()}ensureDirectory(a,b){return this.getFileRuntime(a).ensureDirectory(b)}setExpandedPaths(a,b){this.getFileRuntime(a).setExpandedPaths(b)}setTreeScrollTop(a,b){this.workspaces.get(a)?.files.setTreeScrollTop(b)}refreshTree(a){this.getFileRuntime(a).refreshTree()}setSearchQuery(a,b){this.getFileRuntime(a).setSearchQuery(b)}search(a,b){return this.getFileRuntime(a).search(b)}openFile(a,b){let c=this.workspaceFor(a);c.windowOpen=!0,c.activePane="files",c.files.openFile(b)}async revealFile(a,b){await this.getFileRuntime(a).revealFile(b)}activateFile(a,b){this.workspaces.get(a)?.files.state.tabs.includes(b)&&this.openFile(a,b)}closeFile(a,b){this.closeTabs(a,b,"current")}closeTabs(a,b,c){this.workspaces.get(a)?.files.closeTabs(b,c)}hideWindow(a){let b=this.workspaces.get(a);b?.windowOpen&&(b.windowOpen=!1,b.activePane="chat",this.expandedWorkId===a&&(this.expandedWorkId=null),this.publish())}showWindow(a){let b=this.workspaceFor(a),{tabs:c,activeDiff:d,activePath:e}=b.files.state;(c.length||d||this.expandedWorkId===a)&&(b.windowOpen=!0,b.activePane="files",this.publish(),!d&&e&&b.files.ensureDocument(e))}setChatWidthPercent(a,b){let c=this.workspaces.get(a);!c||!Number.isFinite(b)||b<=0||b>=100||.001>Math.abs(c.chatWidthPercent-b)||(c.chatWidthPercent=b,this.publish())}setActivePane(a,b){let c=this.workspaces.get(a);c&&c.activePane!==b&&(c.activePane=b,this.publish())}expandWindow(a){this.expandedWorkId=a,this.showWindow(a)}collapseExpandedWindow(){if(!this.expandedWorkId)return;let a=this.workspaces.get(this.expandedWorkId);this.expandedWorkId=null,!a||a.files.state.tabs.length||a.files.state.activeDiff||(a.windowOpen=!1,a.activePane="chat"),this.publish()}reloadFile(a,b){this.workspaces.get(a)?.files.reloadFile(b)}openDiff(a,b,c){let d=this.workspaceFor(a);d.windowOpen=!0,d.activePane="files",d.files.openDiff(b,c)}closeDiff(a){this.closeTabs(a,null,"current")}reloadDiff(a){this.workspaces.get(a)?.files.reloadDiff()}setDiffViewMode(a,b){this.workspaces.get(a)?.files.setDiffViewMode(b)}setDiffWrapLines(a,b){this.workspaces.get(a)?.files.setDiffWrapLines(b)}setDiffCollapseUnchanged(a,b){this.workspaces.get(a)?.files.setDiffCollapseUnchanged(b)}handleGitBranchChanged(a,b){for(let c of this.workspaces.values())for(let d of c.roots.values())d.files.cwd===a&&d.files.handleGitBranchChanged(b)}saveEditorState(a,b,c){this.workspaces.get(a)?.files.saveEditorState(b,c)}setWrapLines(a,b,c){this.workspaces.get(a)?.files.setWrapLines(b,c)}setTextViewMode(a,b,c){this.workspaces.get(a)?.files.setTextViewMode(b,c)}dispose(){for(let a of(this.standaloneImages.dispose(),this.workspaces.values()))this.disposeLayout(a);this.workspaces.clear(),this.sources.clear(),this.previewDirectories.clear(),this.expandedWorkId=null,this.listeners.clear()}workspaceFor(a){if(!this.sources.get(a))throw Error(ze("sourceChanged"));let b=this.workspaces.get(a);if(b)return b;let c={files:this.createFiles(a,this.getDirectory(a)),roots:new Map,windowOpen:!1,chatWidthPercent:50,activePane:"files"};return this.attachRoot(a,c,c.files),this.workspaces.set(a,c),c}createFiles(a,b){let c={workId:a,cwd:b};return new zc.h(b,{list:(a,b)=>this.biz.list({...c,path:a},b),search:(a,b)=>this.biz.search({...c,...a},b),get:(a,b,d)=>this.biz.get({...c,path:a,imagePreviewMode:b},d),diff:(a,b,d)=>this.gitBiz.getDiff({...c,repositoryRoot:a,path:b},d)},{imagePreviewMode:kR.Wq,htmlPreview:!0,onNotice:this.onNotice,reveal:async(a,b)=>{await this.biz.reveal({...c,path:a,..."directory"===b?{targetType:b}:{}})}})}attachRoot(a,b,c){let d=c.subscribe(()=>{b.files===c&&(c.state.activePath||c.state.activeDiff||this.expandedWorkId===a||(b.windowOpen=!1,b.activePane="chat"),this.publish())});b.roots.set(zb(c.cwd),{files:c,unsubscribe:d})}switchFiles(a,b){let c=this.getDirectory(a),d=zb(c);if(zb(b.files.cwd)===d)return;let e=b.roots.get(d);if(!e){let f=this.createFiles(a,c);this.attachRoot(a,b,f),e=b.roots.get(d)}b.files=e.files,e.files.state.activePath||e.files.state.activeDiff||this.expandedWorkId===a||(b.windowOpen=!1,b.activePane="chat")}disposeLayout(a){for(let b of a.roots.values())b.unsubscribe(),b.files.dispose();a.roots.clear()}publish(){for(let a of(this.revision+=1,this.listeners))a()}}var zj=c(39511);function zk(a){return a.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??a}function zl({workId:a,cwd:b,projectName:c,runtime:d,gitRuntime:e,onOpenGitBranches:f,onFileOpened:g}){let h,{t:i}=(0,Q.Bd)("projectFiles");(0,B.useSyncExternalStore)(d.subscribe,d.getRevision,d.getRevision);let j=d.getDirectory(a),k=d.getDirectories(a),l=zb(b)===zb(j),m=l?c:zk(j);return(0,A.jsx)(zj.F,{cwd:j,projectName:m,gitReadOnly:!l,rootTitle:k.length>1?(0,A.jsxs)(bt,{children:[(0,A.jsxs)(bv,{"data-testid":"project-preview-directory-trigger","aria-label":i("selectPreviewDirectory"),title:j,className:"flex min-h-7 min-w-0 flex-1 items-center gap-1 rounded-md px-1 text-left hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring",children:[(0,A.jsx)("span",{className:"max-w-[45%] truncate text-xs font-semibold",children:m}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,A.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:(h=j.replaceAll("\\","/").split("/").filter(Boolean)).length<=2?j:`…/${h.slice(-2).join("/")}`}),(0,A.jsx)(cr.A,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,A.jsx)(bw,{finalFocus:!0,className:"w-[23rem] min-w-0 max-w-[calc(100vw-1.5rem)]","aria-label":i("previewDirectories"),children:(0,A.jsxs)(bx,{children:[(0,A.jsx)(by,{children:i("previewDirectories")}),(0,A.jsx)(bE,{value:j,onValueChange:b=>d.selectDirectory(a,b),children:k.map(a=>(0,A.jsxs)(bF,{value:a,"data-testid":"project-preview-directory-option","data-directory":a,className:"items-start py-2 data-checked:bg-muted",children:[(0,A.jsx)(ch.A,{className:"mt-0.5 size-4 text-muted-foreground"}),(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("span",{className:"flex items-start gap-2",children:[(0,A.jsx)("span",{className:"min-w-0 flex-1 break-all",children:zb(a)===zb(b)?c:zk(a)}),zb(a)===zb(b)?(0,A.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:i("sessionDirectory")}):null]}),(0,A.jsx)("span",{className:"mt-0.5 block break-all font-mono text-xs leading-5 text-muted-foreground",children:a})]})]},zb(a)))})]})})]}):void 0,runtime:d.getFileRuntime(a),gitRuntime:e,onOpenGitBranches:d=>{l&&f({workId:a,cwd:b,projectName:c,repositoryRoot:d})},onFileOpened:()=>{d.showWindow(a),g?.()}})}var zm=c(87348),zn=c(45427),zo=c(55091),zp=c(45694);let zq='data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/%3E';function zr({target:a,paths:b,index:c,onIndexChange:d,biz:e,images:f}){let{t:g}=(0,Q.Bd)("workbench"),[h,i]=(0,B.useState)({});(0,B.useRef)(new Map);let j=b[c],k=h[j],l=(0,kR.Wq)(),m=f.peek(a,j,l),n=k?.status==="ready"||!k&&null!==m;return(0,A.jsxs)("div",{className:"relative size-full","data-testid":"standalone-image-gallery",children:[(0,A.jsx)(j$.k,{mode:"inline",thumbnails:!1,slides:b.map(a=>{let b=h[a];return{src:b?.status==="ready"?b.objectUrl:a===j?m??zq:zq,alt:a}}),index:c,onIndexChange:d}),n?null:(0,A.jsx)("div",{className:"pointer-events-none absolute inset-0 z-[2] flex items-center justify-center p-6 pb-20",children:k?.status==="error"?(0,A.jsxs)("div",{className:"flex max-w-full flex-col items-center gap-3 rounded-lg bg-background/95 p-4 text-center",children:[(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:k.message}),(0,A.jsx)(U.$,{className:"pointer-events-auto",variant:"outline",onClick:()=>{f.invalidate(a,j,(0,kR.Wq)()),i(a=>{let b={...a};return delete b[j],b})},children:g("reloadFile")})]}):(0,A.jsxs)("div",{role:"status",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"}),g("loadingFile")]})})]})}function zs(a){return a.replaceAll("\\","/").split("/").at(-1)??a}function zt({target:a,biz:b,images:c,mobile:d,onClose:e}){let{t:f}=(0,Q.Bd)("workbench"),{t:g}=(0,Q.Bd)("projectFiles"),h=(0,B.useRef)(null),[i,j]=(0,B.useState)({mode:"preview",scrollTop:0}),k=(0,B.useRef)(0),[l,m]=(0,B.useState)(null),[n,o]=(0,B.useState)(0),[p,q]=(0,B.useState)(()=>{let b=a&&!a.imagePaths?c.peek(a,a.path,(0,kR.Wq)()):null;return b?{status:"image",objectUrl:b}:{status:"loading"}}),[r,s]=(0,B.useState)(()=>a?.imagePaths?a.imagePaths.indexOf(a.path):0);if(!a)return null;let t=a.imagePaths?.[r]??a.path,u=(0,zo.g)(t);return(0,A.jsx)(b7.YV,{open:!0,onOpenChange:a=>{a||e()},children:(0,A.jsxs)(b7.hA,{className:d?"inset-x-0 top-[var(--pi-desk-window-inset)] bottom-0 h-[var(--pi-desk-content-height)] max-h-none w-dvw max-w-none translate-x-0 translate-y-0 rounded-none border-0 ring-0":"h-[min(94dvh,1080px)] w-[min(96dvw,1600px)] max-w-none",children:[(0,A.jsx)(b7.YM,{className:"sr-only",children:zs(t)}),(0,A.jsxs)("section",{"data-testid":"plugin-standalone-file-preview",className:"flex size-full min-h-0 min-w-0 flex-col overflow-hidden bg-background","aria-label":f("standaloneViewer",{name:a.projectName}),children:[(0,A.jsxs)("header",{className:"flex min-h-14 shrink-0 items-center gap-3 border-b pl-3 pr-14 pt-[env(safe-area-inset-top)]",children:[(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)("p",{className:"truncate text-sm font-semibold",title:zs(t),children:zs(t)}),(0,A.jsxs)("p",{className:"truncate text-xs text-muted-foreground",title:`${a.projectName} \xb7 ${t}`,children:[a.projectName," \xb7 ",t]})]}),"markdown"===u&&"text"===p.status?(0,A.jsx)("div",{className:"flex shrink-0",role:"group","aria-label":g("markdownMode"),children:["preview","source"].map(a=>(0,A.jsx)(U.$,{size:"sm",variant:i.mode===a?"secondary":"ghost","aria-pressed":i.mode===a,onClick:()=>{i.mode!==a&&j({mode:a,scrollTop:k.current})},children:g("preview"===a?"previewMode":"sourceMode")},a))}):null]}),(0,A.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden pb-[env(safe-area-inset-bottom)]",children:a.imagePaths?(0,A.jsx)(zr,{target:a,paths:a.imagePaths,index:r,onIndexChange:s,biz:b,images:c}):"loading"===p.status?(0,A.jsx)(zu,{}):"error"===p.status?(0,A.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[(0,A.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:p.message}),(0,A.jsx)(U.$,{variant:"outline",onClick:()=>{c.invalidate(a,a.path,(0,kR.Wq)()),q({status:"loading"}),o(a=>a+1)},children:f("reloadFile")})]}):"image"===p.status?(0,A.jsx)(j$.k,{mode:"inline",slides:[{src:p.objectUrl,alt:a.path}],ariaLabel:f("standaloneImage",{name:zs(a.path)})}):"markdown"===u&&"preview"===i.mode?(0,A.jsx)(zn.n,{content:p.content,label:g("markdownPreview",{name:t}),savedScrollTop:i.scrollTop,onScroll:a=>{k.current=a}}):"html"===u?(0,A.jsx)("iframe",{ref:h,className:"block size-full border-0 bg-white",sandbox:"allow-scripts",srcDoc:(0,zp.z)(p.content),title:f("standaloneHtml",{name:a.path})}):(0,A.jsx)(zm.e,{path:a.path,content:p.content,size:p.size,savedState:l,onSaveState:(a,b)=>m(b),onEscape:e})})]})]})})}function zu(){let{t:a}=(0,Q.Bd)("workbench");return(0,A.jsxs)("div",{className:"flex size-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"}),a("loadingFile")]})}var zv=c(70914),zw=c.n(zv),zx=c(794),zy=c.n(zx);let zz=zw()(async()=>{},{loadableGenerated:{modules:["client/l2_biz/workbench/file-workspace/l2-work-session-file-layout.tsx -> ./l2-file-workspace-view"]},ssr:!1});function zA({workSession:a,runtime:b,gitRuntime:c,mobile:d,onOpenGitBranches:e,onOpenSidebar:f,children:g}){let{t:h}=(0,Q.Bd)("workbench");(0,B.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let i=(0,B.useRef)(null),j=(0,X.OG)(),k=(0,B.useRef)(null),l=(0,B.useRef)(null),m=(0,B.useRef)(null),n=(0,B.useRef)(null),o=(0,B.useRef)(null),[p,q]=(0,B.useState)(!1),{workId:r}=a,s=b.getWorkspace(r),t=s?.windowOpen===!0,u=`session-chat-pane-${r}`,v=`session-file-pane-${r}`,w=s?.chatWidthPercent??50,[x]=(0,B.useState)(()=>t?w:100),y=!!(s?.tabs.length||s?.activeDiff),z=p&&!d,C=z&&t,D=b.getExpandedWorkId()===r,E=t&&(C||s?.activePane==="files"),F=!E||C,G=a=>{o.current=a},H=()=>{if(!y)return;let a=b.getWorkspace(r)?.activePane==="files"?"chat":"files";G(a),"files"===a?b.showWindow(r):b.setActivePane(r,"chat")};return(0,A.jsx)("div",{ref:i,"data-testid":"session-file-layout","data-file-layout":C?"split":"single",className:"relative size-full min-h-0 min-w-0 overflow-hidden",onKeyDownCapture:a=>{"Tab"!==a.key||!a.ctrlKey||a.altKey||a.metaKey||a.repeat||a.nativeEvent.isComposing||!y||a.target instanceof Element&&a.target.closest('[role="menu"], [data-slot="app-dialog-content"]')||(a.preventDefault(),a.stopPropagation(),H())},children:(0,A.jsxs)(V.HK,{groupRef:j,className:(0,W.cn)("pi-desk-workbench-resize-group relative size-full min-h-0 min-w-0",z?[y2().panelGroup,zy().wide]:zy().single),orientation:"horizontal",disabled:!C,resizeTargetMinimumSize:{fine:8,coarse:20},onLayoutChanged:(a,c)=>{if(!C||!c.isUserInteraction)return;let d=a[u];void 0!==d&&b.setChatWidthPercent(r,d)},children:[(0,A.jsx)(V.wV,{id:u,"data-pane":"chat",defaultSize:`${x}%`,minSize:320*!!C,"aria-hidden":!F||void 0,inert:!F||void 0,className:"flex min-h-0 min-w-0 !overflow-hidden",children:(0,A.jsx)("div",{ref:k,className:"size-full min-h-0 min-w-0",onPointerDownCapture:()=>b.setActivePane(r,"chat"),onFocusCapture:a=>{m.current=a.target,b.setActivePane(r,"chat")},children:g(F)})}),(0,A.jsx)(V.WM,{id:`session-file-divider-${r}`,"aria-label":h("resizeChatFile"),"aria-hidden":!C||void 0,disabled:!C,disableDoubleClick:!0,className:(0,W.cn)("z-10 w-px cursor-col-resize bg-transparent aria-disabled:cursor-default",!C&&"hidden")}),(0,A.jsx)(V.wV,{id:v,"data-pane":"files",defaultSize:`${100-x}%`,minSize:320*!!C,maxSize:z&&!t?0:void 0,"aria-hidden":!E||void 0,inert:!E||void 0,className:"flex min-h-0 min-w-0 !overflow-hidden",children:(0,A.jsx)("div",{ref:l,className:"size-full min-h-0 min-w-0 overflow-hidden",onPointerDownCapture:()=>b.setActivePane(r,"files"),onFocusCapture:a=>{n.current=a.target,b.setActivePane(r,"files")},children:y&&!D?(0,A.jsx)(zz,{workSession:a,runtime:b,gitRuntime:c,mobile:d,presentation:z?"split":"single",onOpenGitBranches:e,onOpenSidebar:f,onHide:()=>{G("chat"),b.hideWindow(r)},onExpand:()=>b.expandWindow(r),onSwitchPane:H},`${a.sessionId}:${a.branchId}`):null})})]})})}function zB({workSessions:a,runtime:b,gitRuntime:c,mobile:d,onOpenGitBranches:e,onOpenSidebar:f,onOpenTerminal:g}){let{t:h}=(0,Q.Bd)("workbench");(0,B.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let i=a.find(a=>a.workId===b.getExpandedWorkId());if(!i)return null;let j=()=>{d?b.hideWindow(i.workId):b.collapseExpandedWindow()},k=()=>{let a=document.querySelector(`[data-work-id="${CSS.escape(i.workId)}"] textarea`);a&&(b.hideWindow(i.workId),requestAnimationFrame(()=>a.focus({preventScroll:!0})))};return(0,A.jsx)(b7.YV,{open:!0,onOpenChange:a=>{a||j()},children:(0,A.jsxs)(b7.hA,{showCloseButton:!1,onKeyDownCapture:a=>{"Tab"!==a.key||!a.ctrlKey||a.altKey||a.metaKey||a.repeat||a.nativeEvent.isComposing||a.target instanceof Element&&a.target.closest('[role="menu"]')||(a.preventDefault(),a.stopPropagation(),k())},className:d?"inset-x-0 top-[var(--pi-desk-window-inset)] bottom-0 h-[var(--pi-desk-content-height)] max-h-none w-dvw max-w-none translate-x-0 translate-y-0 rounded-none border-0 ring-0":"h-[min(94dvh,1080px)] w-[min(96dvw,1600px)] max-w-none",finalFocus:()=>{let a=document.querySelector(`[data-work-id="${CSS.escape(i.workId)}"]`);return a?.querySelector("[data-file-expand-trigger]")??a?.querySelector('[data-testid="session-files-entry"]')??!1},children:[(0,A.jsx)(b7.YM,{className:"sr-only",children:h("fileViewer",{name:i.projectName})}),(0,A.jsx)(zz,{workSession:i,runtime:b,gitRuntime:c,mobile:d,presentation:d?"single":"expanded",onOpenGitBranches:e,onOpenSidebar:()=>{b.collapseExpandedWindow(),f(i.workId)},onSwitchPane:k,onOpenTerminal:g,onHide:()=>b.hideWindow(i.workId),onExpand:j},`${i.workId}:${i.sessionId}:${i.branchId}`)]})})}var zC=c(95186);let zD=(0,S.A)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var zE=c(35385),zF=c(9365),zG=c(49057);let zH=[];function zI(a,b){let c=b.trim().toLocaleLowerCase();return c?a.filter(a=>a.toLocaleLowerCase().includes(c)):[...a]}function zJ({target:a,runtime:b,mobile:c,onClose:d}){let{t:e}=(0,Q.Bd)("workbench"),{locale:f}=(0,cy.i)();(0,B.useSyncExternalStore)(b.subscribe,b.getRevision,b.getRevision);let g=(0,bK.G)(),[h,i]=(0,B.useState)(null),[j,k]=(0,B.useState)(a?.repositoryRoot!==null),[l,m]=(0,B.useState)(""),[n,o]=(0,B.useState)(()=>({repositoryRoot:null,overrides:new Map})),[p,q]=(0,B.useState)(null),[r,s]=(0,B.useState)(!1),[t,u]=(0,B.useState)(""),[v,w]=(0,B.useState)(null),[x,y]=(0,B.useState)(null),z=b.getWorkspace(a?.cwd??null),C=z?.heads.repositories??zH,D=a?null!==a.repositoryRoot&&C.some(b=>b.root===a.repositoryRoot)?a.repositoryRoot:C.find(a=>""===a.root)?.root??C[0]?.root??null:null,E=h??D,F=C.find(a=>a.root===E)??null,G=null===E?null:z?.branches.get(E)??null,H=G?.data??null,I=null!==E&&!!z?.branchOperations.has(E),J=(0,B.useMemo)(()=>zI(H?.local??[],l),[H?.local,l]),K=(0,B.useMemo)(()=>zI(H?.remote??[],l),[H?.remote,l]),L=(0,B.useMemo)(()=>zI(H?.recent??[],l),[H?.recent,l]),M=(0,B.useMemo)(()=>(0,zG.oY)(J),[J]),N=(0,B.useMemo)(()=>(0,zG.oY)(K),[K]),O=H?.head.type==="branch"?H.head.name:null,P=(0,B.useMemo)(()=>{let a=new Set;if(!O?.includes("/"))return a;let b=O.split("/");for(let c=1;c<b.length;c+=1)a.add(`local:${b.slice(0,c).join("/")}`);return a},[O]);if(!a)return null;let S=a=>{w(a),u(""),s(!0),q(null),y(null)},T=async(a,b)=>{y(null);try{await a(),g.success(b),d()}catch(a){y(a instanceof Error?a.message:e("gitOperationFailed"))}},V=C.length>1,X=1===C.length?e("repositorySummary",{name:(0,zG.Hj)(a.projectName,C[0].root),branch:"ready"===C[0].state?(0,zG.ws)(C[0].head):e("repositoryUnavailable")}):C.length>1?e("repositoryCount",{count:C.length}):e("readingRepos"),Y=(c,d,f=c.name,g=0)=>{let h="local"===c.type&&c.name===O,i=p?.type===c.type&&p.name===c.name;return(0,A.jsxs)("div",{children:[(0,A.jsxs)("button",{type:"button","data-testid":"recent"===d?`git-branch-recent-${c.name}`:`git-branch-${c.type}-${c.name}`,className:(0,W.cn)("grid min-h-9 w-full cursor-pointer grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-lg pr-2 text-left outline-none hover:bg-foreground/8 focus-visible:ring-2 focus-visible:ring-ring",h&&"font-medium text-foreground",i&&"bg-accent"),style:{paddingLeft:`${8+16*g}px`},title:c.name,onClick:()=>q(i?null:c),children:[(0,A.jsx)("span",{className:"text-muted-foreground",children:h?(0,A.jsx)(bs.A,{className:"size-4 text-foreground"}):"remote"===c.type?(0,A.jsx)(zD,{className:"size-3.5"}):(0,A.jsx)(zE.A,{className:"size-3.5"})}),(0,A.jsx)("span",{className:"truncate font-mono text-sm",children:f}),(0,A.jsx)("span",{className:"text-xs text-muted-foreground",children:h?e("current"):"recent"===d?e("recent"):""})]}),i?(0,A.jsxs)("div",{className:"flex flex-wrap gap-2 border-l-2 border-border py-2 pl-2",style:{marginLeft:`${32+16*g}px`},children:[h?null:(0,A.jsx)(U.$,{type:"button",size:"sm",variant:"outline",disabled:I,onClick:()=>{null!==E&&!I&&T(()=>b.replaceBranch(a.cwd,E,c),e("remote"===c.type?"checkedOut":"switchedBranch",{name:c.name}))},children:e("remote"===c.type?"checkoutRemote":"switchGitBranch")}),(0,A.jsx)(U.$,{type:"button",size:"sm",variant:"ghost",disabled:I,onClick:()=>S(c),children:e("branchFromHere")})]}):null]},`${d}:${c.type}:${c.name}`)},$=(a,b)=>{let c=`${a}:${b}`;return(n.repositoryRoot===E?n.overrides.get(c):void 0)??P.has(c)},_=(a,b,c=0)=>a.map(a=>{if(0===a.children.length&&a.branchName)return Y({type:b,name:a.branchName},b,a.name,c);let d=`${b}:${a.path}`,e=!!l.trim()||$(b,a.path);return(0,A.jsxs)("div",{children:[(0,A.jsxs)("button",{type:"button","data-testid":`git-branch-group-${b}-${a.path}`,"aria-expanded":e,className:"grid min-h-9 w-full cursor-pointer grid-cols-[1rem_1rem_minmax(0,1fr)] items-center gap-2 rounded-lg pr-2 text-left text-muted-foreground outline-none hover:bg-foreground/8 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",style:{paddingLeft:`${8+16*c}px`},title:a.path,onClick:()=>((a,b)=>{if(l.trim())return;let c=`${a}:${b}`,d=$(a,b);o(a=>{let b=a.repositoryRoot===E?new Map(a.overrides):new Map;return b.set(c,!d),{repositoryRoot:E,overrides:b}})})(b,a.path),children:[(0,A.jsx)(br.A,{className:(0,W.cn)("size-3 transition-transform",e&&"rotate-90")}),e?(0,A.jsx)(zF.A,{className:"size-4 text-muted-foreground"}):(0,A.jsx)(ch.A,{className:"size-4 text-muted-foreground"}),(0,A.jsx)("span",{className:"truncate font-mono text-sm",children:a.name})]}),e?_(a.children,b,c+1):null]},d)});return(0,A.jsx)(b7.YV,{open:!0,onOpenChange:a=>!a&&d(),children:(0,A.jsxs)(b7.hA,{"data-testid":"git-branch-picker",showCloseButton:!1,finalFocus:!1,className:"h-[min(40rem,calc(100dvh-2rem))] max-w-[45rem] gap-0",children:[(0,A.jsxs)("header",{className:"flex min-h-12 shrink-0 items-center gap-2 border-b px-3",children:[(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)(b7.YM,{children:e("gitBranches")}),(0,A.jsx)(b7.uX,{className:"truncate text-xs",children:X})]}),(0,A.jsx)(U.$,{type:"button",size:"icon-sm",variant:"ghost","aria-label":e("refreshBranches"),disabled:z?.heads.status==="loading",onClick:()=>void b.refreshHeads(a.cwd),children:(0,A.jsx)(bO.A,{className:(0,W.cn)("size-4",z?.heads.status==="loading"&&"animate-spin")})}),(0,A.jsx)(U.$,{type:"button",size:"sm",variant:"ghost",onClick:d,children:e("close")})]}),(0,A.jsxs)("div",{className:(0,W.cn)("grid min-h-0 flex-1",V&&!c?"grid-cols-[220px_minmax(0,1fr)]":"grid-cols-1"),children:[!V||c&&j?null:(0,A.jsxs)("aside",{className:"pi-desk-chat-scrollbar min-h-0 overflow-y-auto border-r bg-sidebar p-2 max-sm:border-r-0",children:[(0,A.jsx)("p",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:e("repositories")}),C.map(b=>{let c=(0,zG.Hj)(a.projectName,b.root),d=b.root===E;return(0,A.jsxs)("button",{"data-testid":`git-branch-picker-repository-${b.root||"root"}`,type:"button",className:(0,W.cn)("grid min-h-12 w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-2 rounded-lg px-2 text-left hover:bg-muted/70",d&&"bg-accent text-accent-foreground"),onClick:()=>{var a;i(a=b.root),k(!0),m(""),o({repositoryRoot:a,overrides:new Map}),q(null),s(!1),w(null),y(null)},children:[(0,A.jsxs)("span",{className:"min-w-0",children:[(0,A.jsx)("strong",{className:"block truncate text-sm font-medium",children:c}),(0,A.jsx)("span",{className:"mt-1 block truncate font-mono text-xs text-muted-foreground",children:b.root||"."})]}),(0,A.jsx)("span",{className:"flex flex-col items-end gap-1 text-xs text-muted-foreground",children:(0,A.jsx)("span",{className:"max-w-28 truncate",children:"ready"===b.state?(0,zG.ws)(b.head):e("unavailable")})})]},b.root)})]}),c&&V&&!j?null:(0,A.jsxs)("section",{className:"flex min-h-0 min-w-0 flex-col",children:[(0,A.jsxs)("div",{className:"flex min-h-13 shrink-0 items-center gap-2 border-b px-3",children:[c&&V?(0,A.jsx)(U.$,{type:"button",size:"icon-sm",variant:"ghost","aria-label":e("backRepositories"),onClick:()=>k(!1),children:(0,A.jsx)(Z.A,{className:"size-4"})}):null,(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("p",{className:"truncate text-sm font-semibold",children:[F?(0,zG.Hj)(a.projectName,F.root):e("chooseRepository"),F?.state==="ready"?` \xb7 ${(0,zG.ws)(F.head)}`:""]}),(0,A.jsx)("p",{className:"mt-1 break-words font-mono text-xs text-muted-foreground",children:F?.root||"."})]}),(0,A.jsxs)(U.$,{type:"button",size:"sm",variant:"outline",disabled:F?.state!=="ready"||I,onClick:()=>S(null),children:[(0,A.jsx)(am,{className:"size-3.5"})," ",e("createBranch")]})]}),z?.heads.status==="error"?(0,A.jsx)("p",{className:"border-b bg-muted px-3 py-2 text-sm text-destructive",children:z.heads.error}):null,x?(0,A.jsx)("p",{className:"border-b bg-muted px-3 py-2 text-sm text-destructive",children:x}):null,(0,A.jsx)("div",{className:"flex shrink-0 items-center gap-2 border-b p-2",children:r?(0,A.jsxs)("form",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",onSubmit:c=>{let d;c.preventDefault(),(d=t.trim())&&null!==E&&!I&&T(()=>b.addBranch(a.cwd,E,d,v),e("branchCreated",{name:d}))},children:[(0,A.jsx)(bY.p,{autoFocus:!0,value:t,onChange:a=>u(a.currentTarget.value),placeholder:e("newBranchName"),"aria-label":e("newBranchName"),className:"min-w-[12rem] flex-1"}),(0,A.jsxs)(U.$,{type:"submit",size:"sm",disabled:!t.trim()||I,children:[I?(0,A.jsx)(R.A,{className:"size-3.5 animate-spin"}):null,e("createAndSwitch")]}),(0,A.jsx)(U.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>{s(!1),w(null)},children:e("cancel")})]}):(0,A.jsx)(bY.p,{value:l,onChange:a=>m(a.currentTarget.value),placeholder:e("searchBranches"),"aria-label":e("searchBranches")})}),(0,A.jsx)("div",{className:"pi-desk-chat-scrollbar min-h-0 flex-1 overflow-y-auto p-2",children:F?.state==="unavailable"?(0,A.jsx)("p",{className:"p-5 text-center text-xs text-destructive",children:(0,cx.fD)(F.message,f)}):G?.status!=="loading"||H?G?.status==="error"?(0,A.jsxs)("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 text-center text-xs text-destructive",children:[(0,A.jsx)("p",{children:G.error}),null!==E?(0,A.jsx)(U.$,{type:"button",size:"sm",variant:"outline",onClick:()=>void b.loadBranches(a.cwd,E),children:e("retry")}):null]}):H?(0,A.jsxs)("div",{className:"space-y-3",children:[L.length>0?(0,A.jsxs)("section",{children:[(0,A.jsx)("p",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:e("recentlyUsed")}),L.map(a=>Y({type:"local",name:a},"recent"))]}):null,J.length>0?(0,A.jsxs)("section",{children:[(0,A.jsx)("p",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:e("localBranches")}),_(M,"local")]}):null,K.length>0?(0,A.jsxs)("section",{children:[(0,A.jsx)("p",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:e("remoteBranches")}),_(N,"remote")]}):null,0===L.length&&0===J.length&&0===K.length?(0,A.jsx)("p",{className:"p-5 text-center text-xs text-muted-foreground",children:e("noBranchMatches")}):null]}):null:(0,A.jsxs)("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-muted-foreground",children:[(0,A.jsx)(R.A,{className:"size-4 animate-spin"})," ",e("loadingBranches")]})})]})]})]})})}function zK(a,b){return a instanceof DOMException&&"AbortError"===a.name?b:a instanceof Error?a.message:b}class zL{constructor(a,b){this.biz=a,this.onRepositoryChanged=b,this.listeners=new Set,this.workspaces=new Map,this.projectRefs=new Map,this.revision=0,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a)),this.getRevision=()=>this.revision}getWorkspace(a){return a?this.workspaces.get(a)??null:null}reconcileWorkSessions(a,b,c=[]){let d=new Map,e=b?a.find(a=>a.workId===b)??null:null;for(let b of(e&&d.set(e.cwd,{workId:e.workId,cwd:e.cwd}),a))d.has(b.cwd)||d.set(b.cwd,{workId:b.workId,cwd:b.cwd});for(let a of c)d.has(a.cwd)||d.set(a.cwd,{...a,readOnly:!0});if(d.size!==this.projectRefs.size||[...d].some(([a,b])=>this.projectRefs.get(a)?.workId!==b.workId||this.projectRefs.get(a)?.readOnly!==b.readOnly)){for(let[a,b]of(this.projectRefs.clear(),d))this.projectRefs.set(a,b);for(let[a,b]of this.workspaces)d.has(a)||(this.abortRequests(b),this.workspaces.delete(a))}}ensureSnapshot(a){let b=this.workspaceFor(a);return"ready"===b.snapshot.status||"loading"===b.snapshot.status?Promise.resolve():this.loadSnapshot(a)}refreshSnapshot(a){return this.loadSnapshot(a)}async refreshHeads(a){let b=this.workspaceFor(a);if(b.headsRequest||Date.now()-b.lastHeadsStartedAt<3e4)return;let c=this.projectRefs.get(a);if(!c){b.heads={...b.heads,status:"error",error:ze("gitNoProjectStatus")},this.publish();return}let d=new AbortController,e={};b.headsRequest={controller:d,token:e},b.lastHeadsStartedAt=Date.now(),b.heads={...b.heads,status:"loading",error:null},this.publish();try{let f=await this.biz.getHeads({workId:c.workId,cwd:a},d.signal);if(b.headsRequest?.token!==e)return;b.headsRequest=null,b.heads={status:"ready",repositories:f.repositories,error:null},this.publish()}catch(a){if(b.headsRequest?.token!==e||(b.headsRequest=null,d.signal.aborted))return;b.heads={...b.heads,status:"error",error:zK(a,ze("gitStatusReadFailed"))},this.publish()}}setLayout(a,b){let c=this.workspaceFor(a);c.layout!==b&&(c.layout=b,this.publish())}setChangesOnly(a,b){let c=this.workspaceFor(a);c.changesOnly!==b&&(c.changesOnly=b,this.publish())}toggleRepository(a,b){let c=this.workspaceFor(a);c.expandedRepositories.has(b)?c.expandedRepositories.delete(b):c.expandedRepositories.add(b),this.publish()}async loadBranches(a,b){let c=this.workspaceFor(a),d=this.projectRefs.get(a);if(!d){c.branches.set(b,{status:"error",data:null,error:ze("gitNoProjectBranches")}),this.publish();return}c.branchRequests.get(b)?.controller.abort();let e=new AbortController,f={};c.branchRequests.set(b,{controller:e,token:f}),c.branches.set(b,{status:"loading",data:c.branches.get(b)?.data??null,error:null}),this.publish();try{let g=await this.biz.listBranches({workId:d.workId,cwd:a,repositoryRoot:b},e.signal);if(c.branchRequests.get(b)?.token!==f)return;c.branchRequests.delete(b),c.branches.set(b,{status:"ready",data:g,error:null}),this.publish()}catch(a){if(c.branchRequests.get(b)?.token!==f||(c.branchRequests.delete(b),e.signal.aborted))return;c.branches.set(b,{status:"error",data:null,error:zK(a,ze("gitBranchesReadFailed"))}),this.publish()}}async replaceBranch(a,b,c){let d=this.requireWritableProject(a),e=this.workspaceFor(a);if(!e.branchOperations.has(b)){e.branchOperations.add(b),this.publish();try{let f=await this.biz.replaceBranch({...d,repositoryRoot:b,target:c});this.applyRepository(e,f.repository),this.clearBranches(e,b),this.onRepositoryChanged(a,b)}finally{e.branchOperations.delete(b),this.publish()}}}async addBranch(a,b,c,d){let e=this.requireWritableProject(a),f=this.workspaceFor(a);if(!f.branchOperations.has(b)){f.branchOperations.add(b),this.publish();try{let g=await this.biz.addBranch({...e,repositoryRoot:b,name:c,startPoint:d});this.applyRepository(f,g.repository),this.clearBranches(f,b),this.onRepositoryChanged(a,b)}finally{f.branchOperations.delete(b),this.publish()}}}getDiff(a,b,c,d){return this.biz.getDiff({...this.requireProject(a),repositoryRoot:b,path:c},d)}dispose(){for(let a of this.workspaces.values())this.abortRequests(a);this.workspaces.clear(),this.projectRefs.clear(),this.listeners.clear()}async loadSnapshot(a){let b=this.workspaceFor(a);if(b.snapshotRequest)return;let c=this.projectRefs.get(a);if(!c){b.snapshot={status:"error",repositories:b.snapshot.repositories,error:ze("gitNoProjectStatus")},this.publish();return}let d=new AbortController,e={};b.snapshotRequest={controller:d,token:e},"ready"!==b.snapshot.status&&(b.snapshot={status:"loading",repositories:b.snapshot.repositories,error:null},this.publish());try{let f=await this.biz.get({workId:c.workId,cwd:a},d.signal);if(b.snapshotRequest?.token!==e)return;b.snapshotRequest=null,b.snapshot={status:"ready",repositories:f.repositories,error:null};let g=new Set(f.repositories.map(a=>a.root));for(let a of(f.repositories.length>0&&!g.has("")&&g.add(""),[...b.expandedRepositories]))g.has(a)||b.expandedRepositories.delete(a);this.publish()}catch(a){if(b.snapshotRequest?.token!==e||(b.snapshotRequest=null,d.signal.aborted))return;b.snapshot={status:"error",repositories:b.snapshot.repositories,error:zK(a,ze("gitStatusReadFailed"))},this.publish()}}requireProject(a){let b=this.projectRefs.get(a);if(!b)throw Error(ze("gitNoProjectOperation"));return{workId:b.workId,cwd:b.cwd}}requireWritableProject(a){if(this.projectRefs.get(a)?.readOnly)throw Error(ze("gitNoProjectOperation"));return this.requireProject(a)}applyRepository(a,b){a.headsRequest?.controller.abort(),a.headsRequest=null,a.snapshotRequest?.controller.abort(),a.snapshotRequest=null;let c={root:b.root,state:b.state,head:b.head},d=[...a.heads.repositories],e=d.findIndex(a=>a.root===b.root);if(e>=0?d[e]=c:d.push(c),a.heads={status:"ready",repositories:d,error:null},a.lastHeadsStartedAt=Date.now(),"idle"===a.snapshot.status)return;let f="loading"===a.snapshot.status,g=[...a.snapshot.repositories],h=g.findIndex(a=>a.root===b.root);h>=0?g[h]=b:g.push(b),a.snapshot={status:"ready"===a.snapshot.status?"ready":"idle",repositories:g,error:null},f&&this.refreshSnapshot(a.cwd)}abortRequests(a){for(let b of(a.headsRequest?.controller.abort(),a.headsRequest=null,a.snapshotRequest?.controller.abort(),a.snapshotRequest=null,a.branchRequests.values()))b.controller.abort();a.branchRequests.clear()}clearBranches(a,b){a.branchRequests.get(b)?.controller.abort(),a.branchRequests.delete(b),a.branches.delete(b)}workspaceFor(a){let b=this.workspaces.get(a);if(b)return b;let c={cwd:a,heads:{status:"idle",repositories:[],error:null},headsRequest:null,lastHeadsStartedAt:0,snapshot:{status:"idle",repositories:[],error:null},snapshotRequest:null,branches:new Map,branchRequests:new Map,layout:"directory",changesOnly:!1,expandedRepositories:new Set,branchOperations:new Set};return this.workspaces.set(a,c),c}publish(){for(let a of(this.revision+=1,[...this.listeners]))a()}}var zM=c(18997);let zN=zM.y2,zO=E.Ik({workId:yT.eW,cwd:yT.ik}).strict(),zP=zM.Ww,zQ=zM.cP,zR=zM.zp,zS=zM.u2;E.Ik({repositories:E.YO(zS).max(zN)}).strict();let zT=zO.extend({repositoryRoot:zP}).strict(),zU=zM.zt,zV=zO.extend({repositoryRoot:zP,target:zU}).strict(),zW=zO.extend({repositoryRoot:zP,name:zQ,startPoint:zU.nullable()}).strict(),zX=E.Ik({repository:zR}).strict(),zY=zO.extend({repositoryRoot:zP,path:jw._g}).strict();var zZ=c(45123);let z$=Object.freeze({messages:[],temporaryMessages:[],runtime:{extensionMode:"normal",presentationMode:"normal",initializationError:null,queues:{steering:[],followUp:[]},model:null,capabilityMode:null,contextUsage:null,plugins:{}}});function z_(a){let b=new Set;for(let[c,d]of a.entries()){if(d.location.index!==c||b.has(d.location.entryId))return null;b.add(d.location.entryId)}let c=a.at(-1);return c?{index:c.location.index,entryId:c.location.entryId}:null}var z0=c(92991);let z1="messages",z2="source",z3="drafts",z4="outbox",z5="pi-super-chat",z6=null,z7=null;function z8(a){return Error((0,bW.B)({msg:z0.n["zh-CN"].common[a],i18n:{key:`common:${a}`}}))}function z9(a,b){a.objectStoreNames.contains(b)||a.createObjectStore(b,{keyPath:["sessionId","branchId"]})}function Aa(){return new Promise((a,b)=>{let c=indexedDB.open(z5,2),d=!1,e=window.setTimeout(()=>{f(z8("dbOpenTimeout"))},1e4),f=a=>{d||(d=!0,window.clearTimeout(e),b(a))};c.addEventListener("upgradeneeded",()=>{let a=c.result;a.objectStoreNames.contains(z1)||a.createObjectStore(z1,{keyPath:["sessionId","branchId","index"]}).createIndex(z2,["sessionId","branchId"],{unique:!1}),z9(a,z3),z9(a,z4)},{once:!0}),c.addEventListener("blocked",()=>{f(z8("dbOpenBlocked"))},{once:!0}),c.addEventListener("success",()=>{let b=c.result;d?b.close():(d=!0,window.clearTimeout(e),a(b))},{once:!0}),c.addEventListener("error",()=>f(c.error??z8("dbOpenFailed")),{once:!0})})}async function Ab(){try{return await Aa()}catch(a){if(!("object"==typeof a&&null!==a&&"name"in a&&"VersionError"===a.name))throw a;return console.warn("[Pi Desk][ChatIndexedDB] 本地数据库版本高于当前版本,清空全部本地聊天数据后重建",{databaseName:z5,requestedVersion:2}),await new Promise((a,b)=>{let c=indexedDB.deleteDatabase(z5),d=!1,e=window.setTimeout(()=>{f(z8("dbDeleteTimeout"))},1e4),f=a=>{d||(d=!0,window.clearTimeout(e),b(a))};c.addEventListener("blocked",()=>{f(z8("dbDeleteBlocked"))},{once:!0}),c.addEventListener("success",()=>{d||(d=!0,window.clearTimeout(e),a())},{once:!0}),c.addEventListener("error",()=>f(c.error??z8("dbDeleteFailed")),{once:!0})}),Aa()}}function Ac(){return z7?Promise.resolve(z7):z6||(z6=Ab().then(a=>(z7=a,a.addEventListener("versionchange",()=>{a.close(),z7===a&&(z7=null,z6=null),console.warn("[Pi Desk][ChatIndexedDB] 数据库版本已变化,当前连接已关闭")}),a)).catch(a=>{throw z6=null,a}))}function Ad(a){return new Promise((b,c)=>{a.addEventListener("success",()=>b(a.result),{once:!0}),a.addEventListener("error",()=>c(a.error??z8("dbRequestFailed")),{once:!0})})}function Ae(a,b,c){let d=a.target;return d?.error??b.error??Error(c)}function Af(a){return new Promise((b,c)=>{a.addEventListener("complete",()=>b(),{once:!0}),a.addEventListener("abort",b=>c(Ae(b,a,z8("dbTransactionAborted").message)),{once:!0}),a.addEventListener("error",b=>c(Ae(b,a,z8("dbTransactionFailed").message)),{once:!0})})}let Ag=E.Ik({sessionId:E.Yj().trim().min(1),branchId:E.Yj().trim().min(1),index:E.ai().int().nonnegative(),entryId:E.Yj().trim().min(1),fixed:zZ.ao,summary:zZ.lV,detail:zZ.wI.optional()}).strict();function Ah(a,b){return Ag.parse({sessionId:a.sessionId,branchId:a.branchId,index:b.location.index,entryId:b.location.entryId,fixed:b.fixed,summary:b.summary,...void 0===b.detail?{}:{detail:b.detail}})}function Ai(a){let b=Ag.parse(a);if("assistant"===b.fixed.type&&"pi-desk/assistant"===b.fixed.viewKey){if(!Object.hasOwn(b.summary,"errorMessage"))throw Error("Assistant Summary cache uses an outdated projection");zZ.Y2.parse(b.summary),void 0!==b.detail&&zZ.$f.parse(b.detail)}return zZ.wR.parse({location:{index:b.index,entryId:b.entryId},fixed:b.fixed,summary:b.summary,...void 0===b.detail?{}:{detail:b.detail}})}function Aj(a,b){a.delete(IDBKeyRange.bound([b.sessionId,b.branchId,0],[b.sessionId,b.branchId,Number.MAX_SAFE_INTEGER]))}let Ak=E.Yj().max(65536),Al=E.Ik({id:E.Yj().uuid(),title:Ak,expiresAt:E.ai().int().nonnegative().nullable()}),Am=E.gM("method",[Al.extend({method:E.eu("confirm"),message:Ak}).strict(),Al.extend({method:E.eu("select"),options:E.YO(Ak).max(200)}).strict(),Al.extend({method:E.eu("input"),placeholder:Ak}).strict(),Al.extend({method:E.eu("editor"),prefill:Ak}).strict()]),An=E.Ik({requests:E.YO(Am).max(32),statuses:E.g1(E.Yj().max(128),Ak),widgets:E.g1(E.Yj().max(128),E.Ik({lines:E.YO(Ak).max(200),placement:E.k5(["aboveEditor","belowEditor"])}).strict())}).strict(),Ao=E.Ik({id:E.Yj().uuid(),value:E.KC([E.zM(),Ak,E.ch()])}).strict(),Ap=E.gM("type",[E.Ik({type:E.eu("snapshot"),snapshot:An}).strict(),E.Ik({type:E.eu("notify"),message:Ak,level:E.k5(["info","warning","error"])}).strict(),E.Ik({type:E.eu("editor_text"),text:Ak,mode:E.k5(["replace","paste"])}).strict()]),Aq=E.Ik({source:pe.R}).strict(),Ar=E.Ik({}).strict(),As=Object.freeze({subscribe:(0,F.Vc)({path:"pi/ui/subscribe",inputSchema:Aq,outputSchema:An}),unsubscribe:(0,F.Vc)({path:"pi/ui/unsubscribe",inputSchema:Aq,outputSchema:Ar}),respond:(0,F.Vc)({path:"pi/ui/respond",inputSchema:Aq.extend({response:Ao}).strict(),outputSchema:Ar}),event:(0,F._G)({path:"pi/ui/event",bodySchema:Aq.extend({event:Ap}).strict()})});function At(a){return JSON.stringify([a.workId,a.sessionId,a.branchId])}class Au{constructor(a){this.socket=a,this.records=new Map,this.listeners=new Set,this.notices=new Set,this.releasePush=null,this.connected=!1,this.epoch=0,this.subscribe=a=>(this.listeners.add(a),()=>this.listeners.delete(a))}onNotice(a){return this.notices.add(a),()=>this.notices.delete(a)}getState(a){return this.record(a).state}watch(a){this.releasePush||(this.releasePush=this.socket.subscribe(As.event,({source:a,event:b})=>{let c=this.records.get(At(a));if(c&&this.connected)if("snapshot"===b.type)c.state.refreshing?c.latest=b.snapshot:this.apply(c,b.snapshot);else if("editor_text"===b.type)this.patch(c,{prefill:b});else for(let d of(this.appendNotice(c,b),this.notices))d(a,b)}));let b=this.record(a);!this.connected||b.state.ready||b.state.refreshing||this.refresh(b)}ready(a){for(let b of(this.reconcile(a),this.connected=!0,this.records.values()))this.refresh(b)}reconcile(a){let b=new Set(a.map(At));for(let[a,c]of this.records)!b.has(a)&&(this.records.delete(a),this.connected&&this.socket.request(As.unsubscribe,{source:c.source}).catch(()=>void 0));this.emit()}disconnected(){for(let a of(this.connected=!1,this.epoch+=1,this.records.values()))a.latest=null,this.patch(a,{ready:!1,refreshing:!1,submitting:null,commandPending:null,unknown:a.state.submitting??a.state.unknown})}edit(a,b){this.patch(this.record(a),b)}refreshSource(a){return this.refresh(this.record(a))}async respond(a,b){let c=this.record(a);if(!c.state.ready||c.state.submitting||c.state.unknown)return;let d=this.epoch;this.patch(c,{submitting:b.id,error:null});try{await this.socket.request(As.respond,{source:a,response:b}),this.current(c,d)&&c.state.submitting===b.id&&this.patch(c,{submitting:null})}catch(e){if(!this.current(c,d)||!c.state.snapshot.requests.some(a=>a.id===b.id))return;let a=e instanceof Error&&"code"in e;this.patch(c,{submitting:null,unknown:a?null:b.id,error:a?e.message:ze("nativeUiUnknown")}),this.connected&&await this.refresh(c,a)}}async executeCommand(a,b,c){let d=this.record(a);if(!d.state.ready||d.state.commandPending)return;let e=this.epoch;this.patch(d,{commandPending:`/${b}${c?` ${c}`:""}`});try{await this.socket.request(za.QV.commandExecute,{source:a,command:b,args:c})}catch(a){this.current(d,e)&&this.appendNotice(d,{level:"error",message:a instanceof Error?a.message:ze("operationFailed")})}finally{this.current(d,e)&&this.patch(d,{commandPending:null})}}dispose(){this.disconnected(),this.releasePush?.(),this.releasePush=null,this.records.clear(),this.listeners.clear(),this.notices.clear()}record(a){let b=At(a),c=this.records.get(b);return c||(c={source:a,latest:null,state:{snapshot:{requests:[],statuses:{},widgets:{}},notices:[],commandPending:null,ready:!1,refreshing:!1,error:null,submitting:null,unknown:null,answers:{},collapsed:!1,prefill:null}},this.records.set(b,c)),c}current(a,b){return this.epoch===b&&this.records.get(At(a.source))===a}async refresh(a,b=!1){if(!this.connected||a.state.refreshing)return;let c=this.epoch;a.latest=null,this.patch(a,{ready:!1,refreshing:!0});try{let d=await this.socket.request(As.subscribe,{source:a.source});if(!this.current(a,c))return;this.apply(a,a.latest??d),this.patch(a,{ready:!0,unknown:null,...!b?{error:null}:{}})}catch(b){this.current(a,c)&&this.patch(a,{ready:!1,error:b instanceof Error?b.message:ze("nativeUiFailed")})}finally{this.current(a,c)&&(a.latest=null,this.patch(a,{refreshing:!1}))}}apply(a,b){let c=new Set(b.requests.map(a=>a.id)),d=Object.fromEntries(Object.entries(a.state.answers).filter(([a])=>c.has(a)));this.patch(a,{snapshot:b,answers:d,submitting:a.state.submitting&&c.has(a.state.submitting)?a.state.submitting:null,unknown:a.state.unknown&&c.has(a.state.unknown)?a.state.unknown:null,...b.requests[0]?.id!==a.state.snapshot.requests[0]?.id?{error:null}:{}})}appendNotice(a,b){let c=[...a.state.notices,{level:b.level,message:b.message.slice(0,65536)}].slice(-32),d=c.reduce((a,b)=>a+b.message.length,0);for(;d>65536&&c.length>1;)d-=c.shift().message.length;this.patch(a,{notices:c})}patch(a,b){a.state={...a.state,...b},this.emit()}emit(){for(let a of this.listeners)a()}}let Av=Object.freeze({...z$,syncStatus:"loading"});function Aw(a){return zZ.Pi.parse({workId:a.workId,sessionId:a.sessionId,branchId:a.branchId})}function Ax(a){return JSON.stringify([a.workId,a.sessionId,a.branchId])}function Ay(a,b){return a.workId===b.workId&&a.sessionId===b.sessionId&&a.branchId===b.branchId}let Az={text:"",images:[]};function AA(a){return[a.sessionId,a.branchId]}function AB(a,b){return{sessionId:a.sessionId,branchId:a.branchId,text:b.text,images:b.images}}function AC(a){if(!a||"object"!=typeof a||"string"!=typeof a.text||!Array.isArray(a.images))return null;let b=[];for(let c of a.images){if(!c||"object"!=typeof c||!(c.blob instanceof Blob)||"string"!=typeof c.mimeType||!Number.isSafeInteger(c.width)||c.width<=0||!Number.isSafeInteger(c.height)||c.height<=0||"boolean"!=typeof c.optimized)return null;b.push({blob:c.blob,mimeType:c.mimeType,width:c.width,height:c.height,optimized:c.optimized})}return{text:a.text,images:b}}function AD(a,b){return b?{text:[a.text,b.text].filter(a=>a.trim()).join("\n\n"),images:[...a.images,...b.images]}:a}var AE=c(60141);let AF=new Set(["image/jpeg","image/png","image/webp","image/gif","image/bmp"]),AG=new Set(["image/jpeg","image/png","image/webp","image/gif"]),AH=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]);function AI(a){return a.type.toLowerCase().split(";")[0]??""}async function AJ(a){let b;try{b=await createImageBitmap(a,{imageOrientation:"from-image"})}catch{throw Error(ze("imageDecodeFailed"))}if(!Number.isSafeInteger(b.width)||b.width<=0||b.height<=0)throw b.close(),Error(ze("imageInvalidDimensions"));return{bitmap:b,width:b.width,height:b.height}}function AK(a,b,c){let d=Math.max(a,b);if(d<=c)return{width:a,height:b};let e=c/d;return{width:Math.max(1,Math.round(a*e)),height:Math.max(1,Math.round(b*e))}}function AL(a,b,c,d,e){let f=document.createElement("canvas");f.width=b,f.height=c;let g=f.getContext("2d");if(!g)throw Error(ze("canvasUnavailable"));return g.drawImage(a,0,0,b,c),new Promise((a,b)=>{f.toBlob(c=>c?a(c):b(Error(ze("imageCompressFailed"))),d,e)})}async function AM(a){let b=new Uint8Array(await a.slice(0,262144).arrayBuffer());if(b.length<4||255!==b[0]||216!==b[1])return null;let c=2;for(;c+3<b.length;){for(;c<b.length&&255!==b[c];)c+=1;for(;c<b.length&&255===b[c];)c+=1;if(c>=b.length)break;let a=b[c];if(c+=1,216===a||1===a||a>=208&&a<=215)continue;if(217===a||218===a||c+1>=b.length)break;let d=b[c]<<8|b[c+1];if(d<2||c+d>b.length)break;if(AH.has(a)&&d>=7)return{width:b[c+5]<<8|b[c+6],height:b[c+3]<<8|b[c+4]};c+=d}return null}async function AN(a){let b=AI(a);if(!AF.has(b))throw Error(ze("imageTypeUnsupported"));let c=await AJ(a);return c.bitmap.close(),{blob:a,mimeType:b,width:c.width,height:c.height,optimized:"image/gif"===b}}async function AO(a){if(a.optimized){if(a.blob.size>0xa00000)throw Error(ze("singleImageLimit"));return a}let b=await AJ(a.blob);try{var c;let d=AK(b.width,b.height,2560),e=(c=a.mimeType,"image/jpeg"===c?"image/jpeg":"image/webp"),f=a.blob.size>5242880?.85:"image/jpeg"===e?.9:.92,g=await AL(b.bitmap,d.width,d.height,e,f),h=d.width,i=d.height,j=h!==b.width||i!==b.height,k="image/jpeg"===a.mimeType?await AM(a.blob):null,l="image/jpeg"===a.mimeType&&(null===k||k.width!==b.width||k.height!==b.height),m=AG.has(a.mimeType)&&!l;if(!j&&m&&g.size>=.9*a.blob.size&&(g=a.blob,h=b.width,i=b.height),g.size>0xa00000){let a=AK(b.width,b.height,2048);g=await AL(b.bitmap,a.width,a.height,e,.82),h=a.width,i=a.height}if(g.size>0xa00000)throw Error(ze("compressedImageTooLarge"));let n=AI(g);if(!AG.has(n))throw Error(ze("compressedTypeUnsupported"));return{blob:g,mimeType:n,width:h,height:i,optimized:!0}}finally{b.bitmap.close()}}async function AP(a){if(!a.optimized)throw Error(ze("imagesPending"));let b=new Uint8Array(await a.blob.arrayBuffer()),c="";for(let a=0;a<b.length;a+=32768)c+=String.fromCharCode(...b.subarray(a,a+32768));return{mimeType:a.mimeType,width:a.width,height:a.height,data:btoa(c)}}function AQ(a,b,c=a.optimized?"ready":"optimizing"){return{...a,localId:(0,AE.y)(),objectUrl:URL.createObjectURL(a.blob),name:b,status:c,error:null}}function AR(a){URL.revokeObjectURL(a.objectUrl)}function AS(a){return JSON.stringify([a.workId,a.sessionId,a.branchId])}function AT(a){return a.map(({blob:a,mimeType:b,width:c,height:d,optimized:e})=>({blob:a,mimeType:b,width:c,height:d,optimized:e}))}function AU(a){return{text:a.text,images:AT(a.images)}}function AV(a,b){return a instanceof Error&&a.message?a.message:b}function AW(a,b){return[a,b].filter(a=>a.trim()).join("\n\n")}function AX(a,b,c){return`${AS(a)}\u0000temp\u0000${b}\u0000${c}`}function AY(a,b,c){return`${AS(a)}\u0000entry\u0000${b}\u0000${c}`}function AZ(a){for(let b of a)AR(b)}let A$=(0,S.A)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),A_=(0,S.A)("heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]),A0=(0,S.A)("fingerprint-pattern",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]),A1=(0,S.A)("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"}]]),A2=(0,S.A)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),A3=["title","user"];function A4({active:a,scope:b,query:c,searchIn:d,request:e,failureMessage:f}){let[g,h]=(0,B.useState)(0),i=(0,B.useRef)(!1),j=c.trim(),k=(0,B.useMemo)(()=>({active:a,scope:b,query:j,searchIn:d,request:e,attempt:g,failureMessage:f}),[a,b,j,d,e,g,f]),[l,m]=(0,B.useState)(null);l?.key!==k&&m({key:k,data:null,loading:k.active,error:null});let n=(0,B.useCallback)(()=>{i.current=!0,h(a=>a+1)},[]),o=l?.key===k?l:null;return{data:o?.data??null,loading:a&&(o?.loading??!0),error:o?.error??null,refresh:n}}let A5=[{value:"title",label:"scopeTitle"},{value:"user",label:"scopeUser"},{value:"assistant",label:"scopeAssistant"},{value:"sessionId",label:"Session ID"}];function A6({value:a,onChange:b,disabled:c=!1,compact:d=!1}){let{t:e}=(0,Q.Bd)("workbenchPicker"),f=c=>{a.includes(c)?a.length>1&&b(a.filter(a=>a!==c)):b([...a,c])};return d?(0,A.jsxs)(bt,{children:[(0,A.jsx)(bv,{render:(0,A.jsx)("button",{"data-testid":"work-session-search-scopes",type:"button",disabled:c,"aria-label":e("searchScopes"),title:e("searchScopes"),className:(0,U.r)({variant:"ghost",size:"icon"}),children:(0,A.jsx)(jl,{className:"size-4"})})}),(0,A.jsx)(bw,{align:"end",children:A5.map(b=>(0,A.jsx)(bD,{checked:a.includes(b.value),disabled:c||1===a.length&&a.includes(b.value),closeOnClick:!1,onCheckedChange:()=>f(b.value),children:e(b.label)},b.value))})]}):(0,A.jsxs)("fieldset",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 px-0.5",children:[(0,A.jsx)("legend",{className:"mr-1 text-xs text-muted-foreground",children:e("searchScopes")}),A5.map(b=>{let d=a.includes(b.value);return(0,A.jsxs)("label",{className:"flex min-h-7 cursor-pointer items-center gap-2 text-sm text-muted-foreground has-[:focus-visible]:rounded-sm has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",children:[(0,A.jsx)("input",{type:"checkbox",checked:d,disabled:c||d&&1===a.length,onChange:()=>f(b.value),className:"size-4 accent-primary"}),(0,A.jsx)("span",{children:e(b.label)})]},b.value)})]})}function A7(a,b,c="bg-accent text-accent-foreground"){let d=b.trim().toLocaleLowerCase();if(!d)return a;let e=a.toLocaleLowerCase(),f=[],g=0,h=e.indexOf(d);for(;h>=0;){h>g&&f.push(a.slice(g,h));let b=h+d.length;f.push((0,A.jsx)("mark",{className:`rounded-sm px-px ${c}`,children:a.slice(h,b)},`${h}-${b}`)),g=b,h=e.indexOf(d,g)}return g<a.length&&f.push(a.slice(g)),f.length?f:a}function A8(a){return a.replace(/[\\/]+$/,"").split(/[\\/]/).at(-1)||a}function A9(a){return a.trim().toLocaleLowerCase()}function Ba(a,b,c){return"title"===a?c("scopeTitle"):"sessionId"===a?"Session ID":c("user"===a?"scopeUserMatches":"scopeAssistantMatches",{count:b})}function Bb(a){switch(a){case"user":case"assistant":case"title":return"bg-muted text-foreground";case"sessionId":return"bg-muted text-muted-foreground"}}function Bc(a){switch(a){case"user":case"assistant":case"title":return"bg-accent text-accent-foreground";case"sessionId":return"bg-muted-foreground/25 text-foreground"}}function Bd({scope:a,className:b}){switch(a){case"user":return(0,A.jsx)(A$,{className:b});case"assistant":return(0,A.jsx)(ci,{className:b});case"title":return(0,A.jsx)(A_,{className:b});case"sessionId":return(0,A.jsx)(A0,{className:b})}}function Be({open:a,pickerMode:b,pickerView:c,pickerCwd:d,directories:e,ignoredDirectories:f,directoryBrowser:g,replacementTarget:h,unavailableSessionIds:i,error:j,loading:k,creatingCwd:l,replacingSessionId:m,updatingIgnoreCwd:n,onOpenChange:o,onBack:p,onListSessionHistory:q,onListSessionUserMessages:r,onRefresh:s,onOpenIgnoredDirectories:t,onOpenDirectoryBrowser:u,onNavigateDirectory:v,onSelectBrowserDirectory:w,onReplaceDirectoryIgnore:x,onSelectDirectory:y,onSelectSession:z}){let{t:C}=(0,Q.Bd)("workbenchPicker"),{locale:D,timeZone:E}=(0,cy.i)(),F=(0,B.useMemo)(()=>new Intl.DateTimeFormat("en"===D?"en-US":"zh-CN",{timeZone:E,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[D,E]),[G,H]=(0,B.useState)(""),[I,J]=(0,B.useState)(A3),[K,L]=(0,B.useState)(""),M=JSON.stringify([a,b,d,c]),[N,O]=(0,B.useState)(M);N!==M&&(O(M),H(""),J(A3),L(""));let P=null!==l||null!==m||null!==n,R=function({active:a,cwd:b,query:c,searchIn:d,listSessionHistory:e,listSessionUserMessages:f}){let{t:g}=(0,Q.Bd)("workbenchPicker"),h=(0,B.useCallback)((a,c,d)=>e({...a,cwd:b,forceRefresh:d},c),[b,e]),i=A4({active:a&&null!==b,scope:b,query:c,searchIn:d,request:h,failureMessage:g("loadHistoryFailed")}),[j,k]=(0,B.useState)(null),l=(0,B.useMemo)(()=>({active:a,cwd:b,query:c,searchIn:d}),[a,b,c,d]),[m,n]=(0,B.useState)(l);m!==l&&(n(l),k(null));let o=(0,B.useRef)(null),p=(0,B.useCallback)(()=>{o.current?.abort(),o.current=null,k(null)},[]),q=async(c,d,e,h)=>{if(!a||!b)return;o.current?.abort();let i=new AbortController;o.current=i,k(a=>({sessionId:c,query:d,messages:h&&a?.sessionId===c?a.messages:[],page:h&&a?.sessionId===c?a.page:null,loading:!0,error:null}));try{let a=await f({cwd:b,sessionId:c,query:d,page:{index:e,size:20}},i.signal);if(i.signal.aborted)return;k(b=>({sessionId:c,query:d,messages:h&&b?.sessionId===c?[...b.messages,...a.messages]:a.messages,page:a.page,loading:!1,error:null}))}catch(a){if(i.signal.aborted)return;k(b=>({sessionId:c,query:d,messages:b?.sessionId===c?b.messages:[],page:b?.sessionId===c?b.page:null,loading:!1,error:a instanceof Error?a.message:g("loadUserFailed")}))}finally{o.current===i&&(o.current=null)}};return{sessions:i.data?.sessions??[],loading:i.loading,error:i.error,refresh:()=>{p(),i.refresh()},expandedHistory:a?j:null,toggleUserMessages:a=>{if(j?.sessionId===a.sessionId)return void p();let b=a.matches?.some(a=>"user"===a.scope)?c:"";q(a.sessionId,b,1,!1)},loadUserMessages:q}}({active:a&&"history"===c&&!P,cwd:d,query:G,searchIn:I,listSessionHistory:q,listSessionUserMessages:r}),{sessions:S,expandedHistory:T,toggleUserMessages:V,loadUserMessages:W}=R,X="history"===c?R.loading:k,Y=j??("history"===c?R.error:null),$=(0,B.useMemo)(()=>new Set(i),[i]),_=A9(G),aa=function(a){let b=a.trim();if(b.length<2)return b;let c=b.at(0);return('"'===c||"'"===c)&&b.at(-1)===c?b.slice(1,-1).trim():b}(K),ab=/^(?:[A-Za-z]:[\\/]|[\\/]{2}|\/)/.test(aa),ac="ignored"===c?f:e,ad=ac.filter(a=>!_||A9(`${A8(a.cwd)} ${a.cwd}`).includes(_)),ae=(g?.directories??[]).filter(a=>!_||A9(`${a.name} ${a.cwd}`).includes(_)),af="ignored"===c?C("ignoredRestoreTitle"):"browser"===c?C("browseOtherTitle"):"replace"===b?C("replaceTitle"):C("createTitle"),ag="ignored"===c?C("ignoredRestoreDescription"):"browser"===c?C("browseDescription"):"replace"===b?h?C("replaceDescription",{project:h.projectName,session:h.sessionTitle??C("newSession")}):C("replaceMissingDescription"):C("createDescription"),ah="history"===c?C("searchHistory"):"browser"===c?C("searchBrowser"):"ignored"===c?C("searchIgnored"):C("searchProjects"),ai="history"===c?S.length:"browser"===c?g?.directories.length??0:ac.length,aj=X&&("browser"===c?null===g:0===ai),ak="history"===c?C("currentProject",{path:d??""}):"ignored"===c?C("ignoredCount",{count:f.length}):"browser"===c?g?.cwd??C("rootChoose"):"replace"===b?C("replaceChooseFirst"):C("regularExcludesIgnored"),al="history"===c?C("loadingHistory"):"ignored"===c?C("loadingIgnored"):"browser"===c?C("loadingBrowser"):C("loadingProjects"),am=a=>{H(""),L(""),v(a)},an=()=>{X||P||!ab||(H(""),v(aa))};return(0,A.jsx)(b7.YV,{open:a,onOpenChange:a=>{(a||!P)&&o(a)},children:(0,A.jsxs)(b7.hA,{className:"h-[min(44rem,calc(100dvh-2rem))] max-w-[45rem]",showCloseButton:!P,finalFocus:!1,children:[(0,A.jsx)(b7.Hl,{className:"border-b px-4 py-3 pr-12",children:(0,A.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:["directories"!==c?(0,A.jsx)("button",{type:"button",disabled:P,onClick:p,"aria-label":C("backFolders"),title:C("backFolders"),className:(0,U.r)({variant:"ghost",size:"icon"}),children:(0,A.jsx)(Z.A,{className:"size-4"})}):(0,A.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:(0,A.jsx)(ch.A,{className:"size-4"})}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)(b7.YM,{children:af}),(0,A.jsx)(b7.uX,{className:"mt-1 truncate",title:ag,children:ag})]})]})}),(0,A.jsxs)("div",{className:"shrink-0 border-b px-3 py-2.5 sm:px-4",children:["browser"===c?(0,A.jsxs)("div",{className:"mb-2",children:[(0,A.jsxs)("div",{className:"flex gap-2",children:[(0,A.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,A.jsx)(zF.A,{className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground"}),(0,A.jsx)(bY.p,{value:K,onChange:a=>L(a.target.value),onKeyDown:a=>{"Enter"===a.key&&ab&&(a.preventDefault(),an())},placeholder:C("pastePath"),"aria-label":C("fullPath"),disabled:X||P,className:"pl-9"})]}),(0,A.jsx)("button",{"data-testid":"workbench-picker-open-directory-path",type:"button",disabled:X||P||!ab,onClick:an,title:ab?C("openTyped"):C("enterAbsolute"),className:(0,U.r)({variant:"outline"}),children:C("open")})]}),(0,A.jsx)("p",{className:"mt-1.5 px-0.5 text-sm text-muted-foreground",children:K.trim()&&!ab?C("absoluteExample"):C("pasteHint")})]}):null,(0,A.jsxs)("div",{className:"relative",children:[(0,A.jsx)(bZ.A,{className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground"}),(0,A.jsx)(bY.p,{"data-testid":"history"===c?"workbench-history-search-input":void 0,value:G,maxLength:"history"===c?120:void 0,onChange:a=>H(a.target.value),placeholder:ah,"aria-label":ah,disabled:P,className:"pl-9"})]}),"history"===c?(0,A.jsx)(A6,{value:I,onChange:J,disabled:P}):null]}),(0,A.jsx)(b7._Y,{className:"max-h-none min-h-0",children:(0,A.jsxs)("div",{className:"p-2 sm:p-3","aria-busy":X||P,"aria-live":"polite",children:[Y?(0,A.jsx)("p",{role:"alert",className:"mb-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:Y}):null,"replace"===b&&null===h?(0,A.jsx)("p",{role:"alert",className:"mb-2 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:C("replaceTargetMissing")}):null,aj?(0,A.jsxs)("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3 text-center text-sm text-muted-foreground",children:[(0,A.jsx)(bO.A,{className:"size-5 animate-spin"}),(0,A.jsx)("p",{children:al})]}):"history"===c?0===S.length?null===Y?(0,A.jsx)("p",{className:"px-3 py-10 text-center text-sm text-muted-foreground",children:_?C("noHistoryMatches"):C("noReplaceHistory")}):null:(0,A.jsxs)(A.Fragment,{children:[_?(0,A.jsx)("p",{className:"px-3 pb-1 pt-0.5 text-xs text-muted-foreground",children:C("sessionFound",{count:S.length})}):null,(0,A.jsx)("div",{className:"divide-y",children:S.map(a=>{let b,c=a.name?.trim()||a.firstMessage.trim()||C("sessionFallback",{id:a.sessionId.slice(0,8)}),d=C("sessionMessages",{users:a.userMessageCount,total:a.messageCount,time:(b=a.updatedAt,F.format(b))}),e=h?.sessionId===a.sessionId,f=$.has(a.sessionId),g=m===a.sessionId,i=null===h,j=P||e||f||i,k=T?.sessionId===a.sessionId?T:null,l=a.matches??[],n=l.filter(a=>"title"!==a.scope),o=l.find(a=>"user"===a.scope),p=null===k&&n.length>0,q=`workbench-picker-user-message-panel-${a.sessionId}`,r=g?C("replacing"):e?C("current"):f?C("alreadyUsed"):i?C("targetUnavailable"):C("replace"),s=e?C("currentBound"):f?C("historyUsed"):i?C("replaceTargetUnavailable"):C("replaceWith",{name:c}),t=k?C("hideUserMessages"):o?C("viewMatching",{count:o.count}):C("viewUserMessages",{count:a.userMessageCount}),u=k?.page!==null&&null!==k&&k.messages.length<k.page.total;return(0,A.jsxs)("div",{className:"px-2 sm:px-3",children:[(0,A.jsxs)("div",{className:"flex min-h-15 items-center gap-2 py-2",children:[(0,A.jsx)(A1,{className:"size-4 shrink-0 text-muted-foreground"}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)("p",{className:"truncate text-sm font-medium",title:c,children:l.some(a=>"title"===a.scope)?A7(c,_,Bc("title")):c}),(0,A.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",title:d,children:d})]}),a.userMessageCount>0?(0,A.jsx)("button",{"data-testid":`workbench-picker-user-messages-${a.sessionId}`,type:"button",disabled:P,"aria-label":t,"aria-expanded":null!==k,"aria-controls":q,onClick:()=>V(a),title:t,className:(0,U.r)({variant:"ghost",size:"icon"}),children:(0,A.jsx)(cr.A,{className:`size-4 transition-transform${k?" rotate-180":""}`})}):null,(0,A.jsx)("button",{"data-testid":`workbench-picker-replace-${a.sessionId}`,type:"button",disabled:j,onClick:()=>z(a.sessionId),title:s,className:(0,U.r)({variant:"outline"}),children:g?(0,A.jsx)(bO.A,{className:"size-3.5 animate-spin"}):r})]}),p?(0,A.jsx)("div",{className:"mb-2 ml-6 min-w-0 space-y-1.5 overflow-hidden",children:n.map(b=>{let c,d="user"===b.scope,e=(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Bd,{scope:b.scope,className:"mt-0.5 size-3.5 shrink-0"}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-xs leading-5",children:[(0,A.jsx)("span",{className:`shrink-0 rounded px-1.5 py-0.5 font-medium ${Bb(b.scope)}`,children:Ba(b.scope,b.count,C)}),null!==b.timestampMs?(0,A.jsx)("span",{className:"truncate text-muted-foreground",children:(c=b.timestampMs,F.format(c))}):null]}),(0,A.jsx)("p",{className:"mt-1 line-clamp-2 break-words text-sm leading-5 text-foreground",children:A7(b.preview,_,Bc(b.scope))})]})]}),f=`flex w-full max-w-full min-w-0 items-start gap-2 overflow-hidden rounded-md px-2.5 py-2 text-left ${Bb(b.scope)}`;return d?(0,A.jsx)("button",{"data-testid":`workbench-picker-user-message-preview-${a.sessionId}`,type:"button",disabled:P,onClick:()=>V(a),"aria-label":C("viewMatch",{label:Ba(b.scope,b.count,C)}),className:`${f} outline-none transition-colors hover:brightness-95 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50`,children:e},b.scope):(0,A.jsx)("div",{className:f,children:e},b.scope)})}):null,k?(0,A.jsxs)("div",{id:q,"data-testid":q,className:"mb-2 ml-6 rounded-md border bg-background px-3 py-2.5",children:[(0,A.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[(0,A.jsxs)("p",{className:"flex min-w-0 items-center gap-1.5 text-xs font-medium",children:[(0,A.jsx)(A2,{className:"size-3.5 shrink-0 text-primary"}),(0,A.jsx)("span",{className:"truncate",children:k.query?C("matchingUserCount",{count:k.page?.total??0}):C("userCount",{count:k.page?.total??a.userMessageCount})})]}),k.query?(0,A.jsx)("button",{type:"button",disabled:k.loading||P,onClick:()=>void W(a.sessionId,"",1,!1),className:(0,U.r)({variant:"ghost",size:"sm"}),children:C("viewAll")}):null]}),k.error?(0,A.jsx)("p",{className:"mt-2 text-xs text-destructive",children:k.error}):null,k.loading&&0===k.messages.length?(0,A.jsx)("div",{className:"flex min-h-16 items-center justify-center text-muted-foreground",children:(0,A.jsx)(bO.A,{className:"size-4 animate-spin"})}):0===k.messages.length?(0,A.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:C("noUserMessages")}):(0,A.jsx)("div",{className:"mt-2 divide-y",children:k.messages.map(a=>{let b;return(0,A.jsxs)("div",{className:"py-2 first:pt-0 last:pb-0",children:[(0,A.jsx)("p",{className:"text-xs tabular-nums text-muted-foreground",children:(b=a.timestampMs,F.format(b))}),(0,A.jsx)("p",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-6",children:a.text?A7(a.text,k.query):C("noText")})]},a.entryId)})}),u?(0,A.jsxs)("button",{type:"button",disabled:k.loading||P,onClick:()=>void W(a.sessionId,k.query,(k.page?.index??0)+1,!0),className:(0,U.r)({variant:"outline",className:"mt-2"}),children:[k.loading?(0,A.jsx)(bO.A,{className:"size-3.5 animate-spin"}):null,C("loadMore")]}):null]}):null]},a.sessionId)})})]}):"browser"===c?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"mb-2 flex min-h-10 items-center gap-2 rounded-md bg-muted/60 px-3 text-xs text-muted-foreground",children:[(0,A.jsx)(zF.A,{className:"size-4 shrink-0"}),(0,A.jsx)("span",{className:"truncate",title:g?.cwd??C("root"),children:g?.cwd??C("root")})]}),0===ae.length?null===Y?(0,A.jsx)("p",{className:"px-3 py-10 text-center text-sm text-muted-foreground",children:(g?.directories.length??0)===0?g?.cwd?C("browserEmpty"):C("rootsEmpty"):C("subfoldersNoMatches")}):null:(0,A.jsx)("div",{className:"divide-y",children:ae.map(a=>(0,A.jsxs)("button",{type:"button",disabled:X||P,onClick:()=>am(a.cwd),className:"group flex min-h-15 w-full items-center gap-3 rounded-md px-2 py-2 text-left outline-none transition-colors hover:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-55 sm:px-3",children:[(0,A.jsx)(ch.A,{className:"size-4 shrink-0 text-muted-foreground group-hover:text-primary"}),(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsx)("span",{className:"block truncate text-sm font-medium",title:a.name,children:a.name}),(0,A.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",title:a.cwd,children:a.cwd})]}),(0,A.jsx)(br.A,{className:"size-4 shrink-0 text-muted-foreground group-hover:text-foreground"})]},a.cwd))})]}):0===ad.length?null===Y?(0,A.jsx)("p",{className:"px-3 py-10 text-center text-sm text-muted-foreground",children:0===ac.length?"ignored"===c?C("ignoredEmpty"):C("projectsEmpty"):C("projectNoMatches")}):null:"ignored"===c?(0,A.jsx)("div",{className:"divide-y",children:ad.map(a=>{let b=A8(a.cwd),c=n===a.cwd;return(0,A.jsxs)("div",{className:"flex min-h-15 items-center gap-3 px-2 py-2 sm:px-3",children:[(0,A.jsx)(ch.A,{className:"size-4 shrink-0 text-muted-foreground"}),(0,A.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,A.jsx)("p",{className:"truncate text-sm font-medium",title:b,children:b}),(0,A.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",title:a.cwd,children:a.cwd})]}),(0,A.jsxs)("button",{"data-testid":`workbench-picker-restore-directory-${a.cwd}`,type:"button",disabled:P,onClick:()=>x(a.cwd,!1),"aria-label":C("restoreFolder",{name:b}),title:C("restoreTip"),className:(0,U.r)({variant:"outline"}),children:[c?(0,A.jsx)(bO.A,{className:"size-3.5 animate-spin"}):(0,A.jsx)(pF,{className:"size-3.5"}),(0,A.jsx)("span",{children:C("restore")})]})]},a.cwd)})}):(0,A.jsx)("div",{className:"divide-y",children:ad.map(a=>{let c,d=A8(a.cwd),e=C("directorySessions",{count:a.sessionCount,time:(c=a.updatedAt,F.format(c))}),f=l===a.cwd,g=n===a.cwd;return(0,A.jsxs)("div",{className:"flex items-center gap-1",children:[(0,A.jsxs)("button",{"data-testid":`workbench-picker-directory-${a.cwd}`,type:"button",disabled:P,onClick:()=>y(a.cwd),className:"group flex min-h-15 min-w-0 flex-1 items-center gap-3 rounded-md px-2 py-2 text-left outline-none transition-colors hover:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-55 sm:px-3",children:[(0,A.jsx)(ch.A,{className:"size-4 shrink-0 text-muted-foreground group-hover:text-primary"}),(0,A.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,A.jsx)("span",{className:"block truncate text-sm font-medium",title:d,children:d}),(0,A.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",title:a.cwd,children:a.cwd})]}),f?(0,A.jsxs)("span",{className:"flex min-h-10 shrink-0 items-center gap-1.5 text-xs text-muted-foreground",children:[(0,A.jsx)(bO.A,{className:"size-3.5 animate-spin"}),C("creating")]}):(0,A.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",title:e,children:[(0,A.jsx)("span",{children:C("directoryCount",{count:a.sessionCount})}),(0,A.jsx)(br.A,{className:"size-4 group-hover:text-foreground"})]})]}),"create"===b?(0,A.jsx)("button",{"data-testid":`workbench-picker-ignore-directory-${a.cwd}`,type:"button",disabled:P,onClick:()=>x(a.cwd,!0),"aria-label":C("ignoreFolder",{name:d}),title:C("ignoreTip"),className:(0,U.r)({variant:"ghost",size:"icon"}),children:g?(0,A.jsx)(bO.A,{className:"size-3.5 animate-spin"}):(0,A.jsx)(od.A,{className:"size-4"})}):null]},a.cwd)})})]})}),(0,A.jsxs)(b7.vu,{className:"flex-row flex-wrap items-center justify-between gap-2 px-3 py-2.5 sm:px-4",children:[(0,A.jsx)("p",{className:"min-w-24 flex-1 truncate text-xs text-muted-foreground",title:ak,children:ak}),(0,A.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:["create"===b&&"directories"===c?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",disabled:X||P,onClick:t,className:(0,U.r)({variant:"outline"}),children:C("ignoredFolders")}),(0,A.jsx)("button",{type:"button",disabled:X||P,onClick:u,className:(0,U.r)({variant:"outline"}),children:C("chooseOther")})]}):null,"browser"===c&&g?.cwd?(0,A.jsx)("button",{"data-testid":"workbench-picker-select-browser-directory",type:"button",disabled:X||P,onClick:()=>w(g.cwd),className:(0,U.r)(),children:C("selectCurrent")}):null,"browser"===c&&g?.parentCwd?(0,A.jsx)("button",{type:"button",disabled:X||P,onClick:()=>am(g.parentCwd),"aria-label":C("parentDirectory"),title:C("parentDirectory"),className:(0,U.r)({variant:"outline",size:"icon"}),children:(0,A.jsx)(Z.A,{className:"size-4"})}):null,"browser"===c&&g?.cwd?(0,A.jsx)("button",{type:"button",disabled:X||P,onClick:()=>am(null),"aria-label":C("backRoots"),title:C("backRoots"),className:(0,U.r)({variant:"outline",size:"icon"}),children:(0,A.jsx)(zF.A,{className:"size-4"})}):null,(0,A.jsx)("button",{"data-testid":"workbench-picker-refresh",type:"button",disabled:X||P,onClick:"history"===c?R.refresh:s,"aria-label":C("refreshList"),title:C("refreshList"),className:(0,U.r)({variant:"outline",size:"icon"}),children:(0,A.jsx)(bO.A,{className:`size-4${X?" animate-spin":""}`})})]})]})]})})}function Bf({variant:a,className:b,children:c}){let{t:d}=(0,Q.Bd)("workbench");return(0,A.jsx)("div",{className:(0,W.cn)("@container/empty-state flex size-full min-h-0 flex-1 items-center justify-center overflow-hidden px-6 py-8 text-center",b),children:"select-session"===a?(0,A.jsxs)("div",{className:"relative",children:[c,(0,A.jsx)("h1",{className:"text-base font-medium text-muted-foreground",children:d("emptySelectSession")})]}):(0,A.jsxs)("div",{role:"status","aria-live":"polite",className:"flex flex-col items-center gap-3 animate-in fade-in-0 fill-mode-both delay-150 duration-150 motion-reduce:animate-none",children:[(0,A.jsx)(R.A,{className:"size-5 animate-spin text-muted-foreground motion-reduce:animate-none"}),(0,A.jsx)("p",{className:"text-sm font-medium text-muted-foreground",children:d("emptyLoading")})]})})}let Bg=(0,S.A)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),Bh=(0,S.A)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),Bi="u">typeof window?B.useLayoutEffect:B.useEffect;function Bj(a,b){if("function"==typeof a)return a(b);null!=a&&(a.current=b)}class Bk extends B.Component{getSnapshotBeforeUpdate(a){let b=this.props.childRef.current;if(xe(b)&&a.isPresent&&!this.props.isPresent&&!1!==this.props.pop){let a=b.offsetParent,c=xe(a)&&a.offsetWidth||0,d=xe(a)&&a.offsetHeight||0,e=getComputedStyle(b),f=this.props.sizeRef.current;f.height=parseFloat(e.height),f.width=parseFloat(e.width),f.top=b.offsetTop,f.left=b.offsetLeft,f.right=c-f.width-f.left,f.bottom=d-f.height-f.top,f.direction=e.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Bl({children:a,isPresent:b,anchorX:c,anchorY:d,root:e,pop:f}){let g=(0,B.useId)(),h=(0,B.useRef)(null),i=(0,B.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:j}=(0,B.useContext)(tX),k=function(...a){return B.useCallback(function(...a){return b=>{let c=!1,d=a.map(a=>{let d=Bj(a,b);return c||"function"!=typeof d||(c=!0),d});if(c)return()=>{for(let b=0;b<d.length;b++){let c=d[b];"function"==typeof c?c():Bj(a[b],null)}}}}(...a),a)}(h,!1!==f?a.props?.ref??a?.ref:void 0);return(0,B.useInsertionEffect)(()=>{let{width:a,height:k,top:l,left:m,right:n,bottom:o,direction:p}=i.current;if(b||!1===f||!h.current||!a||!k)return;let q="rtl"===p,r="left"===c?q?`right: ${n}`:`left: ${m}`:q?`left: ${m}`:`right: ${n}`,s="bottom"===d?`bottom: ${o}`:`top: ${l}`;h.current.dataset.motionPopId=g;let t=document.createElement("style");j&&(t.nonce=j);let u=e??document.head;return u.appendChild(t),t.sheet&&t.sheet.insertRule(`
281
281
  [data-motion-pop-id="${g}"] {
282
282
  position: absolute !important;