@clawos-dev/clawd 0.2.694 → 0.2.696

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.
@@ -92,7 +92,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
92
92
  0 -6px 16px 0 rgba(0, 0, 0, 0.08),
93
93
  0 -3px 6px -4px rgba(0, 0, 0, 0.12),
94
94
  0 -9px 28px 8px rgba(0, 0, 0, 0.05)
95
- `,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var RP=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const mae={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},gae={motionBase:!0,motionUnit:!0},xae={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},R9=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:s}=t,i=RP(t,["override"]);let o=Object.assign(Object.assign({},r),{override:s});return o=T9(o),i&&Object.entries(i).forEach(([l,c])=>{const{theme:u}=c,d=RP(c,["theme"]);let h=d;u&&(h=R9(Object.assign(Object.assign({},o),d),{override:d},u)),o[l]=h}),o};function M9(){const{token:e,hashed:t,theme:n,override:r,cssVar:s}=G.useContext(E9),i=`${fae}-${t||""}`,o=n||j9,[l,c,u]=soe(o,[Qm,e],{salt:i,override:r,getComputedToken:R9,formatToken:T9,cssVar:s&&{prefix:s.prefix,key:s.key,unitless:mae,ignore:gae,preserve:xae}});return[o,u,t?c:"",l,s]}const vae=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),yae=e=>({[`.${e}`]:Object.assign(Object.assign({},vae()),{[`.${e} .${e}-icon`]:{display:"block"}})}),bae=(e,t)=>{const[n,r]=M9();return Moe({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>yae(e))},wae=Object.assign({},lf),{useId:MP}=wae,_ae=()=>"",Sae=typeof MP>"u"?_ae:MP;function kae(e,t,n){var r;const s=e||{},i=s.inherit===!1||!t?Object.assign(Object.assign({},ab),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:ab.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=Sae();return Z8(()=>{var l,c;if(!e)return t;const u=Object.assign({},i.components);Object.keys(e.components||{}).forEach(f=>{u[f]=Object.assign(Object.assign({},u[f]),e.components[f])});const d=`css-var-${o.replace(/:/g,"")}`,h=((l=s.cssVar)!==null&&l!==void 0?l:i.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof i.cssVar=="object"?i.cssVar:{}),typeof s.cssVar=="object"?s.cssVar:{}),{key:typeof s.cssVar=="object"&&((c=s.cssVar)===null||c===void 0?void 0:c.key)||d});return Object.assign(Object.assign(Object.assign({},i),s),{token:Object.assign(Object.assign({},i.token),s.token),components:u,cssVar:h})},[s,i],(l,c)=>l.some((u,d)=>{const h=c[d];return!Mie(u,h,!0)}))}var Cae=["children"],P9=p.createContext({});function Nae(e){var t=e.children,n=ai(e,Cae);return p.createElement(P9.Provider,{value:n},t)}var jae=function(e){Ir(n,e);var t=e9(n);function n(){return Nn(this,n),t.apply(this,arguments)}return jn(n,[{key:"render",value:function(){return this.props.children}}]),n}(p.Component);function Eae(e){var t=p.useReducer(function(l){return l+1},0),n=_t(t,2),r=n[1],s=p.useRef(e),i=wN(function(){return s.current}),o=wN(function(l){s.current=typeof l=="function"?l(s.current):l,r()});return[i,o]}var Tl="none",Dv="appear",Av="enter",$v="leave",PP="none",ho="prepare",Kd="start",Gd="active",s5="end",O9="prepared";function OP(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function Iae(e,t){var n={animationend:OP("Animation","AnimationEnd"),transitionend:OP("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var Tae=Iae(il(),typeof window<"u"?window:{}),D9={};if(il()){var Rae=document.createElement("div");D9=Rae.style}var Lv={};function A9(e){if(Lv[e])return Lv[e];var t=Tae[e];if(t)for(var n=Object.keys(t),r=n.length,s=0;s<r;s+=1){var i=n[s];if(Object.prototype.hasOwnProperty.call(t,i)&&i in D9)return Lv[e]=t[i],Lv[e]}return""}var $9=A9("animationend"),L9=A9("transitionend"),B9=!!($9&&L9),DP=$9||"animationend",AP=L9||"transitionend";function $P(e,t){if(!e)return null;if(Cn(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const Mae=function(e){var t=p.useRef();function n(s){s&&(s.removeEventListener(AP,e),s.removeEventListener(DP,e))}function r(s){t.current&&t.current!==s&&n(t.current),s&&s!==t.current&&(s.addEventListener(AP,e),s.addEventListener(DP,e),t.current=s)}return p.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var F9=il()?p.useLayoutEffect:p.useEffect;const Pae=function(){var e=p.useRef(null);function t(){Q2.cancel(e.current)}function n(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var i=Q2(function(){s<=1?r({isCanceled:function(){return i!==e.current}}):n(r,s-1)});e.current=i}return p.useEffect(function(){return function(){t()}},[]),[n,t]};var Oae=[ho,Kd,Gd,s5],Dae=[ho,O9],z9=!1,Aae=!0;function H9(e){return e===Gd||e===s5}const $ae=function(e,t,n){var r=_N(PP),s=_t(r,2),i=s[0],o=s[1],l=Pae(),c=_t(l,2),u=c[0],d=c[1];function h(){o(ho,!0)}var f=t?Dae:Oae;return F9(function(){if(i!==PP&&i!==s5){var m=f.indexOf(i),g=f[m+1],x=n(i);x===z9?o(g,!0):g&&u(function(b){function y(){b.isCanceled()||o(g,!0)}x===!0?y():Promise.resolve(x).then(y)})}},[e,i]),p.useEffect(function(){return function(){d()}},[]),[h,i]};function Lae(e,t,n,r){var s=r.motionEnter,i=s===void 0?!0:s,o=r.motionAppear,l=o===void 0?!0:o,c=r.motionLeave,u=c===void 0?!0:c,d=r.motionDeadline,h=r.motionLeaveImmediately,f=r.onAppearPrepare,m=r.onEnterPrepare,g=r.onLeavePrepare,x=r.onAppearStart,b=r.onEnterStart,y=r.onLeaveStart,v=r.onAppearActive,w=r.onEnterActive,_=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,j=r.onVisibleChanged,R=_N(),E=_t(R,2),I=E[0],M=E[1],P=Eae(Tl),D=_t(P,2),F=D[0],B=D[1],U=_N(null),$=_t(U,2),O=$[0],T=$[1],V=F(),H=p.useRef(!1),L=p.useRef(null);function q(){return n()}var K=p.useRef(!1);function X(){B(Tl),T(null,!0)}var te=wN(function(je){var Se=F();if(Se!==Tl){var ut=q();if(!(je&&!je.deadline&&je.target!==ut)){var ot=K.current,yt;Se===Dv&&ot?yt=S==null?void 0:S(ut,je):Se===Av&&ot?yt=k==null?void 0:k(ut,je):Se===$v&&ot&&(yt=N==null?void 0:N(ut,je)),ot&&yt!==!1&&X()}}}),oe=Mae(te),Q=_t(oe,1),he=Q[0],be=function(Se){switch(Se){case Dv:return Ke(Ke(Ke({},ho,f),Kd,x),Gd,v);case Av:return Ke(Ke(Ke({},ho,m),Kd,b),Gd,w);case $v:return Ke(Ke(Ke({},ho,g),Kd,y),Gd,_);default:return{}}},Z=p.useMemo(function(){return be(V)},[V]),ce=$ae(V,!e,function(je){if(je===ho){var Se=Z[ho];return Se?Se(q()):z9}if(xe in Z){var ut;T(((ut=Z[xe])===null||ut===void 0?void 0:ut.call(Z,q(),null))||null)}return xe===Gd&&V!==Tl&&(he(q()),d>0&&(clearTimeout(L.current),L.current=setTimeout(function(){te({deadline:!0})},d))),xe===O9&&X(),Aae}),se=_t(ce,2),fe=se[0],xe=se[1],Me=H9(xe);K.current=Me;var Xe=p.useRef(null);F9(function(){if(!(H.current&&Xe.current===t)){M(t);var je=H.current;H.current=!0;var Se;!je&&t&&l&&(Se=Dv),je&&t&&i&&(Se=Av),(je&&!t&&u||!je&&h&&!t&&u)&&(Se=$v);var ut=be(Se);Se&&(e||ut[ho])?(B(Se),fe()):B(Tl),Xe.current=t}},[t]),p.useEffect(function(){(V===Dv&&!l||V===Av&&!i||V===$v&&!u)&&B(Tl)},[l,i,u]),p.useEffect(function(){return function(){H.current=!1,clearTimeout(L.current)}},[]);var me=p.useRef(!1);p.useEffect(function(){I&&(me.current=!0),I!==void 0&&V===Tl&&((me.current||I)&&(j==null||j(I)),me.current=!0)},[I,V]);var Ce=O;return Z[ho]&&xe===Kd&&(Ce=Pt({transition:"none"},Ce)),[V,xe,Ce,I??t]}function Bae(e){var t=e;Cn(e)==="object"&&(t=e.transitionSupport);function n(s,i){return!!(s.motionName&&t&&i!==!1)}var r=p.forwardRef(function(s,i){var o=s.visible,l=o===void 0?!0:o,c=s.removeOnLeave,u=c===void 0?!0:c,d=s.forceRender,h=s.children,f=s.motionName,m=s.leavedClassName,g=s.eventProps,x=p.useContext(P9),b=x.motion,y=n(s,b),v=p.useRef(),w=p.useRef();function _(){try{return v.current instanceof HTMLElement?v.current:xie(w.current)}catch{return null}}var S=Lae(y,l,_,s),k=_t(S,4),N=k[0],j=k[1],R=k[2],E=k[3],I=p.useRef(E);E&&(I.current=!0);var M=p.useCallback(function($){v.current=$,wie(i,$)},[i]),P,D=Pt(Pt({},g),{},{visible:l});if(!h)P=null;else if(N===Tl)E?P=h(Pt({},D),M):!u&&I.current&&m?P=h(Pt(Pt({},D),{},{className:m}),M):d||!u&&!m?P=h(Pt(Pt({},D),{},{style:{display:"none"}}),M):P=null;else{var F;j===ho?F="prepare":H9(j)?F="active":j===Kd&&(F="start");var B=$P(f,"".concat(N,"-").concat(F));P=h(Pt(Pt({},D),{},{className:iie($P(f,N),Ke(Ke({},B,B&&F),f,typeof f=="string")),style:R}),M)}if(p.isValidElement(P)&&_ie(P)){var U=Sie(P);U||(P=p.cloneElement(P,{ref:M}))}return p.createElement(jae,{ref:w},P)});return r.displayName="CSSMotion",r}const Fae=Bae(B9);var SN="add",kN="keep",CN="remove",ek="removed";function zae(e){var t;return e&&Cn(e)==="object"&&"key"in e?t=e:t={key:e},Pt(Pt({},t),{},{key:String(t.key)})}function NN(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(zae)}function Hae(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,s=t.length,i=NN(e),o=NN(t);i.forEach(function(u){for(var d=!1,h=r;h<s;h+=1){var f=o[h];if(f.key===u.key){r<h&&(n=n.concat(o.slice(r,h).map(function(m){return Pt(Pt({},m),{},{status:SN})})),r=h),n.push(Pt(Pt({},f),{},{status:kN})),r+=1,d=!0;break}}d||n.push(Pt(Pt({},u),{},{status:CN}))}),r<s&&(n=n.concat(o.slice(r).map(function(u){return Pt(Pt({},u),{},{status:SN})})));var l={};n.forEach(function(u){var d=u.key;l[d]=(l[d]||0)+1});var c=Object.keys(l).filter(function(u){return l[u]>1});return c.forEach(function(u){n=n.filter(function(d){var h=d.key,f=d.status;return h!==u||f!==CN}),n.forEach(function(d){d.key===u&&(d.status=kN)})}),n}var Uae=["component","children","onVisibleChanged","onAllRemoved"],Wae=["status"],Vae=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function qae(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fae,n=function(r){Ir(i,r);var s=e9(i);function i(){var o;Nn(this,i);for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];return o=s.call.apply(s,[this].concat(c)),Ke(X2(o),"state",{keyEntities:[]}),Ke(X2(o),"removeKey",function(d){o.setState(function(h){var f=h.keyEntities.map(function(m){return m.key!==d?m:Pt(Pt({},m),{},{status:ek})});return{keyEntities:f}},function(){var h=o.state.keyEntities,f=h.filter(function(m){var g=m.status;return g!==ek}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return jn(i,[{key:"render",value:function(){var l=this,c=this.state.keyEntities,u=this.props,d=u.component,h=u.children,f=u.onVisibleChanged;u.onAllRemoved;var m=ai(u,Uae),g=d||p.Fragment,x={};return Vae.forEach(function(b){x[b]=m[b],delete m[b]}),delete m.keys,p.createElement(g,m,c.map(function(b,y){var v=b.status,w=ai(b,Wae),_=v===SN||v===kN;return p.createElement(t,bt({},x,{key:w.key,visible:_,eventProps:w,onVisibleChanged:function(k){f==null||f(k,{key:w.key}),k||l.removeKey(w.key)}}),function(S,k){return h(Pt(Pt({},S),{},{index:y}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(l,c){var u=l.keys,d=c.keyEntities,h=NN(u),f=Hae(d,h);return{keyEntities:f.filter(function(m){var g=d.find(function(x){var b=x.key;return m.key===b});return!(g&&g.status===ek&&m.status===CN)})}}}]),i}(p.Component);return Ke(n,"defaultProps",{component:"div"}),n}qae(B9);const LP=p.createContext(!0);function Kae(e){const t=p.useContext(LP),{children:n}=e,[,r]=M9(),{motion:s}=r,i=p.useRef(!1);return i.current||(i.current=t!==s),i.current?p.createElement(LP.Provider,{value:s},p.createElement(Nae,{motion:s},n)):n}const Gae=()=>null;var Yae=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const Xae=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let U9;function Zae(){return U9||yN}function Qae(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const Jae=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:s}=e;t!==void 0&&(U9=t),r&&Qae(r)&&aae(Zae(),r)},ele=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:s,anchor:i,form:o,locale:l,componentSize:c,direction:u,space:d,splitter:h,virtual:f,dropdownMatchSelectWidth:m,popupMatchSelectWidth:g,popupOverflow:x,legacyLocale:b,parentContext:y,iconPrefixCls:v,theme:w,componentDisabled:_,segmented:S,statistic:k,spin:N,calendar:j,carousel:R,cascader:E,collapse:I,typography:M,checkbox:P,descriptions:D,divider:F,drawer:B,skeleton:U,steps:$,image:O,layout:T,list:V,mentions:H,modal:L,progress:q,result:K,slider:X,breadcrumb:te,menu:oe,pagination:Q,input:he,textArea:be,empty:Z,badge:ce,radio:se,rate:fe,switch:xe,transfer:Me,avatar:Xe,message:me,tag:Ce,table:je,card:Se,tabs:ut,timeline:ot,timePicker:yt,upload:re,notification:ue,tree:Te,colorPicker:Ze,datePicker:at,rangePicker:et,flex:tt,wave:Lt,dropdown:wt,warning:we,tour:He,tooltip:ct,popover:Ot,popconfirm:on,floatButton:Ne,floatButtonGroup:ne,variant:De,inputNumber:Je,treeSelect:dt}=e,Nt=p.useCallback((Dt,Bt)=>{const{prefixCls:mn}=e;if(Bt)return Bt;const Tn=mn||y.getPrefixCls("");return Dt?`${Tn}-${Dt}`:Tn},[y.getPrefixCls,e.prefixCls]),St=v||y.iconPrefixCls||I9,dn=n||y.csp;bae(St,dn);const Dn=kae(w,y.theme,{prefixCls:Nt("")}),Jn={csp:dn,autoInsertSpaceInButton:r,alert:s,anchor:i,locale:l||b,direction:u,space:d,splitter:h,virtual:f,popupMatchSelectWidth:g??m,popupOverflow:x,getPrefixCls:Nt,iconPrefixCls:St,theme:Dn,segmented:S,statistic:k,spin:N,calendar:j,carousel:R,cascader:E,collapse:I,typography:M,checkbox:P,descriptions:D,divider:F,drawer:B,skeleton:U,steps:$,image:O,input:he,textArea:be,layout:T,list:V,mentions:H,modal:L,progress:q,result:K,slider:X,breadcrumb:te,menu:oe,pagination:Q,empty:Z,badge:ce,radio:se,rate:fe,switch:xe,transfer:Me,avatar:Xe,message:me,tag:Ce,table:je,card:Se,tabs:ut,timeline:ot,timePicker:yt,upload:re,notification:ue,tree:Te,colorPicker:Ze,datePicker:at,rangePicker:et,flex:tt,wave:Lt,dropdown:wt,warning:we,tour:He,tooltip:ct,popover:Ot,popconfirm:on,floatButton:Ne,floatButtonGroup:ne,variant:De,inputNumber:Je,treeSelect:dt},ht=Object.assign({},y);Object.keys(Jn).forEach(Dt=>{Jn[Dt]!==void 0&&(ht[Dt]=Jn[Dt])}),Xae.forEach(Dt=>{const Bt=e[Dt];Bt&&(ht[Dt]=Bt)}),typeof r<"u"&&(ht.button=Object.assign({autoInsertSpace:r},ht.button));const Ht=Z8(()=>ht,ht,(Dt,Bt)=>{const mn=Object.keys(Dt),Tn=Object.keys(Bt);return mn.length!==Tn.length||mn.some(Rr=>Dt[Rr]!==Bt[Rr])}),{layer:hn}=p.useContext(nw),En=p.useMemo(()=>({prefixCls:St,csp:dn,layer:hn?"antd":void 0}),[St,dn,hn]);let Mt=p.createElement(p.Fragment,null,p.createElement(Gae,{dropdownMatchSelectWidth:m}),t);const lr=p.useMemo(()=>{var Dt,Bt,mn,Tn;return Boe(((Dt=iw.Form)===null||Dt===void 0?void 0:Dt.defaultValidateMessages)||{},((mn=(Bt=Ht.locale)===null||Bt===void 0?void 0:Bt.Form)===null||mn===void 0?void 0:mn.defaultValidateMessages)||{},((Tn=Ht.form)===null||Tn===void 0?void 0:Tn.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Ht,o==null?void 0:o.validateMessages]);Object.keys(lr).length>0&&(Mt=p.createElement(zoe.Provider,{value:lr},Mt)),l&&(Mt=p.createElement(Woe,{locale:l,_ANT_MARK__:Uoe},Mt)),Mt=p.createElement(Aoe.Provider,{value:En},Mt),c&&(Mt=p.createElement(cae,{size:c},Mt)),Mt=p.createElement(Kae,null,Mt);const In=p.useMemo(()=>{const Dt=Dn||{},{algorithm:Bt,token:mn,components:Tn,cssVar:Rr}=Dt,Ji=Yae(Dt,["algorithm","token","components","cssVar"]),xr=Bt&&(!Array.isArray(Bt)||Bt.length>0)?tN(Bt):j9,vr={};Object.entries(Tn||{}).forEach(([qs,vi])=>{const ve=Object.assign({},vi);"algorithm"in ve&&(ve.algorithm===!0?ve.theme=xr:(Array.isArray(ve.algorithm)||typeof ve.algorithm=="function")&&(ve.theme=tN(ve.algorithm)),delete ve.algorithm),vr[qs]=ve});const us=Object.assign(Object.assign({},Qm),mn);return Object.assign(Object.assign({},Ji),{theme:xr,token:us,components:vr,override:Object.assign({override:us},vr),cssVar:Rr})},[Dn]);return w&&(Mt=p.createElement(E9.Provider,{value:In},Mt)),Ht.warning&&(Mt=p.createElement(Foe.Provider,{value:Ht.warning},Mt)),_!==void 0&&(Mt=p.createElement(lae,{disabled:_},Mt)),p.createElement(ow.Provider,{value:Ht},Mt)},hf=e=>{const t=p.useContext(ow),n=p.useContext(S9);return p.createElement(ele,Object.assign({parentContext:t,legacyLocale:n},e))};hf.ConfigContext=ow;hf.SizeContext=Jm;hf.config=Jae;hf.useConfig=uae;Object.defineProperty(hf,"SizeContext",{get:()=>Jm});var W9={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Ar,function(){var n=1e3,r=6e4,s=36e5,i="millisecond",o="second",l="minute",c="hour",u="day",d="week",h="month",f="quarter",m="year",g="date",x="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var F=["th","st","nd","rd"],B=D%100;return"["+D+(F[(B-20)%10]||F[B]||F[0])+"]"}},w=function(D,F,B){var U=String(D);return!U||U.length>=F?D:""+Array(F+1-U.length).join(B)+D},_={s:w,z:function(D){var F=-D.utcOffset(),B=Math.abs(F),U=Math.floor(B/60),$=B%60;return(F<=0?"+":"-")+w(U,2,"0")+":"+w($,2,"0")},m:function D(F,B){if(F.date()<B.date())return-D(B,F);var U=12*(B.year()-F.year())+(B.month()-F.month()),$=F.clone().add(U,h),O=B-$<0,T=F.clone().add(U+(O?-1:1),h);return+(-(U+(B-$)/(O?$-T:T-$))||0)},a:function(D){return D<0?Math.ceil(D)||0:Math.floor(D)},p:function(D){return{M:h,y:m,w:d,d:u,D:g,h:c,m:l,s:o,ms:i,Q:f}[D]||String(D||"").toLowerCase().replace(/s$/,"")},u:function(D){return D===void 0}},S="en",k={};k[S]=v;var N="$isDayjsObject",j=function(D){return D instanceof M||!(!D||!D[N])},R=function D(F,B,U){var $;if(!F)return S;if(typeof F=="string"){var O=F.toLowerCase();k[O]&&($=O),B&&(k[O]=B,$=O);var T=F.split("-");if(!$&&T.length>1)return D(T[0])}else{var V=F.name;k[V]=F,$=V}return!U&&$&&(S=$),$||!U&&S},E=function(D,F){if(j(D))return D.clone();var B=typeof F=="object"?F:{};return B.date=D,B.args=arguments,new M(B)},I=_;I.l=R,I.i=j,I.w=function(D,F){return E(D,{locale:F.$L,utc:F.$u,x:F.$x,$offset:F.$offset})};var M=function(){function D(B){this.$L=R(B.locale,null,!0),this.parse(B),this.$x=this.$x||B.x||{},this[N]=!0}var F=D.prototype;return F.parse=function(B){this.$d=function(U){var $=U.date,O=U.utc;if($===null)return new Date(NaN);if(I.u($))return new Date;if($ instanceof Date)return new Date($);if(typeof $=="string"&&!/Z$/i.test($)){var T=$.match(b);if(T){var V=T[2]-1||0,H=(T[7]||"0").substring(0,3);return O?new Date(Date.UTC(T[1],V,T[3]||1,T[4]||0,T[5]||0,T[6]||0,H)):new Date(T[1],V,T[3]||1,T[4]||0,T[5]||0,T[6]||0,H)}}return new Date($)}(B),this.init()},F.init=function(){var B=this.$d;this.$y=B.getFullYear(),this.$M=B.getMonth(),this.$D=B.getDate(),this.$W=B.getDay(),this.$H=B.getHours(),this.$m=B.getMinutes(),this.$s=B.getSeconds(),this.$ms=B.getMilliseconds()},F.$utils=function(){return I},F.isValid=function(){return this.$d.toString()!==x},F.isSame=function(B,U){var $=E(B);return this.startOf(U)<=$&&$<=this.endOf(U)},F.isAfter=function(B,U){return E(B)<this.startOf(U)},F.isBefore=function(B,U){return this.endOf(U)<E(B)},F.$g=function(B,U,$){return I.u(B)?this[U]:this.set($,B)},F.unix=function(){return Math.floor(this.valueOf()/1e3)},F.valueOf=function(){return this.$d.getTime()},F.startOf=function(B,U){var $=this,O=!!I.u(U)||U,T=I.p(B),V=function(Q,he){var be=I.w($.$u?Date.UTC($.$y,he,Q):new Date($.$y,he,Q),$);return O?be:be.endOf(u)},H=function(Q,he){return I.w($.toDate()[Q].apply($.toDate("s"),(O?[0,0,0,0]:[23,59,59,999]).slice(he)),$)},L=this.$W,q=this.$M,K=this.$D,X="set"+(this.$u?"UTC":"");switch(T){case m:return O?V(1,0):V(31,11);case h:return O?V(1,q):V(0,q+1);case d:var te=this.$locale().weekStart||0,oe=(L<te?L+7:L)-te;return V(O?K-oe:K+(6-oe),q);case u:case g:return H(X+"Hours",0);case c:return H(X+"Minutes",1);case l:return H(X+"Seconds",2);case o:return H(X+"Milliseconds",3);default:return this.clone()}},F.endOf=function(B){return this.startOf(B,!1)},F.$set=function(B,U){var $,O=I.p(B),T="set"+(this.$u?"UTC":""),V=($={},$[u]=T+"Date",$[g]=T+"Date",$[h]=T+"Month",$[m]=T+"FullYear",$[c]=T+"Hours",$[l]=T+"Minutes",$[o]=T+"Seconds",$[i]=T+"Milliseconds",$)[O],H=O===u?this.$D+(U-this.$W):U;if(O===h||O===m){var L=this.clone().set(g,1);L.$d[V](H),L.init(),this.$d=L.set(g,Math.min(this.$D,L.daysInMonth())).$d}else V&&this.$d[V](H);return this.init(),this},F.set=function(B,U){return this.clone().$set(B,U)},F.get=function(B){return this[I.p(B)]()},F.add=function(B,U){var $,O=this;B=Number(B);var T=I.p(U),V=function(q){var K=E(O);return I.w(K.date(K.date()+Math.round(q*B)),O)};if(T===h)return this.set(h,this.$M+B);if(T===m)return this.set(m,this.$y+B);if(T===u)return V(1);if(T===d)return V(7);var H=($={},$[l]=r,$[c]=s,$[o]=n,$)[T]||1,L=this.$d.getTime()+B*H;return I.w(L,this)},F.subtract=function(B,U){return this.add(-1*B,U)},F.format=function(B){var U=this,$=this.$locale();if(!this.isValid())return $.invalidDate||x;var O=B||"YYYY-MM-DDTHH:mm:ssZ",T=I.z(this),V=this.$H,H=this.$m,L=this.$M,q=$.weekdays,K=$.months,X=$.meridiem,te=function(he,be,Z,ce){return he&&(he[be]||he(U,O))||Z[be].slice(0,ce)},oe=function(he){return I.s(V%12||12,he,"0")},Q=X||function(he,be,Z){var ce=he<12?"AM":"PM";return Z?ce.toLowerCase():ce};return O.replace(y,function(he,be){return be||function(Z){switch(Z){case"YY":return String(U.$y).slice(-2);case"YYYY":return I.s(U.$y,4,"0");case"M":return L+1;case"MM":return I.s(L+1,2,"0");case"MMM":return te($.monthsShort,L,K,3);case"MMMM":return te(K,L);case"D":return U.$D;case"DD":return I.s(U.$D,2,"0");case"d":return String(U.$W);case"dd":return te($.weekdaysMin,U.$W,q,2);case"ddd":return te($.weekdaysShort,U.$W,q,3);case"dddd":return q[U.$W];case"H":return String(V);case"HH":return I.s(V,2,"0");case"h":return oe(1);case"hh":return oe(2);case"a":return Q(V,H,!0);case"A":return Q(V,H,!1);case"m":return String(H);case"mm":return I.s(H,2,"0");case"s":return String(U.$s);case"ss":return I.s(U.$s,2,"0");case"SSS":return I.s(U.$ms,3,"0");case"Z":return T}return null}(he)||T.replace(":","")})},F.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},F.diff=function(B,U,$){var O,T=this,V=I.p(U),H=E(B),L=(H.utcOffset()-this.utcOffset())*r,q=this-H,K=function(){return I.m(T,H)};switch(V){case m:O=K()/12;break;case h:O=K();break;case f:O=K()/3;break;case d:O=(q-L)/6048e5;break;case u:O=(q-L)/864e5;break;case c:O=q/s;break;case l:O=q/r;break;case o:O=q/n;break;default:O=q}return $?O:I.a(O)},F.daysInMonth=function(){return this.endOf(h).$D},F.$locale=function(){return k[this.$L]},F.locale=function(B,U){if(!B)return this.$L;var $=this.clone(),O=R(B,U,!0);return O&&($.$L=O),$},F.clone=function(){return I.w(this.$d,this)},F.toDate=function(){return new Date(this.valueOf())},F.toJSON=function(){return this.isValid()?this.toISOString():null},F.toISOString=function(){return this.$d.toISOString()},F.toString=function(){return this.$d.toUTCString()},D}(),P=M.prototype;return E.prototype=P,[["$ms",i],["$s",o],["$m",l],["$H",c],["$W",u],["$M",h],["$y",m],["$D",g]].forEach(function(D){P[D[1]]=function(F){return this.$g(F,D[0],D[1])}}),E.extend=function(D,F){return D.$i||(D(F,M,E),D.$i=!0),E},E.locale=R,E.isDayjs=j,E.unix=function(D){return E(1e3*D)},E.en=k[S],E.Ls=k,E.p={},E})})(W9);var tle=W9.exports;const jN=pn(tle);var V9={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Ar,function(){return function(n,r,s){var i=r.prototype,o=function(h){return h&&(h.indexOf?h:h.s)},l=function(h,f,m,g,x){var b=h.name?h:h.$locale(),y=o(b[f]),v=o(b[m]),w=y||v.map(function(S){return S.slice(0,g)});if(!x)return w;var _=b.weekStart;return w.map(function(S,k){return w[(k+(_||0))%7]})},c=function(){return s.Ls[s.locale()]},u=function(h,f){return h.formats[f]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(g,x,b){return x||b.slice(1)})}(h.formats[f.toUpperCase()])},d=function(){var h=this;return{months:function(f){return f?f.format("MMMM"):l(h,"months")},monthsShort:function(f){return f?f.format("MMM"):l(h,"monthsShort","months",3)},firstDayOfWeek:function(){return h.$locale().weekStart||0},weekdays:function(f){return f?f.format("dddd"):l(h,"weekdays")},weekdaysMin:function(f){return f?f.format("dd"):l(h,"weekdaysMin","weekdays",2)},weekdaysShort:function(f){return f?f.format("ddd"):l(h,"weekdaysShort","weekdays",3)},longDateFormat:function(f){return u(h.$locale(),f)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return d.bind(this)()},s.localeData=function(){var h=c();return{firstDayOfWeek:function(){return h.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(f){return u(h,f)},meridiem:h.meridiem,ordinal:h.ordinal}},s.months=function(){return l(c(),"months")},s.monthsShort=function(){return l(c(),"monthsShort","months",3)},s.weekdays=function(h){return l(c(),"weekdays",null,null,h)},s.weekdaysShort=function(h){return l(c(),"weekdaysShort","weekdays",3,h)},s.weekdaysMin=function(h){return l(c(),"weekdaysMin","weekdays",2,h)}}})})(V9);var nle=V9.exports;const rle=pn(nle),wi=(e,t)=>new zn(e).setA(t).toRgbString(),fd=(e,t)=>new zn(e).lighten(t).toHexString(),sle=e=>{const t=Eh(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},ile=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:wi(r,.85),colorTextSecondary:wi(r,.65),colorTextTertiary:wi(r,.45),colorTextQuaternary:wi(r,.25),colorFill:wi(r,.18),colorFillSecondary:wi(r,.12),colorFillTertiary:wi(r,.08),colorFillQuaternary:wi(r,.04),colorBgSolid:wi(r,.95),colorBgSolidHover:wi(r,1),colorBgSolidActive:wi(r,.9),colorBgElevated:fd(n,12),colorBgContainer:fd(n,8),colorBgLayout:fd(n,0),colorBgSpotlight:fd(n,26),colorBgBlur:wi(r,.04),colorBorder:fd(n,26),colorBorderSecondary:fd(n,19)}},ole=(e,t)=>{const n=Object.keys(n5).map(i=>{const o=Eh(e[i],{theme:"dark"});return Array.from({length:10},()=>1).reduce((l,c,u)=>(l[`${i}-${u+1}`]=o[u],l[`${i}${u+1}`]=o[u],l),{})}).reduce((i,o)=>(i=Object.assign(Object.assign({},i),o),i),{}),r=t??r5(e),s=N9(e,{generateColorPalettes:sle,generateNeutralColorPalettes:ile});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),s),{colorPrimaryBg:s.colorPrimaryBorder,colorPrimaryBgHover:s.colorPrimaryBorderHover})},BP={defaultSeed:ab.token,defaultAlgorithm:r5,darkAlgorithm:ole};function ale({children:e}){const t=sl(),[n,r]=p.useState(t.theme);return p.useEffect(()=>t.onThemeChange(r),[t]),a.jsx(hf,{theme:{algorithm:n.mode==="dark"?BP.darkAlgorithm:BP.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Kt;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),o={};for(const l of i)o[l]=s[l];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},e.find=(s,i)=>{for(const o of s)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Kt||(Kt={}));var FP;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(FP||(FP={}));const qe=Kt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ol=e=>{switch(typeof e){case"undefined":return qe.undefined;case"string":return qe.string;case"number":return Number.isNaN(e)?qe.nan:qe.number;case"boolean":return qe.boolean;case"function":return qe.function;case"bigint":return qe.bigint;case"symbol":return qe.symbol;case"object":return Array.isArray(e)?qe.array:e===null?qe.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?qe.promise:typeof Map<"u"&&e instanceof Map?qe.map:typeof Set<"u"&&e instanceof Set?qe.set:typeof Date<"u"&&e instanceof Date?qe.date:qe.object;default:return qe.unknown}},ye=Kt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ga extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let l=r,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(n(o))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}};return s(this),r}static assert(t){if(!(t instanceof Ga))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(t(s))}else r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ga.create=e=>new Ga(e);const EN=(e,t)=>{let n;switch(e.code){case ye.invalid_type:e.received===qe.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ye.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Kt.jsonStringifyReplacer)}`;break;case ye.unrecognized_keys:n=`Unrecognized key(s) in object: ${Kt.joinValues(e.keys,", ")}`;break;case ye.invalid_union:n="Invalid input";break;case ye.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Kt.joinValues(e.options)}`;break;case ye.invalid_enum_value:n=`Invalid enum value. Expected ${Kt.joinValues(e.options)}, received '${e.received}'`;break;case ye.invalid_arguments:n="Invalid function arguments";break;case ye.invalid_return_type:n="Invalid function return type";break;case ye.invalid_date:n="Invalid date";break;case ye.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Kt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ye.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case ye.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case ye.custom:n="Invalid input";break;case ye.invalid_intersection_types:n="Intersection results could not be merged";break;case ye.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ye.not_finite:n="Number must be finite";break;default:n=t.defaultError,Kt.assertNever(e)}return{message:n}};let lle=EN;function cle(){return lle}const ule=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let l="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)l=u(o,{data:t,defaultError:l}).message;return{...s,path:i,message:l}};function $e(e,t){const n=cle(),r=ule({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===EN?void 0:EN].filter(s=>!!s)});e.common.issues.push(r)}class vs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return mt;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return vs.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return mt;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:t.value,value:r}}}const mt=Object.freeze({status:"aborted"}),Lp=e=>({status:"dirty",value:e}),Ki=e=>({status:"valid",value:e}),zP=e=>e.status==="aborted",HP=e=>e.status==="dirty",Ih=e=>e.status==="valid",lb=e=>typeof Promise<"u"&&e instanceof Promise;var nt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(nt||(nt={}));class oa{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const UP=(e,t)=>{if(Ih(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ga(e.common.issues);return this._error=n,this._error}}};function Ct(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??r??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:s}}class zt{get description(){return this._def.description}_getType(t){return Ol(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Ol(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new vs,ctx:{common:t.parent.common,data:t.data,parsedType:Ol(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(lb(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ol(t)},s=this._parseSync({data:t,path:r.path,parent:r});return UP(r,s)}"~validate"(t){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ol(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return Ih(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>Ih(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ol(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(lb(s)?s:Promise.resolve(s));return UP(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=t(s),l=()=>i.addIssue({code:ye.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new cc({schema:this,typeName:gt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ha.create(this,this._def)}nullable(){return xu.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Jo.create(this)}promise(){return pb.create(this,this._def)}or(t){return ub.create([this,t],this._def)}and(t){return db.create(this,t,this._def)}transform(t){return new cc({...Ct(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new mb({...Ct(this._def),innerType:this,defaultValue:n,typeName:gt.ZodDefault})}brand(){return new Y9({typeName:gt.ZodBranded,type:this,...Ct(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new gb({...Ct(this._def),innerType:this,catchValue:n,typeName:gt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return o5.create(this,t)}readonly(){return xb.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dle=/^c[^\s-]{8,}$/i,hle=/^[0-9a-z]+$/,fle=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ple=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,mle=/^[a-z0-9_-]{21}$/i,gle=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xle=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,vle=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yle="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tk;const ble=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wle=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,_le=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Sle=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kle=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cle=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,q9="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Nle=new RegExp(`^${q9}$`);function K9(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function jle(e){return new RegExp(`^${K9(e)}$`)}function Ele(e){let t=`${q9}T${K9(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Ile(e,t){return!!((t==="v4"||!t)&&ble.test(e)||(t==="v6"||!t)&&_le.test(e))}function Tle(e,t){if(!gle.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function Rle(e,t){return!!((t==="v4"||!t)&&wle.test(e)||(t==="v6"||!t)&&Sle.test(e))}class Aa extends zt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==qe.string){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_type,expected:qe.string,received:i.parsedType}),mt}const r=new vs;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(t,s),o?$e(s,{code:ye.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&$e(s,{code:ye.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")vle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"email",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")tk||(tk=new RegExp(yle,"u")),tk.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"emoji",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")ple.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"uuid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")mle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"nanoid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")dle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"cuid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")hle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"cuid2",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")fle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"ulid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),$e(s,{validation:"url",code:ye.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"regex",code:ye.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Ele(i).test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Nle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?jle(i).test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?xle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"duration",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Ile(t.data,i.version)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"ip",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Tle(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"jwt",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Rle(t.data,i.version)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"cidr",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?kle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"base64",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Cle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"base64url",code:ye.invalid_string,message:i.message}),r.dirty()):Kt.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:ye.invalid_string,...nt.errToObj(r)})}_addCheck(t){return new Aa({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...nt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...nt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...nt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...nt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...nt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...nt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...nt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...nt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...nt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...nt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...nt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...nt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...nt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...nt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...nt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...nt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...nt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...nt.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...nt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...nt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...nt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...nt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...nt.errToObj(n)})}nonempty(t){return this.min(1,nt.errToObj(t))}trim(){return new Aa({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Aa({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Aa({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Aa.create=e=>new Aa({checks:[],typeName:gt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ct(e)});function Mle(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}class Th extends zt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==qe.number){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_type,expected:qe.number,received:i.parsedType}),mt}let r;const s=new vs;for(const i of this._def.checks)i.kind==="int"?Kt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Mle(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.not_finite,message:i.message}),s.dirty()):Kt.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,nt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,nt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,nt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,nt.toString(n))}setLimit(t,n,r,s){return new Th({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:nt.toString(s)}]})}_addCheck(t){return new Th({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:nt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:nt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:nt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:nt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:nt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:nt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:nt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:nt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:nt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Kt.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Th.create=e=>new Th({checks:[],typeName:gt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ct(e)});class eg extends zt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==qe.bigint)return this._getInvalidInput(t);let r;const s=new vs;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Kt.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return $e(n,{code:ye.invalid_type,expected:qe.bigint,received:n.parsedType}),mt}gte(t,n){return this.setLimit("min",t,!0,nt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,nt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,nt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,nt.toString(n))}setLimit(t,n,r,s){return new eg({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:nt.toString(s)}]})}_addCheck(t){return new eg({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:nt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:nt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:nt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:nt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:nt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}eg.create=e=>new eg({checks:[],typeName:gt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ct(e)});class IN extends zt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==qe.boolean){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.boolean,received:r.parsedType}),mt}return Ki(t.data)}}IN.create=e=>new IN({typeName:gt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ct(e)});class cb extends zt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==qe.date){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_type,expected:qe.date,received:i.parsedType}),mt}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_date}),mt}const r=new vs;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Kt.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new cb({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:nt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:nt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}cb.create=e=>new cb({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:gt.ZodDate,...Ct(e)});class WP extends zt{_parse(t){if(this._getType(t)!==qe.symbol){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.symbol,received:r.parsedType}),mt}return Ki(t.data)}}WP.create=e=>new WP({typeName:gt.ZodSymbol,...Ct(e)});class TN extends zt{_parse(t){if(this._getType(t)!==qe.undefined){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.undefined,received:r.parsedType}),mt}return Ki(t.data)}}TN.create=e=>new TN({typeName:gt.ZodUndefined,...Ct(e)});class RN extends zt{_parse(t){if(this._getType(t)!==qe.null){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.null,received:r.parsedType}),mt}return Ki(t.data)}}RN.create=e=>new RN({typeName:gt.ZodNull,...Ct(e)});class VP extends zt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ki(t.data)}}VP.create=e=>new VP({typeName:gt.ZodAny,...Ct(e)});class MN extends zt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ki(t.data)}}MN.create=e=>new MN({typeName:gt.ZodUnknown,...Ct(e)});class lc extends zt{_parse(t){const n=this._getOrReturnCtx(t);return $e(n,{code:ye.invalid_type,expected:qe.never,received:n.parsedType}),mt}}lc.create=e=>new lc({typeName:gt.ZodNever,...Ct(e)});class qP extends zt{_parse(t){if(this._getType(t)!==qe.undefined){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.void,received:r.parsedType}),mt}return Ki(t.data)}}qP.create=e=>new qP({typeName:gt.ZodVoid,...Ct(e)});class Jo extends zt{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==qe.array)return $e(n,{code:ye.invalid_type,expected:qe.array,received:n.parsedType}),mt;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(o||l)&&($e(n,{code:o?ye.too_big:ye.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&($e(n,{code:ye.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&($e(n,{code:ye.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>s.type._parseAsync(new oa(n,o,n.path,l)))).then(o=>vs.mergeArray(r,o));const i=[...n.data].map((o,l)=>s.type._parseSync(new oa(n,o,n.path,l)));return vs.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new Jo({...this._def,minLength:{value:t,message:nt.toString(n)}})}max(t,n){return new Jo({...this._def,maxLength:{value:t,message:nt.toString(n)}})}length(t,n){return new Jo({...this._def,exactLength:{value:t,message:nt.toString(n)}})}nonempty(t){return this.min(1,t)}}Jo.create=(e,t)=>new Jo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...Ct(t)});function Rd(e){if(e instanceof nr){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ha.create(Rd(r))}return new nr({...e._def,shape:()=>t})}else return e instanceof Jo?new Jo({...e._def,type:Rd(e.element)}):e instanceof Ha?Ha.create(Rd(e.unwrap())):e instanceof xu?xu.create(Rd(e.unwrap())):e instanceof mu?mu.create(e.items.map(t=>Rd(t))):e}class nr extends zt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Kt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==qe.object){const u=this._getOrReturnCtx(t);return $e(u,{code:ye.invalid_type,expected:qe.object,received:u.parsedType}),mt}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof lc&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||l.push(u);const c=[];for(const u of o){const d=i[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new oa(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof lc){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of l)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")l.length>0&&($e(s,{code:ye.unrecognized_keys,keys:l}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of l){const h=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new oa(s,h,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const h=await d.key,f=await d.value;u.push({key:h,value:f,alwaysSet:d.alwaysSet})}return u}).then(u=>vs.mergeObjectSync(r,u)):vs.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return nt.errToObj,new nr({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:nt.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new nr({...this._def,unknownKeys:"strip"})}passthrough(){return new nr({...this._def,unknownKeys:"passthrough"})}extend(t){return new nr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new nr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new nr({...this._def,catchall:t})}pick(t){const n={};for(const r of Kt.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new nr({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Kt.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new nr({...this._def,shape:()=>n})}deepPartial(){return Rd(this)}partial(t){const n={};for(const r of Kt.objectKeys(this.shape)){const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}return new nr({...this._def,shape:()=>n})}required(t){const n={};for(const r of Kt.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ha;)i=i._def.innerType;n[r]=i}return new nr({...this._def,shape:()=>n})}keyof(){return G9(Kt.objectKeys(this.shape))}}nr.create=(e,t)=>new nr({shape:()=>e,unknownKeys:"strip",catchall:lc.create(),typeName:gt.ZodObject,...Ct(t)});nr.strictCreate=(e,t)=>new nr({shape:()=>e,unknownKeys:"strict",catchall:lc.create(),typeName:gt.ZodObject,...Ct(t)});nr.lazycreate=(e,t)=>new nr({shape:e,unknownKeys:"strip",catchall:lc.create(),typeName:gt.ZodObject,...Ct(t)});class ub extends zt{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new Ga(l.ctx.common.issues));return $e(n,{code:ye.invalid_union,unionErrors:o}),mt}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new Ga(c));return $e(n,{code:ye.invalid_union,unionErrors:l}),mt}}get options(){return this._def.options}}ub.create=(e,t)=>new ub({options:e,typeName:gt.ZodUnion,...Ct(t)});const Ra=e=>e instanceof ON?Ra(e.schema):e instanceof cc?Ra(e.innerType()):e instanceof fb?[e.value]:e instanceof gu?e.options:e instanceof DN?Kt.objectValues(e.enum):e instanceof mb?Ra(e._def.innerType):e instanceof TN?[void 0]:e instanceof RN?[null]:e instanceof Ha?[void 0,...Ra(e.unwrap())]:e instanceof xu?[null,...Ra(e.unwrap())]:e instanceof Y9||e instanceof xb?Ra(e.unwrap()):e instanceof gb?Ra(e._def.innerType):[];class i5 extends zt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==qe.object)return $e(n,{code:ye.invalid_type,expected:qe.object,received:n.parsedType}),mt;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):($e(n,{code:ye.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),mt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const o=Ra(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of o){if(s.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);s.set(l,i)}}return new i5({typeName:gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...Ct(r)})}}function PN(e,t){const n=Ol(e),r=Ol(t);if(e===t)return{valid:!0,data:e};if(n===qe.object&&r===qe.object){const s=Kt.objectKeys(t),i=Kt.objectKeys(e).filter(l=>s.indexOf(l)!==-1),o={...e,...t};for(const l of i){const c=PN(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(n===qe.array&&r===qe.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const o=e[i],l=t[i],c=PN(o,l);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===qe.date&&r===qe.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class db extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,o)=>{if(zP(i)||zP(o))return mt;const l=PN(i.value,o.value);return l.valid?((HP(i)||HP(o))&&n.dirty(),{status:n.value,value:l.data}):($e(r,{code:ye.invalid_intersection_types}),mt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}db.create=(e,t,n)=>new db({left:e,right:t,typeName:gt.ZodIntersection,...Ct(n)});class mu extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.array)return $e(r,{code:ye.invalid_type,expected:qe.array,received:r.parsedType}),mt;if(r.data.length<this._def.items.length)return $e(r,{code:ye.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),mt;!this._def.rest&&r.data.length>this._def.items.length&&($e(r,{code:ye.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new oa(r,o,r.path,l)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>vs.mergeArray(n,o)):vs.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new mu({...this._def,rest:t})}}mu.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mu({items:e,typeName:gt.ZodTuple,rest:null,...Ct(t)})};class hb extends zt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.object)return $e(r,{code:ye.invalid_type,expected:qe.object,received:r.parsedType}),mt;const s=[],i=this._def.keyType,o=this._def.valueType;for(const l in r.data)s.push({key:i._parse(new oa(r,l,r.path,l)),value:o._parse(new oa(r,r.data[l],r.path,l)),alwaysSet:l in r.data});return r.common.async?vs.mergeObjectAsync(n,s):vs.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof zt?new hb({keyType:t,valueType:n,typeName:gt.ZodRecord,...Ct(r)}):new hb({keyType:Aa.create(),valueType:t,typeName:gt.ZodRecord,...Ct(n)})}}class KP extends zt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.map)return $e(r,{code:ye.invalid_type,expected:qe.map,received:r.parsedType}),mt;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([l,c],u)=>({key:s._parse(new oa(r,l,r.path,[u,"key"])),value:i._parse(new oa(r,c,r.path,[u,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of o){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}}}}KP.create=(e,t,n)=>new KP({valueType:t,keyType:e,typeName:gt.ZodMap,...Ct(n)});class tg extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.set)return $e(r,{code:ye.invalid_type,expected:qe.set,received:r.parsedType}),mt;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&($e(r,{code:ye.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&($e(r,{code:ye.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(c){const u=new Set;for(const d of c){if(d.status==="aborted")return mt;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const l=[...r.data.values()].map((c,u)=>i._parse(new oa(r,c,r.path,u)));return r.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,n){return new tg({...this._def,minSize:{value:t,message:nt.toString(n)}})}max(t,n){return new tg({...this._def,maxSize:{value:t,message:nt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}tg.create=(e,t)=>new tg({valueType:e,minSize:null,maxSize:null,typeName:gt.ZodSet,...Ct(t)});class ON extends zt{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ON.create=(e,t)=>new ON({getter:e,typeName:gt.ZodLazy,...Ct(t)});class fb extends zt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return $e(n,{received:n.data,code:ye.invalid_literal,expected:this._def.value}),mt}return{status:"valid",value:t.data}}get value(){return this._def.value}}fb.create=(e,t)=>new fb({value:e,typeName:gt.ZodLiteral,...Ct(t)});function G9(e,t){return new gu({values:e,typeName:gt.ZodEnum,...Ct(t)})}class gu extends zt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return $e(n,{expected:Kt.joinValues(r),received:n.parsedType,code:ye.invalid_type}),mt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return $e(n,{received:n.data,code:ye.invalid_enum_value,options:r}),mt}return Ki(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return gu.create(t,{...this._def,...n})}exclude(t,n=this._def){return gu.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}gu.create=G9;class DN extends zt{_parse(t){const n=Kt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==qe.string&&r.parsedType!==qe.number){const s=Kt.objectValues(n);return $e(r,{expected:Kt.joinValues(s),received:r.parsedType,code:ye.invalid_type}),mt}if(this._cache||(this._cache=new Set(Kt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=Kt.objectValues(n);return $e(r,{received:r.data,code:ye.invalid_enum_value,options:s}),mt}return Ki(t.data)}get enum(){return this._def.values}}DN.create=(e,t)=>new DN({values:e,typeName:gt.ZodNativeEnum,...Ct(t)});class pb extends zt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==qe.promise&&n.common.async===!1)return $e(n,{code:ye.invalid_type,expected:qe.promise,received:n.parsedType}),mt;const r=n.parsedType===qe.promise?n.data:Promise.resolve(n.data);return Ki(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}pb.create=(e,t)=>new pb({type:e,typeName:gt.ZodPromise,...Ct(t)});class cc extends zt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:o=>{$e(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return mt;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?mt:c.status==="dirty"||n.value==="dirty"?Lp(c.value):c});{if(n.value==="aborted")return mt;const l=this._def.schema._parseSync({data:o,path:r.path,parent:r});return l.status==="aborted"?mt:l.status==="dirty"||n.value==="dirty"?Lp(l.value):l}}if(s.type==="refinement"){const o=l=>{const c=s.refinement(l,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ih(o))return mt;const l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ih(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:n.value,value:l})):mt);Kt.assertNever(s)}}cc.create=(e,t,n)=>new cc({schema:e,typeName:gt.ZodEffects,effect:t,...Ct(n)});cc.createWithPreprocess=(e,t,n)=>new cc({schema:t,effect:{type:"preprocess",transform:e},typeName:gt.ZodEffects,...Ct(n)});class Ha extends zt{_parse(t){return this._getType(t)===qe.undefined?Ki(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ha.create=(e,t)=>new Ha({innerType:e,typeName:gt.ZodOptional,...Ct(t)});class xu extends zt{_parse(t){return this._getType(t)===qe.null?Ki(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}xu.create=(e,t)=>new xu({innerType:e,typeName:gt.ZodNullable,...Ct(t)});class mb extends zt{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===qe.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}mb.create=(e,t)=>new mb({innerType:e,typeName:gt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ct(t)});class gb extends zt{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return lb(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ga(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ga(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}gb.create=(e,t)=>new gb({innerType:e,typeName:gt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ct(t)});class GP extends zt{_parse(t){if(this._getType(t)!==qe.nan){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.nan,received:r.parsedType}),mt}return{status:"valid",value:t.data}}}GP.create=e=>new GP({typeName:gt.ZodNaN,...Ct(e)});class Y9 extends zt{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class o5 extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?mt:i.status==="dirty"?(n.dirty(),Lp(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?mt:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new o5({in:t,out:n,typeName:gt.ZodPipeline})}}class xb extends zt{_parse(t){const n=this._def.innerType._parse(t),r=s=>(Ih(s)&&(s.value=Object.freeze(s.value)),s);return lb(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}xb.create=(e,t)=>new xb({innerType:e,typeName:gt.ZodReadonly,...Ct(t)});var gt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(gt||(gt={}));const C=Aa.create,ee=Th.create,Re=IN.create,Ua=MN.create;lc.create;const ge=Jo.create,z=nr.create;ub.create;const Bs=i5.create;db.create;mu.create;const Gi=hb.create,de=fb.create,Ye=gu.create;pb.create;Ha.create;xu.create;const Ple=cc.createWithPreprocess,Ole=["head","index"],X9=C().regex(/^[A-Za-z0-9][A-Za-z0-9-]{0,127}$/),vb=C().regex(/^[1-9][0-9]*$/),yb=C().regex(/^[A-Za-z0-9_.-]+$/),ng=C().min(1).max(255).refine(e=>!e.startsWith("-")&&e!=="HEAD"&&!e.startsWith("/")&&!e.endsWith("/")&&!e.endsWith(".")&&!/[\s~^:?*\[\\\x00-\x1f\x7f]/.test(e)&&!e.includes("..")&&!e.includes("@{")&&!e.includes("//")&&e.split("/").every(t=>!t.startsWith(".")&&!t.endsWith(".lock")),"Invalid Git branch"),a5=C().min(1).max(4096).refine(e=>!e.startsWith("/")&&!e.includes("\0")&&!e.split(/[\\/]/).includes("..")),l5=z({workspaceId:X9,repoId:vb,owner:yb,name:yb,sourceBranch:ng,defaultBranch:ng}).strict(),Dle=z({repoId:vb,owner:yb,name:yb,defaultBranch:C(),private:Re(),description:C().nullable()}),Ale=l5.extend({initialCommit:C(),head:C(),actualBranch:C().nullable(),branches:ge(C()).optional(),files:ge(z({path:a5,previousPath:C().optional(),comparison:Ye(Ole).optional(),status:C(),added:ee().nonnegative(),removed:ee().nonnegative(),binary:Re(),untracked:Re().optional()})),totalFiles:ee().int().nonnegative().optional(),filesTruncated:Re().optional(),added:ee().nonnegative(),removed:ee().nonnegative(),dirty:Re(),conflicted:Re(),version:C(),measuredAt:ee()}),pd=z({sessionId:X9});Bs("action",[pd.extend({action:de("repositories"),page:ee().int().min(1).max(1e3).optional(),search:C().max(100).optional()}).strict(),pd.extend({action:de("branches"),repoId:vb,page:ee().int().min(1).max(1e3).optional(),search:C().max(100).optional(),cursor:C().min(1).max(1024).optional()}).strict(),pd.extend({action:de("bind"),repoId:vb,branch:ng}).strict(),pd.extend({action:de("status")}).strict(),pd.extend({action:de("intend"),branch:ng.optional()}).strict(),pd.extend({action:de("diff"),filePath:a5}).strict()]);z({binding:l5.nullable().optional(),workspace:Ale.nullable().optional(),repositories:ge(Dle).optional(),branches:ge(C()).optional(),hasMore:Re().optional(),nextCursor:C().min(1).max(1024).optional(),diff:z({path:a5,patch:C(),binary:Re(),truncated:Re(),notStored:Re().optional()}).optional()});new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");z({id:C().min(1),name:C().min(1),baseUrl:C().min(1),apiKey:C().min(1),remark:C().optional(),createdAt:ee(),updatedAt:ee()}).strict();const $le=z({id:C().min(1),name:C().min(1),baseUrl:C().min(1),remark:C().optional(),keyMasked:C(),hasKey:Re(),createdAt:ee(),updatedAt:ee()}).strict();z({activeChannelId:C().nullable(),channels:ge($le)}).strict();z({}).strict();z({id:C().min(1).optional(),name:C().min(1),baseUrl:C().min(1),apiKey:C().optional(),remark:C().optional()}).strict();z({id:C().min(1)}).strict();z({id:C().min(1).nullable()}).strict();z({channelId:C().min(1).optional(),updatedAt:ee().optional()}).strict().refine(e=>e.updatedAt===void 0||e.channelId!==void 0,{message:"updatedAt requires channelId"});z({channelId:C().nullable(),models:ge(z({id:C().min(1),ownedBy:C().optional()}).strict())}).strict();const Lle=["owner"],Ble=["agent","owner","user-upload"],Z9=z({id:C().min(1),relPath:C().min(1),from:Ye(Ble),label:C().optional(),size:ee().int().nonnegative(),mime:C().min(1),addedAt:ee().int().nonnegative(),lastEditedAt:ee().int().nonnegative().optional(),stale:Re().optional()});z({sessionId:C().min(1),relPath:C().min(1),ttlSeconds:ee().int().positive().nullable().optional(),view:Ye(["raw","md-rendered"]).optional()});z({url:C().min(1),expiresAt:ee().int().nonnegative().nullable()});z({sessionId:C().min(1),relPath:C().min(1),label:C().optional(),origin:de("agent").optional()});z({entry:Z9});z({sessionId:C().min(1),relPath:C().min(1)});z({removed:de(!0)});z({sessionId:C().min(1)});z({entries:ge(Z9)});z({attachmentId:C().min(1),url:C().min(1),relPath:C().min(1),sizeBytes:ee().int().nonnegative(),mimeType:C().min(1)});const Fle=Bs("type",[z({type:de("persona"),id:C().min(1)}).strict(),z({type:de("chat"),id:C().min(1)}).strict(),z({type:de("*")}).strict()]),zle=Ye(["read","send","admin"]),c5=z({resource:Fle,actions:ge(zle).min(1)}).strict(),Hle=z({id:C().min(1),secretHash:C().regex(/^[a-f0-9]{64}$/),displayName:C(),grants:ge(c5),issuedAt:ee().int().nonnegative(),expiresAt:ee().int().positive().optional(),maxUses:ee().int().positive().optional(),usedCount:ee().int().nonnegative(),peerOwnerId:C().min(1).optional(),firstUsedByPeerAt:ee().int().positive().optional(),peerDisplayName:C().optional()}).strict(),Ule=Hle.omit({secretHash:!0});z({type:de("whoami:ok"),owner:z({id:C(),kind:Ye(["owner","guest"]),displayName:C(),ownerId:C(),provider:C()}).strict(),capability:Ule,grantedPersonas:ge(z({id:C().min(1),displayName:C()}).strict())}).strict();const Wle="PEER_LOGIN_EXPIRED";z({selfUrl:C().min(1)});z({type:de("contact:handshake:ok"),owner:z({id:C(),ownerId:C(),provider:C(),displayName:C()}),grants:ge(c5)});const Vle=Bs("status",[z({status:de("authorized"),login:C().min(1),source:Ye(["git","file"])}).strict(),z({status:de("missing")}).strict(),z({status:de("invalid"),message:C().min(1)}).strict(),z({status:de("pending"),authUrl:C().url()}).strict()]);z({token:C().min(1)}).strict();z({returnTo:C().url().optional()}).strict();const qle=z({url:C().url(),bin:C(),sha256:C().regex(/^[0-9a-f]{64}$/),size:ee().int().positive()}),Kle={label:"Debian 13"},Q9=["node","npm"],Gle=["claude","codex","git","lark-cli","pi","pi-mcp-bridge","pi-cliproxyapi-provider","python3","jq","rsync","psql","chromium","fonts-wqy-microhei","pnpm","whiteboard-cli","s","supabase-mcp","mcp-server-kibana","aliyun"],Yle=z({name:C().min(1),from:C().optional(),version:C().optional(),min:C().optional(),library:Re().optional(),localVersion:C().optional(),artifact:qle.optional(),aptMissing:de(!0).optional(),aptVersion:C().optional()}),Xle=z({name:C().min(1),env:ge(C().min(1)).min(1)}),u5=C().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),J9=["proxy","env"],e7=["mcp","cli"],Zle=["bearer","lark-sidecar"],t7=["none","shared","personal"],d5=["oauth","fields"],h5=C().regex(/^[A-Z][A-Z0-9_]*$/,"要填的变量名只能是大写字母、数字和下划线,且以字母开头"),n7=z({name:u5,kind:Ye(J9),runner:Ye(e7),protocol:Ye(Zle).optional(),id:C().min(1),credentialSource:Ye(t7).optional(),auth:Ye(d5).optional(),publisherUnionId:C().regex(/^on_[A-Za-z0-9_-]+$/).optional(),fields:ge(h5).default([]),http:z({url:C().min(1),headers:Gi(C(),C())}).optional()}),r7=["LARKSUITE_CLI_APP_ID","LARKSUITE_CLI_APP_SECRET"];function f5(e){return e.name==="feishu"&&e.runner==="cli"&&e.kind==="env"&&e.credentialSource==="shared"}function Qle(e){return e.name==="feishu"&&e.id==="feishu"&&e.runner==="cli"&&e.kind==="proxy"&&e.protocol==="lark-sidecar"&&e.credentialSource==="shared"&&e.auth==="oauth"&&e.fields.length===0}function s7(e){if(!e.credentialSource)return[`连接器 ${e.name} 还没选用谁的账号`];const t=[];return Qle(e)?t:e.protocol==="lark-sidecar"&&e.credentialSource==="shared"?["连接器 feishu 的发布者 OAuth 配置不完整,请重新选择账号身份"]:f5(e)?r7.filter(n=>!e.fields.includes(n)).map(n=>`连接器 feishu 的 Lark App Bot 缺少 ${n==="LARKSUITE_CLI_APP_ID"?"App ID":"App Secret"}`):(e.credentialSource==="personal"&&(e.auth?e.auth==="oauth"&&e.kind==="env"?t.push(`连接器 ${e.name} 是进程型(stdio MCP / CLI),只能粘贴 API key,走不了 OAuth`):e.auth==="fields"&&e.fields.length===0&&t.push(`连接器 ${e.name} 要填的变量还没列`):t.push(`连接器 ${e.name} 还没选用户怎么关联账号`)),e.credentialSource==="shared"&&e.fields.length===0&&t.push(`连接器 ${e.name} 选了发布者的账号,但要填的变量还没列`),t)}function i7(e){var n;const t=Q9.includes(e.name)||Gle.includes(e.name);return(n=e.from)!=null&&n.startsWith("github:")&&!e.artifact&&!t?[`${e.name} 还没钉下载资产(github: 要具体到哪个文件)——重新扫描`]:[]}function aw(e){return e.connectors.filter(t=>t.credentialSource==="shared"&&t.fields.length>0).map(t=>({name:t.name,env:[...t.fields]}))}function Jle(e){return[...new Set([...e.secrets.flatMap(t=>t.env),...aw(e).flatMap(t=>t.env)])]}const ece=e=>{if(!e||typeof e!="object")return e;let t=e;if("clis"in t&&Array.isArray(t.clis)){const{clis:n,...r}=t;t="packages"in r?r:{...r,packages:n}}if("assets"in t&&Array.isArray(t.assets)&&t.assets.length===0){const{assets:n,...r}=t;t=r}return t},tce="Publisher test: ",o7=z({version:de(1),entry:C().max(240).regex(/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*\.mjs$/).refine(e=>!e.split("/").some(t=>[".",".."].includes(t))),timeoutSeconds:ee().int().min(1).max(600),checks:ge(C().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)).min(1).max(64).refine(e=>new Set(e).size===e.length)}).strict(),a7={test:o7.optional(),packages:ge(Yle),secrets:ge(Xle),connectors:ge(n7).default([])};z(a7);const p5=Ple(ece,z({version:de(1),...a7}).strict()),nce=z({target:C().min(1),reason:C().min(1),file:C().min(1),quote:C().min(1)}),rce=["integration","production"],Hs=Ye(rce),Ya=C().regex(/^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[a-f0-9]{64}$/),AN=C().regex(/^[a-f0-9]{40}$/),sce=C().refine(e=>{try{const t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password&&!t.search&&!t.hash&&t.pathname==="/"&&/(^|[.-])int([.-]|$)/.test(t.hostname)}catch{return!1}},"测试验证地址必须明确指向 int HTTPS 环境"),ice=z({version:de(1),runId:C().regex(/^[A-Za-z0-9_-]{1,128}$/),status:de("passed"),exitCode:de(0),result:z({version:de(1),runId:C().regex(/^[A-Za-z0-9_-]{1,128}$/),checks:ge(z({name:C().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),status:de("passed"),reason:C().max(1024).optional()}).strict()).min(1).max(64)}).strict(),execution:z({image:Ya,imageID:C().min(1).max(512),engine:Ye(["codex","pi"]),podUid:C().min(1).max(512),jobUid:C().min(1).max(512)}).strict()}).strict(),l7=z({status:de("passed"),fingerprint:C().regex(/^[a-f0-9]{64}$/),checks:ge(C().regex(/^[a-z0-9-]+$/)),endpoint:sce,verifiedAt:C().refine(e=>Number.isFinite(Date.parse(e))),test:ice.optional()}).strict(),c7=z({engine:C().min(1),model:C(),effort:C(),size:C().min(1),cpu:ee().positive(),taskConcurrency:ee().int().positive()}).strict(),u7=z({version:de(1),environment:de("integration"),component:de("persona"),image:Ya,commit:AN,baseImage:Ya,pipelineCommit:AN,repository:C().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/),config:c7.optional(),verification:l7.refine(e=>e.checks.includes("persona-smoke")),test:o7.optional()}).strict().refine(e=>{if(!e.test)return e.verification.test===void 0;const t=e.verification.test;return["persona-dialogue","persona-task","persona-custom-test"].every(n=>e.verification.checks.includes(n))&&t!==void 0&&t.execution.image===e.image&&t.runId===t.result.runId&&t.result.checks.length===e.test.checks.length&&new Set(t.result.checks.map(n=>n.name)).size===e.test.checks.length&&t.result.checks.every(n=>e.test.checks.includes(n.name))},"Declared publisher acceptance requires complete candidate runtime evidence");z({version:de(1),environment:de("integration"),component:de("base"),image:Ya,commit:AN,verification:l7.refine(e=>e.checks.includes("base-smoke"))}).strict();const rg="-cloud",oce=`codex${rg}`,sg={standard:"default",fast:"priority"},ace=`claude${rg}`;function d7(e){return e==="codex"||e===oce}const h7="pi",lce=`${h7}${rg}`;function f7(e){return e===h7||e===lce}function bb(e){return typeof e=="string"&&e.length>rg.length&&e.endsWith(rg)}const p7=Ye([sg.standard,sg.fast]),m5=["tiny","small","medium","large","xlarge"],cce=Ye(m5),wb="medium",_b=[.5,1,2],uce=ee().refine(e=>_b.includes(e),"Unsupported CPU"),$N={tiny:.5,small:1,medium:2,large:2,xlarge:2},m7=z({model:C().optional(),effort:C().optional()}).strict(),Sb=z({personaId:C(),label:C(),model:C().optional(),effort:C().optional(),serviceTier:p7.optional(),public:Re(),iconKey:C().optional(),tool:C().optional(),size:C().optional(),cpu:ee().finite().optional(),taskConcurrency:ee().int().positive().optional(),cloudEngine:m7.optional(),createdAt:ee(),updatedAt:ee(),cloud:z({gatewayUrl:C().min(1),personaId:C().min(1),publishedByMe:Re().optional(),environment:Hs.optional(),expectedImage:Ya.optional(),testReleaseId:C().optional()}).strict().optional()}).strict(),dce=z({name:C().min(1),description:C().optional()}),hce=z({id:C().min(1)}),g7=z({writableRoots:ge(C()).optional(),denyRead:ge(C()).optional(),network:Re().optional()}).strict(),fce=z({permissions:z({defaultMode:C().optional(),allow:ge(C()).optional(),deny:ge(C()).optional()}).optional(),sandbox:z({enabled:Re().optional(),autoAllowBashIfSandboxed:Re().optional(),allowUnsandboxedCommands:Re().optional(),excludedCommands:ge(C()).optional(),filesystem:z({denyRead:ge(C()).optional(),allowRead:ge(C()).optional(),denyWrite:ge(C()).optional(),allowWrite:ge(C()).optional()}).optional(),network:z({allowedDomains:ge(C()).optional(),allowLocalBinding:Re().optional()}).optional()}).optional()});Sb.extend({personality:C().optional(),personalityLocal:C().optional(),personalityManaged:Re().optional(),skills:ge(dce).optional(),plugins:ge(hce).optional(),sandboxSettings:fce.nullable().optional(),codexSandbox:g7.nullable().optional()});z({slug:C().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:C().min(1),personality:C(),model:C().optional(),effort:C().optional(),serviceTier:Sb.shape.serviceTier,tool:C().optional(),public:Re().optional(),iconKey:C().optional()}).strict();z({personaId:C().min(1)});z({personaId:C().min(1),patch:z({label:C().min(1).optional(),model:C().optional(),effort:C().optional(),serviceTier:Sb.shape.serviceTier,tool:C().optional(),size:cce.optional(),cpu:uce.optional(),taskConcurrency:Sb.shape.taskConcurrency,cloudEngine:m7.optional(),personality:C().optional(),personalityLocal:C().optional(),public:Re().optional(),iconKey:C().nullable().optional(),codexSandbox:g7.optional()}).strict()}).strict();z({version:de(1),manifest:p5}).strict();const pce=["hard","soft"],x7=Ye(pce),mce=Ye(["scanning","done","failed"]),v7=z({id:C().min(1),manifest:p5,scanSessionId:C().optional(),status:mce,evidence:ge(nce).default([]),notes:ge(C()).default([]),head:C().min(1).optional(),baseKind:x7.default("hard"),base:C().min(1).optional(),startedAt:ee(),finishedAt:ee().optional(),error:C().optional()}).strict(),g5=z({id:C().min(1).optional(),environment:Hs.optional(),legacy:Re().optional(),head:C().min(1),contentHead:C().min(1),scanId:C().min(1),at:ee(),pushed:Re().optional(),runId:ee().int().positive().optional(),runAttempt:ee().int().positive().optional(),artifactId:ee().int().positive().optional(),verified:u7.optional(),config:c7.optional(),reconfigOf:C().min(1).optional(),workflowVersion:ee().int().positive().optional(),confirmation:z({fingerprint:C().regex(/^[a-f0-9]{64}$/),runId:ee().int().positive(),runAttempt:ee().int().positive(),at:ee()}).strict().optional()}).strict(),gce=["prepared","main-pushed","dispatching","dispatched","completed","failed"],x5=z({id:C().min(1),releaseId:C().min(1),at:ee(),verified:u7.optional(),phase:Ye(gce),expectedMain:C().optional(),runId:ee().int().positive().optional(),runAttempt:ee().int().positive().optional(),error:C().optional()}).strict(),YP=z({channelId:C().min(1),updatedAt:ee()}).strict(),v5=z({integration:YP.nullable().optional(),production:YP.nullable().optional()}).strict();z({version:de(4),engineChannels:v5.optional(),scans:ge(v7),releases:ge(g5),promotions:ge(x5).default([])}).strict();const xce=z({url:C().min(1),branch:C().min(1),head:C().min(1),dirty:Re(),ahead:ee()}).strict(),ry=z({env:C().min(1),setAt:ee().optional()}).strict(),LN={baseUrl:"CLAWD_ENGINE_BASE_URL",apiKey:"CLAWD_ENGINE_API_KEY"},vce="模型订阅只写进去一半——重填或改回平台默认";function kb(e){if(!e)return;const t=r=>e.some(s=>s.env===r&&s.setAt!==void 0),n=[LN.baseUrl,LN.apiKey].filter(t).length;return n===2?"own":n===0?"platform":"partial"}const yce=["pending","running","done","failed","waiting","skipped"],bce=Ye(yce),mo="verify",dm=["build","smoke","deploy",mo],wce=Ye(dm),_ce=z({key:wce,status:bce,url:C().optional(),jobId:ee().optional(),startedAt:ee().optional(),completedAt:ee().optional()}).strict(),sy=z({runId:ee(),headSha:C().min(1),status:Ye(["queued","running","completed"]),htmlUrl:C().min(1),jobs:ge(_ce),environment:Hs.optional(),branch:C().optional(),event:C().optional(),runAttempt:ee().int().positive().optional(),conclusion:Ye(["success","failure"]).optional(),promotionId:C().optional()}).strict();function y7(e,t){return t&&e.head===t.head?t.contentHead:e.head}function lw(e,t,n){return!e||!t||e.status!=="done"?!1:e.head===y7(t,n)&&!t.dirty}function b7(e,t,n){return!e||!t||e.status!=="done"||!e.head?!1:e.head!==y7(t,n)}function XP(e,t,n){return lw(e,t,n)||b7(e,t,n)}function Sce(e,t){return!t||!e.head?!1:t.contentHead===e.head||t.at>=e.startedAt}const w7=["codex","pi","claude"];function ol(e){return w7.includes(e||"claude")}const _7={codex:"0.157.1",pi:"0.85.1",claude:"0.3.296"},kce="2.1.296";function Cce(e,t){if(!e||!ol(e)||!t)return null;const n=e==="claude"?kce:_7[e];return n===t?null:{tool:e,cloud:n,local:t}}function S7(e){const t=e.tool||"claude",n=t==="claude"?e.cloudEngine??{}:e;return{tool:t,model:n.model??"",effort:n.effort??""}}const nk=z({runId:ee(),status:sy.shape.status,conclusion:Ye(["success","failure"]).optional(),htmlUrl:C().min(1)}).strict(),k7=z({personaId:C().min(1),engineChannels:v5.optional(),github:Vle.optional(),publisherFeishuAuth:z({integration:z({connected:Re(),authUrl:C().optional(),error:C().optional()}).strict(),production:z({connected:Re(),authUrl:C().optional(),error:C().optional()}).strict()}).strict().optional(),repo:xce.optional(),scans:ge(v7).default([]),releases:ge(g5).default([]),promotions:ge(x5).optional(),targets:z({integration:z({run:sy.optional(),secrets:ge(ry).optional(),online:Re().optional(),image:Ya.optional(),unpublish:nk.optional()}).strict().optional(),production:z({run:sy.optional(),secrets:ge(ry).optional(),online:Re().optional(),image:Ya.optional(),unpublish:nk.optional()}).strict().optional()}).strict().optional(),secrets:ge(ry).optional(),run:sy.optional(),online:Re().optional(),unpublish:nk.optional(),historyError:C().optional()}).strict();z({before:ee().nullable()}).strict();k7.pick({personaId:!0,github:!0,repo:!0,scans:!0,releases:!0,promotions:!0,engineChannels:!0,historyError:!0});k7.pick({scans:!0});z({environment:Hs,secrets:ge(ry).optional(),engineChannels:v5.optional()}).strict();const Nce=2,jce=4,Ece=["engine","model","effort","size","cpu","taskConcurrency"];function Ice(e){const{tool:t,model:n,effort:r}=S7(e),s=(e.size??"").trim()||wb,i=e.cpu??$N[s]??$N[wb];return{engine:t,model:n.trim(),effort:r.trim(),size:s,cpu:i,taskConcurrency:e.taskConcurrency??jce}}function C7(e,t){return!e||!t?null:Ece.filter(n=>e[n]!==t[n])}z({sha:C().min(1),actionsUrl:C().min(1),releaseId:C().optional()}).strict();const qg=z({personaId:C().min(1)}).strict();qg.extend({releaseHead:C().min(1).optional(),releaseId:C().min(1).optional(),environment:Hs.optional()}).strict();qg.extend({scanBase:x7.optional()}).strict();qg.extend({scanId:C().min(1)}).strict();qg.extend({releaseId:C().min(1)}).strict();qg.extend({environment:Hs.default("production")}).strict();z({confirmation:g5.shape.confirmation.unwrap()}).strict();z({promotion:x5}).strict();z({personaId:C().min(1),expectedImage:Ya}).strict();z({personaId:C().min(1),scanId:C().min(1),patch:z({manifest:p5.optional(),connector:n7.optional()}).strict()}).strict();z({personaId:C().min(1),environment:Hs.default("production"),scanId:C().min(1),name:C().min(1),values:Gi(C(),C())}).strict();z({personaId:C().min(1),environment:Hs.default("production"),channelId:C().min(1).optional(),auth:z({baseUrl:C(),apiKey:C()}).strict().nullable().optional()}).strict().refine(e=>e.channelId!==void 0||e.auth!==void 0,{message:"Either channelId or auth must be provided"});z({personaId:C().min(1),environment:Hs.default("production"),releaseId:C().optional(),jobId:ee()}).strict();z({personaId:C().min(1),kind:Ye(["package","secret","connector"]),item:Gi(C(),Ua()),evidence:z({reason:C().min(1),file:C().min(1),quote:C().min(1)})}).strict();z({personaId:C().min(1),notes:ge(C()).default([])}).strict();const N7="ottin4ttc";function Rh(e){return e.trim().replace(/^git@[^:]+:/,"").replace(/^https?:\/\/[^/]+\//,"").replace(/\.git$/,"")}z({environment:Hs.default("production")}).strict();const Tce="LOGIN_EXPIRED",Rce=z({deviceId:C().min(1),name:C().min(1),url:C().min(1)});z({type:de("device:list:ok"),devices:ge(Rce)});z({deviceId:C().min(1),url:C().min(1).optional(),name:C().optional()});z({type:de("device:connect:ok"),deviceId:C(),name:C(),url:C()});const j7=z({ownerId:C().min(1),provider:C().min(1),displayName:C().min(1),avatarUrl:C().optional(),unionId:C().optional()});z({type:de("auth:login:start:ok"),environment:Hs.optional(),authUrl:C().min(1),state:C().min(1)});z({type:de("auth:getIdentity:ok"),identity:j7.nullable(),deviceId:C().min(1)});z({type:de("auth:logout:ok")});const E7=C().nullable();z({type:de("auth:apiKey:get:ok"),apiKey:C().nullable(),createdAt:C().nullable(),gatewayUrl:E7});z({type:de("auth:apiKey:regenerate:ok"),apiKey:C().min(1),createdAt:C().min(1),gatewayUrl:E7});z({type:de("auth:apiKey:revoke:ok"),revoked:Re()});z({type:de("auth:login:done"),environment:Hs.optional(),identity:j7});z({type:de("auth:login:failed"),environment:Hs.optional(),reason:C()});z({deviceId:C().min(1),remoteAccessAllowed:Re()}).strict();z({type:de("contact:setRemoteAccess:ok"),deviceId:C().min(1),remoteAccessAllowed:Re()}).strict();z({type:de("contact:remote-access-updated"),deviceId:C().min(1),remoteAccessAllowed:Re()}).strict();z({personaId:C().min(1)}).strict();const Mce=["connected","missing","reauth"],Pce=["link","fill"],Oce=z({name:u5,id:C().min(1),kind:Ye(J9),runner:Ye(e7),auth:Ye(d5),status:Ye(Mce),action:Ye(Pce),authUrl:C().optional(),fields:ge(h5)}).strict();z({connectors:ge(Oce)}).strict();z({personaId:C().min(1),name:u5,values:Gi(h5,C().min(1))}).strict();const Dce=z({deviceId:C().min(1),ownerId:C().min(1),provider:C().min(1),displayName:C(),remoteUrl:C().min(1),connectToken:C(),grants:ge(c5),addedAt:ee().int().nonnegative(),pinnedAt:ee().int().nullable().default(null),remoteAccessAllowed:Re().default(!1),note:C().default("")}).strict(),I7=Dce;z({deviceId:C().min(1)}).strict();z({type:de("contact:remove:ok"),deviceId:C().min(1)}).strict();z({type:de("contact:list:ok"),contacts:ge(I7)}).strict();z({type:de("contact:added"),contact:I7}).strict();z({type:de("contact:removed"),deviceId:C().min(1)}).strict();z({deviceId:C().min(1),pinned:Re()}).strict();z({deviceId:C().min(1),note:C()}).strict();z({type:de("contact:setNote:ok"),deviceId:C().min(1),note:C()}).strict();z({type:de("contact:pin:ok"),deviceId:C().min(1),pinnedAt:ee().int().nullable()}).strict();z({type:de("contact:pinned"),deviceId:C().min(1),pinnedAt:ee().int().nullable()}).strict();const y5=Bs("kind",[z({kind:de("success"),text:C(),brief:C().optional(),filePaths:ge(C()).optional()}),z({kind:de("failure"),reason:C(),brief:C().optional()})]);z({targetPersona:C().min(1).optional(),dispatchId:C().min(1).optional(),prompt:C(),brief:C().optional(),targetDeviceId:C().min(1).optional(),model:C().min(1).optional(),tool:C().min(1).optional(),sessionLabel:C().min(1).max(60).optional(),meta:Gi(Ua()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});z({dispatchId:C().min(1),outcome:y5});const Ace=["running","completed","failed"],b5=Ye(Ace),$ce=z({dispatchId:C().min(1),sourceSessionId:C().min(1),sourcePersonaId:C().min(1).optional(),targetPersonaId:C().min(1),targetDeviceId:C().min(1).optional(),workerSessionId:C().min(1).optional(),taskText:C(),taskBrief:C().optional(),round:ee().int().positive().optional(),status:b5,outcome:y5.optional(),meta:Gi(Ua()).optional(),createdAt:C().min(1),completedAt:C().min(1).optional(),deliveredAt:C().min(1).optional()});z({sourceSessionId:C().min(1).optional(),relatedSessionId:C().min(1).optional()});z({records:ge($ce)});z({dispatchId:C().min(1)});z({type:de("personaDispatch:get:ok"),status:b5,outcome:y5.optional()});const Lce=/^[a-z0-9][a-z0-9-]*$/;Ye(["stopped","starting","running","crashed","invalid"]);const Bce=new Set(["localhost","127.0.0.1"]);function Fce(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&Bce.has(t.hostname))}const Bv=z({id:C().regex(Lce),name:C().min(1),version:C().min(1),apiVersion:de("1"),runtime:z({startCommand:C().min(1)}).passthrough().optional(),entry:z({url:C().url().refine(Fce,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var s;const n=!!e.runtime,r=!!((s=e.entry)!=null&&s.url);n&&r&&t.addIssue({code:ye.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:ye.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),zce=Bs("kind",[z({kind:de("local"),port:ee().int().min(1).max(65535)}),z({kind:de("hosted"),url:C().url()})]);Bs("state",[z({extId:C(),manifest:Bv,state:de("stopped")}),z({extId:C(),manifest:Bv,state:de("starting")}),z({extId:C(),manifest:Bv,state:de("running"),target:zce}),z({extId:C(),manifest:Bv,state:de("crashed")}),z({extId:C(),manifest:Ua().nullable(),state:de("invalid"),invalidReason:C().min(1)})]);z({snapshotHash:C().min(1),version:C().min(1),publishedAt:ee()});const Hce=Bs("kind",[z({kind:de("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1)})]);Bs("kind",[z({kind:de("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1),snapshotHash:C().min(1)})]);z({extId:C().min(1),name:C().min(1),version:C().min(1),contentHash:C().min(1),publishedAt:ee()});const Uce=Bs("kind",[z({kind:de("clean")}),z({kind:de("ready-new-version"),fromVersion:C().min(1),toVersion:C().min(1)}),z({kind:de("error-same-hash"),version:C().min(1)}),z({kind:de("error-version-not-bumped"),localVersion:C().min(1),publishedVersion:C().min(1)}),z({kind:de("error-version-regression"),localVersion:C().min(1),publishedVersion:C().min(1)})]);function Wce(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return(t>>>0).toString(16).padStart(8,"0")}function w5(e,t){return`${e}-${Wce(t)}`}function _5(e){if(typeof e!="string")return{ok:!1,reason:"version must be a string"};const t=e.split(".");if(t.length!==3)return{ok:!1,reason:`"${e}" — only MAJOR.MINOR.PATCH allowed`};for(const n of t)if(!/^\d+$/.test(n))return{ok:!1,reason:`"${e}" — only numeric segments allowed`};return{ok:!0}}function T7(e,t){const n=ZP(e),r=ZP(t);for(let s=0;s<3;s++){if(n[s]<r[s])return-1;if(n[s]>r[s])return 1}return 0}function ZP(e){const t=_5(e);if(!t.ok)throw new Error(t.reason);const[n,r,s]=e.split(".").map(i=>parseInt(i,10));return[n,r,s]}z({localManifest:z({name:C().min(1),version:C().min(1),contentHash:C().min(1)}),publishState:Bs("kind",[z({kind:de("unpublished")}),z({kind:de("published"),version:C().min(1),contentHash:C().min(1),publishedAt:ee()})]),check:Uce});z({extId:C().min(1),newVersion:C().min(1).nullish()});z({extId:C().min(1)});z({extId:C().min(1),snapshotHash:C().min(1)});z({channelRef:Hce,snapshotHash:C().min(1),zipBase64:C().min(1)});z({id:C().min(1),peerDeviceId:C().min(1),senderDeviceId:C().min(1),text:C().min(1),createdAt:ee().int().nonnegative(),readBy:Gi(C().min(1),ee().int().positive()).default({}),origin:z({kind:de("persona"),personaId:C().min(1)}).optional()}).strict();z({peerDeviceId:C().min(1).optional(),id:C().min(1),text:C().min(1),createdAt:ee().int().nonnegative(),origin:z({kind:de("persona"),personaId:C().min(1)}).optional()}).strict();z({peerDeviceId:C().min(1),sinceCreatedAt:ee().int().nonnegative().optional()}).strict();z({peerDeviceId:C().min(1),upToCreatedAt:ee().int().nonnegative()}).strict();z({peerDeviceId:C().min(1).optional(),text:C().min(1)});z({peerDeviceId:C().min(1).optional(),command:C().min(1),timeoutMs:ee().int().positive().optional()}).strict();z({type:de("peerExec:run:ok"),stdout:C(),stderr:C(),exitCode:ee().int().nullable(),timedOut:Re(),stdoutTruncated:Re(),stderrTruncated:Re()}).strict();const R7=Bs("kind",[z({kind:de("at"),at:C().min(1)}),z({kind:de("every"),everyMs:ee().int().positive(),anchorMs:ee().int().nonnegative().optional()}),z({kind:de("cron"),expr:C().min(1),tz:C().min(1).optional()})]),Kg=C().trim().min(1);z({personaId:Kg,name:C().min(1),schedule:R7,prompt:C().min(1),targetPersona:C().min(1).optional(),timeoutMs:ee().int().positive().optional()});z({personaId:Kg,onlyMine:Re().optional()});z({personaId:Kg,shiftId:C().min(1)});const Vce=z({name:C().min(1).optional(),schedule:R7.optional(),prompt:C().min(1).optional(),targetPersona:C().min(1).optional(),timeoutMs:ee().int().positive().optional(),enabled:Re().optional()});z({personaId:Kg,shiftId:C().min(1),patch:Vce});z({personaId:Kg,shiftId:C().min(1),limit:ee().int().positive().optional()});const $i="persona-master",S5=z({personaId:C().min(1),deviceId:C().min(1).optional()}),M7=z({id:C().min(1),name:C().min(1),memberPersonas:ge(S5),memberContactDeviceIds:ge(C().min(1)),createdAt:C().min(1),updatedAt:C().min(1)}),P7=C().trim().min(1);z({name:P7,memberPersonas:ge(S5).default([]),memberContactDeviceIds:ge(C().min(1)).default([])});z({channelId:C().min(1),name:P7.optional(),memberPersonas:ge(S5).optional(),memberContactDeviceIds:ge(C().min(1)).optional()});z({channelId:C().min(1)});z({channels:ge(M7)});z({channel:M7});z({ok:de(!0),removedTopics:ee().int().min(0)});const ar=C().trim().min(1),k5=["master-confirmed","owner-needed"],C5=["open","resolved"],qce=k5[0],O7=k5[1],D7=C5[0],Kce=C5[1],Gce=Ye(k5),Yce=Ye(C5),Xce=z({id:ar.optional(),resolves:ar.optional(),type:Gce,status:Yce,question:ar,recommendation:ar}).superRefine((e,t)=>{e.type===qce&&e.status!==Kce&&t.addIssue({code:ye.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),Zce=["planning","running","done"],Qce=Ye(Zce),A7=z({at:C().min(1),actor:C().min(1),action:C().min(1),target:C().optional(),reason:C().min(1),artifacts:ge(ar).optional(),decision:Xce.optional()}),Jce=z({rejectCount:ee().int().min(0),accepted:Re().default(!1),ordinal:ee().int().min(1).optional(),overrideCount:ee().int().min(0).optional()}),N5=z({id:C().min(1),channelId:C().min(1),title:C(),masterSessionId:C().min(1),goal:C(),boundaries:C(),acceptanceCriteria:ge(C()),activity:ge(A7),lineMeta:Gi(Jce),nextLineOrdinal:ee().int().min(1).optional(),state:Qce,createdAt:C().min(1),updatedAt:C().min(1)}),eue=z({lineId:C().min(1),dispatchId:C().min(1),workerSessionId:C().optional(),assignee:C().min(1),focus:C(),status:b5,acceptance:ge(C()),rejectCount:ee().int().min(0),accepted:Re(),ordinal:ee().int().min(1).nullable()});z({channelId:C().min(1)});z({topicId:C().min(1).optional(),sessionId:C().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});z({channelId:C().min(1),title:ar.optional()});z({topicId:C().min(1),title:ar.optional(),goal:ar,boundaries:C(),acceptanceCriteria:ge(ar).min(1)});z({topicId:C().min(1),action:ar,target:ar.optional(),reason:ar,artifacts:ge(ar).optional(),decision:A7.shape.decision});z({topicId:C().min(1),lineId:ar,reason:ar});z({topicId:C().min(1),lineId:ar,reason:ar,artifacts:ge(ar).optional(),watcherVerdict:Ye(["pass","fail"]),overrideReason:ar.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});z({topicId:C().min(1),state:Ye(["done"])});z({topicId:C().min(1),title:ar});z({topicId:C().min(1)});const tue=N5.extend({lineCount:ee().int().min(0)});z({topics:ge(tue)});z({topic:N5,lines:ge(eue)});z({topicId:C().min(1),masterSessionId:C().min(1)});z({rejectCount:ee().int().min(1),needsOwnerAttention:Re()});z({acceptedLines:ee().int().min(1),totalLines:ee().int().min(1),allAccepted:Re(),overrides:ee().int().min(0),needsOwnerAttention:Re()});z({topic:N5});z({ok:de(!0),removedMasterSessionId:C().min(1).nullable(),removedWorkerSessionIds:ge(C().min(1))});const nue=["ask","allow","deny"],$7=Ye(nue),rue=z({id:C().min(1),desc:C().min(1),action:$7});z({rules:ge(rue)});z({ruleId:C().min(1)});z({action:$7,desc:C(),source:C().min(1)});const sue=["created","review-requested"],L7=/^[A-Za-z0-9._-]+$/,ff=C().min(1).regex(L7),pf=C().min(1).regex(L7),Gg=ee().int().positive();z({role:Ye(sue)});z({owner:ff,repo:pf,number:Gg});z({owner:ff,repo:pf,number:Gg,expectedHeadSha:C().min(1)});z({owner:ff,repo:pf,number:Gg,body:C().min(1)});z({owner:ff,repo:pf,number:Gg,ready:Re()});z({owner:ff,repo:pf});z({owner:ff,repo:pf,number:Gg,reviewers:ge(C().min(1)).min(1)});z({personaId:C().min(1)});z({personaId:C().min(1)});const iue=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],oue=Ye(iue);z({personaId:C().min(1),appId:C().min(1),appSecret:C().min(1),botName:C().min(1).optional()});const aue=z({chatId:C().min(1),chatName:C().optional(),lastActiveAt:ee().int().optional()}),lue=z({state:Ye(["unbound","provisioning","bound","broken"]),appId:C().optional(),botName:C().optional(),brokenReason:C().optional(),qrUrl:C().optional(),provisionId:C().optional(),errorReason:oue.optional(),groups:ge(aue),needsUpgrade:Re().optional(),upgradeQrUrl:C().optional()});lue.extend({personaId:C().min(1)});z({});z({onboardingCompletedAt:ee()});const Mh=["claude","codex","pi"];z({});z({tools:ge(z({id:Ye(Mh),available:Re(),version:C().optional(),path:C().optional()}))});z({});const cue=z({tool:Ye(Mh),cwd:C(),toolSessionId:C(),label:C().optional(),createdAt:C(),updatedAt:C(),turns:ee()});z({candidates:ge(cue)});z({});z({registered:Re()});z({tool:Ye(Mh)});const QP=z({usedPercent:ee(),windowDurationMins:ee().optional(),resetsAt:ee().optional()}).strict(),uue=Bs("kind",[z({kind:de("claude"),loggedIn:Re(),authMethod:C().optional(),apiProvider:C().optional(),apiKeySource:C().optional(),email:C().optional(),orgName:C().optional(),subscriptionType:C().optional()}).strict(),z({kind:de("codex"),login:Bs("type",[z({type:de("none")}).strict(),z({type:de("apiKey")}).strict(),z({type:de("chatgpt"),email:C(),planType:C()}).strict()]),provider:z({name:C(),baseUrl:C().optional()}).strict(),rateLimits:z({primary:QP.optional(),secondary:QP.optional()}).strict().optional()}).strict(),z({kind:de("pi"),providers:ge(z({id:C(),modelCount:ee(),credential:Ye(["api_key","oauth"]).optional(),oauthExpiresAt:ee().optional()}).strict())}).strict()]);z({tool:Ye(Mh),installed:Re(),version:C().optional(),path:C().optional(),account:uue.optional(),error:C().optional(),modelsLoadedAt:ee().optional()}).strict();const j5="https://cpa-portal-d417.app.clawos.chat";z({apiKey:C().min(1)}).strict();z({ok:de(!0)}).strict();const B7=["cloud-persona-metrics","cloud-persona-conversations"],due=Ye(B7);z({page:due}).strict();z({url:C(),expiresAt:ee().int()}).strict();const F7=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","session:queue","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","contact:note-updated","org-mesh:progress","channel:changed","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","larkBot:state"],hue="cloud_history_refresh",E5=["idle","running","running-idle","stopped","error","observing"],fue=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function cw(e){return e==="dispatch-task"||e==="dispatch-result"}const pue=["builtin","global","project","plugin"],mue=["builtin","global","project","policy","plugin"],z7=Ye(["owner","guest"]);z({id:C().min(1),kind:z7,displayName:C(),feishuUnionId:C().optional()}).strict();const gue=z({did:C().min(1),displayName:C(),feishuUnionId:C().optional(),principal:z7}).strict(),xue=Ye(E5),vue=z({inputTokens:ee().int().nonnegative(),outputTokens:ee().int().nonnegative(),cacheReadTokens:ee().int().nonnegative().optional(),cacheCreateTokens:ee().int().nonnegative().optional()}),H7={gitBranch:C().optional(),resolvedModel:C().optional(),resolvedEffort:C().optional(),contextUsage:vue.optional(),contextWindowSize:ee().int().positive().optional(),aiLabel:C().optional()},yue=z(H7),U7=z({value:C(),label:C(),description:C().optional()}),bue=z({id:C().min(1),label:C().min(1),description:C().optional(),contextWindowSize:ee().int().positive(),default:Re().optional(),efforts:ge(U7).optional(),defaultEffort:C().optional(),group:C().optional()}),wue=z({id:C().min(1),label:C().min(1),description:C().optional()}),_ue=z({name:C().min(1),type:Ye(["string","select","toggle"]),label:C().min(1),description:C().optional(),options:ge(U7).optional(),default:Ua().optional(),scope:Ye(["core","tool-specific"])});z({tool:C().min(1),refresh:Re().optional()});const Sue=z({rewind:Re(),subagents:Re(),tui:Re(),observe:Re(),fileSharing:Re(),fork:Re()});z({tool:C().min(1),toolSessionIdLabel:C().optional(),models:ge(bue),permissionModes:ge(wue),configSchema:ge(_ue),features:Sue});const kue=z({tool:C().min(1),pattern:C().min(1),createdAt:C().min(1).optional()});z({cloudEnvironment:Hs.optional(),cloudExpectedImage:Ya.optional(),testReleaseId:C().optional(),sessionId:C().min(1),cloudExecutionId:C().min(1).optional(),cloudConversationId:C().min(1).optional(),cloudWorkspace:l5.optional(),cloudPendingTurns:ge(z({id:C().min(1),text:C(),prepared:Re().optional()})).optional(),cloudBranchIntent:ng.optional(),cloudGatewaySessionId:C().min(1).optional(),cloudPendingCommand:z({id:C().min(1),text:C(),prepared:Re().optional()}).optional(),cwd:C().min(1),tool:de("claude").or(C().min(1)).default("claude"),toolSessionId:C().optional(),label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),serviceTier:C().optional(),...H7,aiLabelGeneratedAt:C().optional(),permissionRules:ge(kue).optional(),pinnedAt:ee().int().nonnegative().nullable().optional(),archivedAt:ee().int().nonnegative().nullable().optional(),pinSortOrder:ee().int().nullable().optional(),unreadAt:C().min(1).nullable().optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Re().optional(),deployId:C().min(1).optional(),ownerPersonaId:C().min(1).optional(),projectPath:C().min(1).optional(),chatId:C().min(1).optional(),creatorPrincipalId:C().min(1).optional(),creatorDisplayName:C().min(1).optional(),creatorFeishuUnionId:C().min(1).optional(),originOwnerPrincipalId:C().min(1).optional(),originOwnerPersonaId:C().min(1).optional(),dispatchedFromSessionId:C().min(1).optional(),shiftFiredFromSessionId:C().min(1).optional(),larkChatId:C().min(1).optional(),larkChatName:C().min(1).optional(),larkChatType:Ye(["p2p","group"]).optional(),createdAt:C().min(1),updatedAt:C().min(1)});const Ns={turnId:C().min(1).optional(),seq:ee().int().nonnegative().optional(),ts:C().optional(),uuid:C().optional()},Cue=Ye(fue),Nue=z({readCount:ee().int().nonnegative().optional(),searchCount:ee().int().nonnegative().optional(),bashCount:ee().int().nonnegative().optional(),editFileCount:ee().int().nonnegative().optional(),linesAdded:ee().int().nonnegative().optional(),linesRemoved:ee().int().nonnegative().optional(),otherToolCount:ee().int().nonnegative().optional()}),jue=z({oldStart:ee().int().nonnegative(),oldLines:ee().int().nonnegative(),newStart:ee().int().nonnegative(),newLines:ee().int().nonnegative(),lines:ge(C())}),Eue=z({agentId:C().optional(),agentType:C().optional(),status:C().optional(),prompt:C().optional(),filePath:C().optional(),structuredPatch:ge(jue).optional(),stats:z({durationMs:ee().int().nonnegative().optional(),tokens:ee().int().nonnegative().optional(),toolUseCount:ee().int().nonnegative().optional(),toolStats:Nue.optional()}).optional()}),Iue=z({path:C(),content:C(),mtimeMs:ee().optional()}),Tue=z({label:C().min(1),description:C().optional()}),W7=z({question:C().min(1),multiSelect:Re(),options:ge(Tue).min(1)}),Rue=["completed","interrupted"];Bs("kind",[z({...Ns,kind:de("session_init"),toolSessionId:C().optional()}),z({...Ns,kind:de("thinking"),text:C(),partialId:C().optional()}),z({...Ns,kind:de("text"),text:C(),partialId:C().optional()}),z({...Ns,kind:de("user_text"),text:C(),meta:Cue.optional(),taskId:C().optional(),parentToolUseId:C().optional(),sender:gue.optional()}),z({...Ns,kind:de("tool_call"),toolUseId:C(),tool:C(),toolKind:C().optional(),input:Ua()}),z({...Ns,kind:de("tool_result"),toolUseId:C(),output:Ua().optional(),error:C().optional(),toolResultExtra:Eue.optional(),sourceToolAssistantUUID:C().optional(),askQuestionAnswers:Gi(C(),C()).optional()}),z({...Ns,kind:de("attachment_memories"),memories:ge(Iue)}),z({...Ns,kind:de("permission_request"),requestId:C(),tool:C(),input:Ua(),toolUseId:C().optional()}),z({...Ns,kind:de("ask_user_question"),toolUseId:C(),questions:ge(W7)}),z({...Ns,kind:de("turn_end"),durationMs:ee().int().nonnegative().optional(),reason:Ye(Rue).optional(),turnId:C().min(1).optional()}),z({...Ns,kind:de("subagent_progress"),toolUseId:C(),agentId:C(),status:Ye(["started","running","completed","failed"]),description:C().optional(),lastToolName:C().optional(),prompt:C().optional(),stats:z({durationMs:ee().int().nonnegative().optional(),tokens:ee().int().nonnegative().optional(),toolUseCount:ee().int().nonnegative().optional()}).optional()}),z({...Ns,kind:de("error"),message:C()}),z({...Ns,kind:de("meta_update"),patch:yue}),z({...Ns,kind:de("meta-text"),text:C(),metaSource:Ye(["cc","owner"]).optional()})]);z({cwd:C().min(1).optional(),tool:C().optional(),label:C().optional(),aiLabel:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),serviceTier:p7.optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Re().optional(),ownerPersonaId:C().min(1).optional(),projectPath:C().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});z({path:C().min(1),name:C().min(1),createdAt:C().datetime(),pinnedAt:ee().optional()});z({path:C().min(1),pinnedAt:ee().nullable()});z({path:C().min(1)});z({path:C().min(1).optional(),name:C().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});z({cwd:C().min(1),tool:C().min(1),toolSessionId:C().min(1),label:C().optional(),aiLabel:C().optional(),iconKey:C().optional(),createdAt:C().datetime(),updatedAt:C().datetime(),ownerPersonaId:C().min(1).optional()});z({originOnly:Re().optional(),ownerPersonaId:C().min(1).optional(),limit:ee().int().positive().optional(),offset:ee().int().nonnegative().optional()});z({sessionId:C().min(1)});z({sessionId:C().min(1),patch:z({label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),cwd:C().optional(),iconKey:C().optional(),ephemeral:de(!1).optional()})});z({id:C().min(1),text:C(),queuedAt:ee(),senderDisplayName:C().optional()});z({sessionId:C().min(1),text:C(),queueWhileRunning:Re().optional()});z({sessionId:C().min(1),id:C().min(1).optional()});z({sessionId:C().min(1),userMessageId:C().min(1),dryRun:Re().optional()});z({canRewind:Re(),error:C().optional(),filesChanged:ge(C()).optional(),insertions:ee().int().nonnegative().optional(),deletions:ee().int().nonnegative().optional()});z({sessionId:C().min(1),userMessageId:C().min(1)});const Mue=z({oldStart:ee().int().nonnegative(),oldLines:ee().int().nonnegative(),newStart:ee().int().nonnegative(),newLines:ee().int().nonnegative(),lines:ge(C())}),Pue=z({filePath:C().min(1),hunks:ge(Mue),insertions:ee().int().nonnegative(),deletions:ee().int().nonnegative(),status:Ye(["modified","added","deleted"]).optional()});z({canRewind:Re(),error:C().optional(),files:ge(Pue),totalInsertions:ee().int().nonnegative(),totalDeletions:ee().int().nonnegative()});z({userMessageIds:ge(C())});z({sessionId:C().min(1),toolSessionId:C().min(1)});z({cwd:C().min(1),toolSessionId:C().min(1),messageUuid:C().min(1).optional(),turnId:C().min(1).optional(),sourceSessionId:C().min(1).optional(),targetCwd:C().min(1).optional()}).refine(e=>!!(e.messageUuid||e.turnId),"messageUuid or turnId required");z({forkedToolSessionId:C().min(1),forkedFilePath:C().min(1)});z({sessionId:C().min(1),toolSessionId:C().min(1),jsonlPath:C().optional()});z({sessionId:C().min(1),afterSeq:ee().int().min(-1)});z({sessionId:C().min(1),permissionRequestId:C().min(1),allow:Re(),permanent:Re().optional(),pattern:C().optional()});z({projectPath:C().min(1)});z({sessionId:C().min(1),limit:ee().int().positive().max(5e3).optional(),offset:ee().int().nonnegative().optional(),snapshotId:C().uuid().optional(),slim:Re().optional(),view:Ye(["turns","items"]).optional(),cursor:C().min(1).max(16384).optional(),turnId:C().min(1).max(256).optional()}).superRefine((e,t)=>{e.view==="items"&&!e.turnId&&t.addIssue({code:ye.custom,path:["turnId"],message:"items requires turnId"}),e.view&&(e.offset!==void 0||e.slim!==void 0)&&t.addIssue({code:ye.custom,message:"native views do not accept offset or slim"}),!e.view&&(e.cursor!==void 0||e.turnId!==void 0)&&t.addIssue({code:ye.custom,message:"cursor and turnId require a native view"}),e.view==="turns"&&e.turnId!==void 0&&t.addIssue({code:ye.custom,path:["turnId"],message:"turns does not accept turnId"}),e.view&&e.limit!==void 0&&e.limit>100&&t.addIssue({code:ye.custom,path:["limit"],message:"native page limit is 100"})});z({cwd:C().min(1),toolSessionId:C().min(1)});z({cwd:C().min(1),toolSessionId:C().min(1),subagentId:C().min(1)});z({cwd:C().min(1).optional(),path:C().optional(),showHidden:Re().optional()});z({cwd:C().min(1),path:C().min(1)});z({cwd:C().min(1),tool:C().optional()});z({name:C().min(1),source:Ye(pue),path:C().optional(),description:C().optional(),plugin:C().optional()});const Oue=z({name:C().min(1),source:Ye(mue),path:C().optional(),description:C().optional(),whenToUse:C().optional(),plugin:C().optional()});z({cwd:C().min(1),tool:C().optional()});z({agents:ge(Oue)});z({sessionId:C().optional()});z({sessionId:C().min(1).optional()});z({sessionId:C().min(1),pinned:Re()});z({sessionId:C().min(1),archived:Re()});z({query:C().min(1),sessionIds:ge(C().min(1)),limit:ee().int().positive().max(50).optional()});const Due=z({sessionId:C().min(1),snippet:C()});z({type:de("session:searchContent"),matches:ge(Due)});z({type:de("peerSession:upsert:ok")});z({sessionId:C().min(1)});z({type:de("peerSession:remove:ok")});z({orderedIds:ge(C().min(1)).min(1)});z({cwd:C().min(1)});z({isGitRoot:Re(),gitRoot:C().nullable()});z({cwd:C().min(1)});z({branch:C().nullable()});z({cwd:C().min(1)});z({branches:ge(C()),head:C().nullable()});const Aue=z({cwd:C().min(1),updatedAt:C().min(1)});z({dirs:ge(Aue)});z({type:de("session:question"),sessionId:C().min(1),toolUseId:C().min(1),requestId:C().min(1),questions:ge(W7).min(1)});z({type:de("session:question:cleared"),sessionId:C().min(1),toolUseId:C().min(1),answers:Gi(C(),C()).optional()});z({sessionId:C().min(1),toolUseId:C().min(1),answers:Gi(C(),C())});z({ok:de(!0)});z({sessionId:C().min(1),toolUseId:C().min(1)});z({ok:de(!0)});const V7=z({name:C().min(1),version:C().min(1),instanceId:C().min(1),deviceLabel:C().transform(e=>e.trim().slice(0,64)).optional()});z({type:de("auth"),token:C().min(1),scheme:de("bearer").optional(),clientInfo:V7.optional()});z({type:de("auth:ok"),version:C().min(1).optional(),protocolVersion:ee().int().nonnegative().optional()});const $ue=z({clientId:C().min(1),connectedAt:ee().int().nonnegative(),self:Re(),clientInfo:V7.optional()});z({type:de("device:connections:ok"),connections:ge($ue)});z({type:de("tunnel:ready"),url:C().min(1),subdomain:C().min(1)});z({type:de("tunnel:exited"),code:ee().int().nullable(),subdomain:C().nullable(),url:C().nullable()});z({type:de("tunnel:unavailable"),reason:C().min(1),failedAt:C().min(1)});const Lue=z({sessionId:C().min(1),status:xue,freshSpawn:Re(),pendingPermissionRequestIds:ge(C().min(1)),pendingQuestionToolUseIds:ge(C().min(1))});z({type:de("info"),version:C(),protocolVersion:ee(),hostname:C(),os:C(),tools:ge(z({id:C(),available:Re()})),runningSessions:ge(Lue),tokenRole:Ye(Lle).optional(),isLoopback:Re().optional(),httpBaseUrl:C().optional(),httpToken:C().optional(),daemonSource:Ye(["ota","packaged"]).optional(),globalCliVersion:C().nullable().optional()});z({});z({method:C().min(1).optional()});const Bue=["allowed","conditional","denied"],Fue=Ye(Bue),zue=z({name:C().min(1),status:Fue,description:C().min(1),args:ge(z({name:C(),required:Re()})).nullable(),argsSchema:Gi(Ua()).optional(),reason:C().optional()});z({type:de("meta:methods"),methods:ge(zue)});const JP=1,Hue=z({usedBytes:ee().int().nonnegative(),sizeBytes:ee().int().positive(),measuredAt:ee().int().nonnegative()}).strict();z({volume:Hue.nullable()}).strict();const eO=25*1024*1024,I5={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/plain",".markdown":"text/plain",".csv":"text/plain",".log":"text/plain",".json":"application/json",".xml":"application/xml",".yaml":"application/yaml",".yml":"application/yaml",".html":"text/html",".conf":"text/plain",".cfg":"text/plain",".ini":"text/plain",".toml":"text/plain"},q7=new Set([...Object.values(I5),"application/x-yaml"]),K7=[...q7,"text/*",...Object.keys(I5)].join(",");function G7(e,t){const n=t.split(";",1)[0].trim().toLowerCase();if(n===""||n==="application/octet-stream"){const r=e.lastIndexOf("."),s=r>0?e.slice(r).toLowerCase():"";return I5[s]??null}return q7.has(n)||n.startsWith("text/")?n:null}const Uue=["daemon","main","renderer"],Wue=Ye(Uue),Vue=["debug","info","warn","error"],que=Ye(Vue);z({ts:ee().int(),source:Wue,level:que,msg:C(),ownerPrincipalId:C(),deviceId:C(),appVersion:C(),daemonVersion:C().optional(),os:C(),meta_json:C().optional(),sessionId:C().optional()});z({v:de(1),visitorId:C().min(1),displayName:C(),provider:C(),iat:ee(),exp:ee()});const Kue=z({visitorId:C(),displayName:C(),avatarUrl:C().optional(),provider:C(),firstSeen:ee(),lastSeen:ee()});z({visitors:ge(Kue)});z({type:de("web:open"),url:C().min(1),expiresAt:ee()});z({ticket:C().min(1)}).strict();z({token:C().min(1),expiresAt:ee()});const Gue=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,Y7=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,X7="clawd-dispatch-task",Z7="clawd-dispatch-result",tO=120;function Yue(e){if(!e)return null;const t=e.search(nO(X7)),n=e.search(nO(Z7));return t<0&&n<0?null:n<0?"task":t<0?"result":t<n?"task":"result"}function Xue(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?X7:Z7,s=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let i=s.exec(e);i!==null;i=s.exec(e))t.push({at:i.index,block:Zue(n,i[1]??"",i[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Zue(e,t,n){var u;const r=sde(t),s=BN(rde(rk(n,"detail")??n)),i=(u=rk(n,"brief"))==null?void 0:u.trim(),o=i&&i.length>0?BN(i):Que(s),l=r.round!==void 0?Number.parseInt(r.round,10):void 0,c=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&l!==void 0&&Number.isFinite(l)?{round:l}:{},...e==="result"&&(c==="success"||c==="failure")?{status:c}:{},brief:o,briefIsDerived:!(i&&i.length>0),detail:s,filePaths:nde(rk(n,"files"))}}function Que(e){const t=e.split(/\n\s*\n/).map(r=>r.trim()).find(r=>r.length>0);if(!t)return"";const n=t.replace(/\s+/g," ");return n.length>tO?`${n.slice(0,tO)}…`:n}const Jue="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",ede=new RegExp(`<\\\\(\\\\*)(/?)(${Jue})\\b`,"g");function tde(e){return BN(e)}function BN(e){return e.replace(ede,"<$1$2$3")}function rk(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function nde(e){return e?e.split(`
95
+ `,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var RP=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const mae={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},gae={motionBase:!0,motionUnit:!0},xae={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},R9=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:s}=t,i=RP(t,["override"]);let o=Object.assign(Object.assign({},r),{override:s});return o=T9(o),i&&Object.entries(i).forEach(([l,c])=>{const{theme:u}=c,d=RP(c,["theme"]);let h=d;u&&(h=R9(Object.assign(Object.assign({},o),d),{override:d},u)),o[l]=h}),o};function M9(){const{token:e,hashed:t,theme:n,override:r,cssVar:s}=G.useContext(E9),i=`${fae}-${t||""}`,o=n||j9,[l,c,u]=soe(o,[Qm,e],{salt:i,override:r,getComputedToken:R9,formatToken:T9,cssVar:s&&{prefix:s.prefix,key:s.key,unitless:mae,ignore:gae,preserve:xae}});return[o,u,t?c:"",l,s]}const vae=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),yae=e=>({[`.${e}`]:Object.assign(Object.assign({},vae()),{[`.${e} .${e}-icon`]:{display:"block"}})}),bae=(e,t)=>{const[n,r]=M9();return Moe({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>yae(e))},wae=Object.assign({},lf),{useId:MP}=wae,_ae=()=>"",Sae=typeof MP>"u"?_ae:MP;function kae(e,t,n){var r;const s=e||{},i=s.inherit===!1||!t?Object.assign(Object.assign({},ab),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:ab.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=Sae();return Z8(()=>{var l,c;if(!e)return t;const u=Object.assign({},i.components);Object.keys(e.components||{}).forEach(f=>{u[f]=Object.assign(Object.assign({},u[f]),e.components[f])});const d=`css-var-${o.replace(/:/g,"")}`,h=((l=s.cssVar)!==null&&l!==void 0?l:i.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof i.cssVar=="object"?i.cssVar:{}),typeof s.cssVar=="object"?s.cssVar:{}),{key:typeof s.cssVar=="object"&&((c=s.cssVar)===null||c===void 0?void 0:c.key)||d});return Object.assign(Object.assign(Object.assign({},i),s),{token:Object.assign(Object.assign({},i.token),s.token),components:u,cssVar:h})},[s,i],(l,c)=>l.some((u,d)=>{const h=c[d];return!Mie(u,h,!0)}))}var Cae=["children"],P9=p.createContext({});function Nae(e){var t=e.children,n=ai(e,Cae);return p.createElement(P9.Provider,{value:n},t)}var jae=function(e){Ir(n,e);var t=e9(n);function n(){return Nn(this,n),t.apply(this,arguments)}return jn(n,[{key:"render",value:function(){return this.props.children}}]),n}(p.Component);function Eae(e){var t=p.useReducer(function(l){return l+1},0),n=_t(t,2),r=n[1],s=p.useRef(e),i=wN(function(){return s.current}),o=wN(function(l){s.current=typeof l=="function"?l(s.current):l,r()});return[i,o]}var Tl="none",Dv="appear",Av="enter",$v="leave",PP="none",ho="prepare",Kd="start",Gd="active",s5="end",O9="prepared";function OP(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function Iae(e,t){var n={animationend:OP("Animation","AnimationEnd"),transitionend:OP("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var Tae=Iae(il(),typeof window<"u"?window:{}),D9={};if(il()){var Rae=document.createElement("div");D9=Rae.style}var Lv={};function A9(e){if(Lv[e])return Lv[e];var t=Tae[e];if(t)for(var n=Object.keys(t),r=n.length,s=0;s<r;s+=1){var i=n[s];if(Object.prototype.hasOwnProperty.call(t,i)&&i in D9)return Lv[e]=t[i],Lv[e]}return""}var $9=A9("animationend"),L9=A9("transitionend"),B9=!!($9&&L9),DP=$9||"animationend",AP=L9||"transitionend";function $P(e,t){if(!e)return null;if(Cn(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const Mae=function(e){var t=p.useRef();function n(s){s&&(s.removeEventListener(AP,e),s.removeEventListener(DP,e))}function r(s){t.current&&t.current!==s&&n(t.current),s&&s!==t.current&&(s.addEventListener(AP,e),s.addEventListener(DP,e),t.current=s)}return p.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var F9=il()?p.useLayoutEffect:p.useEffect;const Pae=function(){var e=p.useRef(null);function t(){Q2.cancel(e.current)}function n(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var i=Q2(function(){s<=1?r({isCanceled:function(){return i!==e.current}}):n(r,s-1)});e.current=i}return p.useEffect(function(){return function(){t()}},[]),[n,t]};var Oae=[ho,Kd,Gd,s5],Dae=[ho,O9],z9=!1,Aae=!0;function H9(e){return e===Gd||e===s5}const $ae=function(e,t,n){var r=_N(PP),s=_t(r,2),i=s[0],o=s[1],l=Pae(),c=_t(l,2),u=c[0],d=c[1];function h(){o(ho,!0)}var f=t?Dae:Oae;return F9(function(){if(i!==PP&&i!==s5){var m=f.indexOf(i),g=f[m+1],x=n(i);x===z9?o(g,!0):g&&u(function(b){function y(){b.isCanceled()||o(g,!0)}x===!0?y():Promise.resolve(x).then(y)})}},[e,i]),p.useEffect(function(){return function(){d()}},[]),[h,i]};function Lae(e,t,n,r){var s=r.motionEnter,i=s===void 0?!0:s,o=r.motionAppear,l=o===void 0?!0:o,c=r.motionLeave,u=c===void 0?!0:c,d=r.motionDeadline,h=r.motionLeaveImmediately,f=r.onAppearPrepare,m=r.onEnterPrepare,g=r.onLeavePrepare,x=r.onAppearStart,b=r.onEnterStart,y=r.onLeaveStart,v=r.onAppearActive,w=r.onEnterActive,_=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,j=r.onVisibleChanged,R=_N(),E=_t(R,2),I=E[0],M=E[1],P=Eae(Tl),D=_t(P,2),F=D[0],B=D[1],U=_N(null),$=_t(U,2),O=$[0],T=$[1],V=F(),H=p.useRef(!1),L=p.useRef(null);function q(){return n()}var K=p.useRef(!1);function X(){B(Tl),T(null,!0)}var te=wN(function(je){var Se=F();if(Se!==Tl){var ut=q();if(!(je&&!je.deadline&&je.target!==ut)){var ot=K.current,yt;Se===Dv&&ot?yt=S==null?void 0:S(ut,je):Se===Av&&ot?yt=k==null?void 0:k(ut,je):Se===$v&&ot&&(yt=N==null?void 0:N(ut,je)),ot&&yt!==!1&&X()}}}),oe=Mae(te),Q=_t(oe,1),he=Q[0],be=function(Se){switch(Se){case Dv:return Ke(Ke(Ke({},ho,f),Kd,x),Gd,v);case Av:return Ke(Ke(Ke({},ho,m),Kd,b),Gd,w);case $v:return Ke(Ke(Ke({},ho,g),Kd,y),Gd,_);default:return{}}},Z=p.useMemo(function(){return be(V)},[V]),ce=$ae(V,!e,function(je){if(je===ho){var Se=Z[ho];return Se?Se(q()):z9}if(xe in Z){var ut;T(((ut=Z[xe])===null||ut===void 0?void 0:ut.call(Z,q(),null))||null)}return xe===Gd&&V!==Tl&&(he(q()),d>0&&(clearTimeout(L.current),L.current=setTimeout(function(){te({deadline:!0})},d))),xe===O9&&X(),Aae}),se=_t(ce,2),fe=se[0],xe=se[1],Me=H9(xe);K.current=Me;var Xe=p.useRef(null);F9(function(){if(!(H.current&&Xe.current===t)){M(t);var je=H.current;H.current=!0;var Se;!je&&t&&l&&(Se=Dv),je&&t&&i&&(Se=Av),(je&&!t&&u||!je&&h&&!t&&u)&&(Se=$v);var ut=be(Se);Se&&(e||ut[ho])?(B(Se),fe()):B(Tl),Xe.current=t}},[t]),p.useEffect(function(){(V===Dv&&!l||V===Av&&!i||V===$v&&!u)&&B(Tl)},[l,i,u]),p.useEffect(function(){return function(){H.current=!1,clearTimeout(L.current)}},[]);var me=p.useRef(!1);p.useEffect(function(){I&&(me.current=!0),I!==void 0&&V===Tl&&((me.current||I)&&(j==null||j(I)),me.current=!0)},[I,V]);var Ce=O;return Z[ho]&&xe===Kd&&(Ce=Pt({transition:"none"},Ce)),[V,xe,Ce,I??t]}function Bae(e){var t=e;Cn(e)==="object"&&(t=e.transitionSupport);function n(s,i){return!!(s.motionName&&t&&i!==!1)}var r=p.forwardRef(function(s,i){var o=s.visible,l=o===void 0?!0:o,c=s.removeOnLeave,u=c===void 0?!0:c,d=s.forceRender,h=s.children,f=s.motionName,m=s.leavedClassName,g=s.eventProps,x=p.useContext(P9),b=x.motion,y=n(s,b),v=p.useRef(),w=p.useRef();function _(){try{return v.current instanceof HTMLElement?v.current:xie(w.current)}catch{return null}}var S=Lae(y,l,_,s),k=_t(S,4),N=k[0],j=k[1],R=k[2],E=k[3],I=p.useRef(E);E&&(I.current=!0);var M=p.useCallback(function($){v.current=$,wie(i,$)},[i]),P,D=Pt(Pt({},g),{},{visible:l});if(!h)P=null;else if(N===Tl)E?P=h(Pt({},D),M):!u&&I.current&&m?P=h(Pt(Pt({},D),{},{className:m}),M):d||!u&&!m?P=h(Pt(Pt({},D),{},{style:{display:"none"}}),M):P=null;else{var F;j===ho?F="prepare":H9(j)?F="active":j===Kd&&(F="start");var B=$P(f,"".concat(N,"-").concat(F));P=h(Pt(Pt({},D),{},{className:iie($P(f,N),Ke(Ke({},B,B&&F),f,typeof f=="string")),style:R}),M)}if(p.isValidElement(P)&&_ie(P)){var U=Sie(P);U||(P=p.cloneElement(P,{ref:M}))}return p.createElement(jae,{ref:w},P)});return r.displayName="CSSMotion",r}const Fae=Bae(B9);var SN="add",kN="keep",CN="remove",ek="removed";function zae(e){var t;return e&&Cn(e)==="object"&&"key"in e?t=e:t={key:e},Pt(Pt({},t),{},{key:String(t.key)})}function NN(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(zae)}function Hae(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,s=t.length,i=NN(e),o=NN(t);i.forEach(function(u){for(var d=!1,h=r;h<s;h+=1){var f=o[h];if(f.key===u.key){r<h&&(n=n.concat(o.slice(r,h).map(function(m){return Pt(Pt({},m),{},{status:SN})})),r=h),n.push(Pt(Pt({},f),{},{status:kN})),r+=1,d=!0;break}}d||n.push(Pt(Pt({},u),{},{status:CN}))}),r<s&&(n=n.concat(o.slice(r).map(function(u){return Pt(Pt({},u),{},{status:SN})})));var l={};n.forEach(function(u){var d=u.key;l[d]=(l[d]||0)+1});var c=Object.keys(l).filter(function(u){return l[u]>1});return c.forEach(function(u){n=n.filter(function(d){var h=d.key,f=d.status;return h!==u||f!==CN}),n.forEach(function(d){d.key===u&&(d.status=kN)})}),n}var Uae=["component","children","onVisibleChanged","onAllRemoved"],Wae=["status"],Vae=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function qae(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fae,n=function(r){Ir(i,r);var s=e9(i);function i(){var o;Nn(this,i);for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];return o=s.call.apply(s,[this].concat(c)),Ke(X2(o),"state",{keyEntities:[]}),Ke(X2(o),"removeKey",function(d){o.setState(function(h){var f=h.keyEntities.map(function(m){return m.key!==d?m:Pt(Pt({},m),{},{status:ek})});return{keyEntities:f}},function(){var h=o.state.keyEntities,f=h.filter(function(m){var g=m.status;return g!==ek}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return jn(i,[{key:"render",value:function(){var l=this,c=this.state.keyEntities,u=this.props,d=u.component,h=u.children,f=u.onVisibleChanged;u.onAllRemoved;var m=ai(u,Uae),g=d||p.Fragment,x={};return Vae.forEach(function(b){x[b]=m[b],delete m[b]}),delete m.keys,p.createElement(g,m,c.map(function(b,y){var v=b.status,w=ai(b,Wae),_=v===SN||v===kN;return p.createElement(t,bt({},x,{key:w.key,visible:_,eventProps:w,onVisibleChanged:function(k){f==null||f(k,{key:w.key}),k||l.removeKey(w.key)}}),function(S,k){return h(Pt(Pt({},S),{},{index:y}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(l,c){var u=l.keys,d=c.keyEntities,h=NN(u),f=Hae(d,h);return{keyEntities:f.filter(function(m){var g=d.find(function(x){var b=x.key;return m.key===b});return!(g&&g.status===ek&&m.status===CN)})}}}]),i}(p.Component);return Ke(n,"defaultProps",{component:"div"}),n}qae(B9);const LP=p.createContext(!0);function Kae(e){const t=p.useContext(LP),{children:n}=e,[,r]=M9(),{motion:s}=r,i=p.useRef(!1);return i.current||(i.current=t!==s),i.current?p.createElement(LP.Provider,{value:s},p.createElement(Nae,{motion:s},n)):n}const Gae=()=>null;var Yae=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const Xae=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let U9;function Zae(){return U9||yN}function Qae(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const Jae=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:s}=e;t!==void 0&&(U9=t),r&&Qae(r)&&aae(Zae(),r)},ele=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:s,anchor:i,form:o,locale:l,componentSize:c,direction:u,space:d,splitter:h,virtual:f,dropdownMatchSelectWidth:m,popupMatchSelectWidth:g,popupOverflow:x,legacyLocale:b,parentContext:y,iconPrefixCls:v,theme:w,componentDisabled:_,segmented:S,statistic:k,spin:N,calendar:j,carousel:R,cascader:E,collapse:I,typography:M,checkbox:P,descriptions:D,divider:F,drawer:B,skeleton:U,steps:$,image:O,layout:T,list:V,mentions:H,modal:L,progress:q,result:K,slider:X,breadcrumb:te,menu:oe,pagination:Q,input:he,textArea:be,empty:Z,badge:ce,radio:se,rate:fe,switch:xe,transfer:Me,avatar:Xe,message:me,tag:Ce,table:je,card:Se,tabs:ut,timeline:ot,timePicker:yt,upload:re,notification:ue,tree:Te,colorPicker:Ze,datePicker:at,rangePicker:et,flex:tt,wave:Lt,dropdown:wt,warning:we,tour:He,tooltip:ct,popover:Ot,popconfirm:on,floatButton:Ne,floatButtonGroup:ne,variant:De,inputNumber:Je,treeSelect:dt}=e,Nt=p.useCallback((Dt,Bt)=>{const{prefixCls:mn}=e;if(Bt)return Bt;const Tn=mn||y.getPrefixCls("");return Dt?`${Tn}-${Dt}`:Tn},[y.getPrefixCls,e.prefixCls]),St=v||y.iconPrefixCls||I9,dn=n||y.csp;bae(St,dn);const Dn=kae(w,y.theme,{prefixCls:Nt("")}),Jn={csp:dn,autoInsertSpaceInButton:r,alert:s,anchor:i,locale:l||b,direction:u,space:d,splitter:h,virtual:f,popupMatchSelectWidth:g??m,popupOverflow:x,getPrefixCls:Nt,iconPrefixCls:St,theme:Dn,segmented:S,statistic:k,spin:N,calendar:j,carousel:R,cascader:E,collapse:I,typography:M,checkbox:P,descriptions:D,divider:F,drawer:B,skeleton:U,steps:$,image:O,input:he,textArea:be,layout:T,list:V,mentions:H,modal:L,progress:q,result:K,slider:X,breadcrumb:te,menu:oe,pagination:Q,empty:Z,badge:ce,radio:se,rate:fe,switch:xe,transfer:Me,avatar:Xe,message:me,tag:Ce,table:je,card:Se,tabs:ut,timeline:ot,timePicker:yt,upload:re,notification:ue,tree:Te,colorPicker:Ze,datePicker:at,rangePicker:et,flex:tt,wave:Lt,dropdown:wt,warning:we,tour:He,tooltip:ct,popover:Ot,popconfirm:on,floatButton:Ne,floatButtonGroup:ne,variant:De,inputNumber:Je,treeSelect:dt},ht=Object.assign({},y);Object.keys(Jn).forEach(Dt=>{Jn[Dt]!==void 0&&(ht[Dt]=Jn[Dt])}),Xae.forEach(Dt=>{const Bt=e[Dt];Bt&&(ht[Dt]=Bt)}),typeof r<"u"&&(ht.button=Object.assign({autoInsertSpace:r},ht.button));const Ht=Z8(()=>ht,ht,(Dt,Bt)=>{const mn=Object.keys(Dt),Tn=Object.keys(Bt);return mn.length!==Tn.length||mn.some(Rr=>Dt[Rr]!==Bt[Rr])}),{layer:hn}=p.useContext(nw),En=p.useMemo(()=>({prefixCls:St,csp:dn,layer:hn?"antd":void 0}),[St,dn,hn]);let Mt=p.createElement(p.Fragment,null,p.createElement(Gae,{dropdownMatchSelectWidth:m}),t);const lr=p.useMemo(()=>{var Dt,Bt,mn,Tn;return Boe(((Dt=iw.Form)===null||Dt===void 0?void 0:Dt.defaultValidateMessages)||{},((mn=(Bt=Ht.locale)===null||Bt===void 0?void 0:Bt.Form)===null||mn===void 0?void 0:mn.defaultValidateMessages)||{},((Tn=Ht.form)===null||Tn===void 0?void 0:Tn.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Ht,o==null?void 0:o.validateMessages]);Object.keys(lr).length>0&&(Mt=p.createElement(zoe.Provider,{value:lr},Mt)),l&&(Mt=p.createElement(Woe,{locale:l,_ANT_MARK__:Uoe},Mt)),Mt=p.createElement(Aoe.Provider,{value:En},Mt),c&&(Mt=p.createElement(cae,{size:c},Mt)),Mt=p.createElement(Kae,null,Mt);const In=p.useMemo(()=>{const Dt=Dn||{},{algorithm:Bt,token:mn,components:Tn,cssVar:Rr}=Dt,Ji=Yae(Dt,["algorithm","token","components","cssVar"]),xr=Bt&&(!Array.isArray(Bt)||Bt.length>0)?tN(Bt):j9,vr={};Object.entries(Tn||{}).forEach(([qs,vi])=>{const ve=Object.assign({},vi);"algorithm"in ve&&(ve.algorithm===!0?ve.theme=xr:(Array.isArray(ve.algorithm)||typeof ve.algorithm=="function")&&(ve.theme=tN(ve.algorithm)),delete ve.algorithm),vr[qs]=ve});const us=Object.assign(Object.assign({},Qm),mn);return Object.assign(Object.assign({},Ji),{theme:xr,token:us,components:vr,override:Object.assign({override:us},vr),cssVar:Rr})},[Dn]);return w&&(Mt=p.createElement(E9.Provider,{value:In},Mt)),Ht.warning&&(Mt=p.createElement(Foe.Provider,{value:Ht.warning},Mt)),_!==void 0&&(Mt=p.createElement(lae,{disabled:_},Mt)),p.createElement(ow.Provider,{value:Ht},Mt)},hf=e=>{const t=p.useContext(ow),n=p.useContext(S9);return p.createElement(ele,Object.assign({parentContext:t,legacyLocale:n},e))};hf.ConfigContext=ow;hf.SizeContext=Jm;hf.config=Jae;hf.useConfig=uae;Object.defineProperty(hf,"SizeContext",{get:()=>Jm});var W9={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Ar,function(){var n=1e3,r=6e4,s=36e5,i="millisecond",o="second",l="minute",c="hour",u="day",d="week",h="month",f="quarter",m="year",g="date",x="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(D){var F=["th","st","nd","rd"],B=D%100;return"["+D+(F[(B-20)%10]||F[B]||F[0])+"]"}},w=function(D,F,B){var U=String(D);return!U||U.length>=F?D:""+Array(F+1-U.length).join(B)+D},_={s:w,z:function(D){var F=-D.utcOffset(),B=Math.abs(F),U=Math.floor(B/60),$=B%60;return(F<=0?"+":"-")+w(U,2,"0")+":"+w($,2,"0")},m:function D(F,B){if(F.date()<B.date())return-D(B,F);var U=12*(B.year()-F.year())+(B.month()-F.month()),$=F.clone().add(U,h),O=B-$<0,T=F.clone().add(U+(O?-1:1),h);return+(-(U+(B-$)/(O?$-T:T-$))||0)},a:function(D){return D<0?Math.ceil(D)||0:Math.floor(D)},p:function(D){return{M:h,y:m,w:d,d:u,D:g,h:c,m:l,s:o,ms:i,Q:f}[D]||String(D||"").toLowerCase().replace(/s$/,"")},u:function(D){return D===void 0}},S="en",k={};k[S]=v;var N="$isDayjsObject",j=function(D){return D instanceof M||!(!D||!D[N])},R=function D(F,B,U){var $;if(!F)return S;if(typeof F=="string"){var O=F.toLowerCase();k[O]&&($=O),B&&(k[O]=B,$=O);var T=F.split("-");if(!$&&T.length>1)return D(T[0])}else{var V=F.name;k[V]=F,$=V}return!U&&$&&(S=$),$||!U&&S},E=function(D,F){if(j(D))return D.clone();var B=typeof F=="object"?F:{};return B.date=D,B.args=arguments,new M(B)},I=_;I.l=R,I.i=j,I.w=function(D,F){return E(D,{locale:F.$L,utc:F.$u,x:F.$x,$offset:F.$offset})};var M=function(){function D(B){this.$L=R(B.locale,null,!0),this.parse(B),this.$x=this.$x||B.x||{},this[N]=!0}var F=D.prototype;return F.parse=function(B){this.$d=function(U){var $=U.date,O=U.utc;if($===null)return new Date(NaN);if(I.u($))return new Date;if($ instanceof Date)return new Date($);if(typeof $=="string"&&!/Z$/i.test($)){var T=$.match(b);if(T){var V=T[2]-1||0,H=(T[7]||"0").substring(0,3);return O?new Date(Date.UTC(T[1],V,T[3]||1,T[4]||0,T[5]||0,T[6]||0,H)):new Date(T[1],V,T[3]||1,T[4]||0,T[5]||0,T[6]||0,H)}}return new Date($)}(B),this.init()},F.init=function(){var B=this.$d;this.$y=B.getFullYear(),this.$M=B.getMonth(),this.$D=B.getDate(),this.$W=B.getDay(),this.$H=B.getHours(),this.$m=B.getMinutes(),this.$s=B.getSeconds(),this.$ms=B.getMilliseconds()},F.$utils=function(){return I},F.isValid=function(){return this.$d.toString()!==x},F.isSame=function(B,U){var $=E(B);return this.startOf(U)<=$&&$<=this.endOf(U)},F.isAfter=function(B,U){return E(B)<this.startOf(U)},F.isBefore=function(B,U){return this.endOf(U)<E(B)},F.$g=function(B,U,$){return I.u(B)?this[U]:this.set($,B)},F.unix=function(){return Math.floor(this.valueOf()/1e3)},F.valueOf=function(){return this.$d.getTime()},F.startOf=function(B,U){var $=this,O=!!I.u(U)||U,T=I.p(B),V=function(Q,he){var be=I.w($.$u?Date.UTC($.$y,he,Q):new Date($.$y,he,Q),$);return O?be:be.endOf(u)},H=function(Q,he){return I.w($.toDate()[Q].apply($.toDate("s"),(O?[0,0,0,0]:[23,59,59,999]).slice(he)),$)},L=this.$W,q=this.$M,K=this.$D,X="set"+(this.$u?"UTC":"");switch(T){case m:return O?V(1,0):V(31,11);case h:return O?V(1,q):V(0,q+1);case d:var te=this.$locale().weekStart||0,oe=(L<te?L+7:L)-te;return V(O?K-oe:K+(6-oe),q);case u:case g:return H(X+"Hours",0);case c:return H(X+"Minutes",1);case l:return H(X+"Seconds",2);case o:return H(X+"Milliseconds",3);default:return this.clone()}},F.endOf=function(B){return this.startOf(B,!1)},F.$set=function(B,U){var $,O=I.p(B),T="set"+(this.$u?"UTC":""),V=($={},$[u]=T+"Date",$[g]=T+"Date",$[h]=T+"Month",$[m]=T+"FullYear",$[c]=T+"Hours",$[l]=T+"Minutes",$[o]=T+"Seconds",$[i]=T+"Milliseconds",$)[O],H=O===u?this.$D+(U-this.$W):U;if(O===h||O===m){var L=this.clone().set(g,1);L.$d[V](H),L.init(),this.$d=L.set(g,Math.min(this.$D,L.daysInMonth())).$d}else V&&this.$d[V](H);return this.init(),this},F.set=function(B,U){return this.clone().$set(B,U)},F.get=function(B){return this[I.p(B)]()},F.add=function(B,U){var $,O=this;B=Number(B);var T=I.p(U),V=function(q){var K=E(O);return I.w(K.date(K.date()+Math.round(q*B)),O)};if(T===h)return this.set(h,this.$M+B);if(T===m)return this.set(m,this.$y+B);if(T===u)return V(1);if(T===d)return V(7);var H=($={},$[l]=r,$[c]=s,$[o]=n,$)[T]||1,L=this.$d.getTime()+B*H;return I.w(L,this)},F.subtract=function(B,U){return this.add(-1*B,U)},F.format=function(B){var U=this,$=this.$locale();if(!this.isValid())return $.invalidDate||x;var O=B||"YYYY-MM-DDTHH:mm:ssZ",T=I.z(this),V=this.$H,H=this.$m,L=this.$M,q=$.weekdays,K=$.months,X=$.meridiem,te=function(he,be,Z,ce){return he&&(he[be]||he(U,O))||Z[be].slice(0,ce)},oe=function(he){return I.s(V%12||12,he,"0")},Q=X||function(he,be,Z){var ce=he<12?"AM":"PM";return Z?ce.toLowerCase():ce};return O.replace(y,function(he,be){return be||function(Z){switch(Z){case"YY":return String(U.$y).slice(-2);case"YYYY":return I.s(U.$y,4,"0");case"M":return L+1;case"MM":return I.s(L+1,2,"0");case"MMM":return te($.monthsShort,L,K,3);case"MMMM":return te(K,L);case"D":return U.$D;case"DD":return I.s(U.$D,2,"0");case"d":return String(U.$W);case"dd":return te($.weekdaysMin,U.$W,q,2);case"ddd":return te($.weekdaysShort,U.$W,q,3);case"dddd":return q[U.$W];case"H":return String(V);case"HH":return I.s(V,2,"0");case"h":return oe(1);case"hh":return oe(2);case"a":return Q(V,H,!0);case"A":return Q(V,H,!1);case"m":return String(H);case"mm":return I.s(H,2,"0");case"s":return String(U.$s);case"ss":return I.s(U.$s,2,"0");case"SSS":return I.s(U.$ms,3,"0");case"Z":return T}return null}(he)||T.replace(":","")})},F.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},F.diff=function(B,U,$){var O,T=this,V=I.p(U),H=E(B),L=(H.utcOffset()-this.utcOffset())*r,q=this-H,K=function(){return I.m(T,H)};switch(V){case m:O=K()/12;break;case h:O=K();break;case f:O=K()/3;break;case d:O=(q-L)/6048e5;break;case u:O=(q-L)/864e5;break;case c:O=q/s;break;case l:O=q/r;break;case o:O=q/n;break;default:O=q}return $?O:I.a(O)},F.daysInMonth=function(){return this.endOf(h).$D},F.$locale=function(){return k[this.$L]},F.locale=function(B,U){if(!B)return this.$L;var $=this.clone(),O=R(B,U,!0);return O&&($.$L=O),$},F.clone=function(){return I.w(this.$d,this)},F.toDate=function(){return new Date(this.valueOf())},F.toJSON=function(){return this.isValid()?this.toISOString():null},F.toISOString=function(){return this.$d.toISOString()},F.toString=function(){return this.$d.toUTCString()},D}(),P=M.prototype;return E.prototype=P,[["$ms",i],["$s",o],["$m",l],["$H",c],["$W",u],["$M",h],["$y",m],["$D",g]].forEach(function(D){P[D[1]]=function(F){return this.$g(F,D[0],D[1])}}),E.extend=function(D,F){return D.$i||(D(F,M,E),D.$i=!0),E},E.locale=R,E.isDayjs=j,E.unix=function(D){return E(1e3*D)},E.en=k[S],E.Ls=k,E.p={},E})})(W9);var tle=W9.exports;const jN=pn(tle);var V9={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Ar,function(){return function(n,r,s){var i=r.prototype,o=function(h){return h&&(h.indexOf?h:h.s)},l=function(h,f,m,g,x){var b=h.name?h:h.$locale(),y=o(b[f]),v=o(b[m]),w=y||v.map(function(S){return S.slice(0,g)});if(!x)return w;var _=b.weekStart;return w.map(function(S,k){return w[(k+(_||0))%7]})},c=function(){return s.Ls[s.locale()]},u=function(h,f){return h.formats[f]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(g,x,b){return x||b.slice(1)})}(h.formats[f.toUpperCase()])},d=function(){var h=this;return{months:function(f){return f?f.format("MMMM"):l(h,"months")},monthsShort:function(f){return f?f.format("MMM"):l(h,"monthsShort","months",3)},firstDayOfWeek:function(){return h.$locale().weekStart||0},weekdays:function(f){return f?f.format("dddd"):l(h,"weekdays")},weekdaysMin:function(f){return f?f.format("dd"):l(h,"weekdaysMin","weekdays",2)},weekdaysShort:function(f){return f?f.format("ddd"):l(h,"weekdaysShort","weekdays",3)},longDateFormat:function(f){return u(h.$locale(),f)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return d.bind(this)()},s.localeData=function(){var h=c();return{firstDayOfWeek:function(){return h.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(f){return u(h,f)},meridiem:h.meridiem,ordinal:h.ordinal}},s.months=function(){return l(c(),"months")},s.monthsShort=function(){return l(c(),"monthsShort","months",3)},s.weekdays=function(h){return l(c(),"weekdays",null,null,h)},s.weekdaysShort=function(h){return l(c(),"weekdaysShort","weekdays",3,h)},s.weekdaysMin=function(h){return l(c(),"weekdaysMin","weekdays",2,h)}}})})(V9);var nle=V9.exports;const rle=pn(nle),wi=(e,t)=>new zn(e).setA(t).toRgbString(),fd=(e,t)=>new zn(e).lighten(t).toHexString(),sle=e=>{const t=Eh(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},ile=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:wi(r,.85),colorTextSecondary:wi(r,.65),colorTextTertiary:wi(r,.45),colorTextQuaternary:wi(r,.25),colorFill:wi(r,.18),colorFillSecondary:wi(r,.12),colorFillTertiary:wi(r,.08),colorFillQuaternary:wi(r,.04),colorBgSolid:wi(r,.95),colorBgSolidHover:wi(r,1),colorBgSolidActive:wi(r,.9),colorBgElevated:fd(n,12),colorBgContainer:fd(n,8),colorBgLayout:fd(n,0),colorBgSpotlight:fd(n,26),colorBgBlur:wi(r,.04),colorBorder:fd(n,26),colorBorderSecondary:fd(n,19)}},ole=(e,t)=>{const n=Object.keys(n5).map(i=>{const o=Eh(e[i],{theme:"dark"});return Array.from({length:10},()=>1).reduce((l,c,u)=>(l[`${i}-${u+1}`]=o[u],l[`${i}${u+1}`]=o[u],l),{})}).reduce((i,o)=>(i=Object.assign(Object.assign({},i),o),i),{}),r=t??r5(e),s=N9(e,{generateColorPalettes:sle,generateNeutralColorPalettes:ile});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),s),{colorPrimaryBg:s.colorPrimaryBorder,colorPrimaryBgHover:s.colorPrimaryBorderHover})},BP={defaultSeed:ab.token,defaultAlgorithm:r5,darkAlgorithm:ole};function ale({children:e}){const t=sl(),[n,r]=p.useState(t.theme);return p.useEffect(()=>t.onThemeChange(r),[t]),a.jsx(hf,{theme:{algorithm:n.mode==="dark"?BP.darkAlgorithm:BP.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Kt;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),o={};for(const l of i)o[l]=s[l];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},e.find=(s,i)=>{for(const o of s)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Kt||(Kt={}));var FP;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(FP||(FP={}));const qe=Kt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ol=e=>{switch(typeof e){case"undefined":return qe.undefined;case"string":return qe.string;case"number":return Number.isNaN(e)?qe.nan:qe.number;case"boolean":return qe.boolean;case"function":return qe.function;case"bigint":return qe.bigint;case"symbol":return qe.symbol;case"object":return Array.isArray(e)?qe.array:e===null?qe.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?qe.promise:typeof Map<"u"&&e instanceof Map?qe.map:typeof Set<"u"&&e instanceof Set?qe.set:typeof Date<"u"&&e instanceof Date?qe.date:qe.object;default:return qe.unknown}},ye=Kt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ga extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let l=r,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(n(o))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}};return s(this),r}static assert(t){if(!(t instanceof Ga))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(t(s))}else r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ga.create=e=>new Ga(e);const EN=(e,t)=>{let n;switch(e.code){case ye.invalid_type:e.received===qe.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ye.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Kt.jsonStringifyReplacer)}`;break;case ye.unrecognized_keys:n=`Unrecognized key(s) in object: ${Kt.joinValues(e.keys,", ")}`;break;case ye.invalid_union:n="Invalid input";break;case ye.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Kt.joinValues(e.options)}`;break;case ye.invalid_enum_value:n=`Invalid enum value. Expected ${Kt.joinValues(e.options)}, received '${e.received}'`;break;case ye.invalid_arguments:n="Invalid function arguments";break;case ye.invalid_return_type:n="Invalid function return type";break;case ye.invalid_date:n="Invalid date";break;case ye.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Kt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ye.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case ye.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case ye.custom:n="Invalid input";break;case ye.invalid_intersection_types:n="Intersection results could not be merged";break;case ye.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ye.not_finite:n="Number must be finite";break;default:n=t.defaultError,Kt.assertNever(e)}return{message:n}};let lle=EN;function cle(){return lle}const ule=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let l="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)l=u(o,{data:t,defaultError:l}).message;return{...s,path:i,message:l}};function $e(e,t){const n=cle(),r=ule({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===EN?void 0:EN].filter(s=>!!s)});e.common.issues.push(r)}class vs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return mt;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return vs.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return mt;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:t.value,value:r}}}const mt=Object.freeze({status:"aborted"}),Lp=e=>({status:"dirty",value:e}),Ki=e=>({status:"valid",value:e}),zP=e=>e.status==="aborted",HP=e=>e.status==="dirty",Ih=e=>e.status==="valid",lb=e=>typeof Promise<"u"&&e instanceof Promise;var nt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(nt||(nt={}));class oa{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const UP=(e,t)=>{if(Ih(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ga(e.common.issues);return this._error=n,this._error}}};function Ct(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??r??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:s}}class zt{get description(){return this._def.description}_getType(t){return Ol(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Ol(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new vs,ctx:{common:t.parent.common,data:t.data,parsedType:Ol(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(lb(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ol(t)},s=this._parseSync({data:t,path:r.path,parent:r});return UP(r,s)}"~validate"(t){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ol(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return Ih(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>Ih(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ol(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(lb(s)?s:Promise.resolve(s));return UP(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=t(s),l=()=>i.addIssue({code:ye.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new cc({schema:this,typeName:gt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ha.create(this,this._def)}nullable(){return xu.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Jo.create(this)}promise(){return pb.create(this,this._def)}or(t){return ub.create([this,t],this._def)}and(t){return db.create(this,t,this._def)}transform(t){return new cc({...Ct(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new mb({...Ct(this._def),innerType:this,defaultValue:n,typeName:gt.ZodDefault})}brand(){return new Y9({typeName:gt.ZodBranded,type:this,...Ct(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new gb({...Ct(this._def),innerType:this,catchValue:n,typeName:gt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return o5.create(this,t)}readonly(){return xb.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dle=/^c[^\s-]{8,}$/i,hle=/^[0-9a-z]+$/,fle=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ple=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,mle=/^[a-z0-9_-]{21}$/i,gle=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xle=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,vle=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yle="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tk;const ble=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wle=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,_le=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Sle=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kle=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cle=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,q9="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Nle=new RegExp(`^${q9}$`);function K9(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function jle(e){return new RegExp(`^${K9(e)}$`)}function Ele(e){let t=`${q9}T${K9(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Ile(e,t){return!!((t==="v4"||!t)&&ble.test(e)||(t==="v6"||!t)&&_le.test(e))}function Tle(e,t){if(!gle.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function Rle(e,t){return!!((t==="v4"||!t)&&wle.test(e)||(t==="v6"||!t)&&Sle.test(e))}class Aa extends zt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==qe.string){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_type,expected:qe.string,received:i.parsedType}),mt}const r=new vs;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(t,s),o?$e(s,{code:ye.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&$e(s,{code:ye.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")vle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"email",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")tk||(tk=new RegExp(yle,"u")),tk.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"emoji",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")ple.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"uuid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")mle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"nanoid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")dle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"cuid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")hle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"cuid2",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")fle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"ulid",code:ye.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),$e(s,{validation:"url",code:ye.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"regex",code:ye.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Ele(i).test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Nle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?jle(i).test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?xle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"duration",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Ile(t.data,i.version)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"ip",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Tle(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"jwt",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Rle(t.data,i.version)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"cidr",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?kle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"base64",code:ye.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Cle.test(t.data)||(s=this._getOrReturnCtx(t,s),$e(s,{validation:"base64url",code:ye.invalid_string,message:i.message}),r.dirty()):Kt.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:ye.invalid_string,...nt.errToObj(r)})}_addCheck(t){return new Aa({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...nt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...nt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...nt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...nt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...nt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...nt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...nt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...nt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...nt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...nt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...nt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...nt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...nt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...nt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...nt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...nt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...nt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...nt.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...nt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...nt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...nt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...nt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...nt.errToObj(n)})}nonempty(t){return this.min(1,nt.errToObj(t))}trim(){return new Aa({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Aa({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Aa({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Aa.create=e=>new Aa({checks:[],typeName:gt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Ct(e)});function Mle(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}class Th extends zt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==qe.number){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_type,expected:qe.number,received:i.parsedType}),mt}let r;const s=new vs;for(const i of this._def.checks)i.kind==="int"?Kt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Mle(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.not_finite,message:i.message}),s.dirty()):Kt.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,nt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,nt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,nt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,nt.toString(n))}setLimit(t,n,r,s){return new Th({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:nt.toString(s)}]})}_addCheck(t){return new Th({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:nt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:nt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:nt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:nt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:nt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:nt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:nt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:nt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:nt.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Kt.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Th.create=e=>new Th({checks:[],typeName:gt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Ct(e)});class eg extends zt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==qe.bigint)return this._getInvalidInput(t);let r;const s=new vs;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),$e(r,{code:ye.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Kt.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return $e(n,{code:ye.invalid_type,expected:qe.bigint,received:n.parsedType}),mt}gte(t,n){return this.setLimit("min",t,!0,nt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,nt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,nt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,nt.toString(n))}setLimit(t,n,r,s){return new eg({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:nt.toString(s)}]})}_addCheck(t){return new eg({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:nt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:nt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:nt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:nt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:nt.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}eg.create=e=>new eg({checks:[],typeName:gt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Ct(e)});class IN extends zt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==qe.boolean){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.boolean,received:r.parsedType}),mt}return Ki(t.data)}}IN.create=e=>new IN({typeName:gt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Ct(e)});class cb extends zt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==qe.date){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_type,expected:qe.date,received:i.parsedType}),mt}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return $e(i,{code:ye.invalid_date}),mt}const r=new vs;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),$e(s,{code:ye.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Kt.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new cb({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:nt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:nt.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}cb.create=e=>new cb({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:gt.ZodDate,...Ct(e)});class WP extends zt{_parse(t){if(this._getType(t)!==qe.symbol){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.symbol,received:r.parsedType}),mt}return Ki(t.data)}}WP.create=e=>new WP({typeName:gt.ZodSymbol,...Ct(e)});class TN extends zt{_parse(t){if(this._getType(t)!==qe.undefined){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.undefined,received:r.parsedType}),mt}return Ki(t.data)}}TN.create=e=>new TN({typeName:gt.ZodUndefined,...Ct(e)});class RN extends zt{_parse(t){if(this._getType(t)!==qe.null){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.null,received:r.parsedType}),mt}return Ki(t.data)}}RN.create=e=>new RN({typeName:gt.ZodNull,...Ct(e)});class VP extends zt{constructor(){super(...arguments),this._any=!0}_parse(t){return Ki(t.data)}}VP.create=e=>new VP({typeName:gt.ZodAny,...Ct(e)});class MN extends zt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ki(t.data)}}MN.create=e=>new MN({typeName:gt.ZodUnknown,...Ct(e)});class lc extends zt{_parse(t){const n=this._getOrReturnCtx(t);return $e(n,{code:ye.invalid_type,expected:qe.never,received:n.parsedType}),mt}}lc.create=e=>new lc({typeName:gt.ZodNever,...Ct(e)});class qP extends zt{_parse(t){if(this._getType(t)!==qe.undefined){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.void,received:r.parsedType}),mt}return Ki(t.data)}}qP.create=e=>new qP({typeName:gt.ZodVoid,...Ct(e)});class Jo extends zt{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==qe.array)return $e(n,{code:ye.invalid_type,expected:qe.array,received:n.parsedType}),mt;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(o||l)&&($e(n,{code:o?ye.too_big:ye.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&($e(n,{code:ye.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&($e(n,{code:ye.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>s.type._parseAsync(new oa(n,o,n.path,l)))).then(o=>vs.mergeArray(r,o));const i=[...n.data].map((o,l)=>s.type._parseSync(new oa(n,o,n.path,l)));return vs.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new Jo({...this._def,minLength:{value:t,message:nt.toString(n)}})}max(t,n){return new Jo({...this._def,maxLength:{value:t,message:nt.toString(n)}})}length(t,n){return new Jo({...this._def,exactLength:{value:t,message:nt.toString(n)}})}nonempty(t){return this.min(1,t)}}Jo.create=(e,t)=>new Jo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...Ct(t)});function Rd(e){if(e instanceof nr){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ha.create(Rd(r))}return new nr({...e._def,shape:()=>t})}else return e instanceof Jo?new Jo({...e._def,type:Rd(e.element)}):e instanceof Ha?Ha.create(Rd(e.unwrap())):e instanceof xu?xu.create(Rd(e.unwrap())):e instanceof mu?mu.create(e.items.map(t=>Rd(t))):e}class nr extends zt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Kt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==qe.object){const u=this._getOrReturnCtx(t);return $e(u,{code:ye.invalid_type,expected:qe.object,received:u.parsedType}),mt}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof lc&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||l.push(u);const c=[];for(const u of o){const d=i[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new oa(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof lc){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of l)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")l.length>0&&($e(s,{code:ye.unrecognized_keys,keys:l}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of l){const h=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new oa(s,h,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const h=await d.key,f=await d.value;u.push({key:h,value:f,alwaysSet:d.alwaysSet})}return u}).then(u=>vs.mergeObjectSync(r,u)):vs.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return nt.errToObj,new nr({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:nt.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new nr({...this._def,unknownKeys:"strip"})}passthrough(){return new nr({...this._def,unknownKeys:"passthrough"})}extend(t){return new nr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new nr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new nr({...this._def,catchall:t})}pick(t){const n={};for(const r of Kt.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new nr({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Kt.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new nr({...this._def,shape:()=>n})}deepPartial(){return Rd(this)}partial(t){const n={};for(const r of Kt.objectKeys(this.shape)){const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}return new nr({...this._def,shape:()=>n})}required(t){const n={};for(const r of Kt.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ha;)i=i._def.innerType;n[r]=i}return new nr({...this._def,shape:()=>n})}keyof(){return G9(Kt.objectKeys(this.shape))}}nr.create=(e,t)=>new nr({shape:()=>e,unknownKeys:"strip",catchall:lc.create(),typeName:gt.ZodObject,...Ct(t)});nr.strictCreate=(e,t)=>new nr({shape:()=>e,unknownKeys:"strict",catchall:lc.create(),typeName:gt.ZodObject,...Ct(t)});nr.lazycreate=(e,t)=>new nr({shape:e,unknownKeys:"strip",catchall:lc.create(),typeName:gt.ZodObject,...Ct(t)});class ub extends zt{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new Ga(l.ctx.common.issues));return $e(n,{code:ye.invalid_union,unionErrors:o}),mt}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new Ga(c));return $e(n,{code:ye.invalid_union,unionErrors:l}),mt}}get options(){return this._def.options}}ub.create=(e,t)=>new ub({options:e,typeName:gt.ZodUnion,...Ct(t)});const Ra=e=>e instanceof ON?Ra(e.schema):e instanceof cc?Ra(e.innerType()):e instanceof fb?[e.value]:e instanceof gu?e.options:e instanceof DN?Kt.objectValues(e.enum):e instanceof mb?Ra(e._def.innerType):e instanceof TN?[void 0]:e instanceof RN?[null]:e instanceof Ha?[void 0,...Ra(e.unwrap())]:e instanceof xu?[null,...Ra(e.unwrap())]:e instanceof Y9||e instanceof xb?Ra(e.unwrap()):e instanceof gb?Ra(e._def.innerType):[];class i5 extends zt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==qe.object)return $e(n,{code:ye.invalid_type,expected:qe.object,received:n.parsedType}),mt;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):($e(n,{code:ye.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),mt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const o=Ra(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of o){if(s.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);s.set(l,i)}}return new i5({typeName:gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...Ct(r)})}}function PN(e,t){const n=Ol(e),r=Ol(t);if(e===t)return{valid:!0,data:e};if(n===qe.object&&r===qe.object){const s=Kt.objectKeys(t),i=Kt.objectKeys(e).filter(l=>s.indexOf(l)!==-1),o={...e,...t};for(const l of i){const c=PN(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(n===qe.array&&r===qe.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const o=e[i],l=t[i],c=PN(o,l);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===qe.date&&r===qe.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class db extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,o)=>{if(zP(i)||zP(o))return mt;const l=PN(i.value,o.value);return l.valid?((HP(i)||HP(o))&&n.dirty(),{status:n.value,value:l.data}):($e(r,{code:ye.invalid_intersection_types}),mt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}db.create=(e,t,n)=>new db({left:e,right:t,typeName:gt.ZodIntersection,...Ct(n)});class mu extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.array)return $e(r,{code:ye.invalid_type,expected:qe.array,received:r.parsedType}),mt;if(r.data.length<this._def.items.length)return $e(r,{code:ye.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),mt;!this._def.rest&&r.data.length>this._def.items.length&&($e(r,{code:ye.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new oa(r,o,r.path,l)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>vs.mergeArray(n,o)):vs.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new mu({...this._def,rest:t})}}mu.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mu({items:e,typeName:gt.ZodTuple,rest:null,...Ct(t)})};class hb extends zt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.object)return $e(r,{code:ye.invalid_type,expected:qe.object,received:r.parsedType}),mt;const s=[],i=this._def.keyType,o=this._def.valueType;for(const l in r.data)s.push({key:i._parse(new oa(r,l,r.path,l)),value:o._parse(new oa(r,r.data[l],r.path,l)),alwaysSet:l in r.data});return r.common.async?vs.mergeObjectAsync(n,s):vs.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof zt?new hb({keyType:t,valueType:n,typeName:gt.ZodRecord,...Ct(r)}):new hb({keyType:Aa.create(),valueType:t,typeName:gt.ZodRecord,...Ct(n)})}}class KP extends zt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.map)return $e(r,{code:ye.invalid_type,expected:qe.map,received:r.parsedType}),mt;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([l,c],u)=>({key:s._parse(new oa(r,l,r.path,[u,"key"])),value:i._parse(new oa(r,c,r.path,[u,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of o){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}}}}KP.create=(e,t,n)=>new KP({valueType:t,keyType:e,typeName:gt.ZodMap,...Ct(n)});class tg extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==qe.set)return $e(r,{code:ye.invalid_type,expected:qe.set,received:r.parsedType}),mt;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&($e(r,{code:ye.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&($e(r,{code:ye.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(c){const u=new Set;for(const d of c){if(d.status==="aborted")return mt;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const l=[...r.data.values()].map((c,u)=>i._parse(new oa(r,c,r.path,u)));return r.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,n){return new tg({...this._def,minSize:{value:t,message:nt.toString(n)}})}max(t,n){return new tg({...this._def,maxSize:{value:t,message:nt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}tg.create=(e,t)=>new tg({valueType:e,minSize:null,maxSize:null,typeName:gt.ZodSet,...Ct(t)});class ON extends zt{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ON.create=(e,t)=>new ON({getter:e,typeName:gt.ZodLazy,...Ct(t)});class fb extends zt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return $e(n,{received:n.data,code:ye.invalid_literal,expected:this._def.value}),mt}return{status:"valid",value:t.data}}get value(){return this._def.value}}fb.create=(e,t)=>new fb({value:e,typeName:gt.ZodLiteral,...Ct(t)});function G9(e,t){return new gu({values:e,typeName:gt.ZodEnum,...Ct(t)})}class gu extends zt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return $e(n,{expected:Kt.joinValues(r),received:n.parsedType,code:ye.invalid_type}),mt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return $e(n,{received:n.data,code:ye.invalid_enum_value,options:r}),mt}return Ki(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return gu.create(t,{...this._def,...n})}exclude(t,n=this._def){return gu.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}gu.create=G9;class DN extends zt{_parse(t){const n=Kt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==qe.string&&r.parsedType!==qe.number){const s=Kt.objectValues(n);return $e(r,{expected:Kt.joinValues(s),received:r.parsedType,code:ye.invalid_type}),mt}if(this._cache||(this._cache=new Set(Kt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=Kt.objectValues(n);return $e(r,{received:r.data,code:ye.invalid_enum_value,options:s}),mt}return Ki(t.data)}get enum(){return this._def.values}}DN.create=(e,t)=>new DN({values:e,typeName:gt.ZodNativeEnum,...Ct(t)});class pb extends zt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==qe.promise&&n.common.async===!1)return $e(n,{code:ye.invalid_type,expected:qe.promise,received:n.parsedType}),mt;const r=n.parsedType===qe.promise?n.data:Promise.resolve(n.data);return Ki(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}pb.create=(e,t)=>new pb({type:e,typeName:gt.ZodPromise,...Ct(t)});class cc extends zt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:o=>{$e(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return mt;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?mt:c.status==="dirty"||n.value==="dirty"?Lp(c.value):c});{if(n.value==="aborted")return mt;const l=this._def.schema._parseSync({data:o,path:r.path,parent:r});return l.status==="aborted"?mt:l.status==="dirty"||n.value==="dirty"?Lp(l.value):l}}if(s.type==="refinement"){const o=l=>{const c=s.refinement(l,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ih(o))return mt;const l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ih(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:n.value,value:l})):mt);Kt.assertNever(s)}}cc.create=(e,t,n)=>new cc({schema:e,typeName:gt.ZodEffects,effect:t,...Ct(n)});cc.createWithPreprocess=(e,t,n)=>new cc({schema:t,effect:{type:"preprocess",transform:e},typeName:gt.ZodEffects,...Ct(n)});class Ha extends zt{_parse(t){return this._getType(t)===qe.undefined?Ki(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ha.create=(e,t)=>new Ha({innerType:e,typeName:gt.ZodOptional,...Ct(t)});class xu extends zt{_parse(t){return this._getType(t)===qe.null?Ki(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}xu.create=(e,t)=>new xu({innerType:e,typeName:gt.ZodNullable,...Ct(t)});class mb extends zt{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===qe.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}mb.create=(e,t)=>new mb({innerType:e,typeName:gt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ct(t)});class gb extends zt{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return lb(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ga(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ga(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}gb.create=(e,t)=>new gb({innerType:e,typeName:gt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ct(t)});class GP extends zt{_parse(t){if(this._getType(t)!==qe.nan){const r=this._getOrReturnCtx(t);return $e(r,{code:ye.invalid_type,expected:qe.nan,received:r.parsedType}),mt}return{status:"valid",value:t.data}}}GP.create=e=>new GP({typeName:gt.ZodNaN,...Ct(e)});class Y9 extends zt{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class o5 extends zt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?mt:i.status==="dirty"?(n.dirty(),Lp(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?mt:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new o5({in:t,out:n,typeName:gt.ZodPipeline})}}class xb extends zt{_parse(t){const n=this._def.innerType._parse(t),r=s=>(Ih(s)&&(s.value=Object.freeze(s.value)),s);return lb(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}xb.create=(e,t)=>new xb({innerType:e,typeName:gt.ZodReadonly,...Ct(t)});var gt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(gt||(gt={}));const C=Aa.create,ee=Th.create,Re=IN.create,Ua=MN.create;lc.create;const ge=Jo.create,z=nr.create;ub.create;const Bs=i5.create;db.create;mu.create;const Gi=hb.create,de=fb.create,Ye=gu.create;pb.create;Ha.create;xu.create;const Ple=cc.createWithPreprocess,Ole=["head","index"],X9=C().regex(/^[A-Za-z0-9][A-Za-z0-9-]{0,127}$/),vb=C().regex(/^[1-9][0-9]*$/),yb=C().regex(/^[A-Za-z0-9_.-]+$/),ng=C().min(1).max(255).refine(e=>!e.startsWith("-")&&e!=="HEAD"&&!e.startsWith("/")&&!e.endsWith("/")&&!e.endsWith(".")&&!/[\s~^:?*\[\\\x00-\x1f\x7f]/.test(e)&&!e.includes("..")&&!e.includes("@{")&&!e.includes("//")&&e.split("/").every(t=>!t.startsWith(".")&&!t.endsWith(".lock")),"Invalid Git branch"),a5=C().min(1).max(4096).refine(e=>!e.startsWith("/")&&!e.includes("\0")&&!e.split(/[\\/]/).includes("..")),l5=z({workspaceId:X9,repoId:vb,owner:yb,name:yb,sourceBranch:ng,defaultBranch:ng}).strict(),Dle=z({repoId:vb,owner:yb,name:yb,defaultBranch:C(),private:Re(),description:C().nullable()}),Ale=l5.extend({initialCommit:C(),head:C(),actualBranch:C().nullable(),branches:ge(C()).optional(),files:ge(z({path:a5,previousPath:C().optional(),comparison:Ye(Ole).optional(),status:C(),added:ee().nonnegative(),removed:ee().nonnegative(),binary:Re(),untracked:Re().optional()})),totalFiles:ee().int().nonnegative().optional(),filesTruncated:Re().optional(),added:ee().nonnegative(),removed:ee().nonnegative(),dirty:Re(),conflicted:Re(),version:C(),measuredAt:ee()}),pd=z({sessionId:X9});Bs("action",[pd.extend({action:de("repositories"),page:ee().int().min(1).max(1e3).optional(),search:C().max(100).optional()}).strict(),pd.extend({action:de("branches"),repoId:vb,page:ee().int().min(1).max(1e3).optional(),search:C().max(100).optional(),cursor:C().min(1).max(1024).optional()}).strict(),pd.extend({action:de("bind"),repoId:vb,branch:ng}).strict(),pd.extend({action:de("status")}).strict(),pd.extend({action:de("intend"),branch:ng.optional()}).strict(),pd.extend({action:de("diff"),filePath:a5}).strict()]);z({binding:l5.nullable().optional(),workspace:Ale.nullable().optional(),repositories:ge(Dle).optional(),branches:ge(C()).optional(),hasMore:Re().optional(),nextCursor:C().min(1).max(1024).optional(),diff:z({path:a5,patch:C(),binary:Re(),truncated:Re(),notStored:Re().optional()}).optional()});new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");z({id:C().min(1),name:C().min(1),baseUrl:C().min(1),apiKey:C().min(1),remark:C().optional(),createdAt:ee(),updatedAt:ee()}).strict();const $le=z({id:C().min(1),name:C().min(1),baseUrl:C().min(1),remark:C().optional(),keyMasked:C(),hasKey:Re(),createdAt:ee(),updatedAt:ee()}).strict();z({activeChannelId:C().nullable(),channels:ge($le)}).strict();z({}).strict();z({id:C().min(1).optional(),name:C().min(1),baseUrl:C().min(1),apiKey:C().optional(),remark:C().optional()}).strict();z({id:C().min(1)}).strict();z({id:C().min(1).nullable()}).strict();z({channelId:C().min(1).optional(),updatedAt:ee().optional()}).strict().refine(e=>e.updatedAt===void 0||e.channelId!==void 0,{message:"updatedAt requires channelId"});z({channelId:C().nullable(),models:ge(z({id:C().min(1),ownedBy:C().optional()}).strict())}).strict();const Lle=["owner"],Ble=["agent","owner","user-upload"],Z9=z({id:C().min(1),relPath:C().min(1),from:Ye(Ble),label:C().optional(),size:ee().int().nonnegative(),mime:C().min(1),addedAt:ee().int().nonnegative(),lastEditedAt:ee().int().nonnegative().optional(),stale:Re().optional()});z({sessionId:C().min(1),relPath:C().min(1),ttlSeconds:ee().int().positive().nullable().optional(),view:Ye(["raw","md-rendered"]).optional()});z({url:C().min(1),expiresAt:ee().int().nonnegative().nullable()});z({sessionId:C().min(1),relPath:C().min(1),label:C().optional(),origin:de("agent").optional()});z({entry:Z9});z({sessionId:C().min(1),relPath:C().min(1)});z({removed:de(!0)});z({sessionId:C().min(1)});z({entries:ge(Z9)});z({attachmentId:C().min(1),url:C().min(1),relPath:C().min(1),sizeBytes:ee().int().nonnegative(),mimeType:C().min(1)});const Fle=Bs("type",[z({type:de("persona"),id:C().min(1)}).strict(),z({type:de("chat"),id:C().min(1)}).strict(),z({type:de("*")}).strict()]),zle=Ye(["read","send","admin"]),c5=z({resource:Fle,actions:ge(zle).min(1)}).strict(),Hle=z({id:C().min(1),secretHash:C().regex(/^[a-f0-9]{64}$/),displayName:C(),grants:ge(c5),issuedAt:ee().int().nonnegative(),expiresAt:ee().int().positive().optional(),maxUses:ee().int().positive().optional(),usedCount:ee().int().nonnegative(),peerOwnerId:C().min(1).optional(),firstUsedByPeerAt:ee().int().positive().optional(),peerDisplayName:C().optional()}).strict(),Ule=Hle.omit({secretHash:!0});z({type:de("whoami:ok"),owner:z({id:C(),kind:Ye(["owner","guest"]),displayName:C(),ownerId:C(),provider:C()}).strict(),capability:Ule,grantedPersonas:ge(z({id:C().min(1),displayName:C()}).strict())}).strict();const Wle="PEER_LOGIN_EXPIRED";z({selfUrl:C().min(1)});z({type:de("contact:handshake:ok"),owner:z({id:C(),ownerId:C(),provider:C(),displayName:C()}),grants:ge(c5)});const Vle=Bs("status",[z({status:de("authorized"),login:C().min(1),source:Ye(["git","file"])}).strict(),z({status:de("missing")}).strict(),z({status:de("invalid"),message:C().min(1)}).strict(),z({status:de("pending"),authUrl:C().url()}).strict()]);z({token:C().min(1)}).strict();z({returnTo:C().url().optional()}).strict();const qle=z({url:C().url(),bin:C(),sha256:C().regex(/^[0-9a-f]{64}$/),size:ee().int().positive()}),Kle={label:"Debian 13"},Q9=["node","npm"],Gle=["claude","codex","git","lark-cli","pi","pi-mcp-bridge","pi-cliproxyapi-provider","python3","jq","rsync","psql","chromium","fonts-wqy-microhei","pnpm","whiteboard-cli","s","supabase-mcp","mcp-server-kibana","aliyun"],Yle=z({name:C().min(1),from:C().optional(),version:C().optional(),min:C().optional(),library:Re().optional(),localVersion:C().optional(),artifact:qle.optional(),aptMissing:de(!0).optional(),aptVersion:C().optional()}),Xle=z({name:C().min(1),env:ge(C().min(1)).min(1)}),u5=C().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),J9=["proxy","env"],e7=["mcp","cli"],Zle=["bearer","lark-sidecar"],t7=["none","shared","personal"],d5=["oauth","fields"],h5=C().regex(/^[A-Z][A-Z0-9_]*$/,"要填的变量名只能是大写字母、数字和下划线,且以字母开头"),n7=z({name:u5,kind:Ye(J9),runner:Ye(e7),protocol:Ye(Zle).optional(),id:C().min(1),credentialSource:Ye(t7).optional(),auth:Ye(d5).optional(),publisherUnionId:C().regex(/^on_[A-Za-z0-9_-]+$/).optional(),fields:ge(h5).default([]),http:z({url:C().min(1),headers:Gi(C(),C())}).optional()}),r7=["LARKSUITE_CLI_APP_ID","LARKSUITE_CLI_APP_SECRET"];function f5(e){return e.name==="feishu"&&e.runner==="cli"&&e.kind==="env"&&e.credentialSource==="shared"}function Qle(e){return e.name==="feishu"&&e.id==="feishu"&&e.runner==="cli"&&e.kind==="proxy"&&e.protocol==="lark-sidecar"&&e.credentialSource==="shared"&&e.auth==="oauth"&&e.fields.length===0}function s7(e){if(!e.credentialSource)return[`连接器 ${e.name} 还没选用谁的账号`];const t=[];return Qle(e)?t:e.protocol==="lark-sidecar"&&e.credentialSource==="shared"?["连接器 feishu 的发布者 OAuth 配置不完整,请重新选择账号身份"]:f5(e)?r7.filter(n=>!e.fields.includes(n)).map(n=>`连接器 feishu 的 Lark App Bot 缺少 ${n==="LARKSUITE_CLI_APP_ID"?"App ID":"App Secret"}`):(e.credentialSource==="personal"&&(e.auth?e.auth==="oauth"&&e.kind==="env"?t.push(`连接器 ${e.name} 是进程型(stdio MCP / CLI),只能粘贴 API key,走不了 OAuth`):e.auth==="fields"&&e.fields.length===0&&t.push(`连接器 ${e.name} 要填的变量还没列`):t.push(`连接器 ${e.name} 还没选用户怎么关联账号`)),e.credentialSource==="shared"&&e.fields.length===0&&t.push(`连接器 ${e.name} 选了发布者的账号,但要填的变量还没列`),t)}function i7(e){var n;const t=Q9.includes(e.name)||Gle.includes(e.name);return(n=e.from)!=null&&n.startsWith("github:")&&!e.artifact&&!t?[`${e.name} 还没钉下载资产(github: 要具体到哪个文件)——重新扫描`]:[]}function aw(e){return e.connectors.filter(t=>t.credentialSource==="shared"&&t.fields.length>0).map(t=>({name:t.name,env:[...t.fields]}))}function Jle(e){return[...new Set([...e.secrets.flatMap(t=>t.env),...aw(e).flatMap(t=>t.env)])]}const ece=e=>{if(!e||typeof e!="object")return e;let t=e;if("clis"in t&&Array.isArray(t.clis)){const{clis:n,...r}=t;t="packages"in r?r:{...r,packages:n}}if("assets"in t&&Array.isArray(t.assets)&&t.assets.length===0){const{assets:n,...r}=t;t=r}return t},tce="Publisher test: ",o7=z({version:de(1),entry:C().max(240).regex(/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*\.mjs$/).refine(e=>!e.split("/").some(t=>[".",".."].includes(t))),timeoutSeconds:ee().int().min(1).max(600),checks:ge(C().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)).min(1).max(64).refine(e=>new Set(e).size===e.length)}).strict(),a7={test:o7.optional(),packages:ge(Yle),secrets:ge(Xle),connectors:ge(n7).default([])};z(a7);const p5=Ple(ece,z({version:de(1),...a7}).strict()),nce=z({target:C().min(1),reason:C().min(1),file:C().min(1),quote:C().min(1)}),rce=["integration","production"],Hs=Ye(rce),Ya=C().regex(/^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[a-f0-9]{64}$/),AN=C().regex(/^[a-f0-9]{40}$/),sce=C().refine(e=>{try{const t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password&&!t.search&&!t.hash&&t.pathname==="/"&&/(^|[.-])int([.-]|$)/.test(t.hostname)}catch{return!1}},"测试验证地址必须明确指向 int HTTPS 环境"),ice=z({version:de(1),runId:C().regex(/^[A-Za-z0-9_-]{1,128}$/),status:de("passed"),exitCode:de(0),result:z({version:de(1),runId:C().regex(/^[A-Za-z0-9_-]{1,128}$/),checks:ge(z({name:C().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),status:de("passed"),reason:C().max(1024).optional()}).strict()).min(1).max(64)}).strict(),execution:z({image:Ya,imageID:C().min(1).max(512),engine:Ye(["codex","pi"]),podUid:C().min(1).max(512),jobUid:C().min(1).max(512)}).strict()}).strict(),l7=z({status:de("passed"),fingerprint:C().regex(/^[a-f0-9]{64}$/),checks:ge(C().regex(/^[a-z0-9-]+$/)),endpoint:sce,verifiedAt:C().refine(e=>Number.isFinite(Date.parse(e))),test:ice.optional()}).strict(),c7=z({engine:C().min(1),model:C(),effort:C(),size:C().min(1),cpu:ee().positive(),taskConcurrency:ee().int().positive()}).strict(),u7=z({version:de(1),environment:de("integration"),component:de("persona"),image:Ya,commit:AN,baseImage:Ya,pipelineCommit:AN,repository:C().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/),config:c7.optional(),verification:l7.refine(e=>e.checks.includes("persona-smoke")),test:o7.optional()}).strict().refine(e=>{if(!e.test)return e.verification.test===void 0;const t=e.verification.test;return["persona-dialogue","persona-task","persona-custom-test"].every(n=>e.verification.checks.includes(n))&&t!==void 0&&t.execution.image===e.image&&t.runId===t.result.runId&&t.result.checks.length===e.test.checks.length&&new Set(t.result.checks.map(n=>n.name)).size===e.test.checks.length&&t.result.checks.every(n=>e.test.checks.includes(n.name))},"Declared publisher acceptance requires complete candidate runtime evidence");z({version:de(1),environment:de("integration"),component:de("base"),image:Ya,commit:AN,verification:l7.refine(e=>e.checks.includes("base-smoke"))}).strict();const rg="-cloud",oce=`codex${rg}`,sg={standard:"default",fast:"priority"},ace=`claude${rg}`;function d7(e){return e==="codex"||e===oce}const h7="pi",lce=`${h7}${rg}`;function f7(e){return e===h7||e===lce}function bb(e){return typeof e=="string"&&e.length>rg.length&&e.endsWith(rg)}const p7=Ye([sg.standard,sg.fast]),m5=["tiny","small","medium","large","xlarge"],cce=Ye(m5),wb="medium",_b=[.5,1,2],uce=ee().refine(e=>_b.includes(e),"Unsupported CPU"),$N={tiny:.5,small:1,medium:2,large:2,xlarge:2},m7=z({model:C().optional(),effort:C().optional()}).strict(),Sb=z({personaId:C(),label:C(),model:C().optional(),effort:C().optional(),serviceTier:p7.optional(),public:Re(),iconKey:C().optional(),tool:C().optional(),size:C().optional(),cpu:ee().finite().optional(),taskConcurrency:ee().int().positive().optional(),cloudEngine:m7.optional(),createdAt:ee(),updatedAt:ee(),cloud:z({gatewayUrl:C().min(1),personaId:C().min(1),publishedByMe:Re().optional(),environment:Hs.optional(),expectedImage:Ya.optional(),testReleaseId:C().optional()}).strict().optional()}).strict(),dce=z({name:C().min(1),description:C().optional()}),hce=z({id:C().min(1)}),g7=z({writableRoots:ge(C()).optional(),denyRead:ge(C()).optional(),network:Re().optional()}).strict(),fce=z({permissions:z({defaultMode:C().optional(),allow:ge(C()).optional(),deny:ge(C()).optional()}).optional(),sandbox:z({enabled:Re().optional(),autoAllowBashIfSandboxed:Re().optional(),allowUnsandboxedCommands:Re().optional(),excludedCommands:ge(C()).optional(),filesystem:z({denyRead:ge(C()).optional(),allowRead:ge(C()).optional(),denyWrite:ge(C()).optional(),allowWrite:ge(C()).optional()}).optional(),network:z({allowedDomains:ge(C()).optional(),allowLocalBinding:Re().optional()}).optional()}).optional()});Sb.extend({personality:C().optional(),personalityLocal:C().optional(),personalityManaged:Re().optional(),skills:ge(dce).optional(),plugins:ge(hce).optional(),sandboxSettings:fce.nullable().optional(),codexSandbox:g7.nullable().optional()});z({slug:C().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:C().min(1),personality:C(),model:C().optional(),effort:C().optional(),serviceTier:Sb.shape.serviceTier,tool:C().optional(),public:Re().optional(),iconKey:C().optional()}).strict();z({personaId:C().min(1)});z({personaId:C().min(1),patch:z({label:C().min(1).optional(),model:C().optional(),effort:C().optional(),serviceTier:Sb.shape.serviceTier,tool:C().optional(),size:cce.optional(),cpu:uce.optional(),taskConcurrency:Sb.shape.taskConcurrency,cloudEngine:m7.optional(),personality:C().optional(),personalityLocal:C().optional(),public:Re().optional(),iconKey:C().nullable().optional(),codexSandbox:g7.optional()}).strict()}).strict();z({version:de(1),manifest:p5}).strict();const pce=["hard","soft"],x7=Ye(pce),mce=Ye(["scanning","done","failed"]),v7=z({id:C().min(1),manifest:p5,scanSessionId:C().optional(),status:mce,evidence:ge(nce).default([]),notes:ge(C()).default([]),head:C().min(1).optional(),baseKind:x7.default("hard"),base:C().min(1).optional(),startedAt:ee(),finishedAt:ee().optional(),error:C().optional()}).strict(),g5=z({id:C().min(1).optional(),environment:Hs.optional(),legacy:Re().optional(),head:C().min(1),contentHead:C().min(1),scanId:C().min(1),at:ee(),pushed:Re().optional(),runId:ee().int().positive().optional(),runAttempt:ee().int().positive().optional(),artifactId:ee().int().positive().optional(),verified:u7.optional(),config:c7.optional(),reconfigOf:C().min(1).optional(),workflowVersion:ee().int().positive().optional(),confirmation:z({fingerprint:C().regex(/^[a-f0-9]{64}$/),runId:ee().int().positive(),runAttempt:ee().int().positive(),at:ee()}).strict().optional()}).strict(),gce=["prepared","main-pushed","dispatching","dispatched","completed","failed"],x5=z({id:C().min(1),releaseId:C().min(1),at:ee(),verified:u7.optional(),phase:Ye(gce),expectedMain:C().optional(),runId:ee().int().positive().optional(),runAttempt:ee().int().positive().optional(),error:C().optional()}).strict(),YP=z({channelId:C().min(1),updatedAt:ee()}).strict(),v5=z({integration:YP.nullable().optional(),production:YP.nullable().optional()}).strict();z({version:de(4),engineChannels:v5.optional(),scans:ge(v7),releases:ge(g5),promotions:ge(x5).default([])}).strict();const xce=z({url:C().min(1),branch:C().min(1),head:C().min(1),dirty:Re(),ahead:ee()}).strict(),ry=z({env:C().min(1),setAt:ee().optional()}).strict(),LN={baseUrl:"CLAWD_ENGINE_BASE_URL",apiKey:"CLAWD_ENGINE_API_KEY"},vce="模型订阅只写进去一半——重填或改回平台默认";function kb(e){if(!e)return;const t=r=>e.some(s=>s.env===r&&s.setAt!==void 0),n=[LN.baseUrl,LN.apiKey].filter(t).length;return n===2?"own":n===0?"platform":"partial"}const yce=["pending","running","done","failed","waiting","skipped"],bce=Ye(yce),mo="verify",dm=["build","smoke","deploy",mo],wce=Ye(dm),_ce=z({key:wce,status:bce,url:C().optional(),jobId:ee().optional(),startedAt:ee().optional(),completedAt:ee().optional()}).strict(),sy=z({runId:ee(),headSha:C().min(1),status:Ye(["queued","running","completed"]),htmlUrl:C().min(1),jobs:ge(_ce),environment:Hs.optional(),branch:C().optional(),event:C().optional(),runAttempt:ee().int().positive().optional(),conclusion:Ye(["success","failure"]).optional(),promotionId:C().optional()}).strict();function y7(e,t){return t&&e.head===t.head?t.contentHead:e.head}function lw(e,t,n){return!e||!t||e.status!=="done"?!1:e.head===y7(t,n)&&!t.dirty}function b7(e,t,n){return!e||!t||e.status!=="done"||!e.head?!1:e.head!==y7(t,n)}function XP(e,t,n){return lw(e,t,n)||b7(e,t,n)}function Sce(e,t){return!t||!e.head?!1:t.contentHead===e.head||t.at>=e.startedAt}const w7=["codex","pi","claude"];function ol(e){return w7.includes(e||"claude")}const _7={codex:"0.163.0",pi:"1.3.0",claude:"0.3.304"},kce="2.1.304";function Cce(e,t){if(!e||!ol(e)||!t)return null;const n=e==="claude"?kce:_7[e];return n===t?null:{tool:e,cloud:n,local:t}}function S7(e){const t=e.tool||"claude",n=t==="claude"?e.cloudEngine??{}:e;return{tool:t,model:n.model??"",effort:n.effort??""}}const nk=z({runId:ee(),status:sy.shape.status,conclusion:Ye(["success","failure"]).optional(),htmlUrl:C().min(1)}).strict(),k7=z({personaId:C().min(1),engineChannels:v5.optional(),github:Vle.optional(),publisherFeishuAuth:z({integration:z({connected:Re(),authUrl:C().optional(),error:C().optional()}).strict(),production:z({connected:Re(),authUrl:C().optional(),error:C().optional()}).strict()}).strict().optional(),repo:xce.optional(),scans:ge(v7).default([]),releases:ge(g5).default([]),promotions:ge(x5).optional(),targets:z({integration:z({run:sy.optional(),secrets:ge(ry).optional(),online:Re().optional(),image:Ya.optional(),unpublish:nk.optional()}).strict().optional(),production:z({run:sy.optional(),secrets:ge(ry).optional(),online:Re().optional(),image:Ya.optional(),unpublish:nk.optional()}).strict().optional()}).strict().optional(),secrets:ge(ry).optional(),run:sy.optional(),online:Re().optional(),unpublish:nk.optional(),historyError:C().optional()}).strict();z({before:ee().nullable()}).strict();k7.pick({personaId:!0,github:!0,repo:!0,scans:!0,releases:!0,promotions:!0,engineChannels:!0,historyError:!0});k7.pick({scans:!0});z({environment:Hs,secrets:ge(ry).optional(),engineChannels:v5.optional()}).strict();const Nce=2,jce=4,Ece=["engine","model","effort","size","cpu","taskConcurrency"];function Ice(e){const{tool:t,model:n,effort:r}=S7(e),s=(e.size??"").trim()||wb,i=e.cpu??$N[s]??$N[wb];return{engine:t,model:n.trim(),effort:r.trim(),size:s,cpu:i,taskConcurrency:e.taskConcurrency??jce}}function C7(e,t){return!e||!t?null:Ece.filter(n=>e[n]!==t[n])}z({sha:C().min(1),actionsUrl:C().min(1),releaseId:C().optional()}).strict();const qg=z({personaId:C().min(1)}).strict();qg.extend({releaseHead:C().min(1).optional(),releaseId:C().min(1).optional(),environment:Hs.optional()}).strict();qg.extend({scanBase:x7.optional()}).strict();qg.extend({scanId:C().min(1)}).strict();qg.extend({releaseId:C().min(1)}).strict();qg.extend({environment:Hs.default("production")}).strict();z({confirmation:g5.shape.confirmation.unwrap()}).strict();z({promotion:x5}).strict();z({personaId:C().min(1),expectedImage:Ya}).strict();z({personaId:C().min(1),scanId:C().min(1),patch:z({manifest:p5.optional(),connector:n7.optional()}).strict()}).strict();z({personaId:C().min(1),environment:Hs.default("production"),scanId:C().min(1),name:C().min(1),values:Gi(C(),C())}).strict();z({personaId:C().min(1),environment:Hs.default("production"),channelId:C().min(1).optional(),auth:z({baseUrl:C(),apiKey:C()}).strict().nullable().optional()}).strict().refine(e=>e.channelId!==void 0||e.auth!==void 0,{message:"Either channelId or auth must be provided"});z({personaId:C().min(1),environment:Hs.default("production"),releaseId:C().optional(),jobId:ee()}).strict();z({personaId:C().min(1),kind:Ye(["package","secret","connector"]),item:Gi(C(),Ua()),evidence:z({reason:C().min(1),file:C().min(1),quote:C().min(1)})}).strict();z({personaId:C().min(1),notes:ge(C()).default([])}).strict();const N7="ottin4ttc";function Rh(e){return e.trim().replace(/^git@[^:]+:/,"").replace(/^https?:\/\/[^/]+\//,"").replace(/\.git$/,"")}z({environment:Hs.default("production")}).strict();const Tce="LOGIN_EXPIRED",Rce=z({deviceId:C().min(1),name:C().min(1),url:C().min(1)});z({type:de("device:list:ok"),devices:ge(Rce)});z({deviceId:C().min(1),url:C().min(1).optional(),name:C().optional()});z({type:de("device:connect:ok"),deviceId:C(),name:C(),url:C()});const j7=z({ownerId:C().min(1),provider:C().min(1),displayName:C().min(1),avatarUrl:C().optional(),unionId:C().optional()});z({type:de("auth:login:start:ok"),environment:Hs.optional(),authUrl:C().min(1),state:C().min(1)});z({type:de("auth:getIdentity:ok"),identity:j7.nullable(),deviceId:C().min(1)});z({type:de("auth:logout:ok")});const E7=C().nullable();z({type:de("auth:apiKey:get:ok"),apiKey:C().nullable(),createdAt:C().nullable(),gatewayUrl:E7});z({type:de("auth:apiKey:regenerate:ok"),apiKey:C().min(1),createdAt:C().min(1),gatewayUrl:E7});z({type:de("auth:apiKey:revoke:ok"),revoked:Re()});z({type:de("auth:login:done"),environment:Hs.optional(),identity:j7});z({type:de("auth:login:failed"),environment:Hs.optional(),reason:C()});z({deviceId:C().min(1),remoteAccessAllowed:Re()}).strict();z({type:de("contact:setRemoteAccess:ok"),deviceId:C().min(1),remoteAccessAllowed:Re()}).strict();z({type:de("contact:remote-access-updated"),deviceId:C().min(1),remoteAccessAllowed:Re()}).strict();z({personaId:C().min(1)}).strict();const Mce=["connected","missing","reauth"],Pce=["link","fill"],Oce=z({name:u5,id:C().min(1),kind:Ye(J9),runner:Ye(e7),auth:Ye(d5),status:Ye(Mce),action:Ye(Pce),authUrl:C().optional(),fields:ge(h5)}).strict();z({connectors:ge(Oce)}).strict();z({personaId:C().min(1),name:u5,values:Gi(h5,C().min(1))}).strict();const Dce=z({deviceId:C().min(1),ownerId:C().min(1),provider:C().min(1),displayName:C(),remoteUrl:C().min(1),connectToken:C(),grants:ge(c5),addedAt:ee().int().nonnegative(),pinnedAt:ee().int().nullable().default(null),remoteAccessAllowed:Re().default(!1),note:C().default("")}).strict(),I7=Dce;z({deviceId:C().min(1)}).strict();z({type:de("contact:remove:ok"),deviceId:C().min(1)}).strict();z({type:de("contact:list:ok"),contacts:ge(I7)}).strict();z({type:de("contact:added"),contact:I7}).strict();z({type:de("contact:removed"),deviceId:C().min(1)}).strict();z({deviceId:C().min(1),pinned:Re()}).strict();z({deviceId:C().min(1),note:C()}).strict();z({type:de("contact:setNote:ok"),deviceId:C().min(1),note:C()}).strict();z({type:de("contact:pin:ok"),deviceId:C().min(1),pinnedAt:ee().int().nullable()}).strict();z({type:de("contact:pinned"),deviceId:C().min(1),pinnedAt:ee().int().nullable()}).strict();const y5=Bs("kind",[z({kind:de("success"),text:C(),brief:C().optional(),filePaths:ge(C()).optional()}),z({kind:de("failure"),reason:C(),brief:C().optional()})]);z({targetPersona:C().min(1).optional(),dispatchId:C().min(1).optional(),prompt:C(),brief:C().optional(),targetDeviceId:C().min(1).optional(),model:C().min(1).optional(),tool:C().min(1).optional(),sessionLabel:C().min(1).max(60).optional(),meta:Gi(Ua()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});z({dispatchId:C().min(1),outcome:y5});const Ace=["running","completed","failed"],b5=Ye(Ace),$ce=z({dispatchId:C().min(1),sourceSessionId:C().min(1),sourcePersonaId:C().min(1).optional(),targetPersonaId:C().min(1),targetDeviceId:C().min(1).optional(),workerSessionId:C().min(1).optional(),taskText:C(),taskBrief:C().optional(),round:ee().int().positive().optional(),status:b5,outcome:y5.optional(),meta:Gi(Ua()).optional(),createdAt:C().min(1),completedAt:C().min(1).optional(),deliveredAt:C().min(1).optional()});z({sourceSessionId:C().min(1).optional(),relatedSessionId:C().min(1).optional()});z({records:ge($ce)});z({dispatchId:C().min(1)});z({type:de("personaDispatch:get:ok"),status:b5,outcome:y5.optional()});const Lce=/^[a-z0-9][a-z0-9-]*$/;Ye(["stopped","starting","running","crashed","invalid"]);const Bce=new Set(["localhost","127.0.0.1"]);function Fce(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&Bce.has(t.hostname))}const Bv=z({id:C().regex(Lce),name:C().min(1),version:C().min(1),apiVersion:de("1"),runtime:z({startCommand:C().min(1)}).passthrough().optional(),entry:z({url:C().url().refine(Fce,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var s;const n=!!e.runtime,r=!!((s=e.entry)!=null&&s.url);n&&r&&t.addIssue({code:ye.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:ye.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),zce=Bs("kind",[z({kind:de("local"),port:ee().int().min(1).max(65535)}),z({kind:de("hosted"),url:C().url()})]);Bs("state",[z({extId:C(),manifest:Bv,state:de("stopped")}),z({extId:C(),manifest:Bv,state:de("starting")}),z({extId:C(),manifest:Bv,state:de("running"),target:zce}),z({extId:C(),manifest:Bv,state:de("crashed")}),z({extId:C(),manifest:Ua().nullable(),state:de("invalid"),invalidReason:C().min(1)})]);z({snapshotHash:C().min(1),version:C().min(1),publishedAt:ee()});const Hce=Bs("kind",[z({kind:de("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1)})]);Bs("kind",[z({kind:de("p2p-tunnel"),ownerPrincipalId:C().min(1),extId:C().min(1),snapshotHash:C().min(1)})]);z({extId:C().min(1),name:C().min(1),version:C().min(1),contentHash:C().min(1),publishedAt:ee()});const Uce=Bs("kind",[z({kind:de("clean")}),z({kind:de("ready-new-version"),fromVersion:C().min(1),toVersion:C().min(1)}),z({kind:de("error-same-hash"),version:C().min(1)}),z({kind:de("error-version-not-bumped"),localVersion:C().min(1),publishedVersion:C().min(1)}),z({kind:de("error-version-regression"),localVersion:C().min(1),publishedVersion:C().min(1)})]);function Wce(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return(t>>>0).toString(16).padStart(8,"0")}function w5(e,t){return`${e}-${Wce(t)}`}function _5(e){if(typeof e!="string")return{ok:!1,reason:"version must be a string"};const t=e.split(".");if(t.length!==3)return{ok:!1,reason:`"${e}" — only MAJOR.MINOR.PATCH allowed`};for(const n of t)if(!/^\d+$/.test(n))return{ok:!1,reason:`"${e}" — only numeric segments allowed`};return{ok:!0}}function T7(e,t){const n=ZP(e),r=ZP(t);for(let s=0;s<3;s++){if(n[s]<r[s])return-1;if(n[s]>r[s])return 1}return 0}function ZP(e){const t=_5(e);if(!t.ok)throw new Error(t.reason);const[n,r,s]=e.split(".").map(i=>parseInt(i,10));return[n,r,s]}z({localManifest:z({name:C().min(1),version:C().min(1),contentHash:C().min(1)}),publishState:Bs("kind",[z({kind:de("unpublished")}),z({kind:de("published"),version:C().min(1),contentHash:C().min(1),publishedAt:ee()})]),check:Uce});z({extId:C().min(1),newVersion:C().min(1).nullish()});z({extId:C().min(1)});z({extId:C().min(1),snapshotHash:C().min(1)});z({channelRef:Hce,snapshotHash:C().min(1),zipBase64:C().min(1)});z({id:C().min(1),peerDeviceId:C().min(1),senderDeviceId:C().min(1),text:C().min(1),createdAt:ee().int().nonnegative(),readBy:Gi(C().min(1),ee().int().positive()).default({}),origin:z({kind:de("persona"),personaId:C().min(1)}).optional()}).strict();z({peerDeviceId:C().min(1).optional(),id:C().min(1),text:C().min(1),createdAt:ee().int().nonnegative(),origin:z({kind:de("persona"),personaId:C().min(1)}).optional()}).strict();z({peerDeviceId:C().min(1),sinceCreatedAt:ee().int().nonnegative().optional()}).strict();z({peerDeviceId:C().min(1),upToCreatedAt:ee().int().nonnegative()}).strict();z({peerDeviceId:C().min(1).optional(),text:C().min(1)});z({peerDeviceId:C().min(1).optional(),command:C().min(1),timeoutMs:ee().int().positive().optional()}).strict();z({type:de("peerExec:run:ok"),stdout:C(),stderr:C(),exitCode:ee().int().nullable(),timedOut:Re(),stdoutTruncated:Re(),stderrTruncated:Re()}).strict();const R7=Bs("kind",[z({kind:de("at"),at:C().min(1)}),z({kind:de("every"),everyMs:ee().int().positive(),anchorMs:ee().int().nonnegative().optional()}),z({kind:de("cron"),expr:C().min(1),tz:C().min(1).optional()})]),Kg=C().trim().min(1);z({personaId:Kg,name:C().min(1),schedule:R7,prompt:C().min(1),targetPersona:C().min(1).optional(),timeoutMs:ee().int().positive().optional()});z({personaId:Kg,onlyMine:Re().optional()});z({personaId:Kg,shiftId:C().min(1)});const Vce=z({name:C().min(1).optional(),schedule:R7.optional(),prompt:C().min(1).optional(),targetPersona:C().min(1).optional(),timeoutMs:ee().int().positive().optional(),enabled:Re().optional()});z({personaId:Kg,shiftId:C().min(1),patch:Vce});z({personaId:Kg,shiftId:C().min(1),limit:ee().int().positive().optional()});const $i="persona-master",S5=z({personaId:C().min(1),deviceId:C().min(1).optional()}),M7=z({id:C().min(1),name:C().min(1),memberPersonas:ge(S5),memberContactDeviceIds:ge(C().min(1)),createdAt:C().min(1),updatedAt:C().min(1)}),P7=C().trim().min(1);z({name:P7,memberPersonas:ge(S5).default([]),memberContactDeviceIds:ge(C().min(1)).default([])});z({channelId:C().min(1),name:P7.optional(),memberPersonas:ge(S5).optional(),memberContactDeviceIds:ge(C().min(1)).optional()});z({channelId:C().min(1)});z({channels:ge(M7)});z({channel:M7});z({ok:de(!0),removedTopics:ee().int().min(0)});const ar=C().trim().min(1),k5=["master-confirmed","owner-needed"],C5=["open","resolved"],qce=k5[0],O7=k5[1],D7=C5[0],Kce=C5[1],Gce=Ye(k5),Yce=Ye(C5),Xce=z({id:ar.optional(),resolves:ar.optional(),type:Gce,status:Yce,question:ar,recommendation:ar}).superRefine((e,t)=>{e.type===qce&&e.status!==Kce&&t.addIssue({code:ye.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),Zce=["planning","running","done"],Qce=Ye(Zce),A7=z({at:C().min(1),actor:C().min(1),action:C().min(1),target:C().optional(),reason:C().min(1),artifacts:ge(ar).optional(),decision:Xce.optional()}),Jce=z({rejectCount:ee().int().min(0),accepted:Re().default(!1),ordinal:ee().int().min(1).optional(),overrideCount:ee().int().min(0).optional()}),N5=z({id:C().min(1),channelId:C().min(1),title:C(),masterSessionId:C().min(1),goal:C(),boundaries:C(),acceptanceCriteria:ge(C()),activity:ge(A7),lineMeta:Gi(Jce),nextLineOrdinal:ee().int().min(1).optional(),state:Qce,createdAt:C().min(1),updatedAt:C().min(1)}),eue=z({lineId:C().min(1),dispatchId:C().min(1),workerSessionId:C().optional(),assignee:C().min(1),focus:C(),status:b5,acceptance:ge(C()),rejectCount:ee().int().min(0),accepted:Re(),ordinal:ee().int().min(1).nullable()});z({channelId:C().min(1)});z({topicId:C().min(1).optional(),sessionId:C().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});z({channelId:C().min(1),title:ar.optional()});z({topicId:C().min(1),title:ar.optional(),goal:ar,boundaries:C(),acceptanceCriteria:ge(ar).min(1)});z({topicId:C().min(1),action:ar,target:ar.optional(),reason:ar,artifacts:ge(ar).optional(),decision:A7.shape.decision});z({topicId:C().min(1),lineId:ar,reason:ar});z({topicId:C().min(1),lineId:ar,reason:ar,artifacts:ge(ar).optional(),watcherVerdict:Ye(["pass","fail"]),overrideReason:ar.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});z({topicId:C().min(1),state:Ye(["done"])});z({topicId:C().min(1),title:ar});z({topicId:C().min(1)});const tue=N5.extend({lineCount:ee().int().min(0)});z({topics:ge(tue)});z({topic:N5,lines:ge(eue)});z({topicId:C().min(1),masterSessionId:C().min(1)});z({rejectCount:ee().int().min(1),needsOwnerAttention:Re()});z({acceptedLines:ee().int().min(1),totalLines:ee().int().min(1),allAccepted:Re(),overrides:ee().int().min(0),needsOwnerAttention:Re()});z({topic:N5});z({ok:de(!0),removedMasterSessionId:C().min(1).nullable(),removedWorkerSessionIds:ge(C().min(1))});const nue=["ask","allow","deny"],$7=Ye(nue),rue=z({id:C().min(1),desc:C().min(1),action:$7});z({rules:ge(rue)});z({ruleId:C().min(1)});z({action:$7,desc:C(),source:C().min(1)});const sue=["created","review-requested"],L7=/^[A-Za-z0-9._-]+$/,ff=C().min(1).regex(L7),pf=C().min(1).regex(L7),Gg=ee().int().positive();z({role:Ye(sue)});z({owner:ff,repo:pf,number:Gg});z({owner:ff,repo:pf,number:Gg,expectedHeadSha:C().min(1)});z({owner:ff,repo:pf,number:Gg,body:C().min(1)});z({owner:ff,repo:pf,number:Gg,ready:Re()});z({owner:ff,repo:pf});z({owner:ff,repo:pf,number:Gg,reviewers:ge(C().min(1)).min(1)});z({personaId:C().min(1)});z({personaId:C().min(1)});const iue=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],oue=Ye(iue);z({personaId:C().min(1),appId:C().min(1),appSecret:C().min(1),botName:C().min(1).optional()});const aue=z({chatId:C().min(1),chatName:C().optional(),lastActiveAt:ee().int().optional()}),lue=z({state:Ye(["unbound","provisioning","bound","broken"]),appId:C().optional(),botName:C().optional(),brokenReason:C().optional(),qrUrl:C().optional(),provisionId:C().optional(),errorReason:oue.optional(),groups:ge(aue),needsUpgrade:Re().optional(),upgradeQrUrl:C().optional()});lue.extend({personaId:C().min(1)});z({});z({onboardingCompletedAt:ee()});const Mh=["claude","codex","pi"];z({});z({tools:ge(z({id:Ye(Mh),available:Re(),version:C().optional(),path:C().optional()}))});z({});const cue=z({tool:Ye(Mh),cwd:C(),toolSessionId:C(),label:C().optional(),createdAt:C(),updatedAt:C(),turns:ee()});z({candidates:ge(cue)});z({});z({registered:Re()});z({tool:Ye(Mh)});const QP=z({usedPercent:ee(),windowDurationMins:ee().optional(),resetsAt:ee().optional()}).strict(),uue=Bs("kind",[z({kind:de("claude"),loggedIn:Re(),authMethod:C().optional(),apiProvider:C().optional(),apiKeySource:C().optional(),email:C().optional(),orgName:C().optional(),subscriptionType:C().optional()}).strict(),z({kind:de("codex"),login:Bs("type",[z({type:de("none")}).strict(),z({type:de("apiKey")}).strict(),z({type:de("chatgpt"),email:C(),planType:C()}).strict()]),provider:z({name:C(),baseUrl:C().optional()}).strict(),rateLimits:z({primary:QP.optional(),secondary:QP.optional()}).strict().optional()}).strict(),z({kind:de("pi"),providers:ge(z({id:C(),modelCount:ee(),credential:Ye(["api_key","oauth"]).optional(),oauthExpiresAt:ee().optional()}).strict())}).strict()]);z({tool:Ye(Mh),installed:Re(),version:C().optional(),path:C().optional(),account:uue.optional(),error:C().optional(),modelsLoadedAt:ee().optional()}).strict();const j5="https://cpa-portal-d417.app.clawos.chat";z({apiKey:C().min(1)}).strict();z({ok:de(!0)}).strict();const B7=["cloud-persona-metrics","cloud-persona-conversations"],due=Ye(B7);z({page:due}).strict();z({url:C(),expiresAt:ee().int()}).strict();const F7=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","session:queue","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","contact:note-updated","org-mesh:progress","channel:changed","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","larkBot:state"],hue="cloud_history_refresh",E5=["idle","running","running-idle","stopped","error","observing"],fue=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function cw(e){return e==="dispatch-task"||e==="dispatch-result"}const pue=["builtin","global","project","plugin"],mue=["builtin","global","project","policy","plugin"],z7=Ye(["owner","guest"]);z({id:C().min(1),kind:z7,displayName:C(),feishuUnionId:C().optional()}).strict();const gue=z({did:C().min(1),displayName:C(),feishuUnionId:C().optional(),principal:z7}).strict(),xue=Ye(E5),vue=z({inputTokens:ee().int().nonnegative(),outputTokens:ee().int().nonnegative(),cacheReadTokens:ee().int().nonnegative().optional(),cacheCreateTokens:ee().int().nonnegative().optional()}),H7={gitBranch:C().optional(),resolvedModel:C().optional(),resolvedEffort:C().optional(),contextUsage:vue.optional(),contextWindowSize:ee().int().positive().optional(),aiLabel:C().optional()},yue=z(H7),U7=z({value:C(),label:C(),description:C().optional()}),bue=z({id:C().min(1),label:C().min(1),description:C().optional(),contextWindowSize:ee().int().positive(),default:Re().optional(),efforts:ge(U7).optional(),defaultEffort:C().optional(),group:C().optional()}),wue=z({id:C().min(1),label:C().min(1),description:C().optional()}),_ue=z({name:C().min(1),type:Ye(["string","select","toggle"]),label:C().min(1),description:C().optional(),options:ge(U7).optional(),default:Ua().optional(),scope:Ye(["core","tool-specific"])});z({tool:C().min(1),refresh:Re().optional()});const Sue=z({rewind:Re(),subagents:Re(),tui:Re(),observe:Re(),fileSharing:Re(),fork:Re()});z({tool:C().min(1),toolSessionIdLabel:C().optional(),models:ge(bue),permissionModes:ge(wue),configSchema:ge(_ue),features:Sue});const kue=z({tool:C().min(1),pattern:C().min(1),createdAt:C().min(1).optional()});z({cloudEnvironment:Hs.optional(),cloudExpectedImage:Ya.optional(),testReleaseId:C().optional(),sessionId:C().min(1),cloudExecutionId:C().min(1).optional(),cloudConversationId:C().min(1).optional(),cloudWorkspace:l5.optional(),cloudPendingTurns:ge(z({id:C().min(1),text:C(),prepared:Re().optional()})).optional(),cloudBranchIntent:ng.optional(),cloudGatewaySessionId:C().min(1).optional(),cloudPendingCommand:z({id:C().min(1),text:C(),prepared:Re().optional()}).optional(),cwd:C().min(1),tool:de("claude").or(C().min(1)).default("claude"),toolSessionId:C().optional(),label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),serviceTier:C().optional(),...H7,aiLabelGeneratedAt:C().optional(),permissionRules:ge(kue).optional(),pinnedAt:ee().int().nonnegative().nullable().optional(),archivedAt:ee().int().nonnegative().nullable().optional(),pinSortOrder:ee().int().nullable().optional(),unreadAt:C().min(1).nullable().optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Re().optional(),deployId:C().min(1).optional(),ownerPersonaId:C().min(1).optional(),projectPath:C().min(1).optional(),chatId:C().min(1).optional(),creatorPrincipalId:C().min(1).optional(),creatorDisplayName:C().min(1).optional(),creatorFeishuUnionId:C().min(1).optional(),originOwnerPrincipalId:C().min(1).optional(),originOwnerPersonaId:C().min(1).optional(),dispatchedFromSessionId:C().min(1).optional(),shiftFiredFromSessionId:C().min(1).optional(),larkChatId:C().min(1).optional(),larkChatName:C().min(1).optional(),larkChatType:Ye(["p2p","group"]).optional(),createdAt:C().min(1),updatedAt:C().min(1)});const Ns={turnId:C().min(1).optional(),seq:ee().int().nonnegative().optional(),ts:C().optional(),uuid:C().optional()},Cue=Ye(fue),Nue=z({readCount:ee().int().nonnegative().optional(),searchCount:ee().int().nonnegative().optional(),bashCount:ee().int().nonnegative().optional(),editFileCount:ee().int().nonnegative().optional(),linesAdded:ee().int().nonnegative().optional(),linesRemoved:ee().int().nonnegative().optional(),otherToolCount:ee().int().nonnegative().optional()}),jue=z({oldStart:ee().int().nonnegative(),oldLines:ee().int().nonnegative(),newStart:ee().int().nonnegative(),newLines:ee().int().nonnegative(),lines:ge(C())}),Eue=z({agentId:C().optional(),agentType:C().optional(),status:C().optional(),prompt:C().optional(),filePath:C().optional(),structuredPatch:ge(jue).optional(),stats:z({durationMs:ee().int().nonnegative().optional(),tokens:ee().int().nonnegative().optional(),toolUseCount:ee().int().nonnegative().optional(),toolStats:Nue.optional()}).optional()}),Iue=z({path:C(),content:C(),mtimeMs:ee().optional()}),Tue=z({label:C().min(1),description:C().optional()}),W7=z({question:C().min(1),multiSelect:Re(),options:ge(Tue).min(1)}),Rue=["completed","interrupted"];Bs("kind",[z({...Ns,kind:de("session_init"),toolSessionId:C().optional()}),z({...Ns,kind:de("thinking"),text:C(),partialId:C().optional()}),z({...Ns,kind:de("text"),text:C(),partialId:C().optional()}),z({...Ns,kind:de("user_text"),text:C(),meta:Cue.optional(),taskId:C().optional(),parentToolUseId:C().optional(),sender:gue.optional()}),z({...Ns,kind:de("tool_call"),toolUseId:C(),tool:C(),toolKind:C().optional(),input:Ua()}),z({...Ns,kind:de("tool_result"),toolUseId:C(),output:Ua().optional(),error:C().optional(),toolResultExtra:Eue.optional(),sourceToolAssistantUUID:C().optional(),askQuestionAnswers:Gi(C(),C()).optional()}),z({...Ns,kind:de("attachment_memories"),memories:ge(Iue)}),z({...Ns,kind:de("permission_request"),requestId:C(),tool:C(),input:Ua(),toolUseId:C().optional()}),z({...Ns,kind:de("ask_user_question"),toolUseId:C(),questions:ge(W7)}),z({...Ns,kind:de("turn_end"),durationMs:ee().int().nonnegative().optional(),reason:Ye(Rue).optional(),turnId:C().min(1).optional()}),z({...Ns,kind:de("subagent_progress"),toolUseId:C(),agentId:C(),status:Ye(["started","running","completed","failed"]),description:C().optional(),lastToolName:C().optional(),prompt:C().optional(),stats:z({durationMs:ee().int().nonnegative().optional(),tokens:ee().int().nonnegative().optional(),toolUseCount:ee().int().nonnegative().optional()}).optional()}),z({...Ns,kind:de("error"),message:C()}),z({...Ns,kind:de("meta_update"),patch:yue}),z({...Ns,kind:de("meta-text"),text:C(),metaSource:Ye(["cc","owner"]).optional()})]);z({cwd:C().min(1).optional(),tool:C().optional(),label:C().optional(),aiLabel:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),serviceTier:p7.optional(),iconKey:C().optional(),forkedFromSessionId:C().min(1).optional(),ephemeral:Re().optional(),ownerPersonaId:C().min(1).optional(),projectPath:C().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});z({path:C().min(1),name:C().min(1),createdAt:C().datetime(),pinnedAt:ee().optional()});z({path:C().min(1),pinnedAt:ee().nullable()});z({path:C().min(1)});z({path:C().min(1).optional(),name:C().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});z({cwd:C().min(1),tool:C().min(1),toolSessionId:C().min(1),label:C().optional(),aiLabel:C().optional(),iconKey:C().optional(),createdAt:C().datetime(),updatedAt:C().datetime(),ownerPersonaId:C().min(1).optional()});z({originOnly:Re().optional(),ownerPersonaId:C().min(1).optional(),limit:ee().int().positive().optional(),offset:ee().int().nonnegative().optional()});z({sessionId:C().min(1)});z({sessionId:C().min(1),patch:z({label:C().optional(),model:C().optional(),permissionMode:C().optional(),effort:C().optional(),cwd:C().optional(),iconKey:C().optional(),ephemeral:de(!1).optional()})});z({id:C().min(1),text:C(),queuedAt:ee(),senderDisplayName:C().optional()});z({sessionId:C().min(1),text:C(),queueWhileRunning:Re().optional()});z({sessionId:C().min(1),id:C().min(1).optional()});z({sessionId:C().min(1),userMessageId:C().min(1),dryRun:Re().optional()});z({canRewind:Re(),error:C().optional(),filesChanged:ge(C()).optional(),insertions:ee().int().nonnegative().optional(),deletions:ee().int().nonnegative().optional()});z({sessionId:C().min(1),userMessageId:C().min(1)});const Mue=z({oldStart:ee().int().nonnegative(),oldLines:ee().int().nonnegative(),newStart:ee().int().nonnegative(),newLines:ee().int().nonnegative(),lines:ge(C())}),Pue=z({filePath:C().min(1),hunks:ge(Mue),insertions:ee().int().nonnegative(),deletions:ee().int().nonnegative(),status:Ye(["modified","added","deleted"]).optional()});z({canRewind:Re(),error:C().optional(),files:ge(Pue),totalInsertions:ee().int().nonnegative(),totalDeletions:ee().int().nonnegative()});z({userMessageIds:ge(C())});z({sessionId:C().min(1),toolSessionId:C().min(1)});z({cwd:C().min(1),toolSessionId:C().min(1),messageUuid:C().min(1).optional(),turnId:C().min(1).optional(),sourceSessionId:C().min(1).optional(),targetCwd:C().min(1).optional()}).refine(e=>!!(e.messageUuid||e.turnId),"messageUuid or turnId required");z({forkedToolSessionId:C().min(1),forkedFilePath:C().min(1)});z({sessionId:C().min(1),toolSessionId:C().min(1),jsonlPath:C().optional()});z({sessionId:C().min(1),afterSeq:ee().int().min(-1)});z({sessionId:C().min(1),permissionRequestId:C().min(1),allow:Re(),permanent:Re().optional(),pattern:C().optional()});z({projectPath:C().min(1)});z({sessionId:C().min(1),limit:ee().int().positive().max(5e3).optional(),offset:ee().int().nonnegative().optional(),snapshotId:C().uuid().optional(),slim:Re().optional(),view:Ye(["turns","items"]).optional(),cursor:C().min(1).max(16384).optional(),turnId:C().min(1).max(256).optional()}).superRefine((e,t)=>{e.view==="items"&&!e.turnId&&t.addIssue({code:ye.custom,path:["turnId"],message:"items requires turnId"}),e.view&&(e.offset!==void 0||e.slim!==void 0)&&t.addIssue({code:ye.custom,message:"native views do not accept offset or slim"}),!e.view&&(e.cursor!==void 0||e.turnId!==void 0)&&t.addIssue({code:ye.custom,message:"cursor and turnId require a native view"}),e.view==="turns"&&e.turnId!==void 0&&t.addIssue({code:ye.custom,path:["turnId"],message:"turns does not accept turnId"}),e.view&&e.limit!==void 0&&e.limit>100&&t.addIssue({code:ye.custom,path:["limit"],message:"native page limit is 100"})});z({cwd:C().min(1),toolSessionId:C().min(1)});z({cwd:C().min(1),toolSessionId:C().min(1),subagentId:C().min(1)});z({cwd:C().min(1).optional(),path:C().optional(),showHidden:Re().optional()});z({cwd:C().min(1),path:C().min(1)});z({cwd:C().min(1),tool:C().optional()});z({name:C().min(1),source:Ye(pue),path:C().optional(),description:C().optional(),plugin:C().optional()});const Oue=z({name:C().min(1),source:Ye(mue),path:C().optional(),description:C().optional(),whenToUse:C().optional(),plugin:C().optional()});z({cwd:C().min(1),tool:C().optional()});z({agents:ge(Oue)});z({sessionId:C().optional()});z({sessionId:C().min(1).optional()});z({sessionId:C().min(1),pinned:Re()});z({sessionId:C().min(1),archived:Re()});z({query:C().min(1),sessionIds:ge(C().min(1)),limit:ee().int().positive().max(50).optional()});const Due=z({sessionId:C().min(1),snippet:C()});z({type:de("session:searchContent"),matches:ge(Due)});z({type:de("peerSession:upsert:ok")});z({sessionId:C().min(1)});z({type:de("peerSession:remove:ok")});z({orderedIds:ge(C().min(1)).min(1)});z({cwd:C().min(1)});z({isGitRoot:Re(),gitRoot:C().nullable()});z({cwd:C().min(1)});z({branch:C().nullable()});z({cwd:C().min(1)});z({branches:ge(C()),head:C().nullable()});const Aue=z({cwd:C().min(1),updatedAt:C().min(1)});z({dirs:ge(Aue)});z({type:de("session:question"),sessionId:C().min(1),toolUseId:C().min(1),requestId:C().min(1),questions:ge(W7).min(1)});z({type:de("session:question:cleared"),sessionId:C().min(1),toolUseId:C().min(1),answers:Gi(C(),C()).optional()});z({sessionId:C().min(1),toolUseId:C().min(1),answers:Gi(C(),C())});z({ok:de(!0)});z({sessionId:C().min(1),toolUseId:C().min(1)});z({ok:de(!0)});const V7=z({name:C().min(1),version:C().min(1),instanceId:C().min(1),deviceLabel:C().transform(e=>e.trim().slice(0,64)).optional()});z({type:de("auth"),token:C().min(1),scheme:de("bearer").optional(),clientInfo:V7.optional()});z({type:de("auth:ok"),version:C().min(1).optional(),protocolVersion:ee().int().nonnegative().optional()});const $ue=z({clientId:C().min(1),connectedAt:ee().int().nonnegative(),self:Re(),clientInfo:V7.optional()});z({type:de("device:connections:ok"),connections:ge($ue)});z({type:de("tunnel:ready"),url:C().min(1),subdomain:C().min(1)});z({type:de("tunnel:exited"),code:ee().int().nullable(),subdomain:C().nullable(),url:C().nullable()});z({type:de("tunnel:unavailable"),reason:C().min(1),failedAt:C().min(1)});const Lue=z({sessionId:C().min(1),status:xue,freshSpawn:Re(),pendingPermissionRequestIds:ge(C().min(1)),pendingQuestionToolUseIds:ge(C().min(1))});z({type:de("info"),version:C(),protocolVersion:ee(),hostname:C(),os:C(),tools:ge(z({id:C(),available:Re()})),runningSessions:ge(Lue),tokenRole:Ye(Lle).optional(),isLoopback:Re().optional(),httpBaseUrl:C().optional(),httpToken:C().optional(),daemonSource:Ye(["ota","packaged"]).optional(),globalCliVersion:C().nullable().optional()});z({});z({method:C().min(1).optional()});const Bue=["allowed","conditional","denied"],Fue=Ye(Bue),zue=z({name:C().min(1),status:Fue,description:C().min(1),args:ge(z({name:C(),required:Re()})).nullable(),argsSchema:Gi(Ua()).optional(),reason:C().optional()});z({type:de("meta:methods"),methods:ge(zue)});const JP=1,Hue=z({usedBytes:ee().int().nonnegative(),sizeBytes:ee().int().positive(),measuredAt:ee().int().nonnegative()}).strict();z({volume:Hue.nullable()}).strict();const eO=25*1024*1024,I5={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/plain",".markdown":"text/plain",".csv":"text/plain",".log":"text/plain",".json":"application/json",".xml":"application/xml",".yaml":"application/yaml",".yml":"application/yaml",".html":"text/html",".conf":"text/plain",".cfg":"text/plain",".ini":"text/plain",".toml":"text/plain"},q7=new Set([...Object.values(I5),"application/x-yaml"]),K7=[...q7,"text/*",...Object.keys(I5)].join(",");function G7(e,t){const n=t.split(";",1)[0].trim().toLowerCase();if(n===""||n==="application/octet-stream"){const r=e.lastIndexOf("."),s=r>0?e.slice(r).toLowerCase():"";return I5[s]??null}return q7.has(n)||n.startsWith("text/")?n:null}const Uue=["daemon","main","renderer"],Wue=Ye(Uue),Vue=["debug","info","warn","error"],que=Ye(Vue);z({ts:ee().int(),source:Wue,level:que,msg:C(),ownerPrincipalId:C(),deviceId:C(),appVersion:C(),daemonVersion:C().optional(),os:C(),meta_json:C().optional(),sessionId:C().optional()});z({v:de(1),visitorId:C().min(1),displayName:C(),provider:C(),iat:ee(),exp:ee()});const Kue=z({visitorId:C(),displayName:C(),avatarUrl:C().optional(),provider:C(),firstSeen:ee(),lastSeen:ee()});z({visitors:ge(Kue)});z({type:de("web:open"),url:C().min(1),expiresAt:ee()});z({ticket:C().min(1)}).strict();z({token:C().min(1),expiresAt:ee()});const Gue=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,Y7=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,X7="clawd-dispatch-task",Z7="clawd-dispatch-result",tO=120;function Yue(e){if(!e)return null;const t=e.search(nO(X7)),n=e.search(nO(Z7));return t<0&&n<0?null:n<0?"task":t<0?"result":t<n?"task":"result"}function Xue(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?X7:Z7,s=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let i=s.exec(e);i!==null;i=s.exec(e))t.push({at:i.index,block:Zue(n,i[1]??"",i[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Zue(e,t,n){var u;const r=sde(t),s=BN(rde(rk(n,"detail")??n)),i=(u=rk(n,"brief"))==null?void 0:u.trim(),o=i&&i.length>0?BN(i):Que(s),l=r.round!==void 0?Number.parseInt(r.round,10):void 0,c=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&l!==void 0&&Number.isFinite(l)?{round:l}:{},...e==="result"&&(c==="success"||c==="failure")?{status:c}:{},brief:o,briefIsDerived:!(i&&i.length>0),detail:s,filePaths:nde(rk(n,"files"))}}function Que(e){const t=e.split(/\n\s*\n/).map(r=>r.trim()).find(r=>r.length>0);if(!t)return"";const n=t.replace(/\s+/g," ");return n.length>tO?`${n.slice(0,tO)}…`:n}const Jue="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",ede=new RegExp(`<\\\\(\\\\*)(/?)(${Jue})\\b`,"g");function tde(e){return BN(e)}function BN(e){return e.replace(ede,"<$1$2$3")}function rk(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function nde(e){return e?e.split(`
96
96
  `).map(t=>t.trim()).filter(t=>t.startsWith("- ")).map(t=>t.slice(2).trim()).filter(t=>t.length>0):[]}function rde(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function nO(e){return new RegExp(`<${e}\\b[^>]*>`,"i")}function sde(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=ide(r[2]??"");return t}function ide(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}/**
97
97
  * @license lucide-react v0.577.0 - ISC
98
98
  *
@@ -912,7 +912,7 @@ Minimum version required to store current data is: `+i+`.
912
912
  `;return typeof r=="function"&&r(null,f),f};const i4e=b3e,lE=tY,gY=pY,o4e=mY;function CR(e,t,n,r,s){const i=[].slice.call(arguments,1),o=i.length,l=typeof i[o-1]=="function";if(!l&&!i4e())throw new Error("Callback required as last argument");if(l){if(o<2)throw new Error("Too few arguments provided");o===2?(s=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof s>"u"?(s=r,r=void 0):(s=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(c,u){try{const d=lE.create(n,r);c(e(d,t,r))}catch(d){u(d)}})}try{const c=lE.create(n,r);s(null,e(c,t,r))}catch(c){s(c)}}Yu.create=lE.create;Yu.toCanvas=CR.bind(null,gY.render);Yu.toDataURL=CR.bind(null,gY.renderToDataURL);Yu.toString=CR.bind(null,function(e,t,n){return o4e.render(e,n)});const bs=ZH,a4e=QH,xY=p.forwardRef(({className:e,...t},n)=>a.jsx(q5,{ref:n,className:J("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));xY.displayName=q5.displayName;const ss=p.forwardRef(({className:e,children:t,...n},r)=>a.jsxs(a4e,{children:[a.jsx(xY,{}),a.jsxs(K5,{ref:r,className:J("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,a.jsxs(JH,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[a.jsx(Xt,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ss.displayName=K5.displayName;const zs=({className:e,...t})=>a.jsx("div",{className:J("flex flex-col space-y-1.5 text-left",e),...t});zs.displayName="DialogHeader";const el=({className:e,...t})=>a.jsx("div",{className:J("flex flex-row justify-end gap-2",e),...t});el.displayName="DialogFooter";const is=p.forwardRef(({className:e,...t},n)=>a.jsx(G5,{ref:n,className:J("text-lg font-semibold leading-none text-text-100",e),...t}));is.displayName=G5.displayName;const Ui=p.forwardRef(({className:e,...t},n)=>a.jsx(Y5,{ref:n,className:J("text-sm text-text-300",e),...t}));Ui.displayName=Y5.displayName;function l4e({persona:e,open:t,onClose:n,onDelete:r,embedded:s,onLoadPersonality:i,onSavePersonality:o,onLoadPersonalityLocal:l,onSavePersonalityLocal:c,hasPersonalityLocal:u=!1,onDirtyChange:d,initialPersonality:h,onShareCapability:f,readOnly:m=!1,larkBot:g}){const[x,b]=p.useState(!1),[y,v]=p.useState(!1),w=x||y,_=G.useRef(d);p.useEffect(()=>{_.current=d}),p.useEffect(()=>{var k;(k=_.current)==null||k.call(_,w)},[w]);const S=()=>{w&&!window.confirm("修改未保存,确定关闭?")||n()};return t?a.jsxs(a.Fragment,{children:[!s&&a.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:S,"aria-hidden":"true"}),a.jsxs("aside",{className:s?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[a.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(pw,{className:"h-4 w-4 text-text-300"}),a.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),a.jsx("button",{type:"button",onClick:S,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:a.jsx(Xt,{className:"h-4 w-4"})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[a.jsxs("header",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?a.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[a.jsx($5,{className:"h-3 w-3"})," 公开"]}):a.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[a.jsx(Ehe,{className:"h-3 w-3"})," 已关闭"]})]}),a.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[f?a.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[a.jsx(mw,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?a.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:a.jsx(ys,{className:"h-4 w-4"})}):null]})]}),a.jsx("hr",{className:"border-border"}),g?a.jsxs(a.Fragment,{children:[a.jsx(vY,{...g}),a.jsx("hr",{className:"border-border"})]}):null,i?a.jsxs(a.Fragment,{children:[a.jsx(K$,{onLoad:i,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:b,initialPersonality:h,readOnly:m||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?m?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||u)&&l?a.jsx(K$,{onLoad:l,...c?{onSave:c}:{},onDirtyChange:v,readOnly:m,title:m?"补充设定":"你的补充",hint:m?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的会话生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,a.jsx("hr",{className:"border-border"})]}):null,a.jsx(d4e,{settings:e.sandboxSettings??null}),a.jsx("hr",{className:"border-border"}),a.jsx(h4e,{skills:e.skills??[]}),a.jsx("hr",{className:"border-border"}),a.jsx(f4e,{plugins:e.plugins??[]})]})]})]}):null}function q$({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:s="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[i,o]=p.useState(null);return p.useEffect(()=>{let l=!1;return Yu.toDataURL(e,{width:240,margin:1}).then(c=>{l||o(c)}).catch(()=>{l||o(null)}),()=>{l=!0}},[e]),a.jsx(bs,{open:!0,onOpenChange:l=>l||n==null?void 0:n(),children:a.jsxs(ss,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:l=>l.preventDefault(),onEscapeKeyDown:l=>l.preventDefault(),children:[a.jsx(zs,{children:a.jsx(is,{children:r})}),a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[i?a.jsx("img",{src:i,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):a.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),a.jsx("span",{className:"text-center text-[12px] text-text-300",children:s}),n?a.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const c4e={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},u4e=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function vY({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:s,onUpgrade:i,runtime:o="local"}){const[l,c]=p.useState(!1),[u,d]=p.useState(null),[h,f]=p.useState(""),[m,g]=p.useState(""),[x,b]=p.useState(null),y=N=>{N&&(c(!0),d(null),N().catch(j=>d(j instanceof Error?j.message:String(j))).finally(()=>c(!1)))},v=()=>{b(null),y(t)},w=!l&&!!h&&!!m,_=()=>{!w||!r||y(()=>r({appId:h,appSecret:m}))},S=mi(_),k=a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(ea,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?a.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[k,e.state==="unbound"||e.state==="provisioning"?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"text-[11px] text-text-400",children:["关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它,",o==="cloud"?"云 Persona 在云端处理消息,回复自动发回去。":"推理跑在你本机,回复自动发回去。"]}),t?a.jsx("button",{type:"button",disabled:l||e.state==="provisioning",onClick:v,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!x?a.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[a.jsx("span",{className:"text-[11px] text-error",children:c4e[e.errorReason]}),a.jsxs("div",{className:"flex gap-1.5",children:[u4e.has(e.errorReason)&&t?a.jsx("button",{type:"button",disabled:l,onClick:v,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,a.jsx("button",{type:"button",onClick:()=>b(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?a.jsx(q$,{qrUrl:e.qrUrl,busy:l,onCancel:n?()=>y(n):void 0}):null,r&&e.state==="unbound"?a.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[a.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),a.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[a.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),a.jsx("input",{value:h,onChange:N=>f(N.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),a.jsx("input",{value:m,onChange:N=>g(N.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),a.jsx("button",{type:"button",disabled:!w,onClick:_,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:l?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?a.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?a.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[a.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),i?a.jsx("button",{type:"button",disabled:l,onClick:()=>y(i),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?a.jsx(q$,{qrUrl:e.upgradeQrUrl,busy:l,onCancel:n?()=>y(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?a.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,a.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[a.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?a.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),a.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?a.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(N=>a.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",N.chatName??N.chatId]},N.chatId))}):a.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),s?a.jsx("button",{type:"button",disabled:l,onClick:()=>y(s),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,u?a.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:u}):null]}):a.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[k,a.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function d4e({settings:e}){var t,n,r,s,i,o,l,c,u,d,h,f,m;return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[a.jsxs("header",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),a.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?a.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):a.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[a.jsx(x0,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),a.jsx(x0,{label:"沙箱启用",value:cC((n=e.sandbox)==null?void 0:n.enabled)}),a.jsx(x0,{label:"沙箱内自动放行 Bash",value:cC((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),a.jsx(x0,{label:"允许非沙箱命令",value:cC((s=e.sandbox)==null?void 0:s.allowUnsandboxedCommands)}),a.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[a.jsx(Np,{label:"沙箱外命令",paths:(i=e.sandbox)==null?void 0:i.excludedCommands}),a.jsx(Np,{label:"允许读取",paths:(l=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:l.allowRead}),a.jsx(Np,{label:"拒绝读取",paths:(u=(c=e.sandbox)==null?void 0:c.filesystem)==null?void 0:u.denyRead}),a.jsx(Np,{label:"允许写入",paths:(h=(d=e.sandbox)==null?void 0:d.filesystem)==null?void 0:h.allowWrite}),a.jsx(Np,{label:"拒绝写入",paths:(m=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:m.denyWrite})]})]})]})}function cC(e){return e===!0?"是":e===!1?"否":"—"}function x0({label:e,value:t}){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[a.jsx("span",{className:"text-text-300",children:e}),a.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Np({label:e,paths:t}){const n=!t||t.length===0;return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?a.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):a.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,s)=>a.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${s}-${r}`))})]})}function h4e({skills:e}){return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[a.jsxs("header",{className:"flex flex-col gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),a.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),a.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",a.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?a.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):a.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>a.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[a.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?a.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):a.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function f4e({plugins:e}){return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[a.jsxs("header",{className:"flex flex-col gap-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),a.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),a.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",a.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",a.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?a.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):a.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>a.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:a.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function K$({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:s=!1,title:i,hint:o,placeholder:l,testIdPrefix:c}){const u=r!==void 0,[d,h]=p.useState(u),[f,m]=p.useState(u?r:""),[g,x]=p.useState(u?r:""),[b,y]=p.useState(null),[v,w]=p.useState(!1),[_,S]=p.useState(null),k=G.useRef(e),N=G.useRef(t),j=G.useRef(n);G.useEffect(()=>{k.current=e,N.current=t,j.current=n});const R=G.useCallback(()=>{h(!1),y(null),k.current().then(D=>{m(D),x(D),h(!0)}).catch(D=>{y(D instanceof Error?D.message:String(D))})},[]);G.useEffect(()=>{u||R()},[u,R]);const E=!s&&d&&g!==f;G.useEffect(()=>{s||j.current(E)},[E,s]);const I=()=>{N.current&&(w(!0),S(null),N.current(g).then(()=>{m(g),w(!1)}).catch(D=>{S(D instanceof Error?D.message:String(D)),w(!1)}))},M=()=>{x(f),S(null)},P=mi(()=>{!E||v||I()},()=>{!E||v||M()});return a.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${c}-section`,children:[a.jsx("span",{className:"text-[12px] font-medium text-text-200",children:i}),b?a.jsxs("div",{"data-testid":`${c}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[a.jsxs("span",{children:["加载失败:",b]}),a.jsx("button",{type:"button",onClick:R,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,_?a.jsxs("div",{"data-testid":`${c}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",_]}):null,a.jsx("textarea",{"data-testid":`${c}-textarea`,value:g,onChange:D=>x(D.target.value),...P,readOnly:s,disabled:!s&&(!d||v),placeholder:d?l??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?a.jsx("p",{className:"text-[10px] text-text-400",children:o}):s?null:a.jsx("p",{className:"text-[10px] text-text-400",children:"写入人格文件。修改只对新启动的会话生效。"}),d&&E?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:M,disabled:v,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),a.jsx("button",{type:"button",onClick:I,disabled:v,"data-testid":`${c}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:v?"保存中…":"保存"})]}):null]})}function Xu(){const e=Kn();return p.useMemo(()=>new Vt(e),[e])}function yY(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,serviceTier:e.serviceTier,tool:e.tool,...e.size!==void 0?{size:e.size}:{},...e.cpu!==void 0?{cpu:e.cpu}:{},...e.taskConcurrency!==void 0?{taskConcurrency:e.taskConcurrency}:{},...e.cloudEngine?{cloudEngine:e.cloudEngine}:{},public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt,...e.cloud?{cloud:e.cloud}:{}}}function i_(){const e=Ws(),t=Xu(),n=ua("personas")??[],r=p.useMemo(()=>n.map(i=>yY(i)),[n]),s=p.useCallback(async()=>{const i=await t.personaList();e.setData("personas",()=>i.personas??[])},[t,e]);return{personas:r,raw:n,loaded:ua("personas")!==void 0,refresh:s}}function NR(e){const{raw:t}=i_(),n=Ws(),r=Xu(),s=e?t.find(l=>l.personaId===e)??null:null,i=s?yY(s):null,o=p.useCallback(async l=>{if(!e)return;(l==null?void 0:l.personaId)===e&&n.setData("personas",u=>{const d=u??[];return d.some(h=>h.personaId===e)?d.map(h=>h.personaId===e?l:h):[...d,l]});const c=await r.personaList();n.setData("personas",()=>c.personas??[])},[e,r,n]);return{persona:i,raw:s,loaded:!!i,refresh:o}}function p4e(e){const t=Xu(),n=Ws(),r=e?`persona-detail/${e}`:"",s=ua(r),i=p.useCallback(async()=>{const o={personality:"",personalityLocal:"",personalityManaged:!1,skills:[],plugins:[],sandboxSettings:null,codexSandbox:null};if(!e)return o;let l=null;try{l=await t.personaGet(e)}catch(u){Pe("personas","personaGet failed → empty detail",{personaId:e,err:u}),l=null}const c=l?{personality:l.personality??"",personalityLocal:l.personalityLocal??"",personalityManaged:l.personalityManaged??!1,skills:l.skills??[],plugins:l.plugins??[],sandboxSettings:l.sandboxSettings??null,codexSandbox:l.codexSandbox??null}:o;return n.setData(r,()=>c),c},[t,n,e,r]);return p.useEffect(()=>{e&&i()},[e,i]),{personality:(s==null?void 0:s.personality)??"",personalityLocal:(s==null?void 0:s.personalityLocal)??"",personalityManaged:(s==null?void 0:s.personalityManaged)??!1,skills:(s==null?void 0:s.skills)??[],plugins:(s==null?void 0:s.plugins)??[],sandboxSettings:(s==null?void 0:s.sandboxSettings)??null,codexSandbox:(s==null?void 0:s.codexSandbox)??null,loaded:s!==void 0,refresh:i}}function jR(){const e=Ws(),t=Xu();return p.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function m4e(){const e=Xu(),t=jR();return p.useCallback(async n=>{const r=await e.personaCreate(n);return await t(),r},[e,t])}function g4e(){const e=Xu(),t=jR();return p.useCallback(async(n,r)=>{const s=await e.personaUpdate(n,r);return await t(),s},[e,t])}function bY(){const e=Xu(),t=jR();return p.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const x4e={state:"unbound",groups:[]};function wY(e,t,n="local"){const[r,s]=p.useState(null),i=h=>`${n==="cloud"?"cloud:":""}larkBot:${h}`;p.useEffect(()=>{if(!e)return;let h=!1,f=0,m=!1;s(null);const g=async()=>{const v=++f;m=!0;try{const w=await e.request(i("status"),{personaId:t});if(h||v!==f)return;s(_=>n==="cloud"&&(_!=null&&_.upgradeQrUrl)&&w.state==="bound"&&w.needsUpgrade!==!1?{...w,upgradeQrUrl:_.upgradeQrUrl}:w.state==="unbound"&&!w.errorReason&&(_==null?void 0:_.state)==="unbound"&&_.errorReason?{...w,errorReason:_.errorReason}:w)}catch{!h&&v===f&&s(w=>w??x4e)}finally{v===f&&(m=!1)}};g();const x=e.on("larkBot:state",v=>{const w=v;if(w.personaId!==t)return;const{personaId:_,...S}=w;++f,m=!1,s(S)}),b=e.on("daemon:connected",()=>{g()}),y=n==="cloud"?setInterval(()=>{m||g()},5e3):null;return()=>{h=!0,y&&clearInterval(y),x(),b()}},[e,t,n]);const o=p.useCallback(async()=>{e&&await e.request(i("provision"),{personaId:t})},[e,t,n]),l=p.useCallback(async()=>{e&&await e.request(i("provisionCancel"),{personaId:t})},[e,t,n]),c=p.useCallback(async h=>{e&&await e.request(i("bindManual"),{personaId:t,...h})},[e,t,n]),u=p.useCallback(async()=>{e&&await e.request(i("upgrade"),{personaId:t})},[e,t,n]),d=p.useCallback(async()=>{e&&await e.request(i("unbind"),{personaId:t})},[e,t,n]);return{status:r,provision:o,cancelProvision:l,bindManual:c,unbind:d,upgrade:u}}function _Y(e,t="owner"){var N;const{persona:n}=NR(e),r=p4e(e),s=g4e(),i=bY(),{httpBaseUrl:o}=ux(),l=Kn(),c=wY(t==="guest"?null:l,e),{capabilities:u}=si((n==null?void 0:n.tool)??"claude"),d=p.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),h=p.useCallback((j,R)=>{s(e,R).catch(E=>{Pe("persona",`${j} failed`,E)})},[s,e]),f=p.useCallback(j=>h("togglePublic",{public:j}),[h]),m=p.useCallback(async j=>{await s(e,{codexSandbox:{network:j}}),await r.refresh()},[s,e,r]),g=p.useCallback(j=>h("changeTool",{tool:j}),[h]),x=p.useCallback(j=>h("changeModel",{model:j}),[h]),b=p.useCallback(j=>h("changeEffort",{effort:j}),[h]),y=p.useCallback(j=>h("toggleFastMode",{serviceTier:j?sg.fast:sg.standard}),[h]),v=p.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(i(e).catch(j=>{Pe("persona","delete failed",j)}),!0),[n,i,e]),w=p.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),_=p.useCallback(async j=>{await s(e,{personality:j}),await r.refresh()},[s,e,r]),S=p.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),k=p.useCallback(async j=>{await s(e,{personalityLocal:j}),await r.refresh()},[s,e,r]);return{persona:n,detail:r,configSchema:(u==null?void 0:u.configSchema)??[],larkBot:c,guestShareUrl:d,changeTool:g,changeModel:x,changeEffort:b,toggleFastMode:y,togglePublic:f,guestNetwork:((N=r.codexSandbox)==null?void 0:N.network)??!1,toggleGuestNetwork:m,remove:v,loadPersonality:w,savePersonality:_,loadPersonalityLocal:S,savePersonalityLocal:k}}function SY({personaId:e,open:t,onClose:n,api:r,embedded:s,onDirtyChange:i,onShareCapability:o,viewerRole:l="owner"}){const c=_Y(e,l),{persona:u,detail:d}=c,h=p.useCallback(()=>{c.remove()&&n()},[c,n]);if(!u)return null;const f=l==="guest";return a.jsx(l4e,{embedded:s,persona:{...u,skills:d.skills,plugins:d.plugins,sandboxSettings:d.sandboxSettings,personalityManaged:d.personalityManaged},open:t,onClose:n,onLoadPersonality:c.loadPersonality,onLoadPersonalityLocal:c.loadPersonalityLocal,hasPersonalityLocal:d.personalityLocal!=="",onDirtyChange:i,readOnly:f,...f?{}:{onTogglePublic:c.togglePublic,guestShareUrl:c.guestShareUrl,onChangeTool:c.changeTool,onChangeModel:c.changeModel,onChangeEffort:c.changeEffort,configSchema:c.configSchema,onDelete:h,onSavePersonality:c.savePersonality,onSavePersonalityLocal:c.savePersonalityLocal,larkBot:{status:c.larkBot.status,onProvision:c.larkBot.provision,onCancelProvision:c.larkBot.cancelProvision,onBindManual:c.larkBot.bindManual,onUnbind:c.larkBot.unbind,onUpgrade:c.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const v4e={resolve:()=>{}},kY=p.createContext(v4e);function y4e(){return p.useContext(kY)}const b4e={...Ja,h1:({node:e,...t})=>a.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>a.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>a.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>a.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>a.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>a.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>a.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>a.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>a.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>a.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>a.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?a.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):a.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>a.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>a.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>a.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>a.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>a.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>a.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>a.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>a.jsx("em",{...t,className:"italic"})};function w4e(e){const t=e.split("/");return t[t.length-1]||e}function CY({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[s,i]=p.useState(null),[o,l]=p.useState(null),[c,u]=p.useState(!1);return p.useEffect(()=>{if(!e)return;let d=!1;return u(!0),l(null),i(null),(async()=>{try{const h=await t(e);if(d)return;i(h)}catch(h){if(d)return;l(h.message||String(h))}finally{d||u(!1)}})(),()=>{d=!0}},[e,t]),a.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?a.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[a.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:w4e(e)}),a.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,a.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:c?a.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?a.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):s!==null?a.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:a.jsx(Eu,{remarkPlugins:[Hh],components:b4e,children:s})}):null})]})}function _4e({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:s}){return e?a.jsx("div",{"data-testid":"md-preview-drawer",className:`${Xw} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:a.jsx(CY,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:a.jsxs(a.Fragment,{children:[s?a.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:s,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:a.jsx(hH,{className:"h-4 w-4"})}):null,a.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:a.jsx(Xt,{className:"h-4 w-4"})})]})})}):null}const G$=4;function S4e({children:e,onHeightChange:t}){const n=p.useRef(null),[r,s]=p.useState(0);return p.useEffect(()=>{const i=n.current;if(!i)return;const o=()=>s(i.offsetHeight>0?i.offsetHeight+G$*2:0);if(o(),typeof ResizeObserver>"u")return;const l=new ResizeObserver(o);return l.observe(i),()=>l.disconnect()},[]),p.useEffect(()=>{t==null||t(r)},[r,t]),a.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:a.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:G$},children:e})})}function k4e(e,t,n,r,s,i){const o=ix(),[l,c]=p.useState(null),[u,d]=p.useState(s??null),[h,f]=p.useState(!1),[m,g]=p.useState(!1),[x,b]=p.useState(null),y=p.useRef({api:e,sessionId:t,enabled:n,epoch:0,read:null,again:!1,mutating:!1}),v=p.useRef({api:e,sessionId:t,enabled:n});v.current={api:e,sessionId:t,enabled:n};const w=p.useRef(t),_=p.useRef(async()=>{}),S=j=>{if(j.workspace!==void 0&&c(j.workspace),j.binding!==void 0)d(j.binding);else if(j.workspace){const{workspaceId:R,repoId:E,owner:I,name:M,sourceBranch:P,defaultBranch:D}=j.workspace;d({workspaceId:R,repoId:E,owner:I,name:M,sourceBranch:P,defaultBranch:D})}},k=p.useCallback(async()=>{const j=y.current;if(!n||j.sessionId!==t||j.api!==e)return;if(j.mutating){j.again=!0;return}if(j.read)return j.again=!0,j.read;const R=j.epoch;f(!0);const E=(async()=>{try{const I=await e.cloudWorkspace({sessionId:t,action:"status"});y.current===j&&j.epoch===R&&v.current.sessionId===t&&(S(I),b(null))}catch(I){y.current===j&&j.epoch===R&&b(I.message)}finally{y.current===j&&(j.read=null,f(!1),j.again&&!j.mutating&&(j.again=!1,_.current()))}})();return j.read=E,E},[e,t,n]);_.current=k;const N=p.useCallback(async(j,R)=>{const E=y.current;if(!n||E.sessionId!==t)throw new Error("Cloud workspace unavailable");const I=j.action==="bind",M=["repositories","branches"].includes(j.action);if(I&&E.mutating)throw new Error("工作区操作正在进行");I&&(E.mutating=!0,E.epoch++,E.again=!1,g(!0),b(null));try{const P=await(R?e.cloudWorkspace({...j,sessionId:t},{requestId:R}):e.cloudWorkspace({...j,sessionId:t}));return y.current===E&&v.current.sessionId===t&&(S(P),M||b(null)),P}catch(P){throw y.current===E&&!M&&b(P.message),P}finally{I&&y.current===E&&(E.mutating=!1,g(!1),(j.action==="bind"||E.again)&&(E.again=!1,_.current()))}},[e,t,n]);return p.useEffect(()=>{const j={api:e,sessionId:t,enabled:n,epoch:0,read:null,again:!1,mutating:!1};return y.current=j,w.current!==t&&(w.current=t,c(null),d(s??null)),b(null),g(!1),f(!1),n&&_.current(),()=>{j.epoch++,y.current===j&&(y.current={...j,enabled:!1,again:!1})}},[e,t,n]),p.useEffect(()=>{if(!n||!r)return;const j=r.on("session:event",E=>{var M;const I=E;I.sessionId===t&&((M=I.event)==null?void 0:M.kind)==="session_init"&&_.current()}),R=r.on("daemon:connected",()=>{_.current()});return()=>{j(),R()}},[r,t,n]),p.useEffect(()=>{if(!(!r||!n))return r.on("cloud:workspace:timing",j=>{const R=j;if(R.sessionId===t)try{o==null||o.push({level:"info",msg:"cloud.workspace.transport."+R.phase,sessionId:t,meta:R})}catch{}})},[r,n,o,t]),{sessionId:t,workspace:l,binding:u,branchIntent:i,loading:h,busy:m,error:x,refresh:k,run:N}}function C4e(e,t,n=()=>performance.now(),r){const s="workspace-"+crypto.randomUUID(),i=n(),o=r!==void 0&&Number.isFinite(r)&&r>=0&&r<=i?r:i,l=Math.round(i-o);let c,u,d="ok",h=!1;const f=(g,x={})=>{try{t("cloud.workspace.ui."+g,{...e,hasSearch:e.searchLength>0,traceId:s,inputDelayMs:l,...x})}catch{}},m=g=>{if(h)return;h=!0;const x=n();f("finished",{outcome:g,durationMs:Math.round(x-o),waitMs:c===void 0?void 0:Math.round(c-o),requestMs:c===void 0||u===void 0?void 0:Math.round(u-c),commitMs:u===void 0?void 0:Math.round(x-u)})};return f("started"),{requestId:s,get done(){return h},request(){c=n(),f("requested",{waitMs:Math.round(c-o)})},response(g,x,b){u=n(),d=g,f("response",{outcome:d,ignored:x,count:b,requestMs:c===void 0?void 0:Math.round(u-c)})},commit(){u!==void 0&&m(d)},finish:m}}function yx(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,s=Math.floor(r/6e4);if(s<1)return"just now";if(s<60)return`${s}m`;const i=Math.floor(s/60);if(i<24)return`${i}h`;const o=Math.floor(i/24);if(o<7)return`${o}d`;if(o<30)return`${Math.floor(o/7)}w`;const l=new Date(n),c=String(l.getMonth()+1).padStart(2,"0"),u=String(l.getDate()).padStart(2,"0");return`${c}/${u}`}function ER(e){const t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const s=Math.floor(r/60);if(s<24)return`${s}h ago`;const i=Math.floor(s/24);return i<7?`${i}d ago`:t.toLocaleDateString()}function N4e(e,t=Date.now()){const n=new Date(e).getTime();if(Number.isNaN(n))return"—";const r=Math.max(0,Math.floor((t-n)/1e3)),s=Math.floor(r/3600),i=Math.floor(r%3600/60),o=r%60,l=String(i).padStart(2,"0"),c=String(o).padStart(2,"0");return s>0?`${s}:${l}:${c}`:`${i}:${c}`}var o_="Popover",[NY]=ga(o_,[wf]),bx=wf(),[j4e,Sc]=NY(o_),jY=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=e,l=bx(t),c=p.useRef(null),[u,d]=p.useState(!1),[h,f]=Hu({prop:r,defaultProp:s??!1,onChange:i,caller:o_});return a.jsx(Rw,{...l,children:a.jsx(j4e,{scope:t,contentId:wo(),triggerRef:c,open:h,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(m=>!m),[f]),hasCustomAnchor:u,onCustomAnchorAdd:p.useCallback(()=>d(!0),[]),onCustomAnchorRemove:p.useCallback(()=>d(!1),[]),modal:o,children:n})})};jY.displayName=o_;var EY="PopoverAnchor",E4e=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Sc(EY,n),i=bx(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=s;return p.useEffect(()=>(o(),()=>l()),[o,l]),a.jsx(Mw,{...i,...r,ref:t})});E4e.displayName=EY;var IY="PopoverTrigger",TY=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Sc(IY,n),i=bx(n),o=Zn(t,s.triggerRef),l=a.jsx(sn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":DY(s.open),...r,ref:o,onClick:rt(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?l:a.jsx(Mw,{asChild:!0,...i,children:l})});TY.displayName=IY;var IR="PopoverPortal",[I4e,T4e]=NY(IR,{forceMount:void 0}),RY=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,i=Sc(IR,t);return a.jsx(I4e,{scope:t,forceMount:n,children:a.jsx(Yi,{present:n||i.open,children:a.jsx(vw,{asChild:!0,container:s,children:r})})})};RY.displayName=IR;var Yh="PopoverContent",MY=p.forwardRef((e,t)=>{const n=T4e(Yh,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,i=Sc(Yh,e.__scopePopover);return a.jsx(Yi,{present:r||i.open,children:i.modal?a.jsx(M4e,{...s,ref:t}):a.jsx(P4e,{...s,ref:t})})});MY.displayName=Yh;var R4e=Dh("PopoverContent.RemoveScroll"),M4e=p.forwardRef((e,t)=>{const n=Sc(Yh,e.__scopePopover),r=p.useRef(null),s=Zn(t,r),i=p.useRef(!1);return p.useEffect(()=>{const o=r.current;if(o)return H5(o)},[]),a.jsx(bw,{as:R4e,allowPinchZoom:!0,children:a.jsx(PY,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:rt(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),i.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:rt(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:rt(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),P4e=p.forwardRef((e,t)=>{const n=Sc(Yh,e.__scopePopover),r=p.useRef(!1),s=p.useRef(!1);return a.jsx(PY,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),PY=p.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,...h}=e,f=Sc(Yh,n),m=bx(n);return z5(),a.jsx(xw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:a.jsx(Xg,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:a.jsx(vT,{"data-state":DY(f.open),role:"dialog",id:f.contentId,...m,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),OY="PopoverClose",O4e=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Sc(OY,n);return a.jsx(sn.button,{type:"button",...r,ref:t,onClick:rt(e.onClick,()=>s.onOpenChange(!1))})});O4e.displayName=OY;var D4e="PopoverArrow",A4e=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=bx(n);return a.jsx(yT,{...s,...r,ref:t})});A4e.displayName=D4e;function DY(e){return e?"open":"closed"}var wx=jY,_x=TY,$4e=RY,Ef=MY;const a_=wx,l_=_x,Sx=p.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>a.jsx($4e,{children:a.jsx(Ef,{ref:s,align:t,sideOffset:n,className:J("z-50 w-72 rounded-md border border-border bg-elevated p-4 text-text-100 shadow-md outline-none",e),...r})}));Sx.displayName=Ef.displayName;const Ba="flex w-full min-w-0 items-center gap-2.5 rounded-md px-1.5 py-1.5 text-left text-[13px] hover:bg-text-100/5 disabled:opacity-40";function Y$({title:e,children:t,trailing:n}){const[r,s]=p.useState(!0);return a.jsxs("section",{className:"rounded-[22px] border border-border bg-bg-100 p-3.5 shadow-[0_2px_12px_rgba(0,0,0,0.06)]",children:[a.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center gap-1.5 py-0.5 text-[13px] text-text-400","aria-expanded":r,children:[e,a.jsx(Yt,{className:`h-3 w-3 text-text-400 ${r?"":"-rotate-90"}`})]}),n]}),r&&t]})}const L4e=6e4,AY=300;function $Y({message:e,onRetry:t}){return a.jsxs("div",{role:"alert",className:"m-2 rounded-md bg-error/5 p-2 text-[11px] leading-relaxed text-error",children:[e,a.jsx("button",{className:"ml-2 underline",onClick:t,children:"重试"})]})}function LY(e,t,n){const r=ix(),s=p.useRef(null),i=p.useRef(void 0),o=u=>{i.current=u.timeStamp},l=(u,d,h)=>{var m;(m=s.current)==null||m.finish("superseded");const f=C4e({sessionId:e.sessionId,action:t,searchLength:u,page:d},(g,x)=>{r==null||r.push({level:"info",msg:g,sessionId:e.sessionId,meta:x})},void 0,h);return s.current=f,f};return p.useLayoutEffect(()=>{var u;n||(u=s.current)==null||u.commit()}),p.useEffect(()=>()=>{var u;(u=s.current)==null||u.finish("unmounted")},[]),{current:s,begin:l,open:(u,d)=>{const h=i.current;i.current=void 0,l(u,d,h)},captureOpen:o}}function BY({controller:e,compact:t=!1}){const{binding:n,run:r,busy:s}=e,[i,o]=p.useState(!1),[l,c]=p.useState(""),[u,d]=p.useState(""),[h,f]=p.useState([]),[m,g]=p.useState(1),[x,b]=p.useState(!1),[y,v]=p.useState(!1),[w,_]=p.useState(null),[S,k]=p.useState(0),N=LY(e,"repositories",y),j=p.useRef(!1),R=p.useRef(new Map);return p.useEffect(()=>{if(l===u)return;const E=setTimeout(()=>{d(l),g(1)},AY);return()=>clearTimeout(E)},[l,u]),p.useEffect(()=>{if(!i||n)return;const E=N.current.current&&!N.current.current.done?N.current.current:N.begin(u.length,m),I=u+"|"+m,M=B=>{b(B.hasMore),f(U=>m===1?B.repos:[...U,...B.repos])},P=R.current.get(I);_(null);const D=j.current;if(j.current=!1,P&&Date.now()-P.at<L4e&&!D){E.response("cache",!1,P.repos.length),M({...P,repos:[...P.repos]}),v(!1);return}let F=!1;return v(!0),E.request(),r({action:"repositories",page:m,search:u},E.requestId).then(B=>{var $;if(E.response("ok",F,(($=B.repositories)==null?void 0:$.length)??0),F)return;const U={at:Date.now(),repos:B.repositories??[],hasMore:B.hasMore??!1};R.current.set(I,U),M(U)}).catch(B=>{E.response("error",F),F||_(B.message)}).finally(()=>{F||v(!1)}),()=>{F=!0,E.finish("cancelled")}},[i,n,u,m,S,r]),n?a.jsxs("button",{className:t?"flex min-w-0 items-center gap-1.5 text-[11px] text-text-300 hover:text-text-100":Ba,title:n.owner+"/"+n.name,"aria-label":"在 GitHub 查看仓库",onClick:()=>window.open(`https://github.com/${n.owner}/${n.name}`,"_blank","noopener"),children:[a.jsx(sk,{className:"h-4 w-4 shrink-0 text-text-400"}),a.jsx("span",{className:"truncate",children:n.name}),!t&&a.jsx(Fr,{className:"ml-auto h-3 w-3 text-text-400"})]}):a.jsxs(a_,{open:i,onOpenChange:E=>{var I;E?N.open(u.length,m):(I=N.current.current)==null||I.finish("closed"),o(E),E||(g(1),c(""),d(""))},children:[a.jsx(l_,{asChild:!0,children:a.jsxs("button",{disabled:s,onClickCapture:N.captureOpen,className:t?"flex items-center gap-1.5 text-[11px] text-text-300":Ba,"aria-label":"添加或选择仓库",children:[a.jsx(sk,{className:"h-4 w-4 text-text-400"}),a.jsx("span",{className:"flex-1",children:"添加 repo"}),!t&&a.jsx(Fs,{className:"h-3.5 w-3.5 text-text-400"})]})}),a.jsxs(Sx,{align:"end",className:"w-[330px] p-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-border p-2",children:[a.jsx(ci,{className:"h-3.5 w-3.5 text-text-400"}),a.jsx("input",{autoFocus:!0,"aria-label":"搜索仓库",placeholder:"搜索 GitHub 仓库…",value:l,onChange:E=>{E.target.value!==l&&N.begin(E.target.value.length,1,E.timeStamp),c(E.target.value)},className:"w-full bg-transparent text-[12px] outline-none"})]}),a.jsxs("div",{className:"max-h-[340px] overflow-y-auto py-1",children:[h.map(E=>a.jsxs("button",{disabled:s,className:Ba,onClick:()=>{_(null),r({action:"bind",repoId:E.repoId,branch:E.defaultBranch}).then(()=>o(!1)).catch(I=>_(I.message))},children:[a.jsx(sk,{className:"h-4 w-4 shrink-0 text-text-400"}),a.jsxs("span",{className:"truncate text-[12px]",children:[E.owner,"/",E.name]})]},E.repoId)),w&&a.jsx($Y,{message:w,onRetry:()=>{N.begin(u.length,m),j.current=!0,k(E=>E+1)}}),!y&&!w&&!h.length&&a.jsx("p",{className:"p-3 text-[12px] text-text-400",children:"没有找到仓库"}),y&&a.jsxs("div",{className:"flex items-center gap-2 p-3 text-[12px] text-text-400",children:[a.jsx(st,{className:"h-3 w-3 animate-spin"}),"正在读取…"]}),x&&!y&&a.jsx("button",{className:Ba,onClick:E=>{N.begin(u.length,m+1,E.timeStamp),g(I=>I+1)},children:"加载更多"})]})]})]})}function FY({controller:e,compact:t=!1,disabled:n=!1}){const{binding:r,workspace:s,branchIntent:i,run:o,busy:l}=e,[c,u]=p.useState(!1),[d,h]=p.useState(""),[f,m]=p.useState(""),[g,x]=p.useState([]),[b,y]=p.useState(1),[v,w]=p.useState(),[_,S]=p.useState(),[k,N]=p.useState(!1),[j,R]=p.useState(!1),[E,I]=p.useState(null),[M,P]=p.useState(0),D=LY(e,"branches",j),F=d.trim();p.useEffect(()=>{if(F===f)return;if(!F){m("");return}const T=setTimeout(()=>m(F),AY);return()=>clearTimeout(T)},[F,f]),p.useEffect(()=>{if(!c||!r||F!==f)return;const T=D.current.current&&!D.current.current.done?D.current.current:D.begin(f.length,b);let V=!1;return I(null),R(!0),T.request(),o({action:"branches",repoId:r.repoId,...f?{search:f,...v?{cursor:v}:{}}:{page:b}},T.requestId).then(H=>{var L;T.response("ok",V,((L=H.branches)==null?void 0:L.length)??0),V||(x(q=>(f?!v:b===1)?H.branches??[]:[...q,...H.branches??[]]),N(!!(H.hasMore&&(!f||H.nextCursor))),S(H.nextCursor))}).catch(H=>{T.response("error",V),V||I(H.message)}).finally(()=>{V||R(!1)}),()=>{V=!0,T.finish("cancelled")}},[c,r==null?void 0:r.repoId,F,f,b,v,M,o]);const B=T=>{var V;T?D.open(f.length,b):(V=D.current.current)==null||V.finish("closed"),u(T),T||(h(""),m(""),x([]),y(1),w(void 0),S(void 0),N(!1),R(!1),I(null))},U=i??(s==null?void 0:s.actualBranch)??(s?"HEAD · "+s.head.slice(0,7):(r==null?void 0:r.sourceBranch)??"选择 branch"),$=[...new Set([...[...r?[r.defaultBranch]:[],...s!=null&&s.actualBranch?[s.actualBranch]:[],...(s==null?void 0:s.branches)??[]].filter(T=>T.toLowerCase().includes(F.toLowerCase())),...g])],O=T=>{const V=T===((s==null?void 0:s.actualBranch)??(r==null?void 0:r.sourceBranch));o(V?{action:"intend"}:{action:"intend",branch:T}).then(()=>{B(!1)}).catch(()=>{})};return a.jsxs(a_,{open:c,onOpenChange:B,children:[a.jsx(l_,{asChild:!0,children:a.jsxs("button",{onClickCapture:D.captureOpen,className:t?"flex min-w-0 items-center gap-1.5 text-[11px] text-text-300 disabled:opacity-40":Ba,"aria-label":`选择分支,当前 ${U}`,disabled:l||n,children:[a.jsx(yu,{className:"h-3.5 w-3.5 shrink-0 text-text-400"}),a.jsx("span",{className:"truncate",children:U}),a.jsx(Yt,{className:"ml-auto h-3 w-3 shrink-0 text-text-400"})]})}),a.jsxs(Sx,{align:"end",className:"w-[280px] p-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-border p-2",children:[a.jsx(ci,{className:"h-3.5 w-3.5 text-text-400"}),a.jsx("input",{autoFocus:!0,"aria-label":"搜索分支",placeholder:"搜索分支…",value:d,maxLength:100,onChange:T=>{h(T.target.value),T.target.value.trim()!==F&&(D.begin(T.target.value.trim().length,1,T.timeStamp),x([]),y(1),w(void 0),S(void 0),N(!1),I(null),R(!0))},className:"w-full bg-transparent text-[12px] outline-none"})]}),a.jsxs("div",{className:"max-h-[300px] overflow-y-auto",children:[(F===f?$:[]).map(T=>a.jsxs("button",{className:Ba,onClick:()=>O(T),children:[a.jsx(yu,{className:"h-3.5 w-3.5 text-text-400"}),a.jsx("span",{className:"flex-1 truncate",children:T}),T===(r==null?void 0:r.defaultBranch)&&a.jsx("span",{className:"text-[10px] text-text-400",children:"默认"}),T===U&&a.jsx(Jt,{className:"h-3.5 w-3.5"})]},T)),E&&a.jsx($Y,{message:E,onRetry:()=>{D.begin(f.length,b),P(T=>T+1)}}),j&&a.jsxs("div",{role:"status",className:"flex items-center gap-2 p-3 text-[12px] text-text-400",children:[a.jsx(st,{className:"h-3 w-3 animate-spin"}),"正在读取…"]}),!j&&!E&&!$.length&&a.jsx("p",{className:"p-3 text-[12px] text-text-400",children:"没有找到分支"}),k&&a.jsx("button",{className:Ba,disabled:j||!!E,onClick:T=>{D.begin(f.length,b+1,T.timeStamp),R(!0),f?w(_):y(V=>V+1)},children:"加载更多分支"})]})]})]})}function B4e({controller:e,disabled:t=!1}){return a.jsxs("div",{"data-testid":"workspace-input-chip",className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-1 pb-2 text-text-300",children:[a.jsx("div",{className:"max-w-[200px] min-w-0",children:a.jsx(BY,{controller:e,compact:!0})}),e.binding&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"h-3 w-px bg-border"}),a.jsx("div",{className:"min-w-0 max-w-[230px]",children:a.jsx(FY,{controller:e,compact:!0,disabled:t},e.binding.repoId)})]}),e.loading&&a.jsx(st,{className:"h-3 w-3 shrink-0 animate-spin text-text-400"})]})}function F4e({controller:e,disabled:t=!1}){var x;const{binding:n,workspace:r,branchIntent:s,loading:i,busy:o,error:l,refresh:c,run:u}=e,[d,h]=p.useState(null),[f,m]=p.useState();p.useEffect(()=>{if(!d){m(void 0);return}let b=!1;return m(void 0),u({action:"diff",filePath:d}).then(y=>{b||m(y.diff)}).catch(()=>{}),()=>{b=!0}},[d,u]);const g=(x=r==null?void 0:r.files.find(b=>b.path===d))==null?void 0:x.comparison;return a.jsxs("div",{className:"space-y-3",children:[a.jsxs(Y$,{title:"环境",trailing:a.jsx("button",{"aria-label":"刷新工作区",title:"刷新工作区",disabled:o||i,onClick:()=>void c(),className:"p-1 text-text-400 disabled:opacity-40",children:a.jsx(ko,{className:`h-3 w-3 ${i?"animate-spin":""}`})}),children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-1.5 py-1.5 text-[13px]",children:[a.jsx(uw,{className:"h-4 w-4 text-text-400"}),a.jsx("span",{children:"云端"}),a.jsx("span",{className:"ml-auto text-[11px] text-text-400",children:n?"已关联":"待关联"})]}),a.jsx(BY,{controller:e}),n&&a.jsx(FY,{controller:e,disabled:t},n.repoId),s&&a.jsxs("p",{className:"mt-1 px-1.5 text-[11px] text-text-400",children:["将在下一条消息里让 agent 切换到 ",s]}),r&&a.jsxs("p",{className:"mt-1 px-1.5 text-[10px] text-text-400",children:["截至 ",yx(new Date(r.measuredAt).toISOString())," ·"," ",r.head.slice(0,7)]}),!n&&a.jsx("p",{className:"mt-2 px-1.5 text-[11px] leading-relaxed text-text-400",children:"关联仓库和分支,在这个会话的独立工作区里开发。"}),l&&a.jsxs("div",{role:"alert",className:"mt-2 rounded-md bg-error/5 p-2 text-[11px] leading-relaxed text-error",children:[l,a.jsx("button",{className:"ml-2 underline",onClick:()=>void c(),children:"重试读取"})]})]}),!!(r!=null&&r.files.length)&&a.jsxs(Y$,{title:"Changes",trailing:a.jsxs("span",{className:"text-[10px] text-text-400",children:[r.totalFiles??r.files.length," 个文件"]}),children:[a.jsxs("button",{"aria-label":"查看全部改动",className:Ba,onClick:()=>h(r.files[0].path),children:[a.jsx(che,{className:"h-4 w-4 text-text-400"}),a.jsxs("span",{className:"tabular-nums text-success",children:["+",r.added]}),a.jsxs("span",{className:"tabular-nums text-error",children:["−",r.removed]}),a.jsx(tH,{className:"ml-auto h-3 w-3 text-text-400"})]}),a.jsx("div",{className:"mb-2",children:r.files.map(b=>a.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1.5 text-left text-[11px] hover:bg-text-100/5",onClick:()=>h(b.path),children:[a.jsx("span",{className:"w-4 shrink-0 text-[10px] text-text-400",children:b.status}),a.jsx("span",{title:b.path,className:"min-w-0 flex-1 truncate text-text-300",children:b.path.split("/").at(-1)}),a.jsxs("span",{className:"text-success",children:["+",b.added]}),a.jsxs("span",{className:"text-error",children:["−",b.removed]})]},b.path))}),r.filesTruncated&&a.jsx("p",{className:"mb-2 px-1 text-[11px] text-text-400",children:"仅展示前 200 个改动文件。"})]}),a.jsx(bs,{open:d!==null,onOpenChange:b=>{b||h(null)},children:a.jsxs(ss,{className:"flex h-[min(680px,84vh)] w-[min(1080px,94vw)] max-w-none flex-col gap-0 overflow-hidden p-0",children:[a.jsxs("div",{className:"border-b border-border px-5 py-4",children:[a.jsx(is,{className:"text-[14px]",children:"代码改动"}),a.jsxs(Ui,{className:"mt-2 text-[11px]",children:[(r==null?void 0:r.actualBranch)??"HEAD"," ·"," ",g==="index"?"暂存区相对当前提交的改动":g==="head"?"尚未提交的改动":"相对起始提交 "+(r==null?void 0:r.initialCommit.slice(0,7))+" 的累计改动"]})]}),a.jsxs("div",{className:"flex min-h-0 flex-1",children:[a.jsx("nav",{"aria-label":"改动文件",className:"w-[225px] shrink-0 overflow-auto border-r border-border bg-bg-50 p-2 max-[700px]:hidden",children:r==null?void 0:r.files.map(b=>a.jsx("button",{className:Ba+" text-[11px]",onClick:()=>h(b.path),children:a.jsx("span",{className:"truncate",children:b.path.split("/").at(-1)})},b.path))}),a.jsxs("div",{className:"min-w-0 flex-1 overflow-auto",children:[a.jsx("div",{className:"sticky top-0 border-b border-border bg-bg-50 px-4 py-3 font-mono text-[11px]",children:d}),f?f.binary?a.jsx("p",{className:"p-5 text-[12px] text-text-400",children:"二进制文件发生变化"}):f.notStored?a.jsx("p",{className:"p-5 text-[12px] text-text-400",children:"这个文件的补丁暂不可用(文件较多或体积较大时只保存部分补丁)。"}):a.jsxs("pre",{className:"min-w-fit py-2 font-mono text-[11px] leading-6",children:[f.patch.split(`
913
913
  `).map((b,y)=>a.jsx("div",{className:`px-4 ${b.startsWith("+")?"bg-success/8 text-success":b.startsWith("-")?"bg-error/8 text-error":"text-text-300"}`,children:b||" "},y)),f.truncated&&a.jsx("div",{className:"px-4 text-text-400",children:"Diff 较大,已截断显示。"})]}):a.jsx("div",{className:"p-5 text-[12px] text-text-400",children:l??"正在读取 diff…"})]})]})]})})]})}const z4e=250;function H4e(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function U4e({agents:e}){var c,u,d;const[t,n]=p.useState(!1),r=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const h=f=>{const m=r.current;m&&f.target instanceof Node&&m.contains(f.target)||n(!1)};return window.addEventListener("pointerdown",h,!0),()=>window.removeEventListener("pointerdown",h,!0)},[t]),e.length===0)return null;const s=e.length===1?e[0]:null,i=s?s.description:`${e.length} 个后台任务`,o=s?H4e((u=(c=s.progress)==null?void 0:c.stats)==null?void 0:u.durationMs):null,l=s?(d=s.progress)==null?void 0:d.lastToolName:null;return a.jsxs("div",{ref:r,"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?a.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:a.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:z4e},children:e.map(h=>a.jsx(KK,{expandable:!1,description:h.description,input:h.input,output:h.output,...h.error!==void 0?{error:h.error}:{},pending:h.pending,notifications:h.notifications,...h.toolResultExtra?{toolResultExtra:h.toolResultExtra}:{},...h.progress?{progress:h.progress}:{}},h.toolUseId))})}):null,a.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(h=>!h),className:J("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[a.jsx(st,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),o?a.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:o}):null,l?a.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",l]}):null,a.jsx(nH,{className:J("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const W4e={closeTrailing:!1},V4e={closeTrailing:!0};function q4e(e){return e?W4e:V4e}function K4e({session:e,api:t,onPromoteQuickAsk:n}){const r=GV(e.sessionId);return a.jsx(zY,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function G4e({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:s="full",ephemeral:i,onPromote:o,hideHeader:l=!1,flatProcess:c=!1,lines:u,pendingPermissions:d,procAlive:h,rewindableUserMessageIds:f,onPermissionRespond:m,onPermissionInterrupt:g,onRewind:x,onFork:b,onQuickAsk:y,topSlot:v,codexHistory:w,realtimeQuestionAnswers:_,onSubmitQuestion:S,onCancelQuestion:k,liveQuestionToolUseIds:N,api:j,cwd:R,tool:E,cloudVolume:I,sessionKey:M,onSend:P,awaitingUser:D,queued:F,onDequeue:B,onAbort:U,onNewSession:$,onClearSession:O,configSlot:T,workspaceInput:V,workspaceInputDisabled:H,chatRootRef:L,chatBodyRef:q,drawers:K,xtermSlot:X,fileSharingScope:te,onShareFile:oe,onOpenInTab:Q,onPreviewMarkdown:he,onOpenFilePath:be,dispatchOrigin:Z}){const[ce,se]=p.useState(0),fe=p.useMemo(()=>s==="full"?qwe(gq(u)):[],[u,s]),xe=p.useMemo(()=>new Set(fe.map(Me=>Me.toolUseId)),[fe]);return a.jsx(HIe,{children:a.jsxs("div",{ref:L,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[l?null:a.jsx(B5e,{meta:e,...E?{tool:E}:{},...I?{cloudVolume:I}:{},connState:t,variant:s,...n!==void 0?{liveWorktreeRoot:n}:{},...s==="full"&&r?{onOpenConfig:r}:{},...s==="quickask"?{ephemeral:i??!1,...o?{onPromote:o}:{}}:{}}),a.jsx("div",{ref:q,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:ce},children:a.jsx(XK,{lines:u,forkByTurn:E==="codex",...m?{onPermissionRespond:m}:{},...g&&h?{onPermissionInterrupt:g}:{},topSlot:v,codexHistory:w,...x?{onRewind:x}:{},rewindableUserMessageIds:f,...b?{onFork:b}:{},...y?{onQuickAsk:y}:{},realtimeQuestionAnswers:_,onSubmitQuestion:S,...k?{onCancelQuestion:k}:{},liveQuestionToolUseIds:N,...te?{fileSharingScope:te}:{},...oe?{onShareFile:oe}:{},...Q?{onOpenInTab:Q}:{},...he?{onPreviewMarkdown:he}:{},...be?{onOpenFilePath:be}:{},...Z?{dispatchOrigin:Z}:{},...s==="full"&&!c?{turnCollapse:q4e(h)}:{},dockedAgentToolUseIds:xe})}),X,a.jsx(S4e,{onHeightChange:se,children:a.jsx(U4e,{agents:fe})}),e.larkChatName?a.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):a.jsx(iG,{meta:e,aboveSlot:V,disabled:H,...j?{api:j}:{},cwd:R,...E?{tool:E}:{},sessionKey:M,onSend:P,awaitingUser:D,...F?{queued:F}:{},...B?{onDequeue:B}:{},...U?{onAbort:U}:{},...$?{onNewSession:$}:{},...O?{onClearSession:O}:{},...T?{configSlot:T}:{}}),K]})})}function zY({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){var ve;const{session:s,api:i,liveGitBranch:o,liveWorktreeRoot:l,cloudVolume:c,onNewSession:u,onTurnEnd:d,onOpenConfig:h,onFork:f,onQuickAsk:m,viewerRole:g,onPromoteQuickAsk:x,configSlot:b,hideHeader:y,flatProcess:v}=t,{capabilities:w}=si(s.tool||"claude"),_=(w==null?void 0:w.features)??uG(s.tool),[S,k]=p.useState(null),[N,j]=p.useState(null),R=ux(),E=!!i&&R.actionsLevel==="owner"&&_.fileSharing,I=NR(s.ownerPersonaId??null).persona,M=(I==null?void 0:I.label)??null,P=!!M&&!!s.ownerPersonaId,D=y4e(),F=p.useMemo(()=>({resolve:(ae,Ue)=>D.resolve(ae,Ue,s.sessionId),...D.onOpenSession?{onOpenSession:D.onOpenSession}:{}}),[D,s.sessionId]),B=p.useCallback((ae,Ue)=>{k({kind:ae,text:Ue}),setTimeout(()=>{k(ze=>(ze==null?void 0:ze.text)===Ue?null:ze)},2e3)},[]),U=Kn(),$=bb(s.tool)&&g!=="guest"&&!s.larkChatId&&!x,O=k4e(i,s.sessionId,$,U,s.cloudWorkspace,s.cloudBranchIntent),T=wU(),V=HV(s.sessionId,s.toolSessionId),{events:H,pendingQuestions:L,clearQuestion:q,markQuestionSubmitted:K,status:X}=V,te=e.historyLoading,oe=KV(X);p.useEffect(()=>{Pe("chat-panel","sessionStatus",{sessionId:s.sessionId,sessionStatus:X,procAlive:oe})},[X,oe,s.sessionId]);const Q=e.lines,he=e.pendingPermissions,be=he[0]??null,Z=p.useMemo(()=>Wwe(H),[H]),[ce,se]=p.useState(null),[fe,xe]=p.useState(()=>new Set);zwe(i,s.sessionId,s.toolSessionId,_.observe);const Me=p.useRef(s.sessionId);p.useEffect(()=>{if(Me.current=s.sessionId,!_.rewind){se(null);return}let ae=!1;return se(null),(async()=>{try{const Ue=await i.sessionRewindableMessageIds(s.sessionId);if(ae)return;se(new Set(Ue.userMessageIds))}catch{ae||se(null)}})(),()=>{ae=!0}},[i,s.sessionId,_.rewind]);const Xe=p.useCallback(()=>{const ae=s.sessionId;i.sessionRewindableMessageIds(ae).then(Ue=>{Me.current===ae&&se(new Set(Ue.userMessageIds))}).catch(()=>{})},[i,s.sessionId]),me=p.useMemo(()=>{if(ce!==null){const Ut=new Set(ce);for(const cr of fe)Ut.delete(cr);return Ut}const ae=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),Ue=new Set;let ze=null;for(const Ut of Q)Ut.kind==="user-text"?ze=Ut.uuid??null:ze&&Ut.kind==="tool-call"&&ae.has(Ut.tool)&&!fe.has(ze)&&Ue.add(ze);return Ue},[Q,fe,ce]),Ce=p.useRef(d);Ce.current=d,Hwe(s.sessionId,s.toolSessionId,()=>{yt(null),xe(new Set)});const je=cG({sessionStatus:X}),Se=p.useRef(null);p.useEffect(()=>{var ze;const ae=Se.current,Ue=(ae==null?void 0:ae.sid)===s.sessionId;Ue&&ae.phase===je||(Se.current={sid:s.sessionId,phase:je},Pe("session-phase",je,{sid:s.sessionId,phase:je,prev:Ue?ae.phase:null,desc:tTe[je]}),Ue&&ae.phase==="turn-running"&&je!=="turn-running"&&((ze=Ce.current)==null||ze.call(Ce),Xe()))},[je,s.sessionId,Xe]);const ut=p.useCallback(async()=>{const ae=await i.sessionInterrupt(s.sessionId).catch(()=>{});return(ae==null?void 0:ae.queued)??[]},[i,s.sessionId]),[ot,yt]=p.useState(null),re=p.useCallback(ae=>{yt(ae)},[]),[ue,Te]=p.useState(!1),Ze=p.useCallback(()=>{i.sessionStop(s.sessionId).catch(()=>{}),Te(!1)},[i,s.sessionId]);p.useCallback(ae=>{i.pinSession(s.sessionId,ae).catch(Ue=>{Pe("chat-panel","pinSession failed",{err:Ue==null?void 0:Ue.message})})},[i,s.sessionId]);const at=x?"quickask":"full",{container:et,workspaceContainer:tt,onCollapse:Lt,hostExtras:wt}=uR(),we=p.useRef(0),He=p.useRef(null);p.useEffect(()=>{const ae=Ue=>{if(Ue.key!=="Escape")return;if(!oe){we.current=0;return}if(Ue.isComposing)return;const Ut=Ue.target;if(Ut&&Ut.closest("[data-cc-chat-root]")!==He.current)return;const cr=Date.now();cr-we.current<2e3?(we.current=0,Te(!0)):(we.current=cr,ut())};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[ut,oe]);const ct=p.useRef(null),Ot=p.useRef(null),on=p.useRef(!!e.codexHistory);on.current=!!e.codexHistory;const Ne=p.useRef(!0),ne=p.useRef(void 0),De=p.useRef(0),Je=p.useRef(0),dt=p.useRef(void 0);p.useEffect(()=>{j(null)},[s.sessionId]),p.useEffect(()=>{const ae=ct.current;if(!ae)return;const Ue=150,ze=Ut=>{on.current||Date.now()<Je.current&&(Ut.preventDefault(),Je.current=Date.now()+Ue)};return ae.addEventListener("wheel",ze,{passive:!1}),()=>ae.removeEventListener("wheel",ze)},[]),p.useEffect(()=>{const ae=ct.current;if(!ae)return;const Ue=32,ze=()=>{var cr;const Ut=ae.scrollHeight-ae.scrollTop-ae.clientHeight;Ne.current=Ut<=Ue,e.codexHistory&&(Ot.current=DA(ae)),ae.scrollTop<=24&&e.historyHasMore&&!e.historyLoadingOlder&&!e.historyError&&!te&&((cr=e.loadOlderHistory)==null||cr.call(e))};return ae.addEventListener("scroll",ze,{passive:!0}),()=>ae.removeEventListener("scroll",ze)},[e.codexHistory,e.historyHasMore,e.historyLoadingOlder,e.historyError,e.loadOlderHistory,te]),p.useLayoutEffect(()=>{var eo;const ae=ct.current;if(!ae)return;const Ue=dt.current!==s.sessionId;Ue&&(dt.current=s.sessionId,Ne.current=!0,ne.current=void 0,De.current=0,Je.current=0,Ot.current=null);const ze=ne.current,Ut=(eo=Q[0])==null?void 0:eo.seq;if(ne.current=Ut,e.codexHistory){!Ue&&Ot.current&&!Ne.current?a5e(ae,Ot.current):Ne.current&&(ae.scrollTop=ae.scrollHeight),Ot.current=DA(ae),De.current=ae.scrollHeight-ae.scrollTop;return}!Ue&&ze!==void 0&&Ut!==void 0&&Ut<ze?(ae.scrollTop=ae.scrollHeight-De.current,Je.current=Date.now()+200):Ne.current&&(ae.scrollTop=ae.scrollHeight),De.current=ae.scrollHeight-ae.scrollTop},[Q,be==null?void 0:be.requestId,s.sessionId]);const Nt=p.useMemo(()=>{const ae={};for(const[Ue,ze]of Object.entries(L))ze.submittedAnswers&&(ae[Ue]=ze.submittedAnswers);return ae},[L]),St=p.useMemo(()=>new Set(Object.keys(L)),[L]),dn=p.useCallback(async(ae,Ue)=>{try{await i.answerQuestion({sessionId:s.sessionId,toolUseId:ae,answers:Ue}),K(ae,Ue)}catch{}},[i,s.sessionId,K]),Dn=p.useCallback(async ae=>{try{await i.cancelQuestion({sessionId:s.sessionId,toolUseId:ae}),q(ae)}catch{}},[i,s.sessionId,q]),Jn=p.useCallback(async(ae,Ue)=>{var ze;if(be)try{await((ze=e.respondPermission)==null?void 0:ze.call(e,be.requestId,ae?"allow":"deny"))}catch{}},[e,be]),ht=p.useCallback(async()=>{const ae=s.sessionId;try{await i.sessionStop(ae)}catch{}e.clearSession?await e.clearSession():await i.sessionNew(ae)},[e,i,s.sessionId]),Ht=e.meta.streamInProgress??!1,hn=p.useMemo(()=>{if(e.codexHistory)return a.jsxs("div",{className:"flex flex-col items-center gap-2 py-2 text-xs text-text-400","data-testid":"codex-history-top",children:[e.historySyncError?a.jsx("span",{children:e.historySyncError}):null,e.historyError?a.jsx("span",{"data-testid":"history-error",children:e.historyError}):null,te||e.historyLoadingOlder?a.jsx("span",{"data-testid":"history-loading",children:"正在加载历史…"}):e.historyHasMore?a.jsx("button",{type:"button",onClick:()=>{var Ue;return void((Ue=e.loadOlderHistory)==null?void 0:Ue.call(e))},children:e.historyError?"重试更早记录":"加载更早记录"}):e.historyLoaded&&!e.historyError&&!e.historySyncError?a.jsx("span",{children:"已加载全部轮次摘要"}):null,e.historyError||e.historySyncError?a.jsx("button",{type:"button",onClick:()=>{var Ue;return void((Ue=e.refreshHistory)==null?void 0:Ue.call(e))},children:"刷新历史"}):null]});const ae=e.historySyncError?a.jsxs("div",{className:"flex justify-center items-center gap-2 py-2 text-[12px] text-text-400","data-testid":"history-sync-error",children:[a.jsx("span",{children:e.historySyncError}),e.reloadFromCloud?a.jsx("button",{type:"button","data-testid":"history-sync-reload",disabled:Ht,onClick:e.reloadFromCloud,className:"text-accent hover:underline cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:"从云端重新加载"}):null]}):null;return e.historyError?a.jsxs(a.Fragment,{children:[ae,a.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]})]}):ae||(te&&Q.length===0?a.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:a.jsx(st,{className:"w-4 h-4 text-text-400 animate-spin"})}):null)},[te,Q.length,e.historyError,e.historySyncError,e.reloadFromCloud,Ht,e.codexHistory,e.historyHasMore,e.historyLoaded,e.historyLoadingOlder,e.loadOlderHistory,e.refreshHistory]),En=e.meta,Mt=a.jsxs(a.Fragment,{children:[s.toolSessionId&&_.subagents?a.jsx(G5e,{api:i,cwd:s.cwd,toolSessionId:s.toolSessionId,toolKind:s.tool??"claude"}):null,ot&&_.rewind?a.jsx(X5e,{open:!0,onOpenChange:ae=>{ae||yt(null)},api:i,sessionId:s.sessionId,userMessageId:ot,lines:Q,procAlive:oe,onNoChanges:ae=>{xe(Ue=>{if(Ue.has(ae))return Ue;const ze=new Set(Ue);return ze.add(ae),ze})}}):null,ue?a.jsx(Y4e,{onConfirm:Ze,onCancel:()=>Te(!1)}):null]}),lr={kind:"session",sessionId:s.sessionId},In=p.useCallback(async ae=>{if(i)try{await MD(i,U,s.sessionId,ae)}catch(Ue){const ze=Ue.message;Pe("chat-panel","open-in-tab failed",{err:ze}),B("err",`Open in tab 失败:${ze}`)}},[i,U,s.sessionId,B]),[Dt,Bt]=p.useState(!1),[mn,Tn]=p.useState(null),Rr=p.useCallback(ae=>{if(r){r(ae);return}Tn(ae),Bt(!0)},[r]),Ji=p.useCallback(ae=>{if(!i)return;const Ue=async()=>{try{await i.attachmentGroupAdd(s.sessionId,ae)}catch(Ut){Pe("chat-panel","file-link groupAdd skipped",{err:Ut.message})}},ze=Ut=>{const cr=Ut.message;Pe("chat-panel","file-link open failed",{err:cr}),B("err",`打开文件失败:${cr}`)};if(qw(ae)){Ue().then(()=>Rr(ae),ze);return}MD(i,U,s.sessionId,ae,60,Ue).catch(ze)},[i,U,s.sessionId,Rr,B]),xr=p.useCallback(async ae=>{if(!i)throw new Error("daemon api not ready");const Ue=await zT(i,U,s.sessionId,ae,60),ze=await fetch(Ue);if(!ze.ok)throw new Error(`fetch ${ze.status} ${ze.statusText}`);return await ze.text()},[i,U,s.sessionId]),vr=p.useCallback(async(ae,Ue)=>{if(i)try{const{url:ze}=await i.attachmentSignUrl({sessionId:s.sessionId,relPath:ae,...Ue?{view:Ue}:{}}),Ut=await Twe(ze);B(Ut?"ok":"err",Ut?"分享链接已复制到剪贴板":"复制失败:请手动复制")}catch(ze){const Ut=ze.message;Pe("chat-panel","share-file failed",{err:Ut}),B("err",`生成分享链接失败:${Ut}`)}},[i,s.sessionId,B]),us=p.useCallback(()=>j(null),[]),qs=N==="files"&&E&&i?{title:"Edited Files",onBack:us,content:a.jsx(m3e,{api:i,scope:lr,sessionId:s.sessionId,onShareFile:vr,onOpenInTab:In,onPreviewMarkdown:Rr})}:N==="cron"?{title:`定时任务${Z.length?` (${Z.length})`:""}`,onBack:us,content:a.jsx("div",{className:"p-3",children:a.jsx(eTe,{jobs:Z})})}:N==="persona"&&P&&i&&s.ownerPersonaId?{title:`Persona · ${M??""}`,onBack:us,content:a.jsx(SY,{personaId:s.ownerPersonaId,open:!0,onClose:us,api:i,embedded:!0,...g?{viewerRole:g}:{}},s.ownerPersonaId)}:null,vi=at==="full"?a.jsx(q5e,{session:s,meta:En,...$&&O.binding?{liveGitBranch:((ve=O.workspace)==null?void 0:ve.actualBranch)??null}:o!==void 0?{liveGitBranch:o}:{},...l!==void 0?{liveWorktreeRoot:l}:{},...P?{personaName:M}:{},...P?{onOpenPersona:()=>j("persona")}:{},...E?{onOpenFiles:()=>j("files")}:{},cronActiveCount:Z.length,onCronClick:()=>j("cron"),onForceStop:()=>Te(!0),...bb(s.tool)&&e.reloadFromCloud?{onReloadFromCloud:e.reloadFromCloud,reloadFromCloudDisabled:Ht}:{},...g?{viewerRole:g}:{},...w!=null&&w.toolSessionIdLabel?{toolSessionIdLabel:w.toolSessionIdLabel}:{},drill:qs,...Lt?{onCollapse:Lt}:{},...wt?{title:wt.title,leadingEntries:wt.leadingEntries}:{}}):null;return a.jsxs(a.Fragment,{children:[$&&tt?es.createPortal(a.jsx(F4e,{controller:O,disabled:En.streamInProgress}),tt):null,et&&vi?es.createPortal(vi,et):null,a.jsx(G4e,{headerMeta:En,workspaceInput:$?a.jsx(B4e,{controller:O,disabled:En.streamInProgress}):void 0,workspaceInputDisabled:$&&O.busy,connState:e.connState,...l!==void 0?{liveWorktreeRoot:l}:{},...h?{onOpenConfig:h}:{},variant:at,...y||$?{hideHeader:!0}:{},...v?{flatProcess:v}:{},...at==="quickask"?{ephemeral:s.ephemeral!==!1,onPromote:()=>void(x==null?void 0:x(s.sessionId))}:{},lines:Q,pendingPermissions:he,procAlive:oe,rewindableUserMessageIds:me,onPermissionRespond:Jn,onPermissionInterrupt:ut,onRewind:_.rewind?re:void 0,...f&&_.fork?{onFork:f}:{},...n&&_.fork?{onQuickAsk:n}:m&&_.fork?{onQuickAsk:m}:{},topSlot:hn,codexHistory:e.codexHistory,realtimeQuestionAnswers:Nt,onSubmitQuestion:dn,onCancelQuestion:Dn,liveQuestionToolUseIds:St,api:i,cwd:s.cwd,...s.tool?{tool:s.tool}:{},...c?{cloudVolume:c}:{},sessionKey:s.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:he.length>0||Object.values(L).some(ae=>!ae.submittedAnswers),onAbort:ut,...u?{onNewSession:u}:{},onClearSession:ht,...b?{configSlot:b}:{},chatRootRef:He,chatBodyRef:ct,drawers:Mt,xtermSlot:T==="tui"&&oe&&_.tui?a.jsx(p3e,{sessionId:s.sessionId,client:U},s.sessionId):null,fileSharingScope:lr,...i?{onShareFile:vr}:{},...i?{onOpenInTab:In}:{},...i?{onPreviewMarkdown:Rr}:{},...i?{onOpenFilePath:Ji}:{},dispatchOrigin:F}),i?a.jsx(_4e,{open:Dt,onOpenChange:Bt,relPath:mn,loadMarkdown:xr,onShare:mn?()=>void vr(mn,"md-rendered"):void 0}):null,S?a.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:S.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:S.text}):null]})}function Y4e({onConfirm:e,onCancel:t}){return a.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:a.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[a.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[a.jsx(yn,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),a.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),a.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function X4e(e){return e.split("/").pop()||e}function Z4e({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:s,loadMarkdown:i,quickAskSession:o,onPromoteQuickAsk:l}){if(!pq(e))return null;const c=[];e.quickAsk&&c.push({id:"quick-ask",label:"问一下",title:"问一下",icon:a.jsx(cg,{className:"w-3.5 h-3.5"})});for(const u of e.mds)c.push({id:{kind:"md",relPath:u},label:X4e(u),title:u,icon:a.jsx(la,{className:"w-3.5 h-3.5"})});return a.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[a.jsx(ui,{delayDuration:200,skipDelayDuration:100,children:a.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:c.map(u=>{const d=Fwe(e.active,u.id),h=u.id==="quick-ask"?"quick-ask":`md:${u.id.relPath}`;return a.jsxs(Xi,{children:[a.jsx(Zi,{asChild:!0,children:a.jsxs("div",{role:"tab","aria-selected":d,"data-tab-title":u.title,onClick:()=>n(u.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",d?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[u.icon,a.jsx("span",{className:"truncate",children:u.label}),a.jsx("button",{type:"button","aria-label":`关闭 ${u.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",d?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),u.id==="quick-ask"?r():s(u.id.relPath)},children:a.jsx(Xt,{className:"w-3 h-3"})}),d?a.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),a.jsx(pi,{side:"bottom",align:"start",className:"max-w-sm break-all",children:u.title})]},h)})})}),a.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?a.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:a.jsx(K4e,{session:o,api:t,...l?{onPromoteQuickAsk:l}:{}})}):null,e.mds.map(u=>{const d=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===u;return a.jsx("div",{className:"absolute inset-0",style:{display:d?"block":"none"},children:a.jsx(CY,{relPath:u,loadMarkdown:i,showTitleBar:!1})},`md-body:${u}`)})]})]})}function Q4e(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function J4e({state:e,extras:t}){const{api:n,session:r}=t,s=Kn(),[i,o]=p.useState(Pwe()),[l,c]=p.useState(null),u=r.ownerPersonaId!==$i,d=p.useRef(i);d.current=i;const h=p.useRef(!1),f=p.useCallback(async j=>{const R=d.current.quickAsk;c(null);let E;try{E=await Cwe(n,r,j)}catch(I){Pe("quick-ask","fork failed",I),h.current||c(Q4e(I));return}if(!E){h.current||c("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(h.current){n.sessionDelete(E.sessionId).catch(()=>{});return}r0(R)&&n.sessionDelete(R.sessionId).catch(()=>{}),o(I=>Owe(I,{sessionId:E.sessionId}))},[n,r]),m=p.useCallback(async j=>{const R=d.current.quickAsk,E=(R==null?void 0:R.sessionId)===j;try{await Nwe(n,{sessionId:j,stillEphemeral:E&&r0(R)})&&o(M=>$we(M))}catch(I){Pe("quick-ask","promote failed",I)}},[n]),g=p.useCallback(j=>{o(R=>Dwe(R,j))},[]),x=p.useCallback(j=>{o(R=>Bwe(R,j))},[]),b=p.useCallback(()=>{const j=d.current.quickAsk;r0(j)&&n.sessionDelete(j.sessionId).catch(()=>{}),o(R=>Awe(R))},[n]),y=p.useCallback(j=>{o(R=>Lwe(R,j))},[]);p.useEffect(()=>()=>{h.current=!0;const j=d.current.quickAsk;r0(j)&&n.sessionDelete(j.sessionId).catch(()=>{})},[]);const v=ua("sessions")??[],w=i.quickAsk?v.find(j=>j.sessionId===i.quickAsk.sessionId)??{sessionId:i.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,_=p.useCallback(async j=>{const R=await zT(n,s,r.sessionId,j,60),E=await fetch(R);if(!E.ok)throw new Error(`fetch ${E.status} ${E.statusText}`);return E.text()},[n,s,r.sessionId]),S=a.jsx(zY,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:g}),{initialSize:k,setSize:N}=fq("chat-panel-right-slot-width",480);return a.jsxs(Fw,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[a.jsx(Fh,{id:"chat",minSize:"400px",children:a.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[S,l?a.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[a.jsxs("span",{className:"mr-2",children:["问一下没能打开:",l]}),a.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>c(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),pq(i)?a.jsxs(a.Fragment,{children:[a.jsx(FT,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),a.jsx(Fh,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:j=>N(j.inPixels),children:a.jsx(Z4e,{state:i,api:n,onSwitchTab:x,onCloseQuickAsk:b,onCloseMd:y,loadMarkdown:_,quickAskSession:w,...u?{onPromoteQuickAsk:m}:{}})})]}):null]})}function c_({extras:e}){const t=GV(e.session.sessionId,e.focused);return a.jsx(J4e,{state:t,extras:e})}const ePe=HK("inline-flex items-center rounded-sm border px-2 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"border-transparent bg-accent text-accent-contrast",secondary:"border-transparent bg-bg-200 text-text-200",destructive:"border-transparent bg-destructive text-white",outline:"border-border bg-transparent text-text-200"}},defaultVariants:{variant:"default"}});function ra({className:e,variant:t,...n}){return a.jsx("span",{className:J(ePe({variant:t}),e),...n})}const qn=p.forwardRef(({className:e,type:t,...n},r)=>a.jsx("input",{ref:r,type:t??"text",className:J("flex h-9 w-full rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100","placeholder:text-text-400","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:border-accent","disabled:cursor-not-allowed disabled:opacity-50",e),...n}));qn.displayName="Input";function TR(e){const[t,n]=p.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:()=>n(!t),"aria-expanded":t,className:"mt-1 inline-flex cursor-pointer items-center gap-1 text-xs text-text-500 hover:text-accent",children:[a.jsx(Yt,{className:`size-3 transition-transform ${t?"":"-rotate-90"}`}),"为什么列它 · ",e.evidence.file]}),t&&a.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[a.jsx("div",{className:"text-[13px] leading-snug text-text-300",children:e.evidence.reason}),a.jsx("pre",{className:"whitespace-pre-wrap rounded-md border border-border bg-bg-100 px-3 py-2 font-mono text-xs leading-relaxed text-text-300",children:e.evidence.quote})]})]})}function kx(e){return a.jsx("span",{className:`inline-flex shrink-0 items-center rounded-sm bg-warning-dim px-1.5 py-px text-[11px] font-medium leading-4 text-warning ${e.className??""}`,children:"必填"})}function cE(e){const[t,n]=p.useState({}),[r,s]=p.useState(!1),[i,o]=p.useState(null),l=e.presence!==void 0,c=m=>{var g,x;return(x=(g=e.presence)==null?void 0:g.find(b=>b.env===m))==null?void 0:x.setAt},u=l?e.secret.env.filter(m=>!c(m)):[],d=l&&u.length===0,h=Object.values(t).some(m=>m.length>0),f=async()=>{s(!0),o(null);try{const m=Object.fromEntries(Object.entries(t).filter(([,g])=>g.length>0));await e.onSubmitValues(m),n({})}catch(m){o(m instanceof Error?m.message:String(m))}finally{s(!1)}};return a.jsxs("div",{className:e.embedded?"px-4 py-3":"border-b border-border-card px-5 py-4 last:border-b-0",children:[!e.embedded&&a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:e.secret.name}),d?a.jsxs(ra,{variant:"secondary",className:"gap-1",children:[a.jsx(Jt,{className:"size-3"}),"已就绪"]}):l?a.jsxs(ra,{variant:"outline",children:["还差 ",u.length," 个值"]}):a.jsx(ra,{variant:"outline",children:"填没填查不到"})]}),!e.embedded&&e.evidence&&a.jsx(TR,{evidence:e.evidence}),a.jsxs("div",{className:e.embedded?"space-y-1.5":"mt-2.5 space-y-1.5",children:[e.secret.env.map(m=>{const g=c(m);return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"w-64 shrink-0 font-mono text-xs text-text-400",htmlFor:m,children:e.secret.name==="feishu"&&m==="LARKSUITE_CLI_APP_ID"?"App ID":e.secret.name==="feishu"&&m==="LARKSUITE_CLI_APP_SECRET"?"App Secret":m}),a.jsx(qn,{id:m,type:"password",autoComplete:"off",placeholder:g?"已填过,重填即覆盖":"粘贴值",value:t[m]??"",onChange:x=>n({...t,[m]:x.target.value})}),l?g?a.jsxs("span",{className:"w-24 shrink-0 text-xs text-text-400",children:["已填 · ",yx(new Date(g).toISOString())]}):a.jsx("span",{className:"w-24 shrink-0",children:a.jsx(kx,{})}):a.jsx("span",{className:"w-24 shrink-0 text-xs text-text-500",children:"未知"})]},m)}),a.jsxs("div",{className:"flex items-center gap-3 pt-0.5",children:[a.jsx(Le,{size:"sm",disabled:!h||r,onClick:()=>void f(),children:r?"写入中…":"写进仓库 Secrets"}),a.jsx("span",{className:"text-xs text-text-500",children:"直接写进仓库的 GitHub Secrets,不落本机"})]}),i&&a.jsx("div",{className:"text-xs text-error",children:i})]})]})}var u_="DropdownMenu",[tPe]=ga(u_,[$w]),as=$w(),[nPe,HY]=tPe(u_),UY=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,c=as(t),u=p.useRef(null),[d,h]=Hu({prop:s,defaultProp:i??!1,onChange:o,caller:u_});return a.jsx(nPe,{scope:t,triggerId:wo(),triggerRef:u,contentId:wo(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(f=>!f),[h]),modal:l,children:a.jsx(lV,{...c,open:d,onOpenChange:h,dir:r,modal:l,children:n})})};UY.displayName=u_;var WY="DropdownMenuTrigger",VY=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,i=HY(WY,n),o=as(n);return a.jsx(cV,{asChild:!0,...o,children:a.jsx(sn.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:Yg(t,i.triggerRef),onPointerDown:rt(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:rt(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});VY.displayName=WY;var rPe="DropdownMenuPortal",qY=e=>{const{__scopeDropdownMenu:t,...n}=e,r=as(t);return a.jsx(uV,{...r,...n})};qY.displayName=rPe;var KY="DropdownMenuContent",GY=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=HY(KY,n),i=as(n),o=p.useRef(!1);return a.jsx(dV,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...r,ref:t,onCloseAutoFocus:rt(e.onCloseAutoFocus,l=>{var c;o.current||(c=s.triggerRef.current)==null||c.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:rt(e.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!s.modal||d)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});GY.displayName=KY;var sPe="DropdownMenuGroup",iPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(hV,{...s,...r,ref:t})});iPe.displayName=sPe;var oPe="DropdownMenuLabel",YY=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(fV,{...s,...r,ref:t})});YY.displayName=oPe;var aPe="DropdownMenuItem",XY=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(pV,{...s,...r,ref:t})});XY.displayName=aPe;var lPe="DropdownMenuCheckboxItem",ZY=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(mV,{...s,...r,ref:t})});ZY.displayName=lPe;var cPe="DropdownMenuRadioGroup",uPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(gV,{...s,...r,ref:t})});uPe.displayName=cPe;var dPe="DropdownMenuRadioItem",hPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(xV,{...s,...r,ref:t})});hPe.displayName=dPe;var fPe="DropdownMenuItemIndicator",QY=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(vV,{...s,...r,ref:t})});QY.displayName=fPe;var pPe="DropdownMenuSeparator",JY=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(yV,{...s,...r,ref:t})});JY.displayName=pPe;var mPe="DropdownMenuArrow",gPe=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(bV,{...s,...r,ref:t})});gPe.displayName=mPe;var xPe=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:s,defaultOpen:i}=e,o=as(t),[l,c]=Hu({prop:r,defaultProp:i??!1,onChange:s,caller:"DropdownMenuSub"});return a.jsx(Pbe,{...o,open:l,onOpenChange:c,children:n})},vPe="DropdownMenuSubTrigger",eX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(wV,{...s,...r,ref:t})});eX.displayName=vPe;var yPe="DropdownMenuSubContent",tX=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=as(n);return a.jsx(_V,{...s,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});tX.displayName=yPe;var bPe=UY,wPe=VY,nX=qY,rX=GY,sX=YY,iX=XY,oX=ZY,_Pe=QY,aX=JY,SPe=xPe,lX=eX,cX=tX;const ls=bPe,cs=wPe,Ur=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>a.jsx(nX,{children:a.jsx(rX,{ref:r,sideOffset:t,className:J("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Ur.displayName=rX.displayName;const uX=SPe,RR=p.forwardRef(({className:e,...t},n)=>a.jsx(lX,{ref:n,className:J("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));RR.displayName=lX.displayName;const MR=p.forwardRef(({className:e,...t},n)=>a.jsx(nX,{children:a.jsx(cX,{ref:n,className:J("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));MR.displayName=cX.displayName;const Tt=p.forwardRef(({className:e,inset:t,...n},r)=>a.jsx(iX,{ref:r,className:J("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Tt.displayName=iX.displayName;const uE=p.forwardRef(({className:e,children:t,checked:n,...r},s)=>a.jsxs(oX,{ref:s,checked:n,className:J("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(_Pe,{children:a.jsx(Jt,{className:"h-3.5 w-3.5"})})}),t]}));uE.displayName=oX.displayName;const ha=p.forwardRef(({className:e,...t},n)=>a.jsx(aX,{ref:n,className:J("-mx-1 my-1 h-px bg-border",e),...t}));ha.displayName=aX.displayName;const rc=p.forwardRef(({className:e,...t},n)=>a.jsx(sX,{ref:n,className:J("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));rc.displayName=sX.displayName;function Qr(e){const t=e.tone==="accent"?"bg-accent-dim text-accent":e.tone==="warning"?"bg-warning-dim text-warning":"bg-bg-100 text-text-300";return a.jsxs("div",{className:"flex items-center gap-3 border-b border-border-card bg-bg-100/70 px-5 py-3.5",children:[a.jsx("span",{className:`flex size-8 shrink-0 items-center justify-center rounded-lg ${t}`,children:e.icon}),a.jsx("span",{className:"shrink-0 whitespace-nowrap text-lg font-semibold text-text-100",children:e.title}),e.count&&a.jsx("span",{className:"shrink-0 rounded-full border border-border px-2 py-0.5 text-xs text-text-300",children:e.count})]})}function dX(e){const[t,n]=p.useState(!1),[r,s]=p.useState(null),[i,o]=p.useState(!1),[l,c]=p.useState(null),u=p.useRef(0),[d,h]=p.useState(""),[f,m]=p.useState(""),[g,x]=p.useState(!1),[b,y]=p.useState(null),{state:v,channels:w=[]}=e,_=w.length>0,S=r??(e.channelId===null&&v==="own"?"custom":e.channelId),k=S?w.find(F=>F.id===S):w[0],N=!k,j=async()=>{if(!e.onRefreshChannels)return;const F=++u.current;o(!0),c(null);try{await e.onRefreshChannels()}catch(B){F===u.current&&c(B instanceof Error?B.message:String(B))}finally{F===u.current&&o(!1)}},R=v==="partial"||v===void 0,E=t||R,I=N?d.trim().length>0&&f.trim().length>0:!!k,M=async F=>{x(!0),y(null);try{await e.onSave(F),h(""),m(""),n(!1)}catch(B){y(B instanceof Error?B.message:String(B))}finally{x(!1)}},P=()=>{!N&&k?M({channelId:k.id}):N&&I&&M({baseUrl:d.trim(),apiKey:f.trim()})},D=a.jsx(Le,{size:"sm",disabled:g,onClick:()=>void M(null),children:"改回平台默认"});return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"engine-auth-card",children:[a.jsx(Qr,{icon:a.jsx(O5,{className:"size-[18px]"}),title:"模型订阅"}),a.jsxs("div",{className:"space-y-3 px-5 py-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[v==="own"?a.jsxs(a.Fragment,{children:[a.jsxs(ra,{className:"gap-1",children:[a.jsx(Jt,{className:"size-3"}),"自己的订阅"]}),a.jsxs("span",{className:"text-text-300",children:["云上跑这个 persona 花的是你填的订阅",e.channelId&&w.find(F=>F.id===e.channelId)?" · "+w.find(F=>F.id===e.channelId).name:"",e.setAt?a.jsxs("span",{className:"text-text-400",children:[" · 设置于 ",yx(new Date(e.setAt).toISOString())]}):null]})]}):v==="platform"?a.jsxs(a.Fragment,{children:[a.jsx(ra,{variant:"secondary",children:"平台默认"}),a.jsx("span",{className:"text-text-300",children:"云上跑这个 persona 花的是平台的模型额度"})]}):v==="partial"?a.jsxs("span",{className:"flex items-center gap-1.5 text-warning",children:[a.jsx(yn,{className:"size-3.5 shrink-0"}),"只写进去一半(地址和 key 缺一个),发布会被拦——重填或改回平台默认"]}):a.jsx("span",{className:"text-text-400",children:e.createRepoOnSave?"选择云端使用的模型订阅":"填没填查不到"}),!R&&a.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[v==="own"&&!t&&D,a.jsx(Le,{size:"sm",disabled:g,onClick:()=>{t||j(),n(!t),h(""),m("")},children:t?"收起":v==="own"?"换一个":"改用自己的订阅"})]})]}),E&&a.jsxs("div",{className:"space-y-2.5",children:[(_||e.onRefreshChannels)&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"订阅通道"}),a.jsxs(ls,{onOpenChange:F=>{F&&j()},children:[a.jsx(cs,{asChild:!0,children:a.jsxs("button",{type:"button","aria-label":"选择订阅通道",className:"flex h-9 flex-1 items-center justify-between rounded-md border border-border bg-elevated px-3 py-1 text-xs text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",children:[a.jsx("span",{children:k?`${k.name}${k.remark?`(${k.remark})`:""}`:"自定义输入..."}),a.jsx(Yt,{className:"size-4"})]})}),a.jsx(Ur,{children:i?a.jsx("div",{className:"px-2 py-1.5 text-xs text-text-400",children:"正在更新通道…"}):a.jsxs(a.Fragment,{children:[l?a.jsx(Tt,{onSelect:()=>void j(),children:"重试加载通道"}):w.map(F=>a.jsxs(Tt,{onSelect:()=>s(F.id),children:[F.name,F.remark?`(${F.remark})`:""]},F.id)),a.jsx(Tt,{onSelect:()=>s("custom"),children:"自定义输入..."})]})})]})]}),!N&&k?a.jsxs("div",{className:"rounded-md border border-border bg-surface-muted/40 p-2.5 space-y-1 text-xs font-mono","data-testid":"selected-channel-info",children:[a.jsxs("div",{className:"flex items-center gap-2 text-text-300",children:[a.jsx("span",{className:"text-text-400 font-sans",children:"地址:"}),a.jsx("span",{className:"truncate",children:k.baseUrl})]}),a.jsxs("div",{className:"flex items-center gap-2 text-text-300",children:[a.jsx("span",{className:"text-text-400 font-sans",children:"Key:"}),a.jsx("span",{children:k.keyMasked})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"w-20 shrink-0 text-xs text-text-400",htmlFor:"engine-auth-base-url",children:"订阅地址"}),a.jsx(qn,{id:"engine-auth-base-url",autoComplete:"off",placeholder:"https://…(号池地址,带不带 /v1 都行)",value:d,onChange:F=>h(F.target.value)})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"w-20 shrink-0 text-xs text-text-400",htmlFor:"engine-auth-api-key",children:"Key"}),a.jsx(qn,{id:"engine-auth-api-key",type:"password",autoComplete:"off",placeholder:"粘贴 key",value:f,onChange:F=>m(F.target.value)})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[a.jsx(Le,{size:"sm",disabled:!I||g||i||!!l&&!N,onClick:P,children:g?"写入中…":"改用这个订阅"}),v==="partial"&&a.jsx("span",{className:"ml-auto",children:D})]})]}),(b||l)&&a.jsx("div",{className:"text-xs text-error",children:b||l}),e.createRepoOnSave&&a.jsx("div",{className:"text-xs text-text-400",children:"首次保存会建立发布仓库,然后自动读取所选通道的模型列表。"}),a.jsx("div",{className:"text-xs text-text-500",children:"改完点「发布」才上云。无论 persona 引擎是 Codex、pi 还是 Claude,发布后均会直接使用该订阅通道;额度用完不会自动切回平台。"})]})]})}const PR=e=>!!e&&!e.error&&["main-pushed","dispatching","dispatched"].includes(e.phase)&&Date.now()-e.at<30*6e4,cn=e=>e.id??e.head;function kc(e){return e==null?void 0:e[e.length-1]}function ba(e){return e==null?void 0:e[e.length-1]}function sc(e){return(e==null?void 0:e.environment)==="production"?e.status==="completed"&&e.conclusion==="success"&&e.jobs.some(t=>t.key==="deploy"&&t.status==="done"):!!e&&e.status==="completed"&&dm.filter(t=>t!==mo||e.jobs.some(n=>n.key===mo)).every(t=>{var n;return((n=e.jobs.find(r=>r.key===t))==null?void 0:n.status)==="done"})}function X$(e){var r;const t=[...e.releases].reverse().find(s=>s.environment==="integration");if(t)return((r=e.promotions)==null?void 0:r.some(s=>s.releaseId===t.id&&s.phase==="completed"))===!0;const n=ba(e.releases);return n!==void 0&&Ru(n,e.run)&&sc(e.run)}function Sy(e){const t=[...e.releases].reverse().find(r=>r.environment==="integration")??ba(e.releases),n=kc(e.scans);return t&&n&&n.startedAt>t.at?e.releases.length:e.releases.some(r=>r.environment==="integration")?X$(e)?e.releases.length:Math.max(0,e.releases.length-1-[...e.releases].reverse().findIndex(r=>r.environment==="integration")):X$(e)?e.releases.length:Math.max(0,e.releases.length-1)}function hX(e,t){const n=kc(e.scans),r=[...e.releases].reverse().find(d=>d.environment==="integration")??ba(e.releases),s=r&&n&&n.startedAt>r.at,i=s?r:t>0?e.releases[t-1]:void 0,o=s?[]:e.releases.slice(t),l=new Set(o.map(d=>d.scanId)),c=i?e.scans.filter(d=>d.startedAt>i.at||l.has(d.id)):e.scans,u=[...o].reverse().find(d=>d.environment==="integration")??o[o.length-1];return{scans:c,releases:o,...u?{release:u}:{}}}function OR(e,t,n){if(n!==!1)return[...e].reverse().find(r=>{if(r.environment==="integration")return!1;const s=t[cn(r)];return s!=="loading"&&sc(s)})}function fX(e,t){const n=t[cn(e)];return n!==void 0&&n!=="loading"&&n.status!=="completed"}function n1(e,t){const n=kc(e);return!n||!t||n.startedAt>t.at||n.status==="scanning"?n:(e==null?void 0:e.find(r=>r.id===t.scanId))??n}function km(e,t){return e!==void 0&&t!==void 0&&e.startedAt<=t.at&&e.head!==void 0&&t.contentHead===e.head}function Ru(e,t){return e!==void 0&&t!==void 0&&t.headSha===e.head&&(!e.environment||!t.environment||e.environment===t.environment)&&(e.runId===void 0||e.runId===t.runId)&&(e.runAttempt===void 0||e.runAttempt===t.runAttempt)}function Z$(e,t,n){var o,l;const{repo:r}=e,s=[];e.github&&e.github.status!=="authorized"&&s.push("还没关联 GitHub"),r&&!["main","integration"].includes(r.branch)&&s.push("当前分支不用于发布,请重新扫描");const i=c=>{var u,d,h;return(h=((d=(u=e.targets)==null?void 0:u.integration)==null?void 0:d.secrets)??e.secrets)==null?void 0:h.find(f=>f.env===c)};if((t==null?void 0:t.status)==="done"){s.push(...t.notes.filter(u=>u.startsWith(tce)));const c=t.manifest;for(const u of[...c.secrets,...aw(c)]){const d=u.env.filter(h=>{var f;return!((f=i(h))!=null&&f.setAt)});d.length>0&&s.push(`${d.join(" / ")} 还没填`)}for(const u of c.connectors)s.push(...s7(u));for(const u of c.packages)s.push(...i7(u))}return kb(((l=(o=e.targets)==null?void 0:o.integration)==null?void 0:l.secrets)??e.secrets)==="partial"&&s.push(vce),s.push(...pX(n)),s}function pX(e){return e?ol(e.tool)?e.model?[]:[e.tool==="claude"?"还没选云上模型,在「引擎与模型」里选一个":"还没选模型,在「引擎与模型」里选一个"]:["云上只跑 Codex、pi 或 Claude,在「引擎与模型」里选一个"]:[]}const kPe={engine:"引擎",model:"模型",effort:"推理档位",size:"规格",cpu:"CPU",taskConcurrency:"任务并发"};function CPe(e,t){const n=r=>r===""?"未设置":String(r);return(C7(e,t)??[]).map(r=>`${kPe[r]}:${n(e[r])} → ${n(t[r])}`)}function mX(e){const{current:t,release:n}=e;if(!e.anchored||!n||!t)return{kind:"editing"};if(n.reconfigOf){const s=Ru(n,e.run)?e.run:void 0;if(!s||s.status!=="completed")return{kind:"applying"};if(!sc(s))return{kind:"failed"}}const r=C7(t,n.config);return r===null?{kind:"unknown"}:r.length===0?{kind:"synced"}:(n.workflowVersion??0)>=Nce?{kind:"pending",keys:r}:{kind:"needsRepublish",keys:r}}function NPe(e){switch(e.kind){case"pending":return"配置改过了,先「应用到测试环境」并确认再上线";case"needsRepublish":return"配置改过了,要先重新发一次测试环境(旧仓库不能只应用配置)";case"applying":return"正在把新配置应用到测试环境,等它跑完";case"failed":return"应用配置没通过,重新应用或改回原配置后再上线";default:return}}function DR(e,t){const n=e.unpublish;if(t!==void 0){const r=n&&n.runId!==t?n:void 0;return r?r.status!=="completed"?{kind:"unpublishing",runUrl:r.htmlUrl}:r.conclusion==="failure"?{kind:"failed",runUrl:r.htmlUrl}:e.online===!0?{kind:"unpublishing",runUrl:r.htmlUrl}:e.online===!1?{kind:"offline"}:{kind:"unknown"}:{kind:"unpublishing"}}return n&&n.status!=="completed"?{kind:"unpublishing",runUrl:n.htmlUrl}:e.online===!0?{kind:"online"}:e.online===!1?{kind:"offline"}:{kind:"unknown"}}function jPe(e){return e.releases.length>0&&(e.online===!0||e.unpublish!==void 0||sc(e.run))}const Q$=1500,v0=5e3,$c=e=>{var t;return((t=kc(e==null?void 0:e.scans))==null?void 0:t.status)==="scanning"},EPe=e=>{var s,i,o,l,c,u,d;if(!e)return!1;const t=(s=e.promotions)==null?void 0:s.at(-1),n=PR(t);return[(o=(i=e.targets)==null?void 0:i.integration)==null?void 0:o.run,...t?n?[(c=(l=e.targets)==null?void 0:l.production)==null?void 0:c.run]:[]:[(d=(u=e.targets)==null?void 0:u.production)==null?void 0:d.run,e.run]].some(h=>h&&h.status!=="completed")||n},IPe=(e,t)=>e!==null&&DR(e,t).kind==="unpublishing",J$=(e,t)=>{if(!e||e.personaId!==t.personaId)return t;const{repo:n,engineChannels:r,historyError:s,promotions:i,...o}=e;return{...o,...t}};function AR(e,t={}){const n=t.mode??"full",r=Kn(),[s,i]=p.useState(null),[o,l]=p.useState(!0),[c,u]=p.useState(null),[d,h]=p.useState(n!=="staged"),f=p.useRef(n!=="staged"),[m,g]=p.useState(null),x=p.useCallback(se=>{f.current=se,h(se),g(null)},[]),[b,y]=p.useState(null),v=p.useRef(null),[w,_]=p.useState(!1),S=p.useRef(null),[k,N]=p.useState(null),j=p.useCallback(se=>{S.current=se,N(se)},[]),R=p.useRef(void 0),[E,I]=p.useState(void 0),M=p.useRef(e);M.current=e;const P=p.useRef(0),D=p.useRef(null),F=p.useRef(null),B=p.useRef(null);B.current=s;const U=p.useCallback(se=>{var me,Ce,je,Se,ut,ot,yt,re,ue;if(se.personaId!==M.current)return;B.current=se,i(se);const fe=S.current,xe=((Ce=(me=se.targets)==null?void 0:me.integration)==null?void 0:Ce.run)??se.run,Me=fe?(je=xe==null?void 0:xe.jobs.find(Te=>Te.key===fe.key))==null?void 0:je.jobId:void 0;fe&&fe.phase!=="submitting"&&xe&&(xe.runId!==fe.runId||xe.headSha!==fe.headSha||(xe.runAttempt!==void 0?xe.runAttempt>fe.runAttempt:xe.status!=="completed"||Me!==void 0&&Me!==fe.jobId))&&j(null),((ot=((ut=(Se=se.targets)==null?void 0:Se.integration)==null?void 0:ut.run)??se.run)==null?void 0:ot.headSha)===v.current&&(v.current=null),_(v.current!==null),R.current!==void 0&&DR(se,R.current).kind==="offline"&&(R.current=void 0,I(void 0)),y($c(se)?Q$:n==="local"||((yt=S.current)==null?void 0:yt.phase)==="submitting"?null:EPe(se)||((re=S.current)==null?void 0:re.phase)==="waiting"||v.current!==null||IPe(se,R.current)?v0:null);const Xe=(ue=se.promotions)==null?void 0:ue.at(-1);u(Xe&&!["completed","failed"].includes(Xe.phase)&&Date.now()-Xe.at>=30*6e4?"本次上线等待已超过 30 分钟,已停止自动查询。请刷新核实原任务,或点发线上环境继续;不会直接重复发布。":null)},[j,n]),$=p.useCallback(async(se,fe=!1)=>{if(!e)return;const xe=F.current;if((xe==null?void 0:xe.personaId)===e&&xe.client===r)return!fe&&(xe.kind==="full"||se==="local")?xe.promise:(fe&&++P.current,await xe.promise,e!==M.current?void 0:$(se));const Me=++P.current;let Xe=!1;const me=(async()=>{try{const je=new Vt(r);if(se==="full"){const Se=await je.deployGet(e);Me===P.current&&e===M.current&&(U(Se),x(!0))}else{const Se=await je.deployGetLocal(e);if(Me===P.current&&e===M.current){const ut=J$(B.current,Se);Xe=n!=="local"&&$c(B.current)&&!$c(ut),U(ut)}}}catch(je){if(Me===P.current&&e===M.current){const Se=je instanceof Error?je.message:String(je);u(Se),se==="full"&&!f.current&&g(Se)}}finally{Me===P.current&&e===M.current&&l(!1)}})(),Ce={personaId:e,client:r,kind:se,promise:me};F.current=Ce;try{await me}finally{F.current===Ce&&(F.current=null)}Xe&&e===M.current&&$("full")},[r,e,U,n,x]),O=p.useCallback((se=!1)=>$(n==="local"?"local":"full",se),[$,n]),T=p.useCallback(()=>{f.current||$("full",!0)},[$]);p.useEffect(()=>{if(i(null),l(!0),v.current=null,_(!1),j(null),D.current=null,R.current=void 0,I(void 0),B.current=null,x(n!=="staged"),n!=="staged"){O();return}(async()=>{var se;await $("local"),e===M.current&&((se=B.current)==null?void 0:se.personaId)===e&&!$c(B.current)&&await $("full")})()},[O,$,j,n,e,x]),p.useEffect(()=>{if(b===null)return;const se=Date.now(),fe=setInterval(()=>{var xe;if(Date.now()-se>=30*6e4){y(null),((xe=S.current)==null?void 0:xe.phase)==="waiting"&&j({...S.current,phase:"unknown",error:"等待已超过 30 分钟,已停止自动查询。请刷新状态核实这次重试。"}),u("等待已超过 30 分钟,已停止自动查询。请刷新核实原任务。");return}$(n==="local"||$c(B.current)?"local":"full")},b);return()=>clearInterval(fe)},[b,$,j,n]);const V=p.useCallback(se=>{se.personaId===M.current&&(++P.current,l(!1),U(se))},[U]),H=p.useCallback(async se=>{if(!e)return;const fe=await new Vt(r).deployScan(e,se);V(J$(B.current,fe)),$c(B.current)||T()},[r,e,V,T]),L=p.useCallback(async(se,fe)=>{var Me;if(!e)return;const{scans:xe}=await new Vt(r).deployPatch(e,se,fe);e===M.current&&(++P.current,i(Xe=>(Xe==null?void 0:Xe.personaId)===e?{...Xe,scans:xe}:Xe),e===M.current&&((Me=kc(xe))==null?void 0:Me.status)==="scanning"?y(Q$):T())},[r,e,T]),q=p.useCallback(async(se,fe)=>{if(fe!==M.current)return;if(!se.secrets){await O(!0);return}const{environment:xe,secrets:Me,engineChannels:Xe}=se;++P.current,i(me=>(me==null?void 0:me.personaId)!==fe?me:{...me,...me.targets?{targets:{...me.targets,[xe]:{...me.targets[xe],secrets:Me}}}:{},...xe==="production"||!me.targets?{secrets:Me}:{},...Xe?{engineChannels:Xe}:{}}),$c(B.current)||T()},[O,T]),K=p.useCallback(async(se,fe,xe,Me="integration")=>{e&&await q(await new Vt(r).deployPutSecret(e,se,fe,xe,Me),e)},[r,e,q]),X=p.useCallback(async(se,fe="integration")=>{var Me;if(!e)return;let xe;try{xe=await new Vt(r).deploySetEngineAuth(e,se,fe)}catch(Xe){throw await O(!0),Xe}if(!((Me=B.current)!=null&&Me.repo)){await O(!0);return}await q(xe,e)},[r,e,q,O]),te=p.useCallback(async se=>{if(!e)throw new Error("没有 persona");const fe=await new Vt(r).deployRelease(e,se);return e!==M.current||(v.current=fe.sha,R.current=void 0,I(void 0),await O(!0)),fe},[r,e,O]),oe=p.useCallback(async se=>{if(!e)throw new Error("没有 persona");await new Vt(r).deployApplyConfig(e,se),e===M.current&&(y(v0),await O(!0))},[r,e,O]),Q=p.useCallback(async se=>{var Xe,me;if(!e||S.current&&S.current.phase!=="failed")return;const fe=((me=(Xe=s==null?void 0:s.targets)==null?void 0:Xe.integration)==null?void 0:me.run)??(s==null?void 0:s.run),xe=fe==null?void 0:fe.jobs.find(Ce=>Ce.jobId===se);if(!fe||!xe)throw new Error("这一步的状态已经改变,请刷新后重试");const Me={runId:fe.runId,runAttempt:fe.runAttempt??1,headSha:fe.headSha,key:xe.key,jobId:se,phase:"submitting"};++P.current,j(Me),y(null);try{const Ce=await new Vt(r).deployRerunJob(e,se,"integration");if(e!==M.current||S.current!==Me)return;j({...Me,phase:"waiting"}),V(Ce)}catch(Ce){throw e===M.current&&S.current===Me&&j({...Me,phase:"failed",error:Ce instanceof Error?Ce.message:String(Ce)}),Ce}},[r,e,s,V,j]),he=p.useCallback(async()=>{if(!e)return;const{before:se}=await new Vt(r).deployUnpublish(e);e===M.current&&(R.current=se,I(se),y(v0),await O(!0))},[r,e,O]),be=p.useCallback(async se=>{e&&(await new Vt(r).deployConfirmTest(e,se),await O(!0))},[r,e,O]),Z=p.useCallback(async se=>{if(!e||D.current)return;const fe={personaId:e};D.current=fe,++P.current;try{const{promotion:xe}=await new Vt(r).deployPromote(e,se);if(e!==M.current||D.current!==fe)return;++P.current,i(Me=>(Me==null?void 0:Me.personaId)===e?{...Me,promotions:[...(Me.promotions??[]).filter(Xe=>Xe.id!==xe.id),xe]}:Me),y(PR(xe)?v0:null),O(!0)}finally{D.current===fe&&(D.current=null)}},[r,e,O]),ce=p.useCallback(async se=>{if(!e)throw new Error("没有 persona");return new Vt(r).deployOpenTest(e,se)},[r,e]);return{state:s,remoteReady:d,remoteError:m,loading:o,error:c,confirmTest:be,promote:Z,openTest:ce,refresh:O,awaitingRun:w,retry:k,scan:H,patch:L,putSecret:K,setEngineAuth:X,release:te,rerunJob:Q,applyConfig:oe,unpublishFrom:E,unpublish:he}}const TPe=2e3,RPe=()=>{var t;if(typeof window>"u")return;const e=(t=window.location)==null?void 0:t.href;return e&&/^https?:\/\//.test(e)?e:void 0};function gX(){const e=Kn(),[t,n]=p.useState(null),[r,s]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(f=>{n(f),o(null)},[]),c=p.useCallback(async()=>{try{l(await new Vt(e).githubAuthGet())}catch(f){o(f instanceof Error?f.message:String(f))}finally{s(!1)}},[e,l]);p.useEffect(()=>{c()},[c]);const u=(t==null?void 0:t.status)==="pending";p.useEffect(()=>{if(!u)return;const f=setInterval(()=>void c(),TPe);return()=>clearInterval(f)},[u,c]);const d=p.useCallback(async()=>{const f=await new Vt(e).githubAuthOauthStart(RPe());return l(f),f.status==="pending"?f.authUrl:void 0},[e,l]),h=p.useCallback(async f=>{l(await new Vt(e).githubAuthAuthorize(f))},[e,l]);return{status:t,loading:r,error:i,refresh:c,startOauth:d,authorize:h}}function MPe(e,t){const[n,r]=p.useState(null);return p.useEffect(()=>{if(r(null),!t||!ol(t))return;let s=!0;return e.engineStatus(t).then(i=>{s&&r(i.installed&&i.version?i.version:null)},()=>{s&&r(null)}),()=>{s=!1}},[e,t]),n}function PPe(e,t={}){return{models:e,loading:!1,error:null,load:()=>{},...t}}const OPe=e=>e instanceof Error?e.message:String(e);function xX(e,t){const[n,r]=p.useState({key:e,loading:!1,error:null,data:t}),s=p.useRef(0),i=p.useCallback((l,c)=>{const u=++s.current;r(d=>({key:e,loading:!0,error:null,data:d.key===e?d.data:t})),l().then(d=>{s.current===u&&(c==null||c(d),r({key:e,loading:!1,error:null,data:d}))},d=>{s.current===u&&r(h=>({key:e,loading:!1,error:OPe(d),data:h.key===e?h.data:t}))})},[e]);return{...n.key===e?n:{loading:!1,error:null,data:t},run:i}}const vX=[];function gh(e){const t=Kn(),n=p.useMemo(()=>new Vt(t),[t]),r=Ws(),{capabilities:s}=si(e),i=xX(e??"",null),{run:o}=i,l=p.useCallback(()=>{e&&o(()=>n.capabilitiesGet(e,{refresh:!0}),c=>{c&&r.setData(`capabilities/${e}`,()=>c)})},[n,r,e,o]);return{models:(s==null?void 0:s.models)??vX,loading:i.loading,error:i.error,load:l}}function DPe(e,t){const n=t?`${t.channelId??""}:${t.updatedAt??""}`:"",r=xX(n,vX),{run:s}=r,i=p.useRef(t);i.current=t;const o=p.useCallback(()=>{const l=i.current;l&&s(async()=>(await e.subscriptionChannelModels(l)).models.map(u=>({id:u.id,label:u.id,contextWindowSize:0,...u.ownedBy?{description:u.ownedBy}:{}})))},[e,s]);return{models:r.data,loading:r.loading,error:r.error,load:o}}const eL={done:{cls:"bg-success-dim text-success",icon:()=>a.jsx(Jt,{className:"size-4",strokeWidth:3})},running:{cls:"bg-accent-dim text-accent",icon:()=>a.jsx(st,{className:"size-4 animate-spin"})},failed:{cls:"bg-error text-white",icon:()=>a.jsx(Xt,{className:"size-4",strokeWidth:3})},waiting:{cls:"bg-warning-dim text-warning",icon:()=>a.jsx(M5,{className:"size-4"})},skipped:{cls:"bg-text-400/15 text-text-500",icon:()=>a.jsx(mfe,{className:"size-4"})},pending:{cls:"bg-text-400/15 text-text-400",icon:e=>a.jsx("span",{className:"text-xs font-medium tabular-nums",children:e+1})}},APe={done:"text-text-100",running:"text-accent",failed:"text-error",waiting:"text-warning",skipped:"text-text-500",pending:"text-text-400"},$Pe={done:"bg-success/40",running:"bg-accent/50",failed:"bg-error/60",waiting:"bg-warning/50",skipped:"bg-border",pending:"bg-border"},LPe={done:"已完成",running:"进行中",failed:"失败",waiting:"等待中",skipped:"已跳过",pending:"未开始"},BPe={done:"bg-success-dim text-success",running:"bg-accent-dim text-accent",failed:"bg-error-dim text-error",waiting:"bg-warning-dim text-warning",skipped:"bg-text-100-dim text-text-500",pending:"bg-text-100-dim text-text-400"};function r1(e){var n;const t=(...r)=>e.find(s=>r.includes(s.status));return(n=t("failed")??t("running")??t("waiting")??t("pending")??e[e.length-1])==null?void 0:n.key}function FPe(e){var n;const t=(...r)=>e.find(s=>r.includes(s.status));return(n=t("failed")??t("running")??t("waiting"))==null?void 0:n.key}function yX(e){const[t,n]=p.useState(null),r=e.activeKey??t??r1(e.stages),s=e.stages.find(i=>i.key===r)??e.stages[0];return a.jsxs("div",{className:"@container space-y-4",children:[a.jsx("div",{className:"overflow-x-auto pb-2",role:"region","aria-label":"发布进度",tabIndex:0,children:a.jsx("div",{className:"flex min-w-max items-start",children:e.stages.map((i,o)=>a.jsxs("div",{className:"relative min-w-[88px] flex-1",children:[o<e.stages.length-1&&a.jsx("div",{"aria-hidden":"true",className:`absolute left-[calc(50%+18px)] top-5 h-px w-[calc(100%-36px)] ${$Pe[e.stages[o+1].status]}`}),a.jsxs("div",{className:"relative flex flex-col items-center",children:[a.jsxs("button",{onClick:()=>{var l;n(i.key),(l=e.onPick)==null||l.call(e,i.key)},"aria-current":i.key===r,"aria-label":i.label,"data-status":i.status,className:`flex w-full cursor-pointer flex-col items-center gap-2 rounded-lg border px-1 py-1.5 transition-colors ${i.key===r?"border-border bg-surface-page":"border-transparent hover:bg-text-100-dim/60"}`,children:[a.jsx("span",{className:`flex size-7 shrink-0 items-center justify-center rounded-full ${eL[i.status].cls} ${i.next&&i.status==="pending"?"ring-2 ring-accent/60 ring-offset-2 ring-offset-surface-card":""}`,children:eL[i.status].icon(o)}),a.jsx("span",{className:`whitespace-nowrap text-[12px] ${i.next&&i.status==="pending"?"text-accent":APe[i.status]} ${i.key===r?"font-semibold":"font-medium"}`,children:i.label})]}),i.onRetry&&a.jsx("button",{onClick:i.onRetry,title:i.status==="failed"?"原样重跑这一段":"用最新流水线重新构建,后面的步骤会重新跑","aria-label":i.status==="failed"?`原样重跑「${i.label}」`:"重新构建并重跑后面的步骤",className:"mt-1 flex size-6 cursor-pointer items-center justify-center rounded-full text-text-400 transition-colors hover:bg-error-dim hover:text-error",children:a.jsx(mf,{className:"size-3.5"})})]})]},i.key))})}),s&&a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-page",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-border-card px-4 py-2.5",children:[a.jsx("span",{className:`rounded-full px-2 py-0.5 text-[11px] font-medium ${BPe[s.status]}`,children:LPe[s.status]}),a.jsx("span",{className:"text-[13px] font-medium text-text-100",children:s.label}),s.meta&&a.jsx("span",{className:"ml-auto font-mono text-[11px] text-text-400",children:s.meta})]}),a.jsx("div",{className:"px-4 py-3 text-[13px] leading-relaxed text-text-200",children:s.detail??a.jsx("span",{className:"text-text-400",children:"这一段还没有可说的。"})})]})]})}function d_(e,t){return`${e.replace(/\/+$/,"")}/p/${t}/v1`}function zPe(e,t){return`${d_(e,t)}/chat/completions`}function HPe(e,t){return`${d_(e,t)}/tasks`}function dE(e){const t=e.entry==="task"?HPe(e.gatewayUrl,e.personaId):zPe(e.gatewayUrl,e.personaId),n=["# model:将 <model-id> 替换为该 persona 引擎可用的模型;Pi 可用 provider/model。","# 每轮单独选择模型;删除 model 字段使用发布默认模型,不沿用上一轮覆盖。",`curl ${t} \\`,` -H 'authorization: Bearer ${e.apiKey}' \\`," -H 'content-type: application/json' \\"," -d '{",' "model": "<model-id>",',` "messages": [{ "role": "user", "content": ${JSON.stringify(e.prompt)} }]`," }'"];return e.entry==="task"?n.join(`
914
914
  `):[...n,"","# 续聊:把上一条响应的 clawd.podId 和 clawd.threadId 填进下面两个请求头",`curl ${t} \\`,` -H 'authorization: Bearer ${e.apiKey}' \\`," -H 'content-type: application/json' \\"," -H 'X-Clawd-Pod: <podId>' \\"," -H 'X-Clawd-Thread: <threadId>' \\"," -d '{",' "model": "<model-id>",',' "messages": [{ "role": "user", "content": "继续" }]'," }'"].join(`
915
- `)}function UPe(e){const t=e.prompt??"hello";if(!e.gatewayUrl)return a.jsxs(uC,{children:["中心还没配调用地址(",a.jsx("code",{className:"font-mono",children:"PERSONA_CLOUD_GATEWAY_URL"}),"), 这里就给不出能跑的命令。persona 已经在云上了,派活不受影响。"]});if(e.apiKey===void 0)return a.jsx(uC,{children:"正在读你的调用 key…"});if(e.apiKey===null)return a.jsxs(uC,{children:["你还没有调用 key。去",e.onOpenSettings?a.jsx("button",{onClick:e.onOpenSettings,className:"mx-1 cursor-pointer text-accent hover:underline",children:"设置 → 账号"}):a.jsx("span",{className:"mx-1",children:"设置 → 账号"}),"生成一把,这里就会给出填好的命令。"]});const{gatewayUrl:n,apiKey:r,personaId:s}=e,i=d_(n,s),o=l=>dE({gatewayUrl:n,personaId:s,apiKey:r,prompt:t,entry:l});return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:"base_url"}),a.jsx("code",{className:"min-w-0 truncate font-mono text-text-200",children:i}),a.jsx(bX,{text:i,label:"复制"})]}),a.jsx(s1,{label:"chat curl",curl:o("chat")}),a.jsx(s1,{label:"task curl",curl:o("task")})]})}function s1(e){return a.jsxs("div",{className:"space-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:e.label}),a.jsxs("div",{className:"relative rounded-md border border-border bg-surface-page",children:[a.jsx("pre",{"data-testid":e.testId,className:"overflow-x-auto px-3 py-2.5 pr-24 font-mono text-[11px] leading-relaxed text-text-200",children:e.curl}),a.jsx("div",{className:"absolute right-2 top-2",children:a.jsx(bX,{text:e.curl,label:"复制 curl"})})]})]})}function uC(e){return a.jsx("div",{className:"text-[13px] leading-relaxed text-text-400",children:e.children})}function bX(e){const[t,n]=p.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(e.text),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return a.jsxs("button",{onClick:()=>void r(),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-surface-card px-2 py-1 text-[11px] font-medium text-text-300 transition-colors hover:border-accent/50 hover:text-accent",children:[t?a.jsx(Jt,{className:"size-3 text-success"}):a.jsx(ma,{className:"size-3"}),t?"已复制":e.label]})}const WPe={build:"构建镜像",smoke:"云上试跑",deploy:"登记上线",[mo]:"自动验证"};function Mi(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[13px] text-accent hover:underline",children:[e.children,a.jsx(Fr,{className:"size-3"})]})}function VPe(e){return a.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-[13px]",children:e.rows.map(([t,n])=>a.jsxs("div",{className:"contents",children:[a.jsx("dt",{className:"text-text-400",children:t}),a.jsx("dd",{className:"min-w-0 truncate font-mono text-[12px] text-text-200",children:n})]},t))})}function i1(e){return a.jsx("div",{className:"text-xs text-text-400",children:e.children})}function o1(e,t){if(e===void 0||t===void 0)return;const n=Math.round((t-e)/1e3);if(!(n<0))return n<60?`${n}s`:`${Math.floor(n/60)}m${String(n%60).padStart(2,"0")}s`}function qPe(e){if(e.status!=="pending")return e.status==="waiting"?"等审批":e.status==="running"&&e.startedAt!==void 0?"进行中":o1(e.startedAt,e.completedAt)}function dC(e){return a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{children:"前面那一段挂了,这一段没有跑。云上跑的还是上一版。"}),a.jsxs("div",{className:"text-text-400",children:["修好重发之后,它会:",e.children]})]})}function hC(e){return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:e.what}),a.jsx(i1,{children:e.impact}),e.url&&a.jsx(Mi,{href:e.url,children:"看这一段的完整日志"})]})}function KPe(e,t){const n=t.url,r=n?a.jsx(Mi,{href:n,children:t.status==="running"?"看实时日志":"看这一段的日志"}):null;if(e==="build")switch(t.status){case"pending":return a.jsx("div",{children:"会在 runner 上按清单把要装的东西装进底座镜像,构出一层 persona 镜像推到 ACR。镜像 tag 带 commit sha,不可变。"});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在按清单装东西,然后构镜像。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"镜像构出来了,清单里要装的都在、都报得出版本,persona 目录也在。已经推到 ACR。"}),r]});case"failed":return a.jsx(hC,{what:"构镜像这一步挂了。",url:n,impact:"云上跑的还是上一版,没被动过"});default:return a.jsx(dC,{children:"按清单装好东西、构出 persona 镜像推到 ACR。"})}if(e==="smoke")switch(t.status){case"pending":return a.jsxs("div",{children:["会拿刚构出来的镜像在集群上",a.jsx("b",{children:"临时登记一次"}),"、真起一个 Pod、投一句「只回复 ok」,验的是拉得到镜像、容器起得来、卷挂得上、codex 回得了话。验完就撤销。"]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"临时登记好了,在等集群拉镜像、起 Pod。第一次拉几百 MB 的镜像会慢一些。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"集群拉到了镜像、容器起来了、codex 回了话。临时登记已经撤销,没有残留。"}),r]});case"failed":return a.jsx(hC,{what:"镜像在集群上没跑起来,或者跑起来了但没回话。",url:n,impact:"镜像构出来了,但没敢登记;云上跑的还是上一版"});default:return a.jsx(dC,{children:"拿新构出来的镜像在集群上临时起一次,验拉得到、起得来、回得了话。"})}switch(t.status){case"pending":return a.jsxs("div",{children:["会把这份镜像在 gateway 上登记成",a.jsx("b",{children:"正式"}),"。从这一刻起,别人派活过来起的就是这一版。同一台 gateway 上挂着别的 persona 不受影响,重新登记只覆盖自己那一行。"]});case"waiting":return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["仓库给 ",a.jsx("code",{className:"font-mono",children:"production"})," 环境配了审核人,这一步停在这里等人点。批了才会登记成正式,云上现在跑的还是上一版。"]}),n&&a.jsx(Mi,{href:n,children:"去 GitHub 批准"})]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在往 gateway 写这一版的登记(镜像地址 + 部署者提供的那几条凭据)。"}),r]});case"failed":return a.jsx(hC,{what:"gateway 没收下这次登记。",url:n,impact:"云上跑的还是上一版,没被动过"});case"done":return null;default:return a.jsx(dC,{children:"把这份镜像在 gateway 上登记成正式,别人派活过来就起这一版。"})}}function GPe(e,t,n){const r=n?"后来下线了,现在线上没有它。":t?"现在线上跑的就是它。":"后来被更新的发布覆盖了,线上跑的是标「线上」那条。";return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["这一版在 gateway 上登记成了正式。",r]}),e.url&&a.jsx(Mi,{href:e.url,children:"看这一段的日志"})]})}const YPe=(e,t)=>()=>e(t);function Rn(e){return a.jsx("div",{className:"space-y-3",children:e.children})}function XPe(e){const t={key:"scan",label:"扫描"},{latest:n}=e;if(e.frozen){if(!n)return{...t,status:"done",meta:"记录已丢",detail:a.jsx("div",{children:"这次发布对应的扫描记录找不到了(可能是旧版 clawd 留下的)。"})};const s=o1(n.startedAt,n.finishedAt);return{...t,status:"done",...s?{meta:s}:{},detail:a.jsx("div",{children:"清单是这次扫描的,在下面的卡片里。"})}}if(e.starting)return{...t,status:"running",meta:"进行中",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:e.repo?"正在把 persona 目录落存、起管家会话…":"正在建仓库、把 persona 提交进去、起管家会话…"}),e.actions]})};if(!n)return{...t,status:"pending",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"还没扫过。扫描会把 persona 整个读一遍,列出它挪到云上要预备什么:镜像里要装的东西、要连的连接器、要填的凭据。"}),e.actions]})};if(n.status==="scanning")return{...t,status:"running",meta:"进行中",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"管家在读 persona,清单在下面一条条长出来。右上角「管家分析中」能看它读了什么。"}),e.actions]})};if(n.status==="failed")return{...t,status:"failed",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:n.error??"扫描没跑完。"}),a.jsx(i1,{children:"云上跑的还是上一版,没被动过。"}),e.actions]}),...e.onRescan?{onRetry:e.onRescan}:{}};const r=o1(n.startedAt,n.finishedAt);return lw(n,e.repo,e.lastRelease)?!e.anchored&&e.blockers.length>0?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(Rn,{children:[a.jsxs("div",{children:["扫完了,还差 ",a.jsxs("span",{className:"font-medium text-warning",children:[e.blockers.length," 项必填"]}),",填好就能发布。"]}),e.actions]})}:{...t,status:"done",...r?{meta:r}:{},detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"清单是这一版扫的,在下面的卡片里。"}),e.actions]})}:{...t,status:"waiting",meta:"已过时",detail:a.jsxs(Rn,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-warning",children:"有未提交的改动"}),",最新这份清单是改动前扫的。要上云的话重新扫一遍。"]}),e.actions]})}}function fC(e){return a.jsx("ul",{className:"list-disc space-y-0.5 pl-5",children:e.lines.map(t=>a.jsx("li",{children:t},t))})}function ZPe(e){const t={key:"config",label:"配置"},n=e.current&&e.tested?CPe(e.tested,e.current):[],r=e.runUrl?a.jsx(Mi,{href:e.runUrl,children:"在 GitHub 看应用配置的流水线"}):null;switch(e.phase.kind){case"editing":return e.blocker&&e.scanDone?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(Rn,{children:[a.jsx("div",{className:"text-warning",children:e.blocker}),e.actions]})}:{...t,status:e.scanDone?"done":"pending",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"引擎、模型和资源在下面定,随下一次「发测试环境」一起生效。发测试环境之后再改它们,不用重新扫描。"}),e.actions]})};case"synced":return{...t,status:"done",meta:"与测试一致",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"测试环境用的就是当前配置。之后改了引擎、模型或资源,回到这里「应用到测试环境」就行,不用重新扫描、重新构建。"}),e.actions]})};case"pending":return{...t,status:"waiting",meta:`改了 ${e.phase.keys.length} 项`,detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"测试环境还是旧配置,已改:"}),a.jsx(fC,{lines:n}),a.jsx(i1,{children:"只重新登记并验证,不重新构建,几分钟;线上不受影响。应用并确认之前不能上线。"}),e.actions]})};case"needsRepublish":return{...t,status:"waiting",meta:"需重发",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"配置改了:"}),a.jsx(fC,{lines:n}),a.jsx("div",{children:"但这个仓库的发布流水线是旧版本,不认单独应用的配置。重新扫描、再发一次测试环境(会重新构建),之后就能直接应用配置了。"}),e.actions]})};case"applying":return{...t,status:"running",meta:"应用中",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"正在把新配置登记到测试环境,并重新验证真实对话(不重新构建)。"}),n.length>0&&a.jsx(fC,{lines:n}),r,e.actions]})};case"failed":return{...t,status:"failed",meta:"没通过",detail:a.jsxs(Rn,{children:[a.jsx("div",{className:"text-error",children:"应用配置没通过。"}),a.jsx(i1,{children:"测试环境里可能已经是新配置但没验证过,线上没有被动过。看日志找原因,改好配置后重新应用。"}),r,e.actions]})};case"unknown":return{...t,status:"done",meta:"无法比较",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"读不到测试环境当时用的配置,没法比较有没有改过。"}),e.actions]})}}}function QPe(e){const t={key:"push",label:"推送"};if(e.releasing)return{...t,status:"running",meta:"进行中",detail:a.jsxs(Rn,{children:[a.jsxs("div",{children:["正在把这次扫描的清单写进仓库、提交并推送到 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),"…"]}),e.actions]})};if(!e.anchored||!e.released)return{...t,status:"pending",detail:a.jsx(Rn,{children:e.actions})};const n=e.released.head.slice(0,7);return{...t,status:"done",meta:n,detail:a.jsxs(Rn,{children:[e.run?a.jsxs(a.Fragment,{children:[e.released.reconfigOf?a.jsx("div",{children:"这一轮最近一次是「应用配置」:没有新的提交,复用上一次测试验证过的镜像,只换了配置。"}):a.jsxs("div",{children:["persona 目录和这次扫描的清单一起提交并推到了 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),",下面这条流水线由这次推送触发。"]}),a.jsx(VPe,{rows:[["提交",n],["流水线",`#${e.run.runId}`]]}),a.jsx(Mi,{href:e.run.htmlUrl,children:"在 GitHub 看这次流水线"})]}):e.awaitingRun?a.jsx("div",{children:"提交推上去了,GitHub 那边还没把这次流水线列出来。通常几秒。"}):a.jsx("div",{children:"提交推上去了,但 GitHub 上没列出这一版的流水线:查不到 GitHub(没网 / 授权失效)、仓库的 Actions 没开、或者这条 run 已经被 GitHub 清掉了。刷新看看,或者去 GitHub 看。"}),e.actions]})}}const JPe={deploy:"应用配置后,会把新配置重新发到测试环境。",[mo]:"发到测试环境后,流水线会重新验证真实对话。",production:"新配置在测试环境验证通过后才能上线。"};function eOe(e,t){const n=t.kind;if(n!=="pending"&&n!=="applying"&&n!=="failed"&&n!=="needsRepublish")return;const r=d=>{d.status="pending",delete d.meta,delete d.onRetry,delete d.next;const h=JPe[d.key];h?d.detail=a.jsx("div",{children:h}):delete d.detail},s=e.findIndex(d=>d.key==="config");if(s<0)return;if(n==="needsRepublish"){for(const d of e.slice(s+1))r(d);return}const i=e.find(d=>d.key==="build"),o=e[s],l=e.filter(d=>d.key!=="scan"&&d.key!=="config"&&d.key!=="push"&&d.key!=="smoke"&&d.key!=="build"),c=i?[i.status!=="done"?i:{...i,status:"done",meta:"复用上次镜像",detail:a.jsx("div",{children:"只应用配置,不重新构建:用的是上一次测试验证过的镜像。"})}]:[];if(n==="pending")for(const d of l)r(d);else(n==="applying"||l.some(d=>d.status==="failed"))&&(o.status="done",o.meta="已提交");const u=l.findIndex(d=>d.status==="failed");if(u>=0)for(const d of l.slice(u+1))r(d);e.splice(0,e.length,e[0],...c,o,...l)}function wX(e){var y,v,w,_;const t=!!e.frozen,{released:n}=e,r=n1(e.scans,n),s=!!e.releasing&&!t,i=!!e.awaitingRun&&!t,o=t?n!==void 0:km(r,n),l=o&&!s&&Ru(n,e.run)?e.run:void 0,c=!t&&o&&e.retry&&e.retry.headSha===(n==null?void 0:n.head)&&(!e.run||e.run.runId===e.retry.runId)?e.retry:void 0,u=c?dm.indexOf(c.key):-1,d=[XPe({...r?{latest:r}:{},...e.repo?{repo:e.repo}:{},...e.lastRelease??n?{lastRelease:e.lastRelease??n}:{},blockers:e.blockers,starting:!!e.starting&&!t,anchored:o,frozen:t,...e.scanActions!==void 0&&!t?{actions:e.scanActions}:{},...e.onRescan&&!t?{onRescan:e.onRescan}:{}}),...e.config?[ZPe({phase:e.config.phase,...e.config.current?{current:e.config.current}:{},...e.config.tested?{tested:e.config.tested}:{},...e.config.blocker?{blocker:e.config.blocker}:{},scanDone:!!r&&r.status==="done"&&lw(r,e.repo,e.lastRelease??n),...l!=null&&l.htmlUrl?{runUrl:l.htmlUrl}:{},...e.config.actions!==void 0?{actions:e.config.actions}:{}})]:[],QPe({...e.flow?{environment:"integration"}:{},...n?{released:n}:{},...l?{run:l}:{},releasing:s,anchored:o,awaitingRun:i,...e.releaseActions!==void 0?{actions:e.releaseActions}:{}})],h=!s&&o&&(l?l.status!=="completed":i),f=new Map((l==null?void 0:l.jobs.map(S=>[S.key,S]))??[]),m=!!e.flow&&(l==null?void 0:l.status)==="completed"&&!e.flow.confirmed&&!(n!=null&&n.reconfigOf);let g=!0;for(const S of dm){if(S===mo&&!e.flow&&!f.has(S))continue;const k=c&&dm.indexOf(S)>u,N=(c==null?void 0:c.key)===S,j=k?void 0:f.get(S),R=!c&&!j&&h&&g,E=!c&&h&&g&&((j==null?void 0:j.status)==="pending"||R&&(l==null?void 0:l.status)==="queued"),I=k?{status:"pending"}:N?{jobId:c.jobId,status:c.phase==="submitting"?"running":c.phase==="failed"?"failed":"waiting"}:j??{status:"pending"};g=g&&I.status==="done";const M=N?S==="build"?"等待构建开始":"等待这一步开始":"等待开始",P=N?c.phase==="submitting"?"正在重试":c.phase==="failed"?"重试请求失败":c.phase==="unknown"?"状态待确认":M:E?"排队中":R?M:qPe(I),D=N?a.jsxs(Rn,{children:[a.jsx("div",{children:c.phase==="submitting"?"正在提交重试请求,请不要重复点击。":c.phase==="failed"?"重试请求失败,请核实原因后重试。":c.phase==="unknown"?"暂时无法确认这次重试的状态。":"重试请求已返回,正在等待新一轮的执行状态。"}),c.error&&a.jsx("div",{className:"text-error",children:c.error}),(l==null?void 0:l.htmlUrl)&&a.jsx(Mi,{href:l.htmlUrl,children:"查看这次发布"}),c.phase==="unknown"&&e.onRefreshRetry&&a.jsx("button",{className:"text-accent hover:underline",onClick:e.onRefreshRetry,children:"刷新状态"})]}):E||R?a.jsxs(Rn,{children:[a.jsx("div",{children:E?"GitHub 已将这一步排队,等待开始执行。":"正在等待这一步的执行状态;尚未确认开始。"}),(l==null?void 0:l.htmlUrl)&&a.jsx(Mi,{href:l.htmlUrl,children:"查看这次发布"})]}):n!=null&&n.reconfigOf&&S==="build"&&I.status==="done"?a.jsxs(Rn,{children:[a.jsx("div",{children:"这次只应用配置,没有重新构建:用的是上一次测试验证过的镜像。"}),I.url&&a.jsx(Mi,{href:I.url,children:"看这一段的日志"})]}):e.flow&&S==="deploy"?a.jsxs(Rn,{children:[a.jsx("div",{children:I.status==="done"?"已发到测试环境,流水线接着自动验证真实对话。":"这一步会把本次版本发到测试环境。"}),I.url&&a.jsx(Mi,{href:I.url,children:"查看这一步的日志"})]}):S===mo?a.jsxs(Rn,{children:[a.jsx("div",{children:I.status==="running"?"流水线正在用测试账号验证真实对话,收到有效回复并正常结束才算通过。":I.status==="failed"?"自动对话验证失败,线上没有改动。查看日志后重试。":(y=e.flow)!=null&&y.confirmed?"测试通过,已收到有效回复并正常结束。上线将使用同一个版本。":I.status==="done"?"正在核对验证结果和测试环境版本;版本变化时需要重新发布测试。":(l==null?void 0:l.status)==="completed"?"这次发布没有通过自动对话验证,请重新扫描并发布测试环境。":"测试环境发布后,流水线会自动验证真实对话。"}),I.url&&a.jsx(Mi,{href:I.url,children:"查看这一步的日志"}),(v=e.flow)==null?void 0:v.testActions]}):S==="deploy"&&I.status==="done"&&t?GPe(I,e.live,!!e.offline):S==="deploy"&&I.status==="done"&&e.offline?a.jsx("div",{children:"这一版登记上线过,后来下线了:gateway 上已经没有它,别人看不到、用不了。重新扫描、发布就能再上线。"}):S==="deploy"&&I.status==="done"?a.jsx(UPe,{gatewayUrl:((w=e.cloud)==null?void 0:w.gatewayUrl)??null,personaId:e.personaId,apiKey:(_=e.cloud)==null?void 0:_.apiKey,...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{}}):KPe(S,I);d.push({key:S,label:e.flow?{build:"构建",smoke:"自动试跑",deploy:"发测试环境",[mo]:"自动验证"}[S]:WPe[S],status:E||R||S===mo&&e.flow&&!c&&!e.flow.confirmed&&(I.status==="done"||(l==null?void 0:l.status)==="completed"&&!j)?"waiting":I.status,...P?{meta:P}:{},...D?{detail:D}:{},...(I.status==="failed"||m&&S==="build"&&I.status==="done")&&I.jobId!==void 0&&e.onRetry&&!t&&(!c||c.phase==="failed")?{onRetry:YPe(e.onRetry,I.jobId)}:{}})}if(e.flow){const{confirmed:S,promotion:k,productionActions:N,submissionError:j}=e.flow,R=!!e.flow.promoting&&!t,E=R?"正在提交上线":j?"上线请求失败":void 0,I=R?"正在核对测试版本并提交上线,请不要重复点击。":j?"上线请求失败,请核实原因后再继续。":(k==null?void 0:k.phase)==="completed"?"这一版已上线。":(k==null?void 0:k.phase)==="failed"?"上线失败,请查看原因后再继续。":k!=null&&k.error?"上线已暂停,请处理下面的问题后再继续。":(k==null?void 0:k.phase)==="main-pushed"?"已推送到线上分支,正在提交上线任务。":(k==null?void 0:k.phase)==="dispatching"?"正在向 GitHub 提交上线任务。":(k==null?void 0:k.phase)==="dispatched"?"上线任务已提交,正在等待执行结果。":(k==null?void 0:k.phase)==="prepared"?"正在准备上线已测试的版本。":S?"把已测试的提交推到线上分支,上线同一个版本。":"先等待自动对话验证通过。",M=e.repo&&(k!=null&&k.runId)?`${e.repo.url.replace(/\.git$/,"")}/actions/runs/${k.runId}`:void 0;d.push({key:"production",label:"发线上环境",status:R?"running":j?"failed":(k==null?void 0:k.phase)==="completed"?"done":(k==null?void 0:k.phase)==="failed"?"failed":k!=null&&k.error?"waiting":k?"running":"pending",...E?{meta:E}:{},detail:a.jsxs(Rn,{children:[a.jsx("div",{children:I}),!R&&(j||(k==null?void 0:k.error))&&a.jsx("div",{className:"text-error",children:j??(k==null?void 0:k.error)}),!R&&M&&a.jsx(Mi,{href:M,children:"查看上线进度"}),N]})})}e.config&&eOe(d,e.config.phase);const b=d.some(S=>S.status==="failed"||S.status==="running"||S.status==="waiting")?void 0:d.find(S=>S.status==="pending");return b&&(b.next=!0),d}function tOe(e,t,n){if(!e)return{kind:"missing"};const r=e.indexOf(":");if(r===-1)return{kind:"raw",text:e};const s=e.slice(0,r),i=e.slice(r+1);if(!i)return{kind:"raw",text:e};switch(s){case"npm":return{kind:"known",text:`npm i -g ${i}${t?`@${t}`:""}`};case"apt":return{kind:"known",text:`apt-get install -y ${i}`};case"pip":return{kind:"known",text:`pip install ${i}${t?`==${t}`:""}`};case"github":return n?{kind:"known",text:`从 GitHub release 拉二进制 · ${n.url.split("?")[0].split("/").pop()||n.url}`}:{kind:"known",text:`从 GitHub release 拉二进制 · ${i}${t?` v${t}`:""}`};default:return{kind:"raw",text:e}}}function nOe(e,t){if(e)return`= ${e}`;if(t)return`≥ ${t}`}function rOe(e){var r;if(!((r=e.from)!=null&&r.startsWith("apt:")))return;const t=e.localVersion?`(本机 ${e.localVersion})`:"",n=Kle.label;return e.name&&Q9.includes(e.name)?{tone:"info",text:`云上底座自带,不从 ${n} 装${t}`}:e.aptMissing?{tone:"error",text:`${n} 没有这个包,云上装不了${t}`}:e.aptVersion?e.version?e.localVersion&&e.localVersion!==e.version?{tone:"warn",text:`云上装 ${n} 的 ${e.version},本机 ${e.localVersion}`}:{tone:"info",text:`云上装 ${n} 的 ${e.version}`}:{tone:e.min?"error":"warn",text:`云上是 ${n} 的 ${e.aptVersion}${e.min?`,不满足要求 ≥ ${e.min}`:",没按它钉版本"}${t}`}:{tone:"warn",text:`没查到 ${n} 里的版本,云上装它自带的${t}`}}function sOe(e,t){if(!t)return{tone:"warn",text:"本机未探到"};if(e!==t)return{tone:"error",text:`本机 ${t} ≠ 云上 ${e??"—"}`}}function iOe(e){const t=tOe(e.from,e.version,e.artifact);return a.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[a.jsx("span",{className:"shrink-0 text-text-500",children:"装法:"}),t.kind==="missing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-warning",children:"没查到"}),a.jsx("span",{className:"text-text-500",children:"· 见存疑项"})]}):a.jsx("code",{className:"rounded-sm border border-border bg-bg-100 px-1.5 py-0.5 text-text-400",children:t.text})]})}function _X(e){const t=nOe(e.version,e.min),n=rOe(e)??sOe(e.version,e.localVersion),r=e.blockers??[];return a.jsxs("div",{className:"border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:e.name}),r.length>0&&a.jsx(kx,{}),t&&a.jsx("span",{className:"font-mono text-xs text-text-400",children:t}),n&&a.jsx("span",{className:`text-xs ${n.tone==="error"?"text-error":n.tone==="warn"?"text-warning":"text-text-400"}`,children:n.text})]}),r.map(s=>a.jsx("div",{className:"mt-1 text-xs text-error",children:s},s)),a.jsx(iOe,{from:e.from,version:e.version,artifact:e.artifact}),e.evidence&&a.jsx(TR,{evidence:e.evidence})]})}const hE={none:{label:"不用账号",hint:e=>`${e} 是公开服务,不用登录就能用`},shared:{label:"发布者的账号",hint:e=>`用户用发布者的账号使用 ${e}:发布者在这一页填好自己的 key,所有人共用这一份`},personal:{label:"用户自己的账号",hint:e=>`用户用自己的账号使用 ${e}:每个用户第一次用时自己关联一次`}},ky={oauth:{label:"OAuth",hint:e=>`用户点链接跳到 ${e} 的授权页登录,不用碰 key`},fields:{label:"粘贴 API key",hint:()=>"用户把自己的 API key 粘进表单"}},SX=e=>e.runner==="cli"?f5(e)?"CLI · Lark App Bot":e.protocol==="lark-sidecar"?"CLI · 飞书 sidecar":"CLI":e.kind==="proxy"?"http MCP":"stdio MCP",oOe=e=>e.kind==="env"||e.fields.length>0?"fields":"oauth",aOe=/^[A-Z][A-Z0-9_]*$/;function lOe(e){const t=e.connector,[n,r]=p.useState(""),[s,i]=p.useState(null),o=t.name==="feishu"&&t.runner==="cli",l=f5(t),c=o,u=s7(t),d=!t.credentialSource,h=t.credentialSource==="personal"&&!t.auth,f=u.length>0&&!d&&!h,m=t.credentialSource==="personal",g=!o&&(t.credentialSource==="shared"||t.credentialSource==="personal"&&t.auth==="fields"),x=v=>{const{publisherUnionId:w,..._}=t;e.onChange({..._,kind:v==="bot"?"env":"proxy",protocol:v==="bot"?void 0:"lark-sidecar",credentialSource:v==="user"?"personal":"shared",auth:v==="bot"?"fields":"oauth",fields:v==="bot"?[...r7]:[]})},b=v=>{e.onChange({...t,credentialSource:v,...v==="personal"&&!t.auth?{auth:oOe(t)}:{}})},y=()=>{const v=n.trim();if(!aOe.test(v)){i("变量名只能是大写字母、数字、下划线,且以字母开头");return}t.fields.includes(v)||e.onChange({...t,fields:[...t.fields,v]}),r(""),i(null)};return a.jsxs("div",{className:"border-b border-border-card px-5 py-4 last:border-b-0","data-testid":`connector-row-${t.name}`,"data-required":u.length>0||void 0,children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:t.name}),a.jsx("span",{className:"rounded-sm bg-text-100-dim px-1.5 py-px text-[11px] text-text-400",children:SX(t)}),a.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-text-500",title:t.id,children:t.id})]}),e.evidence&&a.jsx(TR,{evidence:e.evidence}),a.jsx(ui,{delayDuration:120,children:a.jsxs("div",{className:"mt-3 space-y-2",children:[o?a.jsx(Cm,{label:"用谁的账号",name:"feishu-source",value:l?"bot":t.credentialSource==="shared"?"publisher":"user",options:[{value:"publisher",label:"发布者账号",hint:"所有使用者共用发布者的飞书 OAuth 权限;发布者需先关联飞书账号"},{value:"user",label:"用户自己的账号",hint:"每个使用者关联自己的飞书账号,使用本人权限"},{value:"bot",label:"Lark App Bot",hint:"发布者填写 App ID 和 App Secret,所有使用者共用这个应用的机器人身份"}],onPick:x}):a.jsx(Cm,{label:"用谁的账号",required:d,name:`${t.name}-source`,value:t.credentialSource,options:t7.map(v=>({value:v,label:hE[v].label,hint:hE[v].hint(t.name)})),disabled:c,onPick:v=>b(v)}),m&&a.jsx(Cm,{label:"关联方式",required:h,name:`${t.name}-auth`,value:t.auth,options:d5.filter(v=>t.kind==="proxy"||v==="fields").map(v=>({value:v,label:ky[v].label,hint:t.kind==="env"?`${ky[v].hint(t.name)}。进程型(stdio MCP / CLI)没有登录页,只有这一种`:ky[v].hint(t.name)})),disabled:c,onPick:v=>e.onChange({...t,auth:v})}),g&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"要填的变量:"}),f&&a.jsx(kx,{}),t.fields.map(v=>a.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-xs text-text-200",children:[v,a.jsx("button",{type:"button","aria-label":`去掉 ${v}`,className:"text-text-400 hover:text-error",onClick:()=>e.onChange({...t,fields:t.fields.filter(w=>w!==v)}),children:a.jsx(Xt,{className:"size-3"})})]},v)),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(qn,{"aria-label":`${t.name} 新增一个变量`,className:"h-7 w-44 font-mono text-xs",placeholder:"变量名,如 GH_TOKEN",value:n,onChange:v=>r(v.target.value.toUpperCase()),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),y())}}),a.jsx("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:y,children:"添加"})]}),s&&a.jsx("span",{className:"w-full text-xs text-error",children:s}),t.fields.length===0&&a.jsx("span",{className:"w-full text-xs text-text-500",children:t.runner==="cli"?"这个工具从哪个环境变量读凭据,查清楚填这里":"扫描没在 .mcp.json 里找到 ${VAR} 占位;它要什么就填什么"})]})]})}),o&&!l&&t.credentialSource==="shared"&&a.jsxs("div",{className:"mt-3 space-y-2 text-xs text-text-300",children:[a.jsx("p",{children:"所有使用者将使用你的飞书权限。请先关联发布者账号:"}),["integration","production"].map(v=>{var S;const w=(S=e.publisherAuth)==null?void 0:S[v],_=v==="integration"?"测试环境":"线上环境";return a.jsx("div",{children:w!=null&&w.connected?a.jsxs("span",{children:[_,":已关联"]}):w!=null&&w.authUrl?a.jsxs("a",{className:"text-accent underline",href:w.authUrl,target:"_blank",rel:"noopener noreferrer",children:["关联",_,"飞书账号"]}):a.jsxs("span",{children:[_,":",(w==null?void 0:w.error)??"请刷新授权状态"]})},v)}),a.jsx("button",{type:"button",className:"text-accent underline",onClick:e.onRefreshPublisherAuth,children:"刷新授权状态"})]}),e.secretCard&&(!o||l)&&a.jsx("div",{className:"mt-3 rounded-md border border-border-card bg-bg-50",children:e.secretCard})]})}function Cm(e){return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"radiogroup","aria-label":e.label,children:[a.jsxs("span",{className:"w-20 shrink-0 text-xs text-text-400",children:[e.label,":"]}),e.required&&a.jsx(kx,{}),e.options.map(t=>{const n=t.value===e.value,r=a.jsx("button",{type:"button",role:"radio","aria-checked":n,disabled:e.disabled,"data-testid":`${e.name}-${t.value}`,onClick:()=>e.onPick(t.value),className:J("rounded-full border px-2.5 py-0.5 text-xs transition-colors",n?"border-accent bg-accent text-accent-contrast":"border-border text-text-300 hover:border-accent/50 hover:text-accent",e.disabled&&"cursor-default opacity-70 hover:border-border hover:text-text-300"),children:t.label});return a.jsxs(Xi,{children:[a.jsx(Zi,{asChild:!0,children:r}),a.jsx(pi,{side:"top",className:"max-w-[360px]",children:t.hint})]},t.value)})]})}const Xh=e=>new Date(e).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});function cOe(e){const t=e.manifest,n=[t.packages.length?`镜像 ${t.packages.length}`:null,t.connectors.length?`连接器 ${t.connectors.length}`:null,t.secrets.length?`凭据 ${t.secrets.length}`:null,e.notes.length?`存疑项 ${e.notes.length}`:null].filter(r=>r!==null);return n.length?n.join(" · "):e.status==="scanning"?"…":"什么都不需要"}function uOe(e){const t=e.scans.map((l,c)=>({s:l,n:c+1})).reverse(),[n,r]=p.useState(!1),s=(l,c)=>{var u;return c===e.scans.length||((u=e.released)==null?void 0:u.scanId)===l.id||l.status==="scanning"||l.id===e.selectedId},i=n?t:t.filter(({s:l,n:c})=>s(l,c)),o=t.length-i.length;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(L5,{className:"size-[18px]"}),title:"扫描历史",count:`${e.scans.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"scan-history",children:[i.map(({s:l,n:c})=>{var g;const u=l.id===e.selectedId,d=c===e.scans.length,h=e.online!==!1&&((g=e.released)==null?void 0:g.scanId)===l.id,f=Sce(l,e.released),m=(l.head??"").slice(0,7);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(l.id),"aria-current":u,"aria-label":`第 ${c} 次扫描`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${u?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",c]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:Xh(l.startedAt)}),e.repo&&f&&m?a.jsxs("a",{href:`https://github.com/${Rh(e.repo.url)}/commit/${l.head}`,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m,a.jsx(Fr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",title:"还没推到 GitHub,发布之后才会有",children:m||"—"}),a.jsx("span",{className:"shrink-0 rounded-full bg-text-100-dim px-1.5 py-0.5 text-[11px] text-text-400",children:l.baseKind==="soft"?"软扫":"硬扫"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-text-300",children:cOe(l)}),d&&a.jsx("span",{className:"shrink-0 rounded-full bg-accent-dim px-1.5 py-0.5 text-[11px] font-medium text-accent",children:"最新"}),h&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx(dOe,{s:l})]})},l.id)}),o>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>r(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Yt,{className:"size-3.5"}),"还有 ",o," 次扫描"]})})]})]})}function dOe({s:e}){return e.status==="scanning"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):e.status==="failed"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-error",children:[a.jsx(Xt,{className:"size-3"}),"失败"]}):a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-text-400",children:[a.jsx(Jt,{className:"size-3 text-success"}),o1(e.startedAt,e.finishedAt)??"完成"]})}const jp={tiny:{label:"微",mem:"256 MB",hint:"纯对话、查资料"},small:{label:"小",mem:"512 MB",hint:"调 MCP、读写文件"},medium:{label:"中",mem:"1 GB",hint:"跑脚本、python / jq 这类"},large:{label:"大",mem:"2 GB",hint:"装依赖、构建、开浏览器"},xlarge:{label:"超大",mem:"4 GB",hint:"较大构建、内存密集任务"}},hOe=e=>e!==void 0&&m5.includes(e);function fOe(e){const t=p.useId(),n=e.taskConcurrency,r=e.size===void 0||e.size==="",s=r?wb:e.size,i=hOe(s),o=e.cpu===void 0,l=o?i?$N[s]:void 0:e.cpu,c=l!==void 0&&_b.includes(l),u=!!e.disabled||!!e.saving;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"resource-estimate",children:[a.jsx(Qr,{icon:a.jsx(D5,{className:"size-[18px]"}),title:"资源预估"}),a.jsxs("div",{className:"px-5 py-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"内存:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的内存预留与上限"}),r&&a.jsx("span",{children:"(没选过,按默认)"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-2 gap-2 sm:grid-cols-5",role:"radiogroup","aria-label":"内存",children:m5.map(d=>{const h=d===s;return a.jsxs("button",{type:"button",role:"radio","aria-checked":h,"aria-label":`${jp[d].label} · ${jp[d].mem}`,disabled:u||!e.onChange,onClick:()=>{var f;h||(f=e.onChange)==null||f.call(e,d)},className:J("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[a.jsx("span",{className:J("text-base font-semibold",h?"text-accent":"text-text-100"),children:jp[d].label}),a.jsx("span",{className:"font-mono text-xs text-text-300",children:jp[d].mem}),d===wb&&a.jsx("span",{className:"ml-auto text-[11px] text-text-400",children:"默认"})]}),a.jsx("div",{className:"mt-0.5 text-xs text-text-400",children:jp[d].hint})]},d)})}),!i&&a.jsxs("div",{className:"mt-2 text-xs text-warning",children:["persona.json 里写的是 ",a.jsx("code",{className:"font-mono",children:s}),",不是支持的内存档,发布会被拒;点一档换掉"]}),a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"CPU:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的 CPU 预留与上限"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-3 gap-2",role:"radiogroup","aria-label":"CPU",children:_b.map(d=>{const h=d===l;return a.jsxs("button",{type:"button",role:"radio","aria-label":`${d} 核`,"aria-checked":h,disabled:u||!e.onChangeCpu,onClick:()=>{var f;(o||!h)&&((f=e.onChangeCpu)==null||f.call(e,d))},className:J("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsx("span",{className:J("text-base font-semibold",h?"text-accent":"text-text-100"),children:d}),a.jsx("span",{className:"ml-1.5 text-xs text-text-300",children:"核"})]},d)})}),o&&c&&a.jsxs("div",{className:"mt-2 text-xs text-text-400",children:["未单独配置,暂按内存档位取 ",l," 核;点选任意 CPU 档位后独立保存(也可点当前档位)。"]}),!c&&a.jsx("div",{className:"mt-2 text-xs text-warning",children:o?"内存档位未知,无法确定默认 CPU;请选择 CPU 和内存后发布。":`CPU 配置 ${String(e.cpu)} 不在支持范围内,发布会被拒;请选择一档修复。`}),a.jsx("div",{role:"status",className:"mt-2 text-xs text-text-400",children:e.saving?"正在保存资源设置…":"资源设置保存后,下次发布生效;运行中的 Pod 不变。预留不是独占物理核心。"}),e.error&&a.jsx("div",{role:"alert",className:"mt-2 text-xs text-error",children:e.error})]}),n&&a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsx("label",{htmlFor:t,className:"text-sm font-medium text-text-100",children:"单 Pod 任务并发数"}),a.jsxs("div",{id:`${t}-hint`,className:"mt-1 text-xs leading-relaxed text-text-400",children:["每个 task Pod 最多同时运行的任务数,仅影响 task 调用。默认 4,保存后下次发布生效。",n.defaulted&&a.jsx("span",{children:"(未配置,按默认)"})]}),a.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[a.jsx(qn,{id:t,inputMode:"numeric",className:"w-28",value:n.value,disabled:n.disabled||n.saving,"aria-describedby":`${t}-hint${n.error?` ${t}-error`:""}`,"aria-invalid":!!n.error,onChange:d=>n.onChange(d.target.value)}),a.jsx(Le,{size:"sm","aria-label":"保存并发数",disabled:n.disabled||n.saving||!n.dirty||!n.valid,onClick:n.onSave,children:n.saving?"保存中…":"保存"})]}),n.error&&a.jsx("div",{id:`${t}-error`,role:"alert",className:"mt-2 text-xs text-error",children:n.error}),!n.error&&a.jsx("div",{role:"status",className:"mt-2 text-xs text-text-400",children:n.saving?"正在保存任务并发数…":n.dirty?"有未保存的修改,请先保存再发布":n.saved?"已保存,下次发布生效":"修改后保存,再发布到云上"})]})]})]})}function Cx(e,t,n){const r=e?t.find(i=>i.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const s=n.find(i=>i.name==="effort");return{options:(s==null?void 0:s.options)??[],defaultValue:typeof(s==null?void 0:s.default)=="string"?s.default:""}}function kX(e,t){var r;const n=t.options.some(s=>s.value===e)?e:t.defaultValue;return{value:n,label:((r=t.options.find(s=>s.value===n))==null?void 0:r.label)??"默认"}}function h_(e,t,n){var c;if(!t)return((c=(e??[]).find(u=>u.id===""))==null?void 0:c.label)??"未指定";const r=t.toLowerCase(),s=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[u,d]of s){if(!r.includes(u))continue;const h=r.match(new RegExp(`${u}-(\\d+)(?:-(\\d+))?`));return h?h[2]?`${d} ${h[1]}.${h[2]}`:`${d} ${h[1]}`:d}const i=e??[],o=i.find(u=>u.id===t);if(o)return o.label;const l=i.find(u=>u.id&&t.toLowerCase().includes(u.id.toLowerCase()));return l?l.label:t}function $R(e){let t;return e.map(n=>{const r=n.group&&n.group!==t?n.group:null;return n.group&&(t=n.group),{...n,groupHeading:r}})}function CX({testid:e,label:t,current:n,items:r,onSelect:s,needsAttention:i=!1,disabled:o=!1,align:l="end"}){return a.jsxs(ls,{children:[a.jsx(cs,{asChild:!0,children:a.jsx(f_,{testid:e,label:t,needsAttention:i,disabled:o})}),a.jsx(Ur,{align:l,className:"max-h-[420px] overflow-y-auto",children:$R(r).map((c,u)=>a.jsxs(G.Fragment,{children:[c.groupHeading?a.jsxs(a.Fragment,{children:[u>0?a.jsx(ha,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:c.groupHeading})]}):null,a.jsxs(Tt,{onSelect:()=>s(c.value),children:[a.jsx(Jt,{className:J("mr-2 h-3.5 w-3.5",n===c.value?"opacity-100":"opacity-0")}),a.jsx("span",{className:"flex-1",children:c.label}),c.description?a.jsx("span",{className:"ml-3 text-[11px] text-text-400",children:c.description}):null]})]},c.value||"default"))})]})}const f_=G.forwardRef(function({testid:t,label:n,needsAttention:r=!1,disabled:s=!1,...i},o){return a.jsxs("button",{ref:o,type:"button",disabled:s,"data-testid":t,"data-needs-attention":r?"":void 0,className:J("flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-50",r?"border-warning/30 bg-warning-dim text-warning hover:bg-warning/20":"border-border bg-bg-50 text-text-200 hover:bg-text-100/5 hover:text-text-100"),...i,children:[n,a.jsx(Yt,{className:J("h-3 w-3",r?"text-warning":"text-text-400")})]})});function pOe(e){return e.map(t=>({value:t.id,label:t.label,...t.description?{description:t.description}:{},...t.group?{group:t.group}:{}}))}function NX({testid:e,list:t,options:n,current:r,onSelect:s}){if(t.loading)return a.jsx(Tt,{disabled:!0,"data-testid":`${e}-loading`,className:"text-[12px] text-text-400",children:"正在读取最新模型…"});if(t.error)return a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":`${e}-error`,className:"px-2 py-1.5 text-[11px] text-warning",children:t.error}),a.jsx(Tt,{"data-testid":`${e}-retry`,className:"text-[12px]",onSelect:o=>{o.preventDefault(),t.load()},children:"重试"})]});const i=n??pOe(t.models);return i.length===0?a.jsx(Tt,{disabled:!0,"data-testid":`${e}-empty`,className:"text-[12px] text-text-400",children:"没有可选模型"}):a.jsx(a.Fragment,{children:$R(i).map((o,l)=>{const c=o.value===r;return a.jsxs(G.Fragment,{children:[o.groupHeading?a.jsxs(a.Fragment,{children:[l>0?a.jsx(ha,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:o.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${o.value||"default"}`,onSelect:()=>s(o.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:J("block text-[12px]",c?"font-medium text-text-100":"text-text-300"),children:o.label}),o.description?a.jsx("span",{className:"mt-0.5 block text-[11px] text-text-400",children:o.description}):null]}),c?a.jsx(Jt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent"}):null]})]},o.value||"default")})})}function p_({testid:e,list:t,options:n,current:r,onSelect:s,trigger:i,align:o="start",side:l,contentClassName:c}){const[u,d]=p.useState(!1),h=f=>{f&&!u&&t.load(),d(f)};return a.jsxs(ls,{open:u,onOpenChange:h,children:[a.jsx(cs,{asChild:!0,children:typeof i=="function"?i(()=>h(!0)):i}),a.jsx(Ur,{align:o,...l?{side:l}:{},className:J("max-h-[420px] w-[260px] overflow-y-auto",c),"data-testid":`${e}-menu`,children:a.jsx(NX,{testid:e,list:t,...n?{options:n}:{},current:r,onSelect:s})})]})}const mOe={codex:"Codex",pi:"pi",claude:"Claude"},gOe={codex:"Codex",pi:"pi",claude:"Claude Agent SDK"},Jd="[1m]",xOe=e=>e.endsWith(Jd)?e.slice(0,-Jd.length):e;function vOe(e){const[t,n]=p.useState(!1),r=ol(e.tool),s=e.tool||"claude",i=s==="claude",o=i?xOe(e.model):e.model,l=i&&e.model.endsWith(Jd),c=e.modelList.models,u=c.filter(g=>g.id!=="").map(g=>({value:g.id,label:g.label,...g.description?{description:g.description}:{},...g.group?{group:g.group}:{}})),d=!e.model,h=Cx(o,c,e.configSchema),{value:f,label:m}=kX(e.effort,h);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"deploy-engine-card",children:[a.jsx(Qr,{icon:a.jsx(O5,{className:"size-[18px]"}),title:"引擎与模型"}),a.jsx(ui,{delayDuration:120,children:a.jsxs("div",{className:"space-y-2.5 px-5 py-4",children:[a.jsx("div",{className:"text-xs text-text-400",children:i?"只影响云上:本机 Claude 的模型不变":"本地 persona 也会改变"}),a.jsx(Cm,{label:"引擎",required:!r,name:"deploy-engine",value:r?s:void 0,options:w7.map(g=>({value:g,label:mOe[g],hint:`云上跑 ${gOe[g]} ${_7[g]}`})),onPick:g=>{g!==s&&e.onChange({tool:g})}}),!r&&a.jsxs("div",{className:"pl-[88px] text-xs text-warning",children:["现在是 ",s,",云上只跑 Codex、pi 或 Claude,选一个"]}),r&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"模型:"}),d&&a.jsx(kx,{}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[a.jsx(p_,{testid:"deploy-engine-model",list:e.modelList,options:u,current:o,onSelect:g=>{g!==o&&e.onChange({model:l?`${g}${Jd}`:g})},trigger:a.jsx(f_,{testid:"deploy-engine-model",label:d?"选一个模型":h_(c,o),needsAttention:d,disabled:e.allowManualModel})}),e.allowManualModel&&a.jsx("div",{className:"text-xs text-warning",children:"请先在上方选择并保存模型订阅,再从下拉框选择模型"}),e.allowManualModel&&a.jsxs("div",{className:"space-y-1",children:[a.jsx(Le,{size:"sm",variant:"ghost","aria-expanded":t,onClick:()=>n(g=>!g),children:"高级:指定模型 ID"}),t&&a.jsx(qn,{defaultValue:o,"aria-label":"云端模型 ID",placeholder:"模型 ID(高级)",onBlur:g=>{const x=g.target.value.trim();x&&x!==o&&e.onChange({model:l?x+Jd:x})},onKeyDown:g=>{g.key==="Enter"&&g.currentTarget.blur()}},o)]})]})]}),r&&i&&!d&&a.jsx(Cm,{label:"上下文",name:"deploy-engine-context",value:l?"1m":"default",options:[{value:"default",label:"默认",hint:"Claude 模型用它自己的窗口;号池里别的模型 Claude Code 不知道窗口多大,按 200K 用"},{value:"1m",label:"1M",hint:"模型 id 带 [1m]:Claude Code 按 1M 窗口用(模型本身和号池都要支持 1M,号池不报这个,要你自己确认)"}],onPick:g=>{g==="1m"!==l&&e.onChange({model:g==="1m"?`${o}${Jd}`:o})}}),r&&!d&&h.options.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"推理强度:"}),a.jsx(CX,{align:"start",testid:"deploy-engine-effort",label:m,current:f,items:h.options.map(g=>({value:g.value,label:g.label})),onSelect:g=>{g!==f&&e.onChange({effort:g})}})]})]})})]})}function jX(e){const[t,n]=p.useState(""),[r,s]=p.useState(!1),[i,o]=p.useState(!1),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[h,f]=p.useState(null),{status:m}=e;if(!m)return null;const g=async()=>{if(!(!e.onAuthorize||t.trim().length===0)){c(!0),f(null);try{await e.onAuthorize(t.trim()),n(""),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{c(!1)}}},x=async()=>{if(e.onStartOauth){d(!0),f(null);try{const v=await e.onStartOauth();v&&window.open(v,"_blank","noopener"),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{d(!1)}}},b=e.onAuthorize&&a.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:v=>{v.preventDefault(),g()},children:[a.jsx(qn,{type:"password",autoComplete:"off",placeholder:"ghp_… 或 github_pat_…","aria-label":"GitHub token",value:t,onChange:v=>n(v.target.value),className:"min-w-0 flex-1 font-mono text-xs",disabled:l||e.busy}),a.jsx(Le,{type:"submit",size:"sm",variant:"outline",disabled:l||e.busy||t.trim().length===0,children:l?"正在核对…":"用这个 token"}),a.jsxs("div",{className:"w-full text-xs text-text-400",children:["去 GitHub 建一个 classic personal access token,勾 ",a.jsx("code",{className:"font-mono",children:"repo"})," 和"," ",a.jsx("code",{className:"font-mono",children:"workflow"}),",账号要在 ",N7," 组织里。"]})]});if(m.status==="authorized"&&!r)return a.jsxs("div",{"data-testid":"github-account-card",className:"flex items-center gap-2 rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx(Jt,{className:"size-3.5 shrink-0 text-success"}),a.jsxs("span",{children:["GitHub 已关联 ",a.jsxs("span",{className:"font-mono text-text-100",children:["@",m.login]}),a.jsxs("span",{className:"text-text-400",children:[" · ",m.source==="git"?"来自本机 git 的凭据":"来自本机凭据表"]})]}),(e.onStartOauth||e.onAuthorize)&&a.jsx("button",{type:"button",onClick:()=>s(!0),className:"ml-auto cursor-pointer whitespace-nowrap text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"换一个"})]});if(m.status==="pending")return a.jsxs("div",{"data-testid":"github-account-card",className:"rounded-lg border border-border bg-surface-card",children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:a.jsx(st,{className:"size-4 animate-spin"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"等你在 GitHub 那页点「Authorize」"})]}),a.jsxs("div",{className:"space-y-2 px-4 py-3 text-[13px] leading-snug text-text-200",children:[a.jsx("div",{children:"已经在新标签页打开了 GitHub 的授权页。点同意之后会自动回到这里,这张卡会自己变绿。"}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs("a",{href:m.authUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent underline underline-offset-4",children:[a.jsx(Fr,{className:"size-3"}),"没打开的话点这里"]}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),i&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h})]})]});const y=m.status==="invalid";return a.jsxs("div",{"data-testid":"github-account-card",className:`rounded-lg border bg-surface-card ${y?"border-error/40":m.status==="missing"?"border-warning/50":"border-border"}`,children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:y?a.jsx(lg,{className:"size-4 text-error"}):a.jsx(og,{className:"size-4"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:y?"GitHub 授权失效":m.status==="missing"?"先关联 GitHub":"换一个 GitHub 账号"})]}),a.jsxs("div",{className:"space-y-3 px-4 py-3",children:[y?a.jsx("div",{className:"text-[13px] leading-snug text-text-200",children:m.message}):a.jsxs("div",{className:"text-[13px] leading-snug text-text-200",children:["关联一次,app-builder 建仓推代码、persona 上云、PR 收件箱、persona 里的 git push 都用它。",m.status==="missing"&&" 本机 git 里没有 github.com 的凭据。","存在本机 git 里,clawd 不另存。"]}),e.onStartOauth&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(Le,{type:"button",size:"sm",onClick:()=>void x(),disabled:u||e.busy,children:u?"正在打开 GitHub…":"关联 GitHub"}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),(i||!e.onStartOauth)&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h}),r&&!l&&!u&&a.jsx("button",{type:"button",onClick:()=>{s(!1),o(!1)},className:"cursor-pointer text-xs text-text-400 hover:text-accent",children:"算了,还用原来的"})]})]})}function tL(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-accent hover:underline",children:[e.children,a.jsx(Fr,{className:"size-3"})]})}function yOe(e){const[t,n]=p.useState(!1),{status:r}=e,s=()=>{var o;n(!1),(o=e.onUnpublish)==null||o.call(e)},i=(()=>{switch(r.kind){case"online":return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full bg-success"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"在线上"}),a.jsx("span",{className:"text-text-400",children:" · 别人能看到、能用"})]}),e.onUnpublish&&a.jsx(Le,{size:"sm",variant:"outline",className:"ml-auto h-7",disabled:e.busy,onClick:()=>n(!0),children:"下线"})]});case"unpublishing":return a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"size-3.5 shrink-0 animate-spin text-text-300"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"正在下线…"}),r.runUrl&&a.jsx("span",{className:"ml-auto",children:a.jsx(tL,{href:r.runUrl,children:"查看流水线"})})]});case"failed":return a.jsxs(a.Fragment,{children:[a.jsx(yn,{className:"size-3.5 shrink-0 text-error"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"下线没成功"}),a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-3",children:[r.runUrl&&a.jsx(tL,{href:r.runUrl,children:"看日志"}),e.onUnpublish&&a.jsx(Le,{size:"sm",variant:"outline",className:"h-7",disabled:e.busy,onClick:()=>n(!0),children:"重试"})]})]});case"offline":return a.jsxs(a.Fragment,{children:[a.jsx(Qde,{className:"size-3.5 shrink-0 text-text-400"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"已下线"}),a.jsx("span",{className:"text-text-400",children:" · 别人看不到、用不了。重新扫描、发布就能再上线"})]})]});case"unknown":return a.jsxs(a.Fragment,{children:[a.jsx(sH,{className:"size-3.5 shrink-0 text-text-400"}),a.jsx("span",{className:"min-w-0 truncate text-text-400",children:"查不到现在在不在线上"})]})}})();return a.jsxs("div",{"data-testid":"deploy-live-card",className:"rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx("div",{className:"flex min-h-7 items-center gap-2",children:i}),e.error&&a.jsx("div",{className:"mt-1 text-error",children:e.error}),a.jsx(bs,{open:t,onOpenChange:n,children:a.jsxs(ss,{children:[a.jsxs(zs,{children:[a.jsx(is,{children:"下线这个 persona?"}),a.jsx(Ui,{children:"下线后别人看不到、也用不了它。正在进行的对话会继续到结束,聊天记录不会丢。以后重新扫描、发布就能再上线。"})]}),a.jsxs(el,{children:[a.jsx(Le,{variant:"outline",onClick:()=>n(!1),children:"取消"}),a.jsx(Le,{variant:"destructive",onClick:s,children:"确认下线"})]})]})})]})}function EX({test:e}){return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(Jt,{className:"size-[18px]"}),title:"发布者验收",count:`${e.checks.length} 项必验`}),a.jsxs("div",{className:"space-y-2 px-5 py-4 text-[13px] text-text-300",children:[a.jsx("div",{className:"font-mono",children:e.entry}),a.jsx("div",{children:e.checks.join(" / ")}),a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境候选镜像中执行 · 最长 ",e.timeoutSeconds," 秒 · 全部通过才可上线"]})]})]})}function bOe(e){var hn,En,Mt,lr,In,Dt,Bt,mn,Tn,Rr,Ji,xr,vr,us,qs,vi;const t=e.state.targets?{...e.state,run:(hn=e.state.targets.integration)==null?void 0:hn.run,secrets:(En=e.state.targets.integration)==null?void 0:En.secrets}:e.state,{repo:n}=t,r=t.releases.find(ve=>{var ae;return ve.head===((ae=t.repo)==null?void 0:ae.head)})??ba(t.releases),s=hX(t,e.roundIdx??Sy(t)),i=e.starting?[]:s.scans,o=e.starting?void 0:s.release,l=((Mt=e.retry)==null?void 0:Mt.headSha)===(o==null?void 0:o.head)?e.retry:void 0,c=!!e.promoting&&!!o&&km(n1(i,o),o),u=e.busy||c||!!l&&l.phase!=="failed",d=kc(i),h=n1(i,o),f=!!e.starting,m=!!e.releasing,g=!!e.awaitingRun&&!!o,x=(d==null?void 0:d.status)==="scanning",b=t.run!==void 0&&t.run.status!=="completed",y=km(h,o),v=!t.github||t.github.status==="authorized",w=!e.engine||ol(e.engine.tool),[_,S]=p.useState(null),[k,N]=p.useState(!1),[j,R]=p.useState(null),[E,I]=p.useState(!1),M=p.useRef(!1),P=_??String(e.taskConcurrency??4),D=Number(P.trim()),F=/^\d+$/.test(P.trim())&&Number.isInteger(D)&&D>0,B=_!==null&&(!F||D!==(e.taskConcurrency??4)),U=e.onSaveTaskConcurrency?k?"正在保存任务并发数,请等待保存完成":B?"先在「资源预估」中保存任务并发数":void 0:void 0,$=e.resourceSaving?"正在保存资源设置,请等待保存完成":e.cpu!==void 0&&!_b.includes(e.cpu)?"先在「资源预估」中修复 CPU 配置":void 0,O=async()=>{if(!(!e.onSaveTaskConcurrency||M.current||!B||!F||m||g||e.resourceSaving)){M.current=!0,N(!0),R(null),I(!1);try{await e.onSaveTaskConcurrency(D),S(null),I(!0)}catch(ve){R(ve instanceof Error?ve.message:String(ve))}finally{M.current=!1,N(!1)}}},T=mX({current:e.currentConfig,release:o,run:t.run,anchored:y}),V=pX(e.engine)[0],H=$??U??V,[L,q]=p.useState(!1),[K,X]=p.useState(null),te=p.useRef(!1),oe=async()=>{if(!(!e.onApplyConfig||!(o!=null&&o.id)||te.current)){te.current=!0,q(!0),X(null);try{await e.onApplyConfig(o.id)}catch(ve){X(ve instanceof Error?ve.message:String(ve))}finally{te.current=!1,q(!1)}}},[Q,he]=p.useState(null),be=ve=>he({latestId:d==null?void 0:d.id,id:ve}),Z=(Q&&Q.latestId===(d==null?void 0:d.id)?t.scans.find(ve=>ve.id===Q.id):void 0)??h,ce=Z?t.scans.indexOf(Z)+1:0,se=Z$(t,h),fe=Z$(t,Z),xe=XP(Z,n,r),Me=b7(Z,n,r),Xe=km(Z,o),[me,Ce]=p.useState(null),je=me?t.scans.find(ve=>ve.id===me):void 0,Se=`${(d==null?void 0:d.id)??""}-${(o==null?void 0:o.head)??""}`,[ut,ot]=p.useState(null),[yt,re]=p.useState(x),ue=v&&w&&!f&&!x&&!m&&!u&&!!e.onScan,Te=v?w?f?n?"正在落存、起管家会话…":"正在建仓库…":x?"管家在读 persona…":n?(d==null?void 0:d.status)==="done"&&!XP(d,n,r)?a.jsx("span",{className:"text-warning",children:"有未提交的改动,清单是改动前扫的"}):d?"再扫一遍会新增一条记录;发布默认用最新那次":"让管家读一遍 persona,列出它需要什么":`会先在 ${N7} 建一个私有仓库、把 persona 提交进去,再让管家读一遍它需要什么`:"云上只跑 Codex、pi 或 Claude,在「引擎与模型」里选一个":"先在上面那张卡里关联 GitHub",Ze=!!Z&&Z.status==="done"&&xe&&fe.length===0&&!x&&!f,at=Ze,et=f||x?"等扫描结束":Z?Z.status==="failed"?"扫描失败了,重新扫描":xe?fe.length>0?`还差 ${fe.length} 项,按下面标「必填」的那几行处理`:void 0:"有未提交的改动,先重新扫描":"先扫描",tt=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"inline-flex",children:[a.jsxs(Le,{size:"sm",className:"rounded-r-none",onClick:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e)},disabled:!ue,children:[f||x?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(zfe,{className:"size-4"}),d?"重新扫描":"开始扫描"]}),a.jsxs(ls,{children:[a.jsx(cs,{asChild:!0,disabled:!ue,children:a.jsx(Le,{size:"sm","aria-label":"选扫描方式",className:"rounded-l-none border-l border-accent-contrast/30 px-2",children:a.jsx(Yt,{className:"size-4"})})}),a.jsxs(Ur,{align:"start",children:[a.jsx(Tt,{onSelect:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e,"soft")},children:a.jsxs("div",{children:[a.jsx("div",{children:"软扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"只重看跟线上正跑那版有差别的部分;不成立会自动改硬扫"})]})}),a.jsx(Tt,{onSelect:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e,"hard")},children:a.jsxs("div",{children:[a.jsx("div",{children:"硬扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"从零把 persona 整个读一遍"})]})})]})]})]}),a.jsxs(Le,{size:"sm",className:"shrink-0",disabled:!Ze,onClick:()=>ot({attempt:Se,key:"config"}),title:Ze?"扫描这一段过了,去配置引擎、模型和资源":et,children:["下一步:配置 ",a.jsx(sO,{className:"size-4"})]})]}),a.jsx("div",{className:"text-xs text-text-400",children:Te}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]}),Lt=i.filter(ve=>ve.status==="done"),wt=g?"刚推上去,等流水线跑起来":b?"上一次还在跑,等它走完":void 0,we=!!Z&&Z.status==="done"&&xe&&fe.length===0&&!wt&&!m&&!f&&!u&&!!e.onRelease&&!H&&!(Me&&x),He=H??(m?"正在提交并推送…":Lt.length===0&&(Z==null?void 0:Z.status)!=="done"?"先扫描":!Z||Z.status!=="done"?"这次扫描没扫完,换一次":Me&&x?"有一次扫描正在跑,等它扫完再回到旧版本":xe?fe.length>0?`还差 ${fe.length} 项必填,回「扫描」段标「必填」的位置填`:wt||(Xe?"这一版已推到测试分支,继续查看测试结果":Me?"会先把本机 persona 回到这次扫描时的内容,再推到测试分支,构建、自动试跑,再发到测试环境":"把这次扫描推到测试分支,构建、自动试跑,再发到测试环境"):"有未提交的改动,这次扫描之后内容变过;重新扫描,或在上面的扫描历史里换一次"),ct=Cce((lr=e.engine)==null?void 0:lr.tool,e.localEngineVersion),Ot=a.jsxs("div",{className:"space-y-3",children:[e.integrationLogin,ct&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-[13px] text-warning",role:"status",children:[a.jsx(yn,{className:"mt-0.5 size-4 shrink-0"}),a.jsxs("div",{children:["本机 ",ct.tool," ",ct.local,",云上底座清单指定 ",ct.tool," ",ct.cloud,"。已发布 persona 的实际版本以其镜像为准;本机验过的行为不保证云上一样。"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-text-400",children:"发布的扫描:"}),Z&&Z.status==="done"?a.jsx(wOe,{s:Z,n:ce,latest:Z===d}):a.jsx("span",{className:"text-text-400",children:"—"}),a.jsx("span",{className:"text-xs text-text-400",children:"想发别的版本,在「扫描」段的扫描历史里点那一次"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs(Le,{size:"sm",onClick:()=>{var ve;!Z||!we||M.current||(Me?Ce(Z.id):(ve=e.onRelease)==null||ve.call(e,Z.id))},disabled:!we,children:[m?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(iy,{className:"size-4"}),Xe?"查看测试发布":Me?"回到这个版本并发测试环境":"发测试环境"]}),a.jsx("span",{className:"text-xs text-text-400",children:He}),e.releaseError&&a.jsx("div",{className:"w-full text-xs text-error",children:e.releaseError})]}),a.jsx(bs,{open:!!je,onOpenChange:ve=>{ve||Ce(null)},children:a.jsxs(ss,{children:[a.jsxs(zs,{children:[a.jsxs(is,{children:["回到第 ",je?t.scans.indexOf(je)+1:0," 次扫描的版本?"]}),a.jsxs(Ui,{children:["本机 persona 的文件会回到这次扫描时的样子(",((je==null?void 0:je.head)??"").slice(0,7),"),作为一个新提交,再推到测试分支。 没提交的改动会先自动保存;现在这一版仍留在 git 历史里(推送失败时这个回退提交会留在本机,重试即可)。引擎、模型和凭据用现在的设置,不跟着回去。"]})]}),a.jsxs(el,{children:[a.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>Ce(null),children:"取消"}),a.jsx(Le,{size:"sm",onClick:()=>{var ae;const ve=me;Ce(null),ve&&((ae=e.onRelease)==null||ae.call(e,ve))},children:"回到这个版本并发布"})]})]})}),y&&o&&n&&a.jsxs("div",{className:"text-xs text-text-400",children:["这一轮发的:第 ",t.scans.findIndex(ve=>ve.id===o.scanId)+1," 次扫描的清单 ·"," ",a.jsxs("a",{href:`https://github.com/${Rh(n.url)}/commit/${o.head}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 font-mono text-accent hover:underline",children:[o.head.slice(0,7),a.jsx(Fr,{className:"size-3"})]})]})]}),on=L||T.kind==="applying",Ne=(T.kind==="pending"||T.kind==="failed")&&!!e.onApplyConfig&&!H&&!on&&!u&&!b&&!g&&!m&&!f,ne=(at||y)&&!H&&!f&&!m,De=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[T.kind==="pending"||T.kind==="failed"||T.kind==="applying"?a.jsxs(Le,{size:"sm",onClick:()=>void oe(),disabled:!Ne,children:[on?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(iy,{className:"size-4"}),T.kind==="applying"||L?"应用中":T.kind==="failed"?"重新应用":"应用到测试环境"]}):T.kind==="needsRepublish"?a.jsx(Le,{size:"sm",onClick:()=>ot({attempt:Se,key:"scan"}),children:"去重新扫描"}):a.jsxs(Le,{size:"sm",disabled:!ne,onClick:()=>ot({attempt:Se,key:"push"}),title:ne?void 0:H,children:["下一步:发测试环境 ",a.jsx(sO,{className:"size-4"})]}),H&&a.jsx("span",{className:"text-xs text-text-400",children:H})]}),K&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:K})]}),Je=wX({personaId:t.personaId,flow:{ready:!!(o!=null&&o.verified)&&Ru(o,t.run)&&sc(t.run)&&((Dt=(In=t.targets)==null?void 0:In.integration)==null?void 0:Dt.image)===o.verified.image,confirmed:Ru(o,t.run)&&sc(t.run)&&!!((Bt=o==null?void 0:o.verified)!=null&&Bt.verification.checks.includes("persona-dialogue"))&&((mn=t.run)==null?void 0:mn.jobs.some(ve=>ve.key===mo&&ve.status==="done"))===!0&&o.runId===t.run.runId&&o.runAttempt===t.run.runAttempt&&((Rr=(Tn=t.targets)==null?void 0:Tn.integration)==null?void 0:Rr.image)===((Ji=o.verified)==null?void 0:Ji.image),promotion:[...t.promotions??[]].reverse().find(ve=>ve.releaseId===(o==null?void 0:o.id)),testActions:e.testActions,productionActions:e.productionActions,promoting:c,submissionError:o&&!e.starting?e.productionError:void 0},...n?{repo:n}:{},scans:i,...o?{released:o}:{},...r?{lastRelease:r}:{},...t.run?{run:t.run}:{},blockers:se,starting:f,releasing:m,awaitingRun:g,...l?{retry:l}:{},...e.onRefreshRetry?{onRefreshRetry:e.onRefreshRetry}:{},...e.cloud?{cloud:e.cloud}:{},config:{phase:T,...e.currentConfig?{current:e.currentConfig}:{},...o!=null&&o.config?{tested:o.config}:{},...H?{blocker:H}:{},actions:De},scanActions:tt,releaseActions:Ot,...e.onRetryJob?{onRetry:e.onRetryJob}:{},...e.onScan&&!u?{onRescan:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e)}}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},offline:t.online===!1&&sc(t.run)}),dt=p.useRef({attempt:Se,key:r1(Je)??"scan"});dt.current.attempt!==Se&&(dt.current={attempt:Se,key:r1(Je)??"scan"});const Nt=FPe(Je);Nt&&(dt.current.key=Nt);const St=ut&&ut.attempt===Se?ut.key:dt.current.key,dn=kb(t.secrets),Dn=(vr=(xr=t.secrets)==null?void 0:xr.find(ve=>ve.env===LN.apiKey))==null?void 0:vr.setAt,Jn=ve=>Z==null?void 0:Z.evidence.find(ae=>ae.target===ve),ht=Z==null?void 0:Z.manifest,Ht=(()=>{if(!ht)return[];const ve=new Set(aw(ht).flatMap(ae=>ae.env));return ht.secrets.map(ae=>({...ae,env:ae.env.filter(Ue=>!ve.has(Ue))})).filter(ae=>ae.env.length>0)})();return a.jsxs("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:[a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(uw,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布到云上"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(_Oe,{state:t,starting:f,scanBase:SOe(d)})]})]}),a.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.workPanel&&a.jsxs("button",{onClick:()=>re(ve=>!ve),"aria-expanded":yt,className:"group inline-flex cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-accent/50 bg-accent-dim px-2.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent hover:text-accent-contrast",children:[x?a.jsx(st,{className:"size-3 animate-spin"}):a.jsx(Jt,{className:"size-3"}),a.jsx("span",{children:x?"管家分析中":"管家的分析过程"}),a.jsx(Yt,{className:`size-3 transition-transform ${yt?"-rotate-90":"rotate-90"}`})]})})]})}),a.jsx(jX,{status:t.github,onAuthorize:e.onAuthorizeGithub,onStartOauth:e.onStartGithubOauth,busy:u}),e.live&&a.jsx(yOe,{status:e.live.status,busy:u,...e.live.error?{error:e.live.error}:{},...e.live.onUnpublish?{onUnpublish:e.live.onUnpublish}:{}}),a.jsxs(Sd,{className:"border-accent/40",children:[a.jsx(Qr,{icon:a.jsx(iy,{className:"size-[18px]"}),title:"上云流程",tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(yX,{stages:Je,activeKey:St,onPick:ve=>ot({attempt:Se,key:ve})},Se)})]}),St==="scan"&&a.jsxs(a.Fragment,{children:[t.historyError&&a.jsx(Sd,{className:"border-error/40",children:a.jsxs("div",{className:"px-4 py-3 text-[13px] leading-snug text-text-200",children:["扫描记录读不出来:",t.historyError,"。重新扫描会重建它。"]})}),!f&&t.scans.length>0&&a.jsx(uOe,{scans:t.scans,...n?{repo:n}:{},...r?{released:r}:{},...Z?{selectedId:Z.id}:{},...t.online!==void 0?{online:t.online}:{},onSelect:be}),ht&&Z&&ht.packages.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(dw,{className:"size-[18px]"}),title:"镜像",count:Z.status==="scanning"?"还在长…":`${ht.packages.length} 项`}),ht.packages.map(ve=>a.jsx(_X,{name:ve.name,version:ve.version,min:ve.min,localVersion:ve.localVersion,from:ve.from,aptVersion:ve.aptVersion,aptMissing:ve.aptMissing,artifact:ve.artifact,evidence:Jn(`package:${ve.name}`),blockers:i7(ve)},ve.name))]}),ht&&Z&&ht.connectors.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(hw,{className:"size-[18px]"}),title:"连接器",count:`${ht.connectors.length} 个`}),ht.connectors.map(ve=>a.jsx(lOe,{connector:ve,publisherAuth:t.publisherFeishuAuth,onRefreshPublisherAuth:e.onRefreshPublisherAuth,evidence:Jn(`connector:${ve.name}`),onChange:ae=>{var Ue;return(Ue=e.onPatchConnector)==null?void 0:Ue.call(e,Z.id,ae)},...ve.credentialSource==="shared"&&ve.fields.length>0?{secretCard:a.jsx(cE,{embedded:!0,secret:{name:ve.name,env:ve.fields},presence:t.secrets?t.secrets.filter(ae=>ve.fields.includes(ae.env)):void 0,onSubmitValues:ae=>e.onPutSecret(Z.id,ve.name,ae)})}:{}},ve.name))]}),ht&&Z&&Ht.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(og,{className:"size-[18px]"}),title:"凭据",count:`${Ht.length} 条`}),Ht.map(ve=>a.jsx(cE,{secret:ve,evidence:Jn(`secret:${ve.name}`),presence:t.secrets?t.secrets.filter(ae=>ve.env.includes(ae.env)):void 0,onSubmitValues:ae=>e.onPutSecret(Z.id,ve.name,ae)},ve.name))]}),(ht==null?void 0:ht.test)&&a.jsx(EX,{test:ht.test}),Z&&Z.notes.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(yn,{className:"size-[18px]"}),title:"存疑项",count:`${Z.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:Z.notes.map((ve,ae)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),ve]},ae))})]})]}),St==="config"&&a.jsxs(a.Fragment,{children:[e.onSetEngineAuth&&a.jsx(dX,{createRepoOnSave:!n,...dn?{state:dn}:{},...Dn?{setAt:Dn}:{},channels:e.channels,channelId:((us=e.state.engineChannels)==null?void 0:us.integration)===null?null:(vi=(qs=e.state.engineChannels)==null?void 0:qs.integration)==null?void 0:vi.channelId,onRefreshChannels:e.onRefreshChannels,onSave:e.onSetEngineAuth}),e.engine&&e.engineEditor&&a.jsx(vOe,{tool:e.engine.tool,model:e.engine.model,effort:e.engine.effort??"",...e.engineEditor}),(e.onChangeSize||e.onChangeCpu)&&a.jsx(fOe,{size:e.size,cpu:e.cpu,onChange:e.onChangeSize,onChangeCpu:e.onChangeCpu,saving:e.resourceSaving,disabled:m||g||u||k||on,taskConcurrency:e.onSaveTaskConcurrency?{value:P,defaulted:e.taskConcurrency===void 0,dirty:B,valid:F,saving:k,disabled:m||g||!!e.resourceSaving,error:F?j:"请输入大于 0 的整数",saved:E,onChange:ve=>{S(ve),R(null),I(!1)},onSave:()=>void O()}:void 0}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]})]})}),e.workPanel&&a.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${yt?"w-[380px]":"w-0"}`,children:a.jsx("div",{className:"h-full w-[380px] border-l border-border bg-surface-card",children:e.workPanel})})]})}function wOe(e){return a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsxs("span",{children:["第 ",e.n," 次"]}),a.jsx("span",{className:"text-text-400",children:Xh(e.s.startedAt)}),a.jsx("span",{className:"font-mono text-xs text-text-400",children:(e.s.head??"").slice(0,7)}),a.jsx("span",{className:"text-xs text-text-400",children:e.s.baseKind==="soft"?"软扫":"硬扫"}),e.latest&&a.jsx("span",{className:"rounded-full bg-text-100-dim px-1.5 text-[11px] text-text-400",children:"最新"})]})}function _Oe(e){const{repo:t}=e.state;if(!t)return a.jsx("span",{children:e.starting?"正在建仓库…":"还没有仓库"});const n=t.dirty?"有未提交的改动":t.ahead>0?`有 ${t.ahead} 个提交没推`:"已同步";return a.jsxs(a.Fragment,{children:[a.jsx(yu,{className:"size-3 shrink-0"}),a.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",title:Rh(t.url),className:"truncate hover:text-accent hover:underline",children:Rh(t.url)}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:t.branch}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:`shrink-0 ${t.dirty||t.ahead>0?"text-warning":""}`,children:n}),e.scanBase&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",title:e.scanBase.title,children:e.scanBase.label})]})]})}function SOe(e){if(e)return e.baseKind==="soft"?{label:"软扫",title:"只重看了跟线上正跑那版有差别的部分"}:{label:"硬扫",title:"从零把 persona 整个读了一遍"}}const Sd=p.forwardRef(function(t,n){return a.jsx("div",{ref:n,className:`rounded-lg border border-border-card bg-surface-card ${t.className??""}`,children:t.children})});function kOe(e){const t=ua("sessions"),n=t==null?void 0:t.find(r=>r.sessionId===e.sessionId);return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-2.5",children:[e.live?a.jsx(st,{className:"size-3.5 animate-spin text-accent"}):a.jsx(Jt,{className:"size-3.5 text-success"}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"管家在读这个 persona"}),a.jsx("span",{className:"text-xs text-text-400",children:e.live?"进行中":"可以接着问它"})]}),a.jsx("div",{className:"min-h-0 flex-1",children:n?a.jsx(c_,{extras:{session:n,api:e.api,hideHeader:!0,flatProcess:!0}},n.sessionId):a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-xs text-text-400",children:[a.jsx(st,{className:"size-3.5 animate-spin"}),"正在接上管家的会话"]})})]})}function COe(e){var lr,In,Dt,Bt,mn,Tn,Rr,Ji,xr,vr,us,qs,vi,ve,ae,Ue,ze,Ut,cr,eo,Kx,ed,Gx,Wf;const{state:t,remoteReady:n,remoteError:r,loading:s,error:i,refresh:o,awaitingRun:l,retry:c,scan:u,patch:d,putSecret:h,setEngineAuth:f,release:m,rerunJob:g,applyConfig:x,unpublishFrom:b,unpublish:y,promote:v,openTest:w}=AR(e.personaId,{mode:"staged"}),_=Kn(),S=$V(_,"integration"),[k,N]=p.useState(null),[j,R]=p.useState(null),[E,I]=p.useState(!1),[M,P]=p.useState(null),[D,F]=p.useState(!1),B=p.useRef(null),U=p.useRef(null),[$,O]=p.useState(!1);p.useEffect(()=>{B.current=null,U.current=null,O(!1),F(!1),P(null)},[e.personaId]);const[T,V]=p.useState(!1),H=p.useRef(e.personaId),L=p.useRef(null);H.current!==e.personaId&&(H.current=e.personaId,L.current=null),t&&n&&L.current===null&&(L.current=Sy(t));const q=t?hX(t,L.current??Sy(t)):void 0,K=!T&&km(n1(q==null?void 0:q.scans,q==null?void 0:q.release),q==null?void 0:q.release)?q==null?void 0:q.release:void 0,X=((Dt=(In=(lr=t==null?void 0:t.targets)==null?void 0:lr.integration)==null?void 0:In.run)==null?void 0:Dt.status)==="completed"&&t.targets.integration.run.conclusion==="success"&&!!(K!=null&&K.verified)&&((mn=(Bt=t==null?void 0:t.targets)==null?void 0:Bt.integration)==null?void 0:mn.image)===K.verified.image&&((Ji=(Rr=(Tn=t==null?void 0:t.targets)==null?void 0:Tn.integration)==null?void 0:Rr.run)==null?void 0:Ji.runId)===K.runId&&((us=(vr=(xr=t.targets)==null?void 0:xr.integration)==null?void 0:vr.run)==null?void 0:us.runAttempt)===K.runAttempt,te=X&&!!((qs=K==null?void 0:K.verified)!=null&&qs.verification.checks.includes("persona-dialogue"))&&((ae=(ve=(vi=t==null?void 0:t.targets)==null?void 0:vi.integration)==null?void 0:ve.run)==null?void 0:ae.jobs.some(Oe=>Oe.key===mo&&Oe.status==="done")),oe=t==null?void 0:t.scans.find(Oe=>Oe.id===(K==null?void 0:K.scanId)),Q=(ze=(Ue=t==null?void 0:t.targets)==null?void 0:Ue.production)==null?void 0:ze.secrets,he=!!oe&&!!Q&&Jle(oe.manifest).every(Oe=>Q.some(jt=>jt.env===Oe&&jt.setAt))&&kb(Q)!=="partial",be=[...(t==null?void 0:t.promotions)??[]].reverse().find(Oe=>Oe.releaseId===(K==null?void 0:K.id)),Z=PR(be),ce=(be==null?void 0:be.phase)==="completed";p.useEffect(()=>{let Oe=!1;return N(null),K!=null&&K.id&&e.api.sessionList().then(({sessions:jt})=>{Oe||N(jt.find(yr=>{var Wr;return yr.testReleaseId===K.id&&yr.cloudExpectedImage===((Wr=K.verified)==null?void 0:Wr.image)})??null)}).catch(()=>{}),()=>{Oe=!0}},[e.api,K==null?void 0:K.id,(Ut=K==null?void 0:K.verified)==null?void 0:Ut.image]);const se=async()=>{if(K!=null&&K.id){I(!0),R(null);try{const Oe=await w(K.id),Wr=(await e.api.sessionList()).sessions.find(hl=>hl.testReleaseId===K.id&&hl.cloudExpectedImage===Oe.expectedImage&&hl.ownerPersonaId===Oe.personaId)??await e.api.sessionCreate({ownerPersonaId:Oe.personaId,label:"测试 · "+e.personaId});N(Wr)}catch(Oe){R(Oe instanceof Error?Oe.message:String(Oe))}finally{I(!1)}}},fe=async()=>{if(!(K!=null&&K.id)||B.current||Z||ce||U.current)return;const Oe={releaseId:K.id};B.current=Oe,F(!0),P(null);try{await v(K.id)}catch(jt){B.current===Oe&&P({releaseId:Oe.releaseId,message:jt instanceof Error?jt.message:String(jt)})}finally{B.current===Oe&&(B.current=null,F(!1))}},{status:xe,startOauth:Me,authorize:Xe}=gX(),me=p.useCallback(async()=>{const Oe=await Me();return await o(),Oe},[Me,o]),Ce=p.useCallback(async Oe=>{await Xe(Oe),await o()},[Xe,o]),je=(xe==null?void 0:xe.status)==="authorized";p.useEffect(()=>{je&&o()},[je,o]);const{persona:Se,refresh:ut}=NR(e.personaId),ot=Se?S7(Se):void 0,yt=Se?Ice(Se):void 0,re=NPe(mX({current:yt,release:q==null?void 0:q.release,run:((eo=(cr=t==null?void 0:t.targets)==null?void 0:cr.integration)==null?void 0:eo.run)??(t==null?void 0:t.run),anchored:!!K})),ue=(ot==null?void 0:ot.tool)==="claude",{capabilities:Te}=si(ot&&ol(ot.tool)?ot.tool:null),Ze=MPe(e.api,ot==null?void 0:ot.tool),[at,et]=p.useState([]),tt=p.useRef(0),Lt=p.useCallback(async()=>{const Oe=++tt.current,jt=await e.api.subscriptionChannelGet();tt.current===Oe&&et(jt.channels)},[e.api]);p.useEffect(()=>(Lt().catch(()=>{}),()=>{tt.current++}),[Lt]);const wt=(Kx=t==null?void 0:t.engineChannels)==null?void 0:Kx.integration,we=DPe(e.api,wt),[He,ct]=p.useState(!1),[Ot,on]=p.useState(!1),[Ne,ne]=p.useState(null),[De,Je]=p.useState(null),[dt,Nt]=p.useState(null),St=Oe=>Oe instanceof Error?Oe.message:String(Oe),dn=async Oe=>{const jt=L.current;t&&(L.current=t.releases.length),V(!0),ne(null),Je(null),R(null),P(null);try{await u(Oe)}catch(yr){L.current=jt,ne(St(yr))}finally{V(!1)}},Dn=async Oe=>{if(!U.current){ct(!0),Je(null),Nt(null);try{await m(Oe)}catch(jt){Je(St(jt))}finally{ct(!1)}}},Jn=async Oe=>{var jt,yr,Wr,hl;Je(null);try{await g(Oe)}catch(Yx){!((Wr=(yr=(jt=t==null?void 0:t.targets)==null?void 0:jt.integration)==null?void 0:yr.run)!=null&&Wr.jobs.some(Ec=>Ec.jobId===Oe))&&!((hl=t==null?void 0:t.run)!=null&&hl.jobs.some(Ec=>Ec.jobId===Oe))&&Je(St(Yx))}},ht=async()=>{on(!0),Nt(null);try{await y()}catch(Oe){Nt(St(Oe).replace(/^[A-Z_]+: /,""))}finally{on(!1)}},Ht=async Oe=>{ne(null);try{const jt=ue&&!("tool"in Oe)?{cloudEngine:{...Se==null?void 0:Se.cloudEngine,...Oe}}:Oe,yr=await e.api.personaUpdate(e.personaId,jt);ut(yr).catch(()=>{})}catch(jt){ne(St(jt))}},hn=async Oe=>{if(U.current)throw new Error("资源设置正在保存,请稍后重试");const jt={};U.current=jt;try{await e.api.personaUpdate(e.personaId,{taskConcurrency:Oe}),await ut()}finally{U.current===jt&&(U.current=null)}},En=async Oe=>{if(U.current||He||l)return;const jt={};U.current=jt,O(!0),ne(null);try{const yr=await e.api.personaUpdate(e.personaId,Oe);if(U.current!==jt)return;await ut(yr)}catch(yr){U.current===jt&&ne(St(yr))}finally{U.current===jt&&(U.current=null,O(!1))}};if(s&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(i&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:i});if(!t)return null;const Mt=kc(t.scans);return a.jsx(bOe,{state:t,...yt?{currentConfig:yt}:{},onApplyConfig:x,integrationLogin:S.identity?a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境 · 已登录 ",S.identity.displayName]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Le,{size:"sm",onClick:()=>{S.login().then(Oe=>window.open(Oe,"_blank","noopener,noreferrer")).catch(Oe=>R(Oe instanceof Error?Oe.message:String(Oe)))},children:"用当前飞书账号登录测试环境"}),S.error&&a.jsx("div",{className:"text-error",children:S.error})]}),testActions:a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex flex-wrap gap-2",children:a.jsx(Le,{size:"sm",onClick:()=>void se(),disabled:!X||E,children:"打开测试对话(可选)"})}),j&&a.jsx("div",{className:"text-error",children:j}),k&&k.testReleaseId===(K==null?void 0:K.id)&&a.jsx("div",{className:"h-[480px] overflow-hidden rounded-lg border border-border",children:a.jsx(c_,{extras:{session:k,api:e.api,hideHeader:!0}},k.sessionId)})]}),productionActions:a.jsxs("div",{className:"space-y-3",children:[oe&&a.jsxs("details",{children:[a.jsx("summary",{className:"cursor-pointer",children:"线上环境的凭据"}),a.jsx("div",{className:"text-xs text-text-400",children:"在这里填写线上使用的账号。测试环境的账号单独保存。"}),[...oe.manifest.secrets,...aw(oe.manifest)].map(Oe=>a.jsx(cE,{secret:Oe,presence:Q,onSubmitValues:jt=>h(oe.id,Oe.name,jt,"production")},Oe.name)),a.jsx(dX,{state:Q?kb(Q):void 0,channels:at,channelId:((ed=t.engineChannels)==null?void 0:ed.production)===null?null:(Wf=(Gx=t.engineChannels)==null?void 0:Gx.production)==null?void 0:Wf.channelId,onRefreshChannels:Lt,onSave:Oe=>f(Oe,"production")})]}),re&&a.jsx("div",{className:"text-warning",children:re}),!re&&!he&&te&&a.jsx("div",{className:"text-warning",children:"先填齐线上环境的凭据,再上线。"}),a.jsx(Le,{size:"sm",onClick:()=>void fe(),disabled:!te||!!re||!he||D||Z||ce||$,children:D?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在提交上线"]}):Z?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在上线"]}):ce?"已上线":"上线"})]}),starting:T,releasing:He,awaitingRun:l,retry:c,promoting:D,productionError:(M==null?void 0:M.releaseId)===(K==null?void 0:K.id)&&!Z&&!ce?M==null?void 0:M.message:void 0,onRefreshRetry:()=>void o(),busy:Ot||D||Z,scanError:Ne??(!n&&r?`读不到线上状态(${r}),先只显示本机已知的内容;关掉再打开发布页可重试。`:null),releaseError:De,onScan:Oe=>void dn(Oe),onRelease:Oe=>void Dn(Oe),onRetryJob:Oe=>void Jn(Oe),onPutSecret:h,onSetEngineAuth:f,channels:at,onRefreshChannels:Lt,onRefreshPublisherAuth:()=>void o(),onPatchConnector:(Oe,jt)=>{ne(null),d(Oe,{connector:jt}).then(()=>jt.protocol==="lark-sidecar"&&jt.credentialSource==="shared"?o():void 0).catch(yr=>ne(St(yr)))},onAuthorizeGithub:Ce,onStartGithubOauth:me,...ot?{engine:ot}:{},localEngineVersion:Ze,...(Se==null?void 0:Se.size)!==void 0?{size:Se.size}:{},...(Se==null?void 0:Se.cpu)!==void 0?{cpu:Se.cpu}:{},resourceSaving:$,onChangeSize:Oe=>void En({size:Oe}),onChangeCpu:Oe=>void En({cpu:Oe}),...Se?{taskConcurrency:Se.taskConcurrency,onSaveTaskConcurrency:hn}:{},engineEditor:{modelList:we,...wt?{}:{allowManualModel:!0},configSchema:(Te==null?void 0:Te.configSchema)??[],onChange:Oe=>void Ht(Oe)},roundIdx:L.current??Sy(t),...jPe(t)||b!==void 0?{live:{status:DR(t,b),error:dt,onUnpublish:()=>void ht()}}:{},...e.cloud?{cloud:e.cloud}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},...Mt!=null&&Mt.scanSessionId?{workPanel:a.jsx(kOe,{api:e.api,sessionId:Mt.scanSessionId,live:Mt.status==="scanning"})}:{}},e.personaId)}function IX(e,t,n){const r=Kn(),[s,i]=p.useState({}),o=p.useRef(0),l=p.useRef(new Set);return p.useEffect(()=>{o.current++,l.current=new Set,i({})},[e]),p.useEffect(()=>{if(!n||!e)return;const c=t.filter(h=>!l.current.has(cn(h)));if(c.length===0)return;for(const h of c)l.current.add(cn(h));i(h=>({...h,...Object.fromEntries(c.map(f=>[cn(f),"loading"]))}));const u=o.current,d=new Vt(r);for(const h of c)d.deployGet(e,h.id?{releaseId:h.id,environment:h.environment}:{releaseHead:h.head}).then(f=>u===o.current&&i(m=>({...m,[cn(h)]:f.run})),()=>u===o.current&&i(f=>({...f,[cn(h)]:void 0})))},[r,e,t,n]),s}function TX(e){const{slot:t}=e;return t==="loading"?a.jsx(st,{className:"size-3 animate-spin text-text-400","aria-label":"查流水线"}):t===void 0?a.jsx("span",{className:"text-text-400",children:"查不到"}):t.status!=="completed"?a.jsxs("span",{className:"inline-flex items-center gap-1 text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):sc(t)?a.jsxs("span",{className:"inline-flex items-center gap-1 text-success",children:[a.jsx(Jt,{className:"size-3"}),"成功"]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-error",children:[a.jsx(Xt,{className:"size-3"}),"失败"]})}function NOe(e){const{releases:t,scans:n}=e,[r,s]=p.useState(!1),i=OR(t,e.runs,e.online),o=ba(t),l=m=>m===o||m===i||fX(m,e.runs)||cn(m)===e.selectedHead,c=t.map((m,g)=>({r:m,n:g+1})).reverse(),u=r?c:c.filter(({r:m})=>l(m)),d=c.length-u.length,h=e.repo?Rh(e.repo.url):void 0,f=m=>n.find(g=>g.id===m.scanId);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(L5,{className:"size-[18px]"}),title:"发布历史",count:`${t.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"release-history",children:[u.map(({r:m,n:g})=>{const x=cn(m)===e.selectedHead,b=f(m);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(cn(m)),"aria-current":x,"aria-label":`第 ${g} 次发布`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${x?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",g]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:Xh(m.at)}),h?a.jsxs("a",{href:`https://github.com/${h}/commit/${m.head}`,target:"_blank",rel:"noreferrer",onClick:y=>y.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m.head.slice(0,7),a.jsx(Fr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",children:m.head.slice(0,7)}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-text-400",children:b?`${b.baseKind==="soft"?"软扫":"硬扫"} · ${Xh(b.startedAt)}`:"扫描记录已丢"}),m.environment&&a.jsx("span",{className:"shrink-0 text-xs text-text-400",children:m.environment==="integration"?"测试":"线上发布"}),i&&cn(i)===cn(m)&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx("span",{className:"w-28 shrink-0 text-right text-xs",children:a.jsx(TX,{slot:e.runs[cn(m)]})})]})},cn(m))}),d>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>s(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Yt,{className:"size-3.5"}),"还有 ",d," 次发布"]})})]})]})}function y0(e){return a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card",children:e.children})}function jOe(e){const{scan:t}=e,n=t.manifest,r=s=>t.evidence.find(i=>i.target===s);return a.jsxs(a.Fragment,{children:[n.packages.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(dw,{className:"size-[18px]"}),title:"镜像",count:`${n.packages.length} 项`}),n.packages.map(s=>a.jsx(_X,{name:s.name,version:s.version,min:s.min,localVersion:s.localVersion,from:s.from,aptVersion:s.aptVersion,aptMissing:s.aptMissing,artifact:s.artifact,evidence:r(`package:${s.name}`)},s.name))]}),n.connectors.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(hw,{className:"size-[18px]"}),title:"连接器",count:`${n.connectors.length} 个`}),n.connectors.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"text-xs text-text-400",children:SX(s)}),a.jsxs("span",{className:"ml-auto text-xs text-text-300",children:[s.credentialSource?hE[s.credentialSource].label:"—",s.credentialSource==="personal"&&s.auth?` · ${ky[s.auth].label}`:"",s.fields.length>0&&(s.credentialSource==="shared"||s.auth==="fields")?` · ${s.fields.join(" / ")}`:""]})]},s.name))]}),n.secrets.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(og,{className:"size-[18px]"}),title:"凭据",count:`${n.secrets.length} 条`}),n.secrets.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"ml-auto font-mono text-xs text-text-300",children:s.env.join(" / ")})]},s.name))]}),n.test&&a.jsx(EX,{test:n.test}),t.notes.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(yn,{className:"size-[18px]"}),title:"存疑项",count:`${t.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:t.notes.map((s,i)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),s]},i))})]})]})}function EOe(e){const{state:t,runs:n}=e,{releases:r,scans:s,repo:i}=t,[o,l]=p.useState(e.initialHead??null),c=(o?r.find(w=>cn(w)===o):void 0)??ba(r),u=c?r.indexOf(c)+1:0,d=OR(r,n,t.online),h=i?Rh(i.url):void 0,f=c?s.find(w=>w.id===c.scanId):void 0,m=c?n[cn(c)]:void 0,g=m==="loading"?void 0:m,x=c?wX({personaId:t.personaId,frozen:!0,live:d!==void 0&&cn(d)===cn(c),offline:t.online===!1,scans:f?[f]:[],released:c,...g?{run:g}:{},blockers:[]}):[],[b,y]=p.useState(null),v=b&&c&&b.head===cn(c)?b.key:r1(x)??"scan";return a.jsx("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(L5,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布历史"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),h&&i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(yu,{className:"size-3 shrink-0"}),a.jsx("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"truncate hover:text-accent hover:underline",children:h})]}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:"只读"})]})]})]})}),r.length===0&&a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card px-5 py-6 text-[13px] text-text-300",children:"还没发布过。去 persona 卡片上点「发布到云上」,从扫描开始。"}),r.length>0&&a.jsx(NOe,{releases:r,scans:s,runs:n,...i?{repo:i}:{},...c?{selectedHead:cn(c)}:{},...t.online!==void 0?{online:t.online}:{},onSelect:w=>{l(w),y(null)}}),c&&a.jsxs("div",{className:"rounded-lg border border-accent/40 bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(iy,{className:"size-[18px]"}),title:`第 ${u} 次发布`,count:Xh(c.at),tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(yX,{stages:x,activeKey:v,onPick:w=>y({head:cn(c),key:w})},cn(c))})]}),f&&a.jsx(jOe,{scan:f})]})})})}function IOe(e){const{state:t,loading:n,error:r}=AR(e.personaId),s=(t==null?void 0:t.releases)??[],i=IX(e.personaId,s,t!==null);if(n&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(r&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:r});if(!t)return null;const o=ba(s),l=o&&Ru(o,t.run)?{...i,[cn(o)]:t.run}:i;return a.jsx(EOe,{state:t,runs:l,...e.initialHead?{initialHead:e.initialHead}:{}})}const pC=10*60*1e3,nL=["bg-rose-500","bg-orange-500","bg-amber-500","bg-lime-500","bg-emerald-500","bg-cyan-500","bg-blue-500","bg-violet-500","bg-fuchsia-500"];function TOe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return nL[Math.abs(t)%nL.length]}function ROe(e){const t=e.trim();if(!t)return"?";const n=t.split(/\s+/);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():t.slice(0,2).toUpperCase()}function fE(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function MOe(e){const t=new Date(e),n=new Date,r=t.toDateString()===n.toDateString(),s=new Date(n);s.setDate(s.getDate()-1);const i=t.toDateString()===s.toDateString();return r?`今天 ${fE(e)}`:i?`昨天 ${fE(e)}`:t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function POe(e){const t=[];let n;for(let r=0;r<e.length;r++){const s=e[r];(!n||s.createdAt-n.createdAt>=pC)&&t.push({kind:"divider",divider:s.createdAt});const i=!!n&&n.fromOwner===s.fromOwner&&s.createdAt-n.createdAt<pC,o=e[r+1],l=o&&o.fromOwner===s.fromOwner&&o.createdAt-s.createdAt<pC;t.push({kind:"bubble",msg:s,showAvatar:!i,isLast:!l}),n=s}return t}function OOe({thread:e,messages:t,selfDisplayName:n,onSend:r,readOnlyHint:s}){const[i,o]=p.useState(""),l=p.useRef(null),c=p.useRef(null),u=p.useMemo(()=>POe(t),[t]);p.useEffect(()=>{const m=c.current;m&&(m.scrollTop=m.scrollHeight)},[t.length]);const d=()=>{const m=l.current;m&&(m.style.height="auto",m.style.height=Math.min(m.scrollHeight,160)+"px")};p.useEffect(()=>{d()},[i]);const h=()=>{const m=i.trim();m&&(r==null||r(m),o(""),l.current&&(l.current.value=""))},f=mi(h);return a.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full bg-bg-100",children:[a.jsxs("header",{className:"px-4 py-3 border-b border-border bg-elevated flex items-center gap-3 shrink-0",children:[a.jsx(LR,{name:e.peerDisplayName,size:"md"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h2",{className:"text-sm font-semibold text-text-100 leading-tight",children:e.peerDisplayName}),a.jsx("p",{className:"text-[11px] text-text-400 mt-0.5 flex items-center gap-1.5",children:s?a.jsx("span",{children:"访客"}):e.peerOnline?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-emerald-500"}),a.jsx("span",{children:"在线"})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-text-400"}),a.jsx("span",{children:"离线"})]})})]}),a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("button",{className:"p-2 rounded text-text-400 hover:bg-bg-200 hover:text-text-100 transition-colors",children:a.jsx(ihe,{className:"h-4 w-4"})})})]}),a.jsx("div",{ref:c,className:"flex-1 overflow-auto px-4 py-3 flex flex-col gap-1",children:t.length===0?a.jsx(DOe,{peerName:e.peerDisplayName}):u.map((m,g)=>m.kind==="divider"?a.jsx("div",{className:"flex items-center justify-center my-3",children:a.jsx("span",{className:"text-[10px] text-text-400 bg-bg-100 px-2 py-0.5 rounded-full",children:MOe(m.divider)})},`d-${g}`):a.jsx(AOe,{msg:m.msg,peerName:e.peerDisplayName,selfName:n,showAvatar:m.showAvatar,isLast:m.isLast},m.msg.id))}),!e.peerOnline&&!s&&a.jsxs("div",{className:"px-4 py-1.5 bg-amber-50 border-t border-amber-100 text-[11px] text-amber-900 shrink-0",children:[e.peerDisplayName," 离线,发出的消息会标记为失败"]}),s?a.jsx("footer",{"data-testid":"dm-readonly-hint",className:"px-4 py-3 border-t border-border bg-elevated shrink-0 text-[12px] text-text-400 text-center",children:s}):a.jsxs("footer",{className:"px-4 py-3 border-t border-border bg-elevated shrink-0",children:[a.jsxs("div",{className:"flex items-end gap-2 rounded-lg border border-border bg-bg-50 focus-within:border-accent focus-within:ring-1 focus-within:ring-accent transition-colors px-3 py-2",children:[a.jsx("textarea",{ref:l,rows:1,placeholder:`给 ${e.peerDisplayName} 发消息...`,value:i,onChange:m=>o(m.target.value),...f,className:"flex-1 resize-none bg-transparent text-sm text-text-100 placeholder:text-text-400 focus:outline-none leading-relaxed py-0.5",style:{maxHeight:160}}),a.jsx(Le,{size:"sm",variant:i.trim()?"default":"ghost",disabled:!i.trim(),onClick:h,className:"h-8 w-8 p-0 shrink-0",children:a.jsx(fw,{className:"h-4 w-4"})})]}),a.jsxs("p",{className:"text-[10px] text-text-400 mt-1.5 px-1",children:[a.jsx("kbd",{className:"font-mono",children:"Enter"})," 发送 · ",a.jsx("kbd",{className:"font-mono",children:"Shift"}),"+",a.jsx("kbd",{className:"font-mono",children:"Enter"})," 换行"]})]})]})}function DOe({peerName:e}){return a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-4 py-8",children:[a.jsx(LR,{name:e,size:"xl"}),a.jsx("p",{className:"text-sm text-text-200 mt-4",children:e}),a.jsx("p",{className:"text-xs text-text-400 mt-1",children:"这是你们之间的开始 — 打个招呼吧"})]})}function AOe({msg:e,peerName:t,selfName:n,showAvatar:r,isLast:s}){const i=e.fromOwner,o=i?n:t;return a.jsxs("div",{className:J("group flex items-start gap-2",i?"flex-row-reverse":"flex-row",r?"mt-2":"mt-0.5"),children:[a.jsx("div",{className:"w-7 shrink-0",children:r&&o?a.jsx(LR,{name:o,size:"sm"}):null}),a.jsxs("div",{className:J("flex flex-col max-w-[70%] min-w-0",i?"items-end":"items-start"),children:[a.jsxs("div",{className:J("px-3 py-1.5 break-words",i?"bg-accent text-accent-contrast":"bg-bg-200 text-text-100",i?J("rounded-2xl",s?"rounded-br-md":"rounded-br-2xl",r?"rounded-tr-2xl":"rounded-tr-md"):J("rounded-2xl",s?"rounded-bl-md":"rounded-bl-2xl",r?"rounded-tl-2xl":"rounded-tl-md")),children:[e.personaOrigin&&a.jsx("span",{"data-testid":"dm-persona-origin",className:J("block text-[10px] mb-0.5 opacity-80",i?"text-accent-contrast":"text-text-300"),children:`${e.personaOrigin} 助手代发`}),a.jsx("p",{className:"text-[13.5px] leading-relaxed whitespace-pre-wrap",children:e.text})]}),a.jsxs("div",{className:J("flex items-center gap-1 px-1 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity",i?"flex-row-reverse":""),children:[a.jsx("span",{className:"text-[10px] text-text-400",children:fE(e.createdAt)}),i&&a.jsx($Oe,{status:e.deliveryStatus})]})]})]})}function $Oe({status:e}){return e==="sending"?a.jsx(M5,{className:"h-3 w-3 text-text-400"}):e==="sent"?a.jsx(Jt,{className:"h-3 w-3 text-text-400"}):e==="delivered"?a.jsx(Pde,{className:"h-3 w-3 text-text-400"}):e==="failed"?a.jsx(pa,{className:"h-3 w-3 text-destructive"}):null}function LR({name:e,size:t="sm"}){const n=t==="xl"?"h-16 w-16 text-xl":t==="md"?"h-9 w-9 text-sm":"h-7 w-7 text-[11px]";return a.jsx("div",{className:J("rounded-full flex items-center justify-center text-white font-semibold shrink-0",TOe(e),n),children:ROe(e)})}const LOe="访客消息由 persona 代发,这里不能回复——请到对应会话里处理";function BOe(e,t,n){var s;const r=e.senderDeviceId===t;return{id:e.id,threadId:e.peerDeviceId,fromOwner:r,fromDisplayName:r?void 0:n,text:e.text,createdAt:e.createdAt,deliveryStatus:r?"delivered":void 0,personaOrigin:((s=e.origin)==null?void 0:s.kind)==="persona"?e.origin.personaId:void 0}}function FOe({contact:e,im:t,selfPrincipalId:n,selfDisplayName:r,readOnly:s}){const i=t.ensurePeerLoaded;p.useEffect(()=>{i(e.deviceId)},[e.deviceId,i]);const o=p.useRef(new Map),l=t.messagesByPeerDeviceId.get(e.deviceId)??[],c=l.length>0?l[l.length-1].createdAt:0;p.useEffect(()=>{c===0||(o.current.get(e.deviceId)??0)>=c||(o.current.set(e.deviceId,c),t.markRead(e.deviceId,c))},[e.deviceId,c,t]);const u=p.useMemo(()=>(t.messagesByPeerDeviceId.get(e.deviceId)??[]).map(m=>BOe(m,n,e.displayName)),[t.messagesByPeerDeviceId,e.deviceId,e.displayName,n]),d=t.statusByPeerDeviceId.get(e.deviceId)==="connected",h={threadId:e.deviceId,peerAlias:e.deviceId,peerDisplayName:e.displayName,lastMessageAt:u.length>0?u[u.length-1].createdAt:0,lastMessagePreview:u.length>0?u[u.length-1].text:"",unreadCount:0,peerOnline:d};return a.jsx(OOe,{thread:h,messages:u,selfDisplayName:r,onSend:s?void 0:f=>void t.sendMessage(e.deviceId,f),readOnlyHint:s?LOe:void 0})}function zOe({status:e,onRetry:t,topBanner:n}){if(e.kind==="starting")return a.jsxs("div",{"data-testid":"extension-iframe-starting",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50",children:[a.jsx(st,{className:"w-6 h-6 text-text-300 animate-spin"}),a.jsxs("div",{className:"text-[13px] text-text-200",children:["Starting ",e.name,"…"]}),a.jsx("div",{className:"text-[11px] text-text-400/80",children:"spawning child process"})]});if(e.kind==="error")return a.jsxs("div",{"data-testid":"extension-iframe-error",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50 px-8",children:[a.jsx(yn,{className:"w-6 h-6 text-red-400"}),a.jsxs("div",{className:"text-[13px] text-text-100",children:["Failed to start ",e.name]}),a.jsx("div",{className:"text-[11px] text-text-400/90 max-w-md text-center font-mono",children:e.message}),a.jsxs("button",{type:"button",onClick:t,"data-testid":"extension-iframe-retry",className:J("mt-1 flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[12px]","border border-border text-text-200 hover:text-text-100 hover:bg-text-100/5 transition-colors"),children:[a.jsx(mf,{className:"w-3.5 h-3.5"}),"Retry"]})]});const r=e.target.kind==="local"?`http://127.0.0.1:${e.target.port}/`:e.target.url;return a.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n,a.jsx("iframe",{"data-testid":"extension-iframe-running","data-target-kind":e.target.kind,title:e.name,src:r,className:"flex-1 w-full h-full border-0 bg-bg-50",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"})]})}function HOe({state:e,onUpdate:t,onDismiss:n,onViewLogs:r}){if(e.kind==="idle")return null;const s=VOe(e.kind);return a.jsxs("div",{"data-testid":"update-available-banner","data-state":e.kind,className:J("flex items-center gap-2 px-4 h-9 shrink-0 text-[12px] border-b",s.className),children:[a.jsx(s.Icon,{className:J("w-3.5 h-3.5 shrink-0",s.iconClassName),"aria-hidden":!0}),a.jsx("span",{className:"truncate flex-1",children:UOe(e)}),WOe(e,{onUpdate:t,onDismiss:n,onViewLogs:r})]})}function UOe(e){switch(e.kind){case"available":return`${e.extName} 有新版 v${e.toVersion}(当前 v${e.fromVersion})`;case"updating":{const t={fetching:"拉取中",extracting:"应用中",restarting:"重启中"}[e.step];return`正在更新 ${e.extName} → v${e.toVersion}(${t}…)`}case"success":return`${e.extName} 已更新到 v${e.toVersion}`;case"failed-rollback":return`${e.extName} v${e.attemptedVersion} 启动失败,已回退到 v${e.rolledBackTo}`}}function WOe(e,{onUpdate:t,onDismiss:n,onViewLogs:r}){return e.kind==="available"?a.jsxs(a.Fragment,{children:[a.jsx(rL,{tone:"accent",onClick:t,testId:"update-banner-update",children:"更新"}),a.jsx(mC,{onClick:n})]}):e.kind==="success"?a.jsx(mC,{onClick:n}):e.kind==="failed-rollback"?a.jsxs(a.Fragment,{children:[r?a.jsx(rL,{tone:"error",onClick:r,testId:"update-banner-view-logs",children:"查看日志"}):null,a.jsx(mC,{onClick:n})]}):null}function rL({tone:e,onClick:t,testId:n,children:r}){const s=e==="accent"?"bg-accent/10 hover:bg-accent/20 text-accent border border-accent/30":"bg-error/10 hover:bg-error/20 text-error border border-error/30";return a.jsx("button",{type:"button",onClick:t,"data-testid":n,className:J("inline-flex items-center gap-1 px-2 h-6 rounded-sm text-[11px] font-medium transition-colors",s),children:r})}function mC({onClick:e}){return a.jsx("button",{type:"button",onClick:e,"data-testid":"update-banner-dismiss",className:"inline-flex items-center justify-center w-5 h-5 text-text-400 hover:text-text-100 rounded-sm","aria-label":"dismiss",children:a.jsx(Xt,{className:"w-3 h-3"})})}function VOe(e){switch(e){case"available":return{Icon:rH,iconClassName:"",className:"bg-accent-dim text-accent border-accent/30"};case"updating":return{Icon:st,iconClassName:"animate-spin",className:"bg-warning-dim text-warning border-warning/30"};case"success":return{Icon:li,iconClassName:"",className:"bg-success-dim text-success border-success/30"};case"failed-rollback":return{Icon:yn,iconClassName:"",className:"bg-error-dim text-error border-error/30"}}}function qOe({client:e,extId:t,updateInfo:n,onApplyUpdate:r}){const[s,i]=p.useState({kind:"starting",name:t}),[o,l]=p.useState(null),[c,u]=p.useState(!1);p.useEffect(()=>{l(null),u(!1)},[t]);const d=p.useCallback(async()=>{let g=t;try{const b=(await e.request("extension.list",{})).extensions.find(y=>y.extId===t);b&&b.state!=="invalid"&&(g=b.manifest.name)}catch{}i({kind:"starting",name:g});try{const x=await e.request("extension.open",{extId:t});i({kind:"running",name:g,target:x})}catch(x){i({kind:"error",name:g,message:x.message})}},[e,t]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async()=>{if(!(!n||!r)){l({kind:"updating",extName:n.extName,toVersion:n.toVersion,step:"fetching"});try{const g=await r(n);g.kind==="updated"?(l({kind:"success",extName:n.extName,toVersion:g.installedVersion}),d()):l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:g.rolledBackTo,reason:g.reason})}catch(g){l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:n.fromVersion,reason:g.message})}}},[n,r,d]);let f={kind:"idle"};o?f=o:n&&!c&&(f={kind:"available",extName:n.extName,fromVersion:n.fromVersion,toVersion:n.toVersion});const m=f.kind==="idle"?null:a.jsx(HOe,{state:f,onUpdate:()=>void h(),onDismiss:()=>{l(null),u(!0)}});return a.jsx(zOe,{status:s,onRetry:()=>void d(),topBanner:m})}function KOe(e){const t=new Map;return{observe(n,r){let s=t.get(n);s||(s={data:void 0,hasData:!1,listeners:new Set},t.set(n,s));const i=c=>r(c);s.listeners.add(i);const o=s.listeners.size===1;i(s.hasData?s.data:void 0),o&&e.onFirstObserver(n);let l=!1;return()=>{if(l)return;l=!0;const c=t.get(n);c&&(c.listeners.delete(i),c.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const s=t.get(n);if(!s)return;const i=s.hasData?s.data:void 0,o=r(i);s.data=o,s.hasData=!0;for(const l of s.listeners)l(o)}}}function GOe(){const e=[],t=new Map,n=r=>{for(const s of e)if(s.pattern.test(r))return s.source;return null};return{register(r,s){e.push({pattern:r,source:s})},activate(r){if(t.has(r))return;const s=n(r);if(!s)throw new Error(`no source registered for key: ${r}`);t.set(r,s.start(r))},deactivate(r){const s=t.get(r);s&&(t.delete(r),s())}}}function YOe(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of F7)n.push(e.on(r,s=>t(r,s)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}const XOe=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:uG(e)});function ZOe(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let s=!1;const i=async()=>{try{const l=await e.request("capabilities:get",{tool:r});if(s)return;t(n,()=>l)}catch{if(s)return;t(n,()=>XOe(r))}},o=e.onConnect(()=>{i()});return i(),()=>{s=!0,o()}}}}function QOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("session:list",void 0);if(r)return;t(n,()=>l.sessions??[])}catch{}},i=e.onFrame((l,c)=>{if(l==="session:info"){const u=c;if(u.chatId!==void 0)return;t(n,d=>[u,...(d??[]).filter(h=>h.sessionId!==u.sessionId)])}else if(l==="session:deleted"){const u=c;t(n,d=>(d??[]).filter(h=>h.sessionId!==u.sessionId))}}),o=e.onConnect(()=>{s()});return s(),()=>{r=!0,i(),o()}}}}const JOe="session/";function eDe(e){return{sid:e.slice(JOe.length)}}const tDe=new Set(E5);function RX(e){return tDe.has(e)}function sL(e){return RX(e)?e:"idle"}function nDe(e,t){return{start(n){const{sid:r}=eDe(n);let s=!1,i=-1;const o=f=>{t(n,m=>zV(m??vg,f,r))},l=async f=>{const m=f==="baseline"?-1:i;try{const g=await e.request("session:events",{sessionId:r,afterSeq:m});if(s)return;const x=g.events??[],b=g.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:x,latestSeq:b}),i=b;else{const y=g.bufferStartSeq??0,v=b<m||y>m+1;o({type:v?"session:events":"session:events:append",sessionId:r,events:x,latestSeq:b}),i=Math.max(i,b)}}catch{}},c=async()=>{try{const f=await e.request("info");if(s)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(m=>({sessionId:m.sessionId,freshSpawn:m.freshSpawn,status:sL(m.status)}))})}catch{}},u=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}s||(await l(i<0?"baseline":"delta"),!s&&await c())},d=e.onFrame((f,m)=>{if(!s)if(f==="session:event"){const g=m;if(g.sessionId!==r)return;const x=g.event.seq;Pe("session-events","push session:event",{sid:r,kind:g.event.kind,seq:x,lastSeqBefore:i}),o({type:"session:event",sessionId:g.sessionId,event:g.event}),typeof x=="number"&&x>i&&(i=x)}else if(f==="session:status"){const g=m;if(g.sessionId!==r)return;if(!RX(g.status)){Pe("session-events","push session:status drop",{sid:r,status:g.status});return}Pe("session-events","push session:status",{sid:r,status:g.status}),o({type:"session:status",sessionId:g.sessionId,status:g.status})}else if(f==="session:cleared"){if(m.sessionId!==r)return;Pe("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),i=-1}else if(f==="session:queue"){const g=m;if(g.sessionId!==r)return;Pe("session-events","push session:queue",{sid:r,count:g.items.length}),o({type:"session:queue",sessionId:g.sessionId,items:g.items})}else if(f==="permission:request"){const g=m;if(g.sessionId!==r)return;o({type:"permission:request",sessionId:g.sessionId,requestId:g.requestId,tool:g.tool,input:g.input,...typeof g.toolUseId=="string"&&g.toolUseId?{toolUseId:g.toolUseId}:{}})}else if(f==="session:question"){const g=m;if(g.sessionId!==r)return;o({type:"session:question",sessionId:g.sessionId,toolUseId:g.toolUseId,requestId:g.requestId,questions:g.questions})}else if(f==="session:question:cleared"){const g=m;if(g.sessionId!==r)return;g.answers&&Object.keys(g.answers).length>0?o({type:"session:question:submitted",sessionId:g.sessionId,toolUseId:g.toolUseId,answers:g.answers}):o({type:"session:question:clear",sessionId:g.sessionId,toolUseId:g.toolUseId})}else if(f==="session:rewound"){const g=m;if(g.sessionId!==r)return;o({type:"session:rewound",sessionId:g.sessionId,userMessageId:g.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(m.runningSessions??[]).map(x=>({sessionId:x.sessionId,freshSpawn:x.freshSpawn,status:sL(x.status)}))})}),h=e.onConnect(()=>{u()});return e.isConnected&&u(),()=>{s=!0,d(),h(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const rDe=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function sDe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("info",void 0);if(r)return;t(n,()=>l)}catch{}},i=e.onConnect(()=>{s()}),o=e.onFrame(l=>{rDe.has(l)&&s()});return s(),()=>{r=!0,i(),o()}}}}function iDe(){return{start(){return()=>{}}}}function oDe(e,t){return{start(n){let r=!1;const s=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},i=e.onConnect(()=>{s()});return s(),()=>{r=!0,i()}}}}function MX(e){const t=YOe(e),n=GOe();let r=null;const s=(o,l)=>{r==null||r.setData(o,l)};n.register(/^capabilities\//,ZOe(t,s)),n.register(/^sessions$/,QOe(t,s)),n.register(/^session\//,nDe(t,s)),n.register(/^personas$/,oDe(t,s)),n.register(/^persona-detail\//,iDe()),n.register(/^daemon-info$/,sDe(t,s));const i=KOe({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=i,{cache:i,channel:t}}function aDe({client:e,children:t}){const n=p.useMemo(()=>MX(e),[e]);return p.useEffect(()=>()=>{},[n]),a.jsx(cxe,{client:e,children:a.jsx(FV,{cache:n.cache,children:a.jsx($K,{children:t})})})}function lDe(e,t){var g,x,b,y;const{models:n,modes:r,configSchema:s}=t,i=e.resolvedModel??e.model,o=Cx(i,n,s),l=o.options,c=l.some(v=>v.value===e.effort)?e.effort:o.defaultValue,u=e.effort===""&&e.resolvedEffort?((g=l.find(v=>v.value===e.resolvedEffort))==null?void 0:g.label)??e.resolvedEffort:((x=l.find(v=>v.value===c))==null?void 0:x.label)??null,d=((b=s.find(v=>v.name==="permissionMode"))==null?void 0:b.default)??"",h=r.some(v=>v.id===e.permissionMode)?e.permissionMode:d,m=h===d?null:((y=r.find(v=>v.id===h))==null?void 0:y.label)??null;return{modelLabel:h_(n,i),effortOptions:l,effortValue:c,effortLabel:u,modeValue:h,modeLabel:m,modeTone:m===null?null:h==="bypassPermissions"?"danger":"info"}}function PX({models:e,modelList:t,modes:n=[],configSchema:r=[],model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c,onPatch:u}){var b;const d=t??PPe(e??[]),h=d.models,f=lDe({model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c},{models:h,modes:n,configSchema:r}),m=i??s,g=h.map(y=>{const v=y.id===""&&i?`${y.description?`${y.description};`:""}当前:${i}`:y.description;return{value:y.id,label:y.label,...v?{description:v}:{},...y.group?{group:y.group}:{}}}),x=n.map(y=>({value:y.id,label:y.label,...y.description?{description:y.description}:{}}));return a.jsxs(ls,{children:[a.jsx(cs,{asChild:!0,children:a.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[a.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:m||f.modelLabel}),f.effortLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:f.effortLabel})]}):null,f.modeLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":f.modeTone,className:J("font-semibold",f.modeTone==="danger"?"text-red-400":"text-blue-400"),children:f.modeLabel})]}):null]})}),a.jsxs(Ur,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[a.jsx(cDe,{list:d,current:s,currentLabel:f.modelLabel,options:g,onSelect:y=>u({model:y})}),a.jsx(iL,{testid:"session-config-effort",label:"Reasoning effort",current:f.effortValue,currentLabel:f.effortLabel??"—",options:f.effortOptions,onSelect:y=>u({effort:y})}),x.length>0?a.jsx(iL,{testid:"session-config-mode",label:"Permission mode",current:f.modeValue,currentLabel:((b=n.find(y=>y.id===f.modeValue))==null?void 0:b.label)??"—",currentTone:f.modeTone,options:x,onSelect:y=>u({permissionMode:y})}):null]})]})}function OX({label:e,currentLabel:t,currentTone:n}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex-1 text-text-200",children:e}),a.jsx("span",{className:J("truncate max-w-[100px]",n==="danger"?"text-red-400 font-semibold":n==="info"?"text-blue-400 font-semibold":"text-text-400"),children:t}),a.jsx(Qn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]})}function cDe({list:e,current:t,currentLabel:n,options:r,onSelect:s}){const[i,o]=p.useState(!1),l=c=>{c&&!i&&e.load(),o(c)};return a.jsxs(uX,{open:i,onOpenChange:l,children:[a.jsx(RR,{"data-testid":"session-config-model",className:"gap-2 text-[12px]",children:a.jsx(OX,{label:"Model",currentLabel:n})}),a.jsx(MR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:a.jsx(NX,{testid:"session-config-model",list:e,options:r,current:t,onSelect:s})})]})}function iL({testid:e,label:t,current:n,currentLabel:r,currentTone:s,options:i,onSelect:o}){const l=i.length===0;return a.jsxs(uX,{children:[a.jsx(RR,{"data-testid":e,disabled:l,className:"gap-2 text-[12px]",children:a.jsx(OX,{label:t,currentLabel:r,currentTone:s??null})}),a.jsx(MR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:$R(i).map((c,u)=>{const d=c.value===n;return a.jsxs(G.Fragment,{children:[c.groupHeading?a.jsxs(a.Fragment,{children:[u>0?a.jsx(ha,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:c.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${c.value||"default"}`,onSelect:()=>o(c.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:J("block text-[12px]",d?"text-text-100 font-medium":"text-text-300"),children:c.label}),c.description?a.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:c.description}):null]}),d?a.jsx(Jt,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},c.value||"default")})})]})}function uDe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitBranch(t);s(c.branch??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{branch:r,loading:i,refresh:()=>void l()}}function dDe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitRoot(t);s(c.gitRoot??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{worktreeRoot:r,loading:i,refresh:()=>void l()}}const hDe=5e3;function fDe(e,t,n=0){const[r,s]=p.useState(null);return p.useEffect(()=>{if(!t){s(null);return}let i=!1;const o=async()=>{try{const c=await e.cloudVolumeGet();i||s(c.volume??null)}catch{i||s(null)}},l=n>0?setTimeout(()=>void o(),hDe):null;return l||o(),()=>{i=!0,l&&clearTimeout(l)}},[e,t,n]),{volume:r}}const pDe=90;function mDe(e){return e.sizeBytes>0?Math.min(100,Math.max(0,Math.round(e.usedBytes/e.sizeBytes*100))):0}function oL(e){const t=e/1073741824;return t>=.1?`${t.toFixed(1)} GB`:`${Math.max(1,Math.round(e/1024**2))} MB`}function gDe({volume:e}){if(!e)return null;const t=mDe(e),n=t>=pDe?"warn":"ok",r=new Date(e.measuredAt).toLocaleString(),s=n==="ok"?"上一次任务结束时量的。":"盘快满了:在会话里说「清理一下云盘」,persona 会分析工作区里哪些能删、列给你确认后清掉。";return a.jsxs("span",{"data-testid":"chat-header-cloud-volume","data-tone":n,title:`云盘已用 ${oL(e.usedBytes)} / ${oL(e.sizeBytes)}(${r})。${s}`,className:J("ml-1.5 inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded text-[11px] tabular-nums",n==="ok"&&"bg-text-100/10 text-text-400",n==="warn"&&"bg-warning-dim text-warning"),children:[a.jsx("span",{className:"relative inline-block w-8 h-1 rounded-full bg-current/20 overflow-hidden","aria-hidden":!0,children:a.jsx("span",{className:"absolute inset-y-0 left-0 rounded-full bg-current",style:{width:`${t}%`}})}),"云盘 ",t,"%"]})}function BR({api:e,session:t,focused:n,totalPanes:r,onFocus:s,onClose:i,onNewSession:o,onOpenConfig:l,onFork:c,onQuickAsk:u,className:d,viewerRole:h="owner",hideHeader:f}){const{capabilities:m}=si(t.tool),g=gh(t.tool),[x,b]=p.useState(0),[y,v]=p.useState(n);G.useEffect(()=>{n&&v(!0)},[n]);const w=bb(t.tool),_=w?void 0:t.cwd,{branch:S}=uDe(e,_,x),{worktreeRoot:k}=dDe(e,_,x),{volume:N}=fDe(e,w,x),j=r>1,R=E=>{e.sessionUpdate(t.sessionId,E).catch(I=>{console.error("[session-config] session:update failed",t.sessionId,I)})};return a.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${j?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:s,"data-testid":`session-pane-${t.sessionId}`,children:[a.jsx(Fw,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:a.jsx(Fh,{id:"chat",minSize:"400px",children:a.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:(n||y)&&a.jsx(xDe,{api:e,session:t,focused:n,liveGitBranch:S,liveWorktreeRoot:k,...w&&N?{cloudVolume:a.jsx(gDe,{volume:N})}:{},onNewSession:o,onTurnEnd:()=>b(E=>E+1),onOpenConfig:l,onFork:c,onQuickAsk:u,viewerRole:h,hideHeader:f,configSlot:m?a.jsx(PX,{modelList:g,modes:m.permissionModes,configSchema:m.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:R}):null})})})}),j&&a.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),i()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:a.jsx(Xt,{className:"w-3.5 h-3.5"})})]})}function xDe({api:e,session:t,focused:n,liveGitBranch:r,liveWorktreeRoot:s,cloudVolume:i,onNewSession:o,onTurnEnd:l,onOpenConfig:c,onFork:u,onQuickAsk:d,viewerRole:h,configSlot:f,hideHeader:m}){return a.jsx(c_,{extras:{session:t,api:e,focused:n,...r!==void 0?{liveGitBranch:r}:{},...s!==void 0?{liveWorktreeRoot:s}:{},...i!==void 0?{cloudVolume:i}:{},onNewSession:o,onTurnEnd:l,onOpenConfig:c,...u?{onFork:g=>{u(g)}}:{},...d?{onQuickAsk:g=>{d(g)}}:{},...h?{viewerRole:h}:{},...f?{configSlot:f}:{},...m?{hideHeader:m}:{}}})}function vDe({client:e,session:t,remoteSessions:n,hasLoadedForOwner:r,focused:s,totalPanes:i,onFocus:o,onClose:l,onMirrorOrphan:c,className:u}){const d=p.useMemo(()=>new Vt(e),[e]),h=t.originOwnerPrincipalId,f=t.sessionId,m=p.useMemo(()=>n.some(g=>g.sessionId===f),[n,f]);return p.useEffect(()=>{!r||!c||m||c(f,h)},[r,m,f,h,c]),a.jsx(aDe,{client:e,children:a.jsx(BR,{api:d,session:t,focused:s,totalPanes:i,onFocus:o,onClose:l,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest",...u!==void 0?{className:u}:{}})})}function yDe(){const e=Kn(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(async()=>{s(!0),o(null);try{const u=await new Vt(e).shiftList();n(u.shifts)}catch(c){o(c instanceof Error?c.message:String(c))}finally{s(!1)}},[e]);return p.useEffect(()=>{l()},[l]),{shifts:t,loading:r,error:i,refresh:l}}var xi={};Object.defineProperty(xi,"__esModule",{value:!0});class Zu extends Error{}class bDe extends Zu{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}}class wDe extends Zu{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}}class _De extends Zu{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}}class eh extends Zu{}class DX extends Zu{constructor(t){super(`Invalid unit ${t}`)}}class Xr extends Zu{}class El extends Zu{constructor(){super("Zone is an abstract class")}}const Ae="numeric",Io="short",ii="long",a1={year:Ae,month:Ae,day:Ae},AX={year:Ae,month:Io,day:Ae},SDe={year:Ae,month:Io,day:Ae,weekday:Io},$X={year:Ae,month:ii,day:Ae},LX={year:Ae,month:ii,day:Ae,weekday:ii},BX={hour:Ae,minute:Ae},FX={hour:Ae,minute:Ae,second:Ae},zX={hour:Ae,minute:Ae,second:Ae,timeZoneName:Io},HX={hour:Ae,minute:Ae,second:Ae,timeZoneName:ii},UX={hour:Ae,minute:Ae,hourCycle:"h23"},WX={hour:Ae,minute:Ae,second:Ae,hourCycle:"h23"},VX={hour:Ae,minute:Ae,second:Ae,hourCycle:"h23",timeZoneName:Io},qX={hour:Ae,minute:Ae,second:Ae,hourCycle:"h23",timeZoneName:ii},KX={year:Ae,month:Ae,day:Ae,hour:Ae,minute:Ae},GX={year:Ae,month:Ae,day:Ae,hour:Ae,minute:Ae,second:Ae},YX={year:Ae,month:Io,day:Ae,hour:Ae,minute:Ae},XX={year:Ae,month:Io,day:Ae,hour:Ae,minute:Ae,second:Ae},kDe={year:Ae,month:Io,day:Ae,weekday:Io,hour:Ae,minute:Ae},ZX={year:Ae,month:ii,day:Ae,hour:Ae,minute:Ae,timeZoneName:Io},QX={year:Ae,month:ii,day:Ae,hour:Ae,minute:Ae,second:Ae,timeZoneName:Io},JX={year:Ae,month:ii,day:Ae,weekday:ii,hour:Ae,minute:Ae,timeZoneName:ii},eZ={year:Ae,month:ii,day:Ae,weekday:ii,hour:Ae,minute:Ae,second:Ae,timeZoneName:ii};class If{get type(){throw new El}get name(){throw new El}get ianaName(){return this.name}get isUniversal(){throw new El}offsetName(t,n){throw new El}formatOffset(t,n){throw new El}offset(t){throw new El}equals(t){throw new El}get isValid(){throw new El}}let gC=null;class Nx extends If{static get instance(){return gC===null&&(gC=new Nx),gC}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return hZ(t,n,r)}formatOffset(t,n){return Nm(this.offset(t),n)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}}const pE=new Map;function CDe(e){let t=pE.get(e);return t===void 0&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),pE.set(e,t)),t}const NDe={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function jDe(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,s,i,o,l,c,u,d]=r;return[o,s,i,l,c,u,d]}function EDe(e,t){const n=e.formatToParts(t),r=[];for(let s=0;s<n.length;s++){const{type:i,value:o}=n[s],l=NDe[i];i==="era"?r[l]=o:ft(l)||(r[l]=parseInt(o,10))}return r}const xC=new Map;class fa extends If{static create(t){let n=xC.get(t);return n===void 0&&xC.set(t,n=new fa(t)),n}static resetCache(){xC.clear(),pE.clear()}static isValidSpecifier(t){return this.isValidZone(t)}static isValidZone(t){if(!t)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=fa.isValidZone(t)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return hZ(t,n,r,this.name)}formatOffset(t,n){return Nm(this.offset(t),n)}offset(t){if(!this.valid)return NaN;const n=new Date(t);if(isNaN(n))return NaN;const r=CDe(this.name);let[s,i,o,l,c,u,d]=r.formatToParts?EDe(r,n):jDe(r,n);l==="BC"&&(s=-Math.abs(s)+1);const f=g_({year:s,month:i,day:o,hour:c===24?0:c,minute:u,second:d,millisecond:0});let m=+n;const g=m%1e3;return m-=g>=0?g:1e3+g,(f-m)/(60*1e3)}equals(t){return t.type==="iana"&&t.name===this.name}get isValid(){return this.valid}}let aL={};function IDe(e,t={}){const n=JSON.stringify([e,t]);let r=aL[n];return r||(r=new Intl.ListFormat(e,t),aL[n]=r),r}const mE=new Map;function gE(e,t={}){const n=JSON.stringify([e,t]);let r=mE.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),mE.set(n,r)),r}const xE=new Map;function TDe(e,t={}){const n=JSON.stringify([e,t]);let r=xE.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),xE.set(n,r)),r}const vE=new Map;function RDe(e,t={}){const{base:n,...r}=t,s=JSON.stringify([e,r]);let i=vE.get(s);return i===void 0&&(i=new Intl.RelativeTimeFormat(e,t),vE.set(s,i)),i}let Gp=null;function MDe(){return Gp||(Gp=new Intl.DateTimeFormat().resolvedOptions().locale,Gp)}const yE=new Map;function tZ(e){let t=yE.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),yE.set(e,t)),t}const bE=new Map;function PDe(e){let t=bE.get(e);if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...nZ,...t}),bE.set(e,t)}return t}function ODe(e){const t=e.indexOf("-x-");t!==-1&&(e=e.substring(0,t));const n=e.indexOf("-u-");if(n===-1)return[e];{let r,s;try{r=gE(e).resolvedOptions(),s=e}catch{const c=e.substring(0,n);r=gE(c).resolvedOptions(),s=c}const{numberingSystem:i,calendar:o}=r;return[s,i,o]}}function DDe(e,t,n){return(n||t)&&(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`)),e}function ADe(e){const t=[];for(let n=1;n<=12;n++){const r=xt.utc(2009,n,1);t.push(e(r))}return t}function $De(e){const t=[];for(let n=1;n<=7;n++){const r=xt.utc(2016,11,13+n);t.push(e(r))}return t}function b0(e,t,n,r){const s=e.listingMode();return s==="error"?null:s==="en"?n(t):r(t)}function LDe(e){return e.numberingSystem&&e.numberingSystem!=="latn"?!1:e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||tZ(e.locale).numberingSystem==="latn"}class BDe{constructor(t,n,r){this.padTo=r.padTo||0,this.floor=r.floor||!1;const{padTo:s,floor:i,...o}=r;if(!n||Object.keys(o).length>0){const l={useGrouping:!1,...r};r.padTo>0&&(l.minimumIntegerDigits=r.padTo),this.inf=TDe(t,l)}}format(t){if(this.inf){const n=this.floor?Math.floor(t):t;return this.inf.format(n)}else{const n=this.floor?Math.floor(t):WR(t,3);return rr(n,this.padTo)}}}class FDe{constructor(t,n,r){this.opts=r,this.originalZone=void 0;let s;if(this.opts.timeZone)this.dt=t;else if(t.zone.type==="fixed"){const o=-1*(t.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;t.offset!==0&&fa.create(l).valid?(s=l,this.dt=t):(s="UTC",this.dt=t.offset===0?t:t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone)}else t.zone.type==="system"?this.dt=t:t.zone.type==="iana"?(this.dt=t,s=t.zone.name):(s="UTC",this.dt=t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone);const i={...this.opts};i.timeZone=i.timeZone||s,this.dtf=gE(n,i)}format(){return this.originalZone?this.formatToParts().map(({value:t})=>t).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const t=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?t.map(n=>{if(n.type==="timeZoneName"){const r=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...n,value:r}}else return n}):t}resolvedOptions(){return this.dtf.resolvedOptions()}}class zDe{constructor(t,n,r){this.opts={style:"long",...r},!n&&uZ()&&(this.rtf=RDe(t,r))}format(t,n){return this.rtf?this.rtf.format(t,n):lAe(n,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,n){return this.rtf?this.rtf.formatToParts(t,n):[]}}const nZ={firstDay:1,minimalDays:4,weekend:[6,7]};class en{static fromOpts(t){return en.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,s,i=!1){const o=t||Bn.defaultLocale,l=o||(i?"en-US":MDe()),c=n||Bn.defaultNumberingSystem,u=r||Bn.defaultOutputCalendar,d=_E(s)||Bn.defaultWeekSettings;return new en(l,c,u,d,o)}static resetCache(){Gp=null,mE.clear(),xE.clear(),vE.clear(),yE.clear(),bE.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:s}={}){return en.create(t,n,r,s)}constructor(t,n,r,s,i){const[o,l,c]=ODe(t);this.locale=o,this.numberingSystem=n||l||null,this.outputCalendar=r||c||null,this.weekSettings=s,this.intl=DDe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=LDe(this)),this.fastNumbersCached}listingMode(){const t=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return t&&n?"en":"intl"}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:en.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,_E(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(t={}){return this.clone({...t,defaultToEN:!0})}redefaultToSystem(t={}){return this.clone({...t,defaultToEN:!1})}months(t,n=!1){return b0(this,t,mZ,()=>{const r=this.intl==="ja"||this.intl.startsWith("ja-");n&=!r;const s=n?{month:t,day:"numeric"}:{month:t},i=n?"format":"standalone";if(!this.monthsCache[i][t]){const o=r?l=>this.dtFormatter(l,s).format():l=>this.extract(l,s,"month");this.monthsCache[i][t]=ADe(o)}return this.monthsCache[i][t]})}weekdays(t,n=!1){return b0(this,t,vZ,()=>{const r=n?{weekday:t,year:"numeric",month:"long",day:"numeric"}:{weekday:t},s=n?"format":"standalone";return this.weekdaysCache[s][t]||(this.weekdaysCache[s][t]=$De(i=>this.extract(i,r,"weekday"))),this.weekdaysCache[s][t]})}meridiems(){return b0(this,void 0,()=>yZ,()=>{if(!this.meridiemCache){const t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[xt.utc(2016,11,13,9),xt.utc(2016,11,13,19)].map(n=>this.extract(n,t,"dayperiod"))}return this.meridiemCache})}eras(t){return b0(this,t,bZ,()=>{const n={era:t};return this.eraCache[t]||(this.eraCache[t]=[xt.utc(-40,1,1),xt.utc(2017,1,1)].map(r=>this.extract(r,n,"era"))),this.eraCache[t]})}extract(t,n,r){const s=this.dtFormatter(t,n),i=s.formatToParts(),o=i.find(l=>l.type.toLowerCase()===r);return o?o.value:null}numberFormatter(t={}){return new BDe(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,n={}){return new FDe(t,this.intl,n)}relFormatter(t={}){return new zDe(this.intl,this.isEnglish(),t)}listFormatter(t={}){return IDe(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||tZ(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:dZ()?PDe(this.locale):nZ}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(t){return this.locale===t.locale&&this.numberingSystem===t.numberingSystem&&this.outputCalendar===t.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let vC=null;class ns extends If{static get utcInstance(){return vC===null&&(vC=new ns(0)),vC}static instance(t){return t===0?ns.utcInstance:new ns(t)}static parseSpecifier(t){if(t){const n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new ns(x_(n[1],n[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Nm(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Nm(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,n){return Nm(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(t){return t.type==="fixed"&&t.fixed===this.fixed}get isValid(){return!0}}class rZ extends If{constructor(t){super(),this.zoneName=t}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function Fl(e,t){if(ft(e)||e===null)return t;if(e instanceof If)return e;if(KDe(e)){const n=e.toLowerCase();return n==="default"?t:n==="local"||n==="system"?Nx.instance:n==="utc"||n==="gmt"?ns.utcInstance:ns.parseSpecifier(n)||fa.create(e)}else return ic(e)?ns.instance(e):typeof e=="object"&&"offset"in e&&typeof e.offset=="function"?e:new rZ(e)}const FR={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},lL={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},HDe=FR.hanidec.replace(/[\[|\]]/g,"").split("");function UDe(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(e[n].search(FR.hanidec)!==-1)t+=HDe.indexOf(e[n]);else for(const s in lL){const[i,o]=lL[s];r>=i&&r<=o&&(t+=r-i)}}return parseInt(t,10)}else return t}const wE=new Map;function WDe(){wE.clear()}function io({numberingSystem:e},t=""){const n=e||"latn";let r=wE.get(n);r===void 0&&(r=new Map,wE.set(n,r));let s=r.get(t);return s===void 0&&(s=new RegExp(`${FR[n]}${t}`),r.set(t,s)),s}let cL=()=>Date.now(),uL="system",dL=null,hL=null,fL=null,pL=60,mL,gL=null;class Bn{static get now(){return cL}static set now(t){cL=t}static set defaultZone(t){uL=t}static get defaultZone(){return Fl(uL,Nx.instance)}static get defaultLocale(){return dL}static set defaultLocale(t){dL=t}static get defaultNumberingSystem(){return hL}static set defaultNumberingSystem(t){hL=t}static get defaultOutputCalendar(){return fL}static set defaultOutputCalendar(t){fL=t}static get defaultWeekSettings(){return gL}static set defaultWeekSettings(t){gL=_E(t)}static get twoDigitCutoffYear(){return pL}static set twoDigitCutoffYear(t){pL=t%100}static get throwOnInvalid(){return mL}static set throwOnInvalid(t){mL=t}static resetCaches(){en.resetCache(),fa.resetCache(),xt.resetCache(),WDe()}}class go{constructor(t,n){this.reason=t,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const sZ=[0,31,59,90,120,151,181,212,243,273,304,334],iZ=[0,31,60,91,121,152,182,213,244,274,305,335];function Oi(e,t){return new go("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function zR(e,t,n){const r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const s=r.getUTCDay();return s===0?7:s}function oZ(e,t,n){return n+(jx(e)?iZ:sZ)[t-1]}function aZ(e,t){const n=jx(e)?iZ:sZ,r=n.findIndex(i=>i<t),s=t-n[r];return{month:r+1,day:s}}function HR(e,t){return(e-t+7)%7+1}function l1(e,t=4,n=1){const{year:r,month:s,day:i}=e,o=oZ(r,s,i),l=HR(zR(r,s,i),n);let c=Math.floor((o-l+14-t)/7),u;return c<1?(u=r-1,c=Eg(u,t,n)):c>Eg(r,t,n)?(u=r+1,c=1):u=r,{weekYear:u,weekNumber:c,weekday:l,...v_(e)}}function xL(e,t=4,n=1){const{weekYear:r,weekNumber:s,weekday:i}=e,o=HR(zR(r,1,t),n),l=xh(r);let c=s*7+i-o-7+t,u;c<1?(u=r-1,c+=xh(u)):c>l?(u=r+1,c-=xh(r)):u=r;const{month:d,day:h}=aZ(u,c);return{year:u,month:d,day:h,...v_(e)}}function yC(e){const{year:t,month:n,day:r}=e,s=oZ(t,n,r);return{year:t,ordinal:s,...v_(e)}}function vL(e){const{year:t,ordinal:n}=e,{month:r,day:s}=aZ(t,n);return{year:t,month:r,day:s,...v_(e)}}function yL(e,t){if(!ft(e.localWeekday)||!ft(e.localWeekNumber)||!ft(e.localWeekYear)){if(!ft(e.weekday)||!ft(e.weekNumber)||!ft(e.weekYear))throw new eh("Cannot mix locale-based week fields with ISO-based week fields");return ft(e.localWeekday)||(e.weekday=e.localWeekday),ft(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),ft(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function VDe(e,t=4,n=1){const r=m_(e.weekYear),s=Di(e.weekNumber,1,Eg(e.weekYear,t,n)),i=Di(e.weekday,1,7);return r?s?i?!1:Oi("weekday",e.weekday):Oi("week",e.weekNumber):Oi("weekYear",e.weekYear)}function qDe(e){const t=m_(e.year),n=Di(e.ordinal,1,xh(e.year));return t?n?!1:Oi("ordinal",e.ordinal):Oi("year",e.year)}function lZ(e){const t=m_(e.year),n=Di(e.month,1,12),r=Di(e.day,1,c1(e.year,e.month));return t?n?r?!1:Oi("day",e.day):Oi("month",e.month):Oi("year",e.year)}function cZ(e){const{hour:t,minute:n,second:r,millisecond:s}=e,i=Di(t,0,23)||t===24&&n===0&&r===0&&s===0,o=Di(n,0,59),l=Di(r,0,59),c=Di(s,0,999);return i?o?l?c?!1:Oi("millisecond",s):Oi("second",r):Oi("minute",n):Oi("hour",t)}function ft(e){return typeof e>"u"}function ic(e){return typeof e=="number"}function m_(e){return typeof e=="number"&&e%1===0}function KDe(e){return typeof e=="string"}function GDe(e){return Object.prototype.toString.call(e)==="[object Date]"}function uZ(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function dZ(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function YDe(e){return Array.isArray(e)?e:[e]}function bL(e,t,n){if(e.length!==0)return e.reduce((r,s)=>{const i=[t(s),s];return r&&n(r[0],i[0])===r[0]?r:i},null)[1]}function XDe(e,t){return t.reduce((n,r)=>(n[r]=e[r],n),{})}function Zh(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function _E(e){if(e==null)return null;if(typeof e!="object")throw new Xr("Week settings must be an object");if(!Di(e.firstDay,1,7)||!Di(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(t=>!Di(t,1,7)))throw new Xr("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Di(e,t,n){return m_(e)&&e>=t&&e<=n}function ZDe(e,t){return e-t*Math.floor(e/t)}function rr(e,t=2){const n=e<0;let r;return n?r="-"+(""+-e).padStart(t,"0"):r=(""+e).padStart(t,"0"),r}function $l(e){if(!(ft(e)||e===null||e===""))return parseInt(e,10)}function Lc(e){if(!(ft(e)||e===null||e===""))return parseFloat(e)}function UR(e){if(!(ft(e)||e===null||e==="")){const t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function WR(e,t,n="round"){const r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function jx(e){return e%4===0&&(e%100!==0||e%400===0)}function xh(e){return jx(e)?366:365}function c1(e,t){const n=ZDe(t-1,12)+1,r=e+(t-n)/12;return n===2?jx(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function g_(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function wL(e,t,n){return-HR(zR(e,1,t),n)+t-1}function Eg(e,t=4,n=1){const r=wL(e,t,n),s=wL(e+1,t,n);return(xh(e)-r+s)/7}function SE(e){return e>99?e:e>Bn.twoDigitCutoffYear?1900+e:2e3+e}function hZ(e,t,n,r=null){const s=new Date(e),i={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(i.timeZone=r);const o={timeZoneName:t,...i},l=new Intl.DateTimeFormat(n,o).formatToParts(s).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function x_(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);const r=parseInt(t,10)||0,s=n<0||Object.is(n,-0)?-r:r;return n*60+s}function fZ(e){const t=Number(e);if(typeof e=="boolean"||e===""||!Number.isFinite(t))throw new Xr(`Invalid unit value ${e}`);return t}function u1(e,t){const n={};for(const r in e)if(Zh(e,r)){const s=e[r];if(s==null)continue;n[t(r)]=fZ(s)}return n}function Nm(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),s=e>=0?"+":"-";switch(t){case"short":return`${s}${rr(n,2)}:${rr(r,2)}`;case"narrow":return`${s}${n}${r>0?`:${r}`:""}`;case"techie":return`${s}${rr(n,2)}${rr(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function v_(e){return XDe(e,["hour","minute","second","millisecond"])}const QDe=["January","February","March","April","May","June","July","August","September","October","November","December"],pZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],JDe=["J","F","M","A","M","J","J","A","S","O","N","D"];function mZ(e){switch(e){case"narrow":return[...JDe];case"short":return[...pZ];case"long":return[...QDe];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const gZ=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],xZ=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],eAe=["M","T","W","T","F","S","S"];function vZ(e){switch(e){case"narrow":return[...eAe];case"short":return[...xZ];case"long":return[...gZ];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const yZ=["AM","PM"],tAe=["Before Christ","Anno Domini"],nAe=["BC","AD"],rAe=["B","A"];function bZ(e){switch(e){case"narrow":return[...rAe];case"short":return[...nAe];case"long":return[...tAe];default:return null}}function sAe(e){return yZ[e.hour<12?0:1]}function iAe(e,t){return vZ(t)[e.weekday-1]}function oAe(e,t){return mZ(t)[e.month-1]}function aAe(e,t){return bZ(t)[e.year<0?0:1]}function lAe(e,t,n="always",r=!1){const s={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},i=["hours","minutes","seconds"].indexOf(e)===-1;if(n==="auto"&&i){const h=e==="days";switch(t){case 1:return h?"tomorrow":`next ${s[e][0]}`;case-1:return h?"yesterday":`last ${s[e][0]}`;case 0:return h?"today":`this ${s[e][0]}`}}const o=Object.is(t,-0)||t<0,l=Math.abs(t),c=l===1,u=s[e],d=r?c?u[1]:u[2]||u[1]:c?s[e][0]:e;return o?`${l} ${d} ago`:`in ${l} ${d}`}function _L(e,t){let n="";for(const r of e)r.literal?n+=r.val:n+=t(r.val);return n}const cAe={D:a1,DD:AX,DDD:$X,DDDD:LX,t:BX,tt:FX,ttt:zX,tttt:HX,T:UX,TT:WX,TTT:VX,TTTT:qX,f:KX,ff:YX,fff:ZX,ffff:JX,F:GX,FF:XX,FFF:QX,FFFF:eZ};class Jr{static create(t,n={}){return new Jr(t,n)}static parseFormat(t){let n=null,r="",s=!1;const i=[];for(let o=0;o<t.length;o++){const l=t.charAt(o);l==="'"?((r.length>0||s)&&i.push({literal:s||/^\s+$/.test(r),val:r===""?"'":r}),n=null,r="",s=!s):s||l===n?r+=l:(r.length>0&&i.push({literal:/^\s+$/.test(r),val:r}),r=l,n=l)}return r.length>0&&i.push({literal:s||/^\s+$/.test(r),val:r}),i}static macroTokenToFormatOpts(t){return cAe[t]}constructor(t,n){this.opts=n,this.loc=t,this.systemLoc=null}formatWithSystemDefault(t,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(t,{...this.opts,...n}).format()}dtFormatter(t,n={}){return this.loc.dtFormatter(t,{...this.opts,...n})}formatDateTime(t,n){return this.dtFormatter(t,n).format()}formatDateTimeParts(t,n){return this.dtFormatter(t,n).formatToParts()}formatInterval(t,n){return this.dtFormatter(t.start,n).dtf.formatRange(t.start.toJSDate(),t.end.toJSDate())}resolvedOptions(t,n){return this.dtFormatter(t,n).resolvedOptions()}num(t,n=0,r=void 0){if(this.opts.forceSimple)return rr(t,n);const s={...this.opts};return n>0&&(s.padTo=n),r&&(s.signDisplay=r),this.loc.numberFormatter(s).format(t)}formatDateTimeFromString(t,n){const r=this.loc.listingMode()==="en",s=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",i=(m,g)=>this.loc.extract(t,m,g),o=m=>t.isOffsetFixed&&t.offset===0&&m.allowZ?"Z":t.isValid?t.zone.formatOffset(t.ts,m.format):"",l=()=>r?sAe(t):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(m,g)=>r?oAe(t,m):i(g?{month:m}:{month:m,day:"numeric"},"month"),u=(m,g)=>r?iAe(t,m):i(g?{weekday:m}:{weekday:m,month:"long",day:"numeric"},"weekday"),d=m=>{const g=Jr.macroTokenToFormatOpts(m);return g?this.formatWithSystemDefault(t,g):m},h=m=>r?aAe(t,m):i({era:m},"era"),f=m=>{switch(m){case"S":return this.num(t.millisecond);case"u":case"SSS":return this.num(t.millisecond,3);case"s":return this.num(t.second);case"ss":return this.num(t.second,2);case"uu":return this.num(Math.floor(t.millisecond/10),2);case"uuu":return this.num(Math.floor(t.millisecond/100));case"m":return this.num(t.minute);case"mm":return this.num(t.minute,2);case"h":return this.num(t.hour%12===0?12:t.hour%12);case"hh":return this.num(t.hour%12===0?12:t.hour%12,2);case"H":return this.num(t.hour);case"HH":return this.num(t.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return t.zone.offsetName(t.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return t.zone.offsetName(t.ts,{format:"long",locale:this.loc.locale});case"z":return t.zoneName;case"a":return l();case"d":return s?i({day:"numeric"},"day"):this.num(t.day);case"dd":return s?i({day:"2-digit"},"day"):this.num(t.day,2);case"c":return this.num(t.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(t.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return s?i({month:"numeric",day:"numeric"},"month"):this.num(t.month);case"LL":return s?i({month:"2-digit",day:"numeric"},"month"):this.num(t.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return s?i({month:"numeric"},"month"):this.num(t.month);case"MM":return s?i({month:"2-digit"},"month"):this.num(t.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return s?i({year:"numeric"},"year"):this.num(t.year);case"yy":return s?i({year:"2-digit"},"year"):this.num(t.year.toString().slice(-2),2);case"yyyy":return s?i({year:"numeric"},"year"):this.num(t.year,4);case"yyyyyy":return s?i({year:"numeric"},"year"):this.num(t.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(t.weekYear.toString().slice(-2),2);case"kkkk":return this.num(t.weekYear,4);case"W":return this.num(t.weekNumber);case"WW":return this.num(t.weekNumber,2);case"n":return this.num(t.localWeekNumber);case"nn":return this.num(t.localWeekNumber,2);case"ii":return this.num(t.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(t.localWeekYear,4);case"o":return this.num(t.ordinal);case"ooo":return this.num(t.ordinal,3);case"q":return this.num(t.quarter);case"qq":return this.num(t.quarter,2);case"X":return this.num(Math.floor(t.ts/1e3));case"x":return this.num(t.ts);default:return d(m)}};return _L(Jr.parseFormat(n),f)}formatDurationFromString(t,n){const r=this.opts.signMode==="negativeLargestOnly"?-1:1,s=d=>{switch(d[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=(d,h)=>f=>{const m=s(f);if(m){const g=h.isNegativeDuration&&m!==h.largestUnit?r:1;let x;return this.opts.signMode==="negativeLargestOnly"&&m!==h.largestUnit?x="never":this.opts.signMode==="all"?x="always":x="auto",this.num(d.get(m)*g,f.length,x)}else return f},o=Jr.parseFormat(n),l=o.reduce((d,{literal:h,val:f})=>h?d:d.concat(f),[]),c=t.shiftTo(...l.map(s).filter(d=>d)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return _L(o,i(c,u))}}const wZ=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Tf(...e){const t=e.reduce((n,r)=>n+r.source,"");return RegExp(`^${t}$`)}function Rf(...e){return t=>e.reduce(([n,r,s],i)=>{const[o,l,c]=i(t,s);return[{...n,...o},l||r,c]},[{},null,1]).slice(0,2)}function Mf(e,...t){if(e==null)return[null,null];for(const[n,r]of t){const s=n.exec(e);if(s)return r(s)}return[null,null]}function _Z(...e){return(t,n)=>{const r={};let s;for(s=0;s<e.length;s++)r[e[s]]=$l(t[n+s]);return[r,null,n+s]}}const SZ=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,uAe=`(?:${SZ.source}?(?:\\[(${wZ.source})\\])?)?`,VR=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,kZ=RegExp(`${VR.source}${uAe}`),qR=RegExp(`(?:[Tt]${kZ.source})?`),dAe=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,hAe=/(\d{4})-?W(\d\d)(?:-?(\d))?/,fAe=/(\d{4})-?(\d{3})/,pAe=_Z("weekYear","weekNumber","weekDay"),mAe=_Z("year","ordinal"),gAe=/(\d{4})-(\d\d)-(\d\d)/,CZ=RegExp(`${VR.source} ?(?:${SZ.source}|(${wZ.source}))?`),xAe=RegExp(`(?: ${CZ.source})?`);function vh(e,t,n){const r=e[t];return ft(r)?n:$l(r)}function vAe(e,t){return[{year:vh(e,t),month:vh(e,t+1,1),day:vh(e,t+2,1)},null,t+3]}function Pf(e,t){return[{hours:vh(e,t,0),minutes:vh(e,t+1,0),seconds:vh(e,t+2,0),milliseconds:UR(e[t+3])},null,t+4]}function Ex(e,t){const n=!e[t]&&!e[t+1],r=x_(e[t+1],e[t+2]),s=n?null:ns.instance(r);return[{},s,t+3]}function Ix(e,t){const n=e[t]?fa.create(e[t]):null;return[{},n,t+1]}const yAe=RegExp(`^T?${VR.source}$`),bAe=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function wAe(e){const[t,n,r,s,i,o,l,c,u]=e,d=t[0]==="-",h=c&&c[0]==="-",f=(m,g=!1)=>m!==void 0&&(g||m&&d)?-m:m;return[{years:f(Lc(n)),months:f(Lc(r)),weeks:f(Lc(s)),days:f(Lc(i)),hours:f(Lc(o)),minutes:f(Lc(l)),seconds:f(Lc(c),c==="-0"),milliseconds:f(UR(u),h)}]}const _Ae={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function KR(e,t,n,r,s,i,o){const l={year:t.length===2?SE($l(t)):$l(t),month:pZ.indexOf(n)+1,day:$l(r),hour:$l(s),minute:$l(i)};return o&&(l.second=$l(o)),e&&(l.weekday=e.length>3?gZ.indexOf(e)+1:xZ.indexOf(e)+1),l}const SAe=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function kAe(e){const[,t,n,r,s,i,o,l,c,u,d,h]=e,f=KR(t,s,r,n,i,o,l);let m;return c?m=_Ae[c]:u?m=0:m=x_(d,h),[f,new ns(m)]}function CAe(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const NAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,jAe=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,EAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function SL(e){const[,t,n,r,s,i,o,l]=e;return[KR(t,s,r,n,i,o,l),ns.utcInstance]}function IAe(e){const[,t,n,r,s,i,o,l]=e;return[KR(t,l,n,r,s,i,o),ns.utcInstance]}const TAe=Tf(dAe,qR),RAe=Tf(hAe,qR),MAe=Tf(fAe,qR),PAe=Tf(kZ),NZ=Rf(vAe,Pf,Ex,Ix),OAe=Rf(pAe,Pf,Ex,Ix),DAe=Rf(mAe,Pf,Ex,Ix),AAe=Rf(Pf,Ex,Ix);function $Ae(e){return Mf(e,[TAe,NZ],[RAe,OAe],[MAe,DAe],[PAe,AAe])}function LAe(e){return Mf(CAe(e),[SAe,kAe])}function BAe(e){return Mf(e,[NAe,SL],[jAe,SL],[EAe,IAe])}function FAe(e){return Mf(e,[bAe,wAe])}const zAe=Rf(Pf);function HAe(e){return Mf(e,[yAe,zAe])}const UAe=Tf(gAe,xAe),WAe=Tf(CZ),VAe=Rf(Pf,Ex,Ix);function qAe(e){return Mf(e,[UAe,NZ],[WAe,VAe])}const kL="Invalid Duration",jZ={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},KAe={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...jZ},ki=146097/400,kd=146097/4800,GAe={years:{quarters:4,months:12,weeks:ki/7,days:ki,hours:ki*24,minutes:ki*24*60,seconds:ki*24*60*60,milliseconds:ki*24*60*60*1e3},quarters:{months:3,weeks:ki/28,days:ki/4,hours:ki*24/4,minutes:ki*24*60/4,seconds:ki*24*60*60/4,milliseconds:ki*24*60*60*1e3/4},months:{weeks:kd/7,days:kd,hours:kd*24,minutes:kd*24*60,seconds:kd*24*60*60,milliseconds:kd*24*60*60*1e3},...jZ},nu=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],YAe=nu.slice(0).reverse();function Ea(e,t,n=!1){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new Wt(r)}function EZ(e,t){var n;let r=(n=t.milliseconds)!=null?n:0;for(const s of YAe.slice(1))t[s]&&(r+=t[s]*e[s].milliseconds);return r}function CL(e,t){const n=EZ(e,t)<0?-1:1;nu.reduceRight((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]*n,o=e[s][r],l=Math.floor(i/o);t[s]+=l*n,t[r]-=l*o*n}return s},null),nu.reduce((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]%1;t[r]-=i,t[s]+=i*e[r][s]}return s},null)}function NL(e){const t={};for(const[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}class Wt{constructor(t){const n=t.conversionAccuracy==="longterm"||!1;let r=n?GAe:KAe;t.matrix&&(r=t.matrix),this.values=t.values,this.loc=t.loc||en.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=t.invalid||null,this.matrix=r,this.isLuxonDuration=!0}static fromMillis(t,n){return Wt.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(t==null||typeof t!="object")throw new Xr(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new Wt({values:u1(t,Wt.normalizeUnit),loc:en.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(ic(t))return Wt.fromMillis(t);if(Wt.isDuration(t))return t;if(typeof t=="object")return Wt.fromObject(t);throw new Xr(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){const[r]=FAe(t);return r?Wt.fromObject(r,n):Wt.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){const[r]=HAe(t);return r?Wt.fromObject(r,n):Wt.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new Xr("need to specify a reason the Duration is invalid");const r=t instanceof go?t:new go(t,n);if(Bn.throwOnInvalid)throw new _De(r);return new Wt({invalid:r})}static normalizeUnit(t){const n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[t&&t.toLowerCase()];if(!n)throw new DX(t);return n}static isDuration(t){return t&&t.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(t,n={}){const r={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?Jr.create(this.loc,r).formatDurationFromString(this,t):kL}toHuman(t={}){if(!this.isValid)return kL;const n=t.showZeros!==!1,r=nu.map(s=>{const i=this.values[s];return ft(i)||i===0&&!n?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...t,unit:s.slice(0,-1)}).format(i)}).filter(s=>s);return this.loc.listFormatter({type:"conjunction",style:t.listStyle||"narrow",...t}).format(r)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let t="P";return this.years!==0&&(t+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(t+=this.months+this.quarters*3+"M"),this.weeks!==0&&(t+=this.weeks+"W"),this.days!==0&&(t+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(t+="T"),this.hours!==0&&(t+=this.hours+"H"),this.minutes!==0&&(t+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(t+=WR(this.seconds+this.milliseconds/1e3,3)+"S"),t==="P"&&(t+="T0S"),t}toISOTime(t={}){if(!this.isValid)return null;const n=this.toMillis();return n<0||n>=864e5?null:(t={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...t,includeOffset:!1},xt.fromMillis(n,{zone:"UTC"}).toISOTime(t))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?EZ(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t),r={};for(const s of nu)(Zh(n.values,s)||Zh(this.values,s))&&(r[s]=n.get(s)+this.get(s));return Ea(this,{values:r},!0)}minus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t);return this.plus(n.negate())}mapUnits(t){if(!this.isValid)return this;const n={};for(const r of Object.keys(this.values))n[r]=fZ(t(this.values[r],r));return Ea(this,{values:n},!0)}get(t){return this[Wt.normalizeUnit(t)]}set(t){if(!this.isValid)return this;const n={...this.values,...u1(t,Wt.normalizeUnit)};return Ea(this,{values:n})}reconfigure({locale:t,numberingSystem:n,conversionAccuracy:r,matrix:s}={}){const o={loc:this.loc.clone({locale:t,numberingSystem:n}),matrix:s,conversionAccuracy:r};return Ea(this,o)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;const t=this.toObject();return CL(this.matrix,t),Ea(this,{values:t},!0)}rescale(){if(!this.isValid)return this;const t=NL(this.normalize().shiftToAll().toObject());return Ea(this,{values:t},!0)}shiftTo(...t){if(!this.isValid)return this;if(t.length===0)return this;t=t.map(o=>Wt.normalizeUnit(o));const n={},r={},s=this.toObject();let i;for(const o of nu)if(t.indexOf(o)>=0){i=o;let l=0;for(const u in r)l+=this.matrix[u][o]*r[u],r[u]=0;ic(s[o])&&(l+=s[o]);const c=Math.trunc(l);n[o]=c,r[o]=(l*1e3-c*1e3)/1e3}else ic(s[o])&&(r[o]=s[o]);for(const o in r)r[o]!==0&&(n[i]+=o===i?r[o]:r[o]/this.matrix[i][o]);return CL(this.matrix,n),Ea(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values))t[n]=this.values[n]===0?0:-this.values[n];return Ea(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;const t=NL(this.values);return Ea(this,{values:t},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(t){if(!this.isValid||!t.isValid||!this.loc.equals(t.loc))return!1;function n(r,s){return r===void 0||r===0?s===void 0||s===0:r===s}for(const r of nu)if(!n(this.values[r],t.values[r]))return!1;return!0}}const Cd="Invalid Interval";function XAe(e,t){return!e||!e.isValid?$n.invalid("missing or invalid start"):!t||!t.isValid?$n.invalid("missing or invalid end"):t<e?$n.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}class $n{constructor(t){this.s=t.start,this.e=t.end,this.invalid=t.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new Xr("need to specify a reason the Interval is invalid");const r=t instanceof go?t:new go(t,n);if(Bn.throwOnInvalid)throw new wDe(r);return new $n({invalid:r})}static fromDateTimes(t,n){const r=Ep(t),s=Ep(n),i=XAe(r,s);return i??new $n({start:r,end:s})}static after(t,n){const r=Wt.fromDurationLike(n),s=Ep(t);return $n.fromDateTimes(s,s.plus(r))}static before(t,n){const r=Wt.fromDurationLike(n),s=Ep(t);return $n.fromDateTimes(s.minus(r),s)}static fromISO(t,n){const[r,s]=(t||"").split("/",2);if(r&&s){let i,o;try{i=xt.fromISO(r,n),o=i.isValid}catch{o=!1}let l,c;try{l=xt.fromISO(s,n),c=l.isValid}catch{c=!1}if(o&&c)return $n.fromDateTimes(i,l);if(o){const u=Wt.fromISO(s,n);if(u.isValid)return $n.after(i,u)}else if(c){const u=Wt.fromISO(r,n);if(u.isValid)return $n.before(l,u)}}return $n.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(t){return t&&t.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(t="milliseconds"){return this.isValid?this.toDuration(t).get(t):NaN}count(t="milliseconds",n){if(!this.isValid)return NaN;const r=this.start.startOf(t,n);let s;return n!=null&&n.useLocaleWeeks?s=this.end.reconfigure({locale:r.locale}):s=this.end,s=s.startOf(t,n),Math.floor(s.diff(r,t).get(t))+(s.valueOf()!==this.end.valueOf())}hasSame(t){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,t):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(t){return this.isValid?this.s>t:!1}isBefore(t){return this.isValid?this.e<=t:!1}contains(t){return this.isValid?this.s<=t&&this.e>t:!1}set({start:t,end:n}={}){return this.isValid?$n.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];const n=t.map(Ep).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),r=[];let{s}=this,i=0;for(;s<this.e;){const o=n[i]||this.e,l=+o>+this.e?this.e:o;r.push($n.fromDateTimes(s,l)),s=l,i+=1}return r}splitBy(t){const n=Wt.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:r}=this,s=1,i;const o=[];for(;r<this.e;){const l=this.start.plus(n.mapUnits(c=>c*s));i=+l>+this.e?this.e:l,o.push($n.fromDateTimes(r,i)),r=i,s+=1}return o}divideEqually(t){return this.isValid?this.splitBy(this.length()/t).slice(0,t):[]}overlaps(t){return this.e>t.s&&this.s<t.e}abutsStart(t){return this.isValid?+this.e==+t.s:!1}abutsEnd(t){return this.isValid?+t.e==+this.s:!1}engulfs(t){return this.isValid?this.s<=t.s&&this.e>=t.e:!1}equals(t){return!this.isValid||!t.isValid?!1:this.s.equals(t.s)&&this.e.equals(t.e)}intersection(t){if(!this.isValid)return this;const n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:$n.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;const n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return $n.fromDateTimes(n,r)}static merge(t){const[n,r]=t.sort((s,i)=>s.s-i.s).reduce(([s,i],o)=>i?i.overlaps(o)||i.abutsStart(o)?[s,i.union(o)]:[s.concat([i]),o]:[s,o],[[],null]);return r&&n.push(r),n}static xor(t){let n=null,r=0;const s=[],i=t.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...i),l=o.sort((c,u)=>c.time-u.time);for(const c of l)r+=c.type==="s"?1:-1,r===1?n=c.time:(n&&+n!=+c.time&&s.push($n.fromDateTimes(n,c.time)),n=null);return $n.merge(s)}difference(...t){return $n.xor([this].concat(t)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Cd}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(t=a1,n={}){return this.isValid?Jr.create(this.s.loc.clone(n),t).formatInterval(this):Cd}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:Cd}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Cd}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:Cd}toFormat(t,{separator:n=" – "}={}){return this.isValid?`${this.s.toFormat(t)}${n}${this.e.toFormat(t)}`:Cd}toDuration(t,n){return this.isValid?this.e.diff(this.s,t,n):Wt.invalid(this.invalidReason)}mapEndpoints(t){return $n.fromDateTimes(t(this.s),t(this.e))}}class Yp{static hasDST(t=Bn.defaultZone){const n=xt.now().setZone(t).set({month:12});return!t.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(t){return fa.isValidZone(t)}static normalizeZone(t){return Fl(t,Bn.defaultZone)}static getStartOfWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getWeekendDays().slice()}static months(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t)}static monthsFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t,!0)}static weekdays(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return en.create(t).meridiems()}static eras(t="short",{locale:n=null}={}){return en.create(n,null,"gregory").eras(t)}static features(){return{relative:uZ(),localeWeek:dZ()}}}function jL(e,t){const n=s=>s.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(Wt.fromMillis(r).as("days"))}function ZAe(e,t,n){const r=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const d=jL(c,u);return(d-d%7)/7}],["days",jL]],s={},i=e;let o,l;for(const[c,u]of r)n.indexOf(c)>=0&&(o=c,s[c]=u(e,t),l=i.plus(s),l>t?(s[c]--,e=i.plus(s),e>t&&(l=e,s[c]--,e=i.plus(s))):e=l);return[e,s,l,o]}function QAe(e,t,n,r){let[s,i,o,l]=ZAe(e,t,n);const c=t-s,u=n.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<t&&(o=s.plus({[l]:1})),o!==s&&(i[l]=(i[l]||0)+c/(o-s)));const d=Wt.fromObject(i,r);return u.length>0?Wt.fromMillis(c,r).shiftTo(...u).plus(d):d}const JAe="missing Intl.DateTimeFormat.formatToParts support";function Zt(e,t=n=>n){return{regex:e,deser:([n])=>t(UDe(n))}}const e$e=" ",IZ=`[ ${e$e}]`,TZ=new RegExp(IZ,"g");function t$e(e){return e.replace(/\./g,"\\.?").replace(TZ,IZ)}function EL(e){return e.replace(/\./g,"").replace(TZ," ").toLowerCase()}function oo(e,t){return e===null?null:{regex:RegExp(e.map(t$e).join("|")),deser:([n])=>e.findIndex(r=>EL(n)===EL(r))+t}}function IL(e,t){return{regex:e,deser:([,n,r])=>x_(n,r),groups:t}}function w0(e){return{regex:e,deser:([t])=>t}}function n$e(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r$e(e,t){const n=io(t),r=io(t,"{2}"),s=io(t,"{3}"),i=io(t,"{4}"),o=io(t,"{6}"),l=io(t,"{1,2}"),c=io(t,"{1,3}"),u=io(t,"{1,6}"),d=io(t,"{1,9}"),h=io(t,"{2,4}"),f=io(t,"{4,6}"),m=b=>({regex:RegExp(n$e(b.val)),deser:([y])=>y,literal:!0}),x=(b=>{if(e.literal)return m(b);switch(b.val){case"G":return oo(t.eras("short"),0);case"GG":return oo(t.eras("long"),0);case"y":return Zt(u);case"yy":return Zt(h,SE);case"yyyy":return Zt(i);case"yyyyy":return Zt(f);case"yyyyyy":return Zt(o);case"M":return Zt(l);case"MM":return Zt(r);case"MMM":return oo(t.months("short",!0),1);case"MMMM":return oo(t.months("long",!0),1);case"L":return Zt(l);case"LL":return Zt(r);case"LLL":return oo(t.months("short",!1),1);case"LLLL":return oo(t.months("long",!1),1);case"d":return Zt(l);case"dd":return Zt(r);case"o":return Zt(c);case"ooo":return Zt(s);case"HH":return Zt(r);case"H":return Zt(l);case"hh":return Zt(r);case"h":return Zt(l);case"mm":return Zt(r);case"m":return Zt(l);case"q":return Zt(l);case"qq":return Zt(r);case"s":return Zt(l);case"ss":return Zt(r);case"S":return Zt(c);case"SSS":return Zt(s);case"u":return w0(d);case"uu":return w0(l);case"uuu":return Zt(n);case"a":return oo(t.meridiems(),0);case"kkkk":return Zt(i);case"kk":return Zt(h,SE);case"W":return Zt(l);case"WW":return Zt(r);case"E":case"c":return Zt(n);case"EEE":return oo(t.weekdays("short",!1),1);case"EEEE":return oo(t.weekdays("long",!1),1);case"ccc":return oo(t.weekdays("short",!0),1);case"cccc":return oo(t.weekdays("long",!0),1);case"Z":case"ZZ":return IL(new RegExp(`([+-]${l.source})(?::(${r.source}))?`),2);case"ZZZ":return IL(new RegExp(`([+-]${l.source})(${r.source})?`),2);case"z":return w0(/[a-z_+-/]{1,256}?/i);case" ":return w0(/[^\S\n\r]/);default:return m(b)}})(e)||{invalidReason:JAe};return x.token=e,x}const s$e={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function i$e(e,t,n){const{type:r,value:s}=e;if(r==="literal"){const c=/^\s+$/.test(s);return{literal:!c,val:c?" ":s}}const i=t[r];let o=r;r==="hour"&&(t.hour12!=null?o=t.hour12?"hour12":"hour24":t.hourCycle!=null?t.hourCycle==="h11"||t.hourCycle==="h12"?o="hour12":o="hour24":o=n.hour12?"hour12":"hour24");let l=s$e[o];if(typeof l=="object"&&(l=l[i]),l)return{literal:!1,val:l}}function o$e(e){return[`^${e.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,e]}function a$e(e,t,n){const r=e.match(t);if(r){const s={};let i=1;for(const o in n)if(Zh(n,o)){const l=n[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(s[l.token.val[0]]=l.deser(r.slice(i,i+c))),i+=c}return[r,s]}else return[r,{}]}function l$e(e){const t=i=>{switch(i){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let n=null,r;return ft(e.z)||(n=fa.create(e.z)),ft(e.Z)||(n||(n=new ns(e.Z)),r=e.Z),ft(e.q)||(e.M=(e.q-1)*3+1),ft(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),ft(e.u)||(e.S=UR(e.u)),[Object.keys(e).reduce((i,o)=>{const l=t(o);return l&&(i[l]=e[o]),i},{}),n,r]}let bC=null;function c$e(){return bC||(bC=xt.fromMillis(1555555555555)),bC}function u$e(e,t){if(e.literal)return e;const n=Jr.macroTokenToFormatOpts(e.val),r=OZ(n,t);return r==null||r.includes(void 0)?e:r}function RZ(e,t){return Array.prototype.concat(...e.map(n=>u$e(n,t)))}class MZ{constructor(t,n){if(this.locale=t,this.format=n,this.tokens=RZ(Jr.parseFormat(n),t),this.units=this.tokens.map(r=>r$e(r,t)),this.disqualifyingUnit=this.units.find(r=>r.invalidReason),!this.disqualifyingUnit){const[r,s]=o$e(this.units);this.regex=RegExp(r,"i"),this.handlers=s}}explainFromTokens(t){if(this.isValid){const[n,r]=a$e(t,this.regex,this.handlers),[s,i,o]=r?l$e(r):[null,null,void 0];if(Zh(r,"a")&&Zh(r,"H"))throw new eh("Can't include meridiem when specifying 24-hour format");return{input:t,tokens:this.tokens,regex:this.regex,rawMatches:n,matches:r,result:s,zone:i,specificOffset:o}}else return{input:t,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function PZ(e,t,n){return new MZ(e,n).explainFromTokens(t)}function d$e(e,t,n){const{result:r,zone:s,specificOffset:i,invalidReason:o}=PZ(e,t,n);return[r,s,i,o]}function OZ(e,t){if(!e)return null;const r=Jr.create(t,e).dtFormatter(c$e()),s=r.formatToParts(),i=r.resolvedOptions();return s.map(o=>i$e(o,e,i))}const wC="Invalid DateTime",TL=864e13;function Xp(e){return new go("unsupported zone",`the zone "${e.name}" is not supported`)}function _C(e){return e.weekData===null&&(e.weekData=l1(e.c)),e.weekData}function SC(e){return e.localWeekData===null&&(e.localWeekData=l1(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Bc(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new xt({...n,...t,old:n})}function DZ(e,t,n){let r=e-t*60*1e3;const s=n.offset(r);if(t===s)return[r,t];r-=(s-t)*60*1e3;const i=n.offset(r);return s===i?[r,s]:[e-Math.min(s,i)*60*1e3,Math.max(s,i)]}function _0(e,t){e+=t*60*1e3;const n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Cy(e,t,n){return DZ(g_(e),t,n)}function RL(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),s=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,i={...e.c,year:r,month:s,day:Math.min(e.c.day,c1(r,s))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=Wt.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),l=g_(i);let[c,u]=DZ(l,n,e.zone);return o!==0&&(c+=o,u=e.zone.offset(c)),{ts:c,o:u}}function Nd(e,t,n,r,s,i){const{setZone:o,zone:l}=n;if(e&&Object.keys(e).length!==0||t){const c=t||l,u=xt.fromObject(e,{...n,zone:c,specificOffset:i});return o?u:u.setZone(l)}else return xt.invalid(new go("unparsable",`the input "${s}" can't be parsed as ${r}`))}function S0(e,t,n=!0){return e.isValid?Jr.create(en.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function kC(e,t,n){const r=e.c.year>9999||e.c.year<0;let s="";if(r&&e.c.year>=0&&(s+="+"),s+=rr(e.c.year,r?6:4),n==="year")return s;if(t){if(s+="-",s+=rr(e.c.month),n==="month")return s;s+="-"}else if(s+=rr(e.c.month),n==="month")return s;return s+=rr(e.c.day),s}function ML(e,t,n,r,s,i,o){let l=!n||e.c.millisecond!==0||e.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=rr(e.c.hour),o==="hour")break;if(t){if(c+=":",c+=rr(e.c.minute),o==="minute")break;l&&(c+=":",c+=rr(e.c.second))}else{if(c+=rr(e.c.minute),o==="minute")break;l&&(c+=rr(e.c.second))}if(o==="second")break;l&&(!r||e.c.millisecond!==0)&&(c+=".",c+=rr(e.c.millisecond,3))}return s&&(e.isOffsetFixed&&e.offset===0&&!i?c+="Z":e.o<0?(c+="-",c+=rr(Math.trunc(-e.o/60)),c+=":",c+=rr(Math.trunc(-e.o%60))):(c+="+",c+=rr(Math.trunc(e.o/60)),c+=":",c+=rr(Math.trunc(e.o%60)))),i&&(c+="["+e.zone.ianaName+"]"),c}const AZ={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},h$e={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},f$e={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Ny=["year","month","day","hour","minute","second","millisecond"],p$e=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],m$e=["year","ordinal","hour","minute","second","millisecond"];function jy(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new DX(e);return t}function PL(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return jy(e)}}function g$e(e){if(Zp===void 0&&(Zp=Bn.now()),e.type!=="iana")return e.offset(Zp);const t=e.name;let n=kE.get(t);return n===void 0&&(n=e.offset(Zp),kE.set(t,n)),n}function OL(e,t){const n=Fl(t.zone,Bn.defaultZone);if(!n.isValid)return xt.invalid(Xp(n));const r=en.fromObject(t);let s,i;if(ft(e.year))s=Bn.now();else{for(const c of Ny)ft(e[c])&&(e[c]=AZ[c]);const o=lZ(e)||cZ(e);if(o)return xt.invalid(o);const l=g$e(n);[s,i]=Cy(e,l,n)}return new xt({ts:s,zone:n,loc:r,o:i})}function DL(e,t,n){const r=ft(n.round)?!0:n.round,s=ft(n.rounding)?"trunc":n.rounding,i=(l,c)=>(l=WR(l,r||n.calendary?0:2,n.calendary?"round":s),t.loc.clone(n).relFormatter(n).format(l,c)),o=l=>n.calendary?t.hasSame(e,l)?0:t.startOf(l).diff(e.startOf(l),l).get(l):t.diff(e,l).get(l);if(n.unit)return i(o(n.unit),n.unit);for(const l of n.units){const c=o(l);if(Math.abs(c)>=1)return i(c,l)}return i(e>t?-0:0,n.units[n.units.length-1])}function AL(e){let t={},n;return e.length>0&&typeof e[e.length-1]=="object"?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}let Zp;const kE=new Map;class xt{constructor(t){const n=t.zone||Bn.defaultZone;let r=t.invalid||(Number.isNaN(t.ts)?new go("invalid input"):null)||(n.isValid?null:Xp(n));this.ts=ft(t.ts)?Bn.now():t.ts;let s=null,i=null;if(!r)if(t.old&&t.old.ts===this.ts&&t.old.zone.equals(n))[s,i]=[t.old.c,t.old.o];else{const l=ic(t.o)&&!t.old?t.o:n.offset(this.ts);s=_0(this.ts,l),r=Number.isNaN(s.year)?new go("invalid input"):null,s=r?null:s,i=r?null:l}this._zone=n,this.loc=t.loc||en.create(),this.invalid=r,this.weekData=null,this.localWeekData=null,this.c=s,this.o=i,this.isLuxonDateTime=!0}static now(){return new xt({})}static local(){const[t,n]=AL(arguments),[r,s,i,o,l,c,u]=n;return OL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static utc(){const[t,n]=AL(arguments),[r,s,i,o,l,c,u]=n;return t.zone=ns.utcInstance,OL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static fromJSDate(t,n={}){const r=GDe(t)?t.valueOf():NaN;if(Number.isNaN(r))return xt.invalid("invalid input");const s=Fl(n.zone,Bn.defaultZone);return s.isValid?new xt({ts:r,zone:s,loc:en.fromObject(n)}):xt.invalid(Xp(s))}static fromMillis(t,n={}){if(ic(t))return t<-TL||t>TL?xt.invalid("Timestamp out of range"):new xt({ts:t,zone:Fl(n.zone,Bn.defaultZone),loc:en.fromObject(n)});throw new Xr(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(ic(t))return new xt({ts:t*1e3,zone:Fl(n.zone,Bn.defaultZone),loc:en.fromObject(n)});throw new Xr("fromSeconds requires a numerical input")}static fromObject(t,n={}){t=t||{};const r=Fl(n.zone,Bn.defaultZone);if(!r.isValid)return xt.invalid(Xp(r));const s=en.fromObject(n),i=u1(t,PL),{minDaysInFirstWeek:o,startOfWeek:l}=yL(i,s),c=Bn.now(),u=ft(n.specificOffset)?r.offset(c):n.specificOffset,d=!ft(i.ordinal),h=!ft(i.year),f=!ft(i.month)||!ft(i.day),m=h||f,g=i.weekYear||i.weekNumber;if((m||d)&&g)throw new eh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(f&&d)throw new eh("Can't mix ordinal dates with month/day");const x=g||i.weekday&&!m;let b,y,v=_0(c,u);x?(b=p$e,y=h$e,v=l1(v,o,l)):d?(b=m$e,y=f$e,v=yC(v)):(b=Ny,y=AZ);let w=!1;for(const E of b){const I=i[E];ft(I)?w?i[E]=y[E]:i[E]=v[E]:w=!0}const _=x?VDe(i,o,l):d?qDe(i):lZ(i),S=_||cZ(i);if(S)return xt.invalid(S);const k=x?xL(i,o,l):d?vL(i):i,[N,j]=Cy(k,u,r),R=new xt({ts:N,zone:r,o:j,loc:s});return i.weekday&&m&&t.weekday!==R.weekday?xt.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${R.toISO()}`):R.isValid?R:xt.invalid(R.invalid)}static fromISO(t,n={}){const[r,s]=$Ae(t);return Nd(r,s,n,"ISO 8601",t)}static fromRFC2822(t,n={}){const[r,s]=LAe(t);return Nd(r,s,n,"RFC 2822",t)}static fromHTTP(t,n={}){const[r,s]=BAe(t);return Nd(r,s,n,"HTTP",n)}static fromFormat(t,n,r={}){if(ft(t)||ft(n))throw new Xr("fromFormat requires an input string and a format");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0}),[l,c,u,d]=d$e(o,t,n);return d?xt.invalid(d):Nd(l,c,r,`format ${n}`,t,u)}static fromString(t,n,r={}){return xt.fromFormat(t,n,r)}static fromSQL(t,n={}){const[r,s]=qAe(t);return Nd(r,s,n,"SQL",t)}static invalid(t,n=null){if(!t)throw new Xr("need to specify a reason the DateTime is invalid");const r=t instanceof go?t:new go(t,n);if(Bn.throwOnInvalid)throw new bDe(r);return new xt({invalid:r})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,n={}){const r=OZ(t,en.fromObject(n));return r?r.map(s=>s?s.val:null).join(""):null}static expandFormat(t,n={}){return RZ(Jr.parseFormat(t),en.fromObject(n)).map(s=>s.val).join("")}static resetCache(){Zp=void 0,kE.clear()}get(t){return this[t]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?_C(this).weekYear:NaN}get weekNumber(){return this.isValid?_C(this).weekNumber:NaN}get weekday(){return this.isValid?_C(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?SC(this).weekday:NaN}get localWeekNumber(){return this.isValid?SC(this).weekNumber:NaN}get localWeekYear(){return this.isValid?SC(this).weekYear:NaN}get ordinal(){return this.isValid?yC(this.c).ordinal:NaN}get monthShort(){return this.isValid?Yp.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Yp.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Yp.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Yp.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const t=864e5,n=6e4,r=g_(this.c),s=this.zone.offset(r-t),i=this.zone.offset(r+t),o=this.zone.offset(r-s*n),l=this.zone.offset(r-i*n);if(o===l)return[this];const c=r-o*n,u=r-l*n,d=_0(c,o),h=_0(u,l);return d.hour===h.hour&&d.minute===h.minute&&d.second===h.second&&d.millisecond===h.millisecond?[Bc(this,{ts:c}),Bc(this,{ts:u})]:[this]}get isInLeapYear(){return jx(this.year)}get daysInMonth(){return c1(this.year,this.month)}get daysInYear(){return this.isValid?xh(this.year):NaN}get weeksInWeekYear(){return this.isValid?Eg(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Eg(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){const{locale:n,numberingSystem:r,calendar:s}=Jr.create(this.loc.clone(t),t).resolvedOptions(this);return{locale:n,numberingSystem:r,outputCalendar:s}}toUTC(t=0,n={}){return this.setZone(ns.instance(t),n)}toLocal(){return this.setZone(Bn.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=Fl(t,Bn.defaultZone),t.equals(this.zone))return this;if(t.isValid){let s=this.ts;if(n||r){const i=t.offset(this.ts),o=this.toObject();[s]=Cy(o,i,t)}return Bc(this,{ts:s,zone:t})}else return xt.invalid(Xp(t))}reconfigure({locale:t,numberingSystem:n,outputCalendar:r}={}){const s=this.loc.clone({locale:t,numberingSystem:n,outputCalendar:r});return Bc(this,{loc:s})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;const n=u1(t,PL),{minDaysInFirstWeek:r,startOfWeek:s}=yL(n,this.loc),i=!ft(n.weekYear)||!ft(n.weekNumber)||!ft(n.weekday),o=!ft(n.ordinal),l=!ft(n.year),c=!ft(n.month)||!ft(n.day),u=l||c,d=n.weekYear||n.weekNumber;if((u||o)&&d)throw new eh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new eh("Can't mix ordinal dates with month/day");let h;i?h=xL({...l1(this.c,r,s),...n},r,s):ft(n.ordinal)?(h={...this.toObject(),...n},ft(n.day)&&(h.day=Math.min(c1(h.year,h.month),h.day))):h=vL({...yC(this.c),...n});const[f,m]=Cy(h,this.o,this.zone);return Bc(this,{ts:f,o:m})}plus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t);return Bc(this,RL(this,n))}minus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t).negate();return Bc(this,RL(this,n))}startOf(t,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;const r={},s=Wt.normalizeUnit(t);switch(s){case"years":r.month=1;case"quarters":case"months":r.day=1;case"weeks":case"days":r.hour=0;case"hours":r.minute=0;case"minutes":r.second=0;case"seconds":r.millisecond=0;break}if(s==="weeks")if(n){const i=this.loc.getStartOfWeek(),{weekday:o}=this;o<i&&(r.weekNumber=this.weekNumber-1),r.weekday=i}else r.weekday=1;if(s==="quarters"){const i=Math.ceil(this.month/3);r.month=(i-1)*3+1}return this.set(r)}endOf(t,n){return this.isValid?this.plus({[t]:1}).startOf(t,n).minus(1):this}toFormat(t,n={}){return this.isValid?Jr.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,t):wC}toLocaleString(t=a1,n={}){return this.isValid?Jr.create(this.loc.clone(n),t).formatDateTime(this):wC}toLocaleParts(t={}){return this.isValid?Jr.create(this.loc.clone(t),t).formatDateTimeParts(this):[]}toISO({format:t="extended",suppressSeconds:n=!1,suppressMilliseconds:r=!1,includeOffset:s=!0,extendedZone:i=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=jy(o);const l=t==="extended";let c=kC(this,l,o);return Ny.indexOf(o)>=3&&(c+="T"),c+=ML(this,l,n,r,s,i,o),c}toISODate({format:t="extended",precision:n="day"}={}){return this.isValid?kC(this,t==="extended",jy(n)):null}toISOWeekDate(){return S0(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:t=!1,suppressSeconds:n=!1,includeOffset:r=!0,includePrefix:s=!1,extendedZone:i=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=jy(l),(s&&Ny.indexOf(l)>=3?"T":"")+ML(this,o==="extended",n,t,r,i,l)):null}toRFC2822(){return S0(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return S0(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?kC(this,!0):null}toSQLTime({includeOffset:t=!0,includeZone:n=!1,includeOffsetSpace:r=!0}={}){let s="HH:mm:ss.SSS";return(n||t)&&(r&&(s+=" "),n?s+="z":t&&(s+="ZZ")),S0(this,s,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():wC}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(t={}){if(!this.isValid)return{};const n={...this.c};return t.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(t,n="milliseconds",r={}){if(!this.isValid||!t.isValid)return Wt.invalid("created by diffing an invalid DateTime");const s={locale:this.locale,numberingSystem:this.numberingSystem,...r},i=YDe(n).map(Wt.normalizeUnit),o=t.valueOf()>this.valueOf(),l=o?this:t,c=o?t:this,u=QAe(l,c,i,s);return o?u.negate():u}diffNow(t="milliseconds",n={}){return this.diff(xt.now(),t,n)}until(t){return this.isValid?$n.fromDateTimes(this,t):this}hasSame(t,n,r){if(!this.isValid)return!1;const s=t.valueOf(),i=this.setZone(t.zone,{keepLocalTime:!0});return i.startOf(n,r)<=s&&s<=i.endOf(n,r)}equals(t){return this.isValid&&t.isValid&&this.valueOf()===t.valueOf()&&this.zone.equals(t.zone)&&this.loc.equals(t.loc)}toRelative(t={}){if(!this.isValid)return null;const n=t.base||xt.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0;let s=["years","months","days","hours","minutes","seconds"],i=t.unit;return Array.isArray(t.unit)&&(s=t.unit,i=void 0),DL(n,this.plus(r),{...t,numeric:"always",units:s,unit:i})}toRelativeCalendar(t={}){return this.isValid?DL(t.base||xt.fromObject({},{zone:this.zone}),this,{...t,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...t){if(!t.every(xt.isDateTime))throw new Xr("min requires all arguments be DateTimes");return bL(t,n=>n.valueOf(),Math.min)}static max(...t){if(!t.every(xt.isDateTime))throw new Xr("max requires all arguments be DateTimes");return bL(t,n=>n.valueOf(),Math.max)}static fromFormatExplain(t,n,r={}){const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});return PZ(o,t,n)}static fromStringExplain(t,n,r={}){return xt.fromFormatExplain(t,n,r)}static buildFormatParser(t,n={}){const{locale:r=null,numberingSystem:s=null}=n,i=en.fromOpts({locale:r,numberingSystem:s,defaultToEN:!0});return new MZ(i,t)}static fromFormatParser(t,n,r={}){if(ft(t)||ft(n))throw new Xr("fromFormatParser requires an input string and a format parser");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});if(!o.equals(n.locale))throw new Xr(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:d}=n.explainFromTokens(t);return d?xt.invalid(d):Nd(l,c,r,`format ${n.format}`,t,u)}static get DATE_SHORT(){return a1}static get DATE_MED(){return AX}static get DATE_MED_WITH_WEEKDAY(){return SDe}static get DATE_FULL(){return $X}static get DATE_HUGE(){return LX}static get TIME_SIMPLE(){return BX}static get TIME_WITH_SECONDS(){return FX}static get TIME_WITH_SHORT_OFFSET(){return zX}static get TIME_WITH_LONG_OFFSET(){return HX}static get TIME_24_SIMPLE(){return UX}static get TIME_24_WITH_SECONDS(){return WX}static get TIME_24_WITH_SHORT_OFFSET(){return VX}static get TIME_24_WITH_LONG_OFFSET(){return qX}static get DATETIME_SHORT(){return KX}static get DATETIME_SHORT_WITH_SECONDS(){return GX}static get DATETIME_MED(){return YX}static get DATETIME_MED_WITH_SECONDS(){return XX}static get DATETIME_MED_WITH_WEEKDAY(){return kDe}static get DATETIME_FULL(){return ZX}static get DATETIME_FULL_WITH_SECONDS(){return QX}static get DATETIME_HUGE(){return JX}static get DATETIME_HUGE_WITH_SECONDS(){return eZ}}function Ep(e){if(xt.isDateTime(e))return e;if(e&&e.valueOf&&ic(e.valueOf()))return xt.fromJSDate(e);if(e&&typeof e=="object")return xt.fromObject(e);throw new Xr(`Unknown datetime argument: ${e}, of type ${typeof e}`)}const x$e="3.7.2";xi.DateTime=xt;xi.Duration=Wt;xi.FixedOffsetZone=ns;xi.IANAZone=fa;xi.Info=Yp;xi.Interval=$n;xi.InvalidZone=rZ;xi.Settings=Bn;xi.SystemZone=Nx;xi.VERSION=x$e;xi.Zone=If;var Fc=xi;vt.prototype.addYear=function(){this._date=this._date.plus({years:1})};vt.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};vt.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};vt.prototype.addHour=function(){var e=this._date;this._date=this._date.plus({hours:1}).startOf("hour"),this._date<=e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addMinute=function(){var e=this._date;this._date=this._date.plus({minutes:1}).startOf("minute"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addSecond=function(){var e=this._date;this._date=this._date.plus({seconds:1}).startOf("second"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};vt.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};vt.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};vt.prototype.subtractHour=function(){var e=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second"),this._date>=e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractMinute=function(){var e=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractSecond=function(){var e=this._date;this._date=this._date.minus({seconds:1}).startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.getDate=function(){return this._date.day};vt.prototype.getFullYear=function(){return this._date.year};vt.prototype.getDay=function(){var e=this._date.weekday;return e==7?0:e};vt.prototype.getMonth=function(){return this._date.month-1};vt.prototype.getHours=function(){return this._date.hour};vt.prototype.getMinutes=function(){return this._date.minute};vt.prototype.getSeconds=function(){return this._date.second};vt.prototype.getMilliseconds=function(){return this._date.millisecond};vt.prototype.getTime=function(){return this._date.valueOf()};vt.prototype.getUTCDate=function(){return this._getUTC().day};vt.prototype.getUTCFullYear=function(){return this._getUTC().year};vt.prototype.getUTCDay=function(){var e=this._getUTC().weekday;return e==7?0:e};vt.prototype.getUTCMonth=function(){return this._getUTC().month-1};vt.prototype.getUTCHours=function(){return this._getUTC().hour};vt.prototype.getUTCMinutes=function(){return this._getUTC().minute};vt.prototype.getUTCSeconds=function(){return this._getUTC().second};vt.prototype.toISOString=function(){return this._date.toUTC().toISO()};vt.prototype.toJSON=function(){return this._date.toJSON()};vt.prototype.setDate=function(e){this._date=this._date.set({day:e})};vt.prototype.setFullYear=function(e){this._date=this._date.set({year:e})};vt.prototype.setDay=function(e){this._date=this._date.set({weekday:e})};vt.prototype.setMonth=function(e){this._date=this._date.set({month:e+1})};vt.prototype.setHours=function(e){this._date=this._date.set({hour:e})};vt.prototype.setMinutes=function(e){this._date=this._date.set({minute:e})};vt.prototype.setSeconds=function(e){this._date=this._date.set({second:e})};vt.prototype.setMilliseconds=function(e){this._date=this._date.set({millisecond:e})};vt.prototype._getUTC=function(){return this._date.toUTC()};vt.prototype.toString=function(){return this.toDate().toString()};vt.prototype.toDate=function(){return this._date.toJSDate()};vt.prototype.isLastDayOfMonth=function(){var e=this._date.plus({days:1}).startOf("day");return this._date.month!==e.month};vt.prototype.isLastWeekdayOfMonth=function(){var e=this._date.plus({days:7}).startOf("day");return this._date.month!==e.month};function vt(e,t){var n={zone:t};if(e?e instanceof vt?this._date=e._date:e instanceof Date?this._date=Fc.DateTime.fromJSDate(e,n):typeof e=="number"?this._date=Fc.DateTime.fromMillis(e,n):typeof e=="string"&&(this._date=Fc.DateTime.fromISO(e,n),this._date.isValid||(this._date=Fc.DateTime.fromRFC2822(e,n)),this._date.isValid||(this._date=Fc.DateTime.fromSQL(e,n)),this._date.isValid||(this._date=Fc.DateTime.fromFormat(e,"EEE, d MMM yyyy HH:mm:ss",n))):this._date=Fc.DateTime.local(),!this._date||!this._date.isValid)throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(e));t&&t!==this._date.zoneName&&(this._date=this._date.setZone(t))}var v$e=vt;function Xc(e){return{start:e,count:1}}function $L(e,t){e.end=t,e.step=t-e.start,e.count=2}function CC(e,t,n){t&&(t.count===2?(e.push(Xc(t.start)),e.push(Xc(t.end))):e.push(t)),n&&e.push(n)}function y$e(e){for(var t=[],n=void 0,r=0;r<e.length;r++){var s=e[r];typeof s!="number"?(CC(t,n,Xc(s)),n=void 0):n?n.count===1?$L(n,s):n.step===s-n.end?(n.count++,n.end=s):n.count===2?(t.push(Xc(n.start)),n=Xc(n.end),$L(n,s)):(CC(t,n),n=Xc(s)):n=Xc(s)}return CC(t,n),t}var b$e=y$e,w$e=b$e;function _$e(e,t,n){var r=w$e(e);if(r.length===1){var s=r[0],i=s.step;if(i===1&&s.start===t&&s.end===n)return"*";if(i!==1&&s.start===t&&s.end===n-i+1)return"*/"+i}for(var o=[],l=0,c=r.length;l<c;++l){var u=r[l];if(u.count===1){o.push(u.start);continue}var i=u.step;if(u.step===1){o.push(u.start+"-"+u.end);continue}var d=u.start==0?u.count-1:u.count;u.step*d>u.end?o=o.concat(Array.from({length:u.end-u.start+1}).map(function(f,m){var g=u.start+m;return(g-u.start)%u.step===0?g:null}).filter(function(f){return f!=null})):u.end===n-u.step+1?o.push(u.start+"/"+u.step):o.push(u.start+"-"+u.end+"/"+u.step)}return o.join(",")}var S$e=_$e,au=v$e,k$e=S$e,LL=1e4;function Be(e,t){this._options=t,this._utc=t.utc||!1,this._tz=this._utc?"UTC":t.tz,this._currentDate=new au(t.currentDate,this._tz),this._startDate=t.startDate?new au(t.startDate,this._tz):null,this._endDate=t.endDate?new au(t.endDate,this._tz):null,this._isIterator=t.iterator||!1,this._hasIterated=!1,this._nthDayOfWeek=t.nthDayOfWeek||0,this.fields=Be._freezeFields(e)}Be.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];Be.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};Be.constraints=[{min:0,max:59,chars:[]},{min:0,max:59,chars:[]},{min:0,max:23,chars:[]},{min:1,max:31,chars:["L"]},{min:1,max:12,chars:[]},{min:0,max:7,chars:["L"]}];Be.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];Be.aliases={month:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dayOfWeek:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}};Be.parseDefaults=["0","*","*","*","*","*"];Be.standardValidCharacters=/^[,*\d/-]+$/;Be.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;Be.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;Be.validCharacters={second:Be.standardValidCharacters,minute:Be.standardValidCharacters,hour:Be.standardValidCharacters,dayOfMonth:Be.dayOfMonthValidCharacters,month:Be.standardValidCharacters,dayOfWeek:Be.dayOfWeekValidCharacters};Be._isValidConstraintChar=function(t,n){return typeof n!="string"?!1:t.chars.some(function(r){return n.indexOf(r)>-1})};Be._parseField=function(t,n,r){switch(t){case"month":case"dayOfWeek":var s=Be.aliases[t];n=n.replace(/[a-z]{3}/gi,function(c){if(c=c.toLowerCase(),typeof s[c]<"u")return s[c];throw new Error('Validation error, cannot resolve alias "'+c+'"')});break}if(!Be.validCharacters[t].test(n))throw new Error("Invalid characters, got value: "+n);n.indexOf("*")!==-1?n=n.replace(/\*/g,r.min+"-"+r.max):n.indexOf("?")!==-1&&(n=n.replace(/\?/g,r.min+"-"+r.max));function i(c){var u=[];function d(g){if(g instanceof Array)for(var x=0,b=g.length;x<b;x++){var y=g[x];if(Be._isValidConstraintChar(r,y)){u.push(y);continue}if(typeof y!="number"||Number.isNaN(y)||y<r.min||y>r.max)throw new Error("Constraint error, got value "+y+" expected range "+r.min+"-"+r.max);u.push(y)}else{if(Be._isValidConstraintChar(r,g)){u.push(g);return}var v=+g;if(Number.isNaN(v)||v<r.min||v>r.max)throw new Error("Constraint error, got value "+g+" expected range "+r.min+"-"+r.max);t==="dayOfWeek"&&(v=v%7),u.push(v)}}var h=c.split(",");if(!h.every(function(g){return g.length>0}))throw new Error("Invalid list value format");if(h.length>1)for(var f=0,m=h.length;f<m;f++)d(o(h[f]));else d(o(c));return u.sort(Be._sortCompareFn),u}function o(c){var u=1,d=c.split("/");if(d.length>2)throw new Error("Invalid repeat: "+c);return d.length>1?(d[0]==+d[0]&&(d=[d[0]+"-"+r.max,d[1]]),l(d[0],d[d.length-1])):l(c,u)}function l(c,u){var d=[],h=c.split("-");if(h.length>1){if(h.length<2)return+c;if(!h[0].length){if(!h[1].length)throw new Error("Invalid range: "+c);return+c}var f=+h[0],m=+h[1];if(Number.isNaN(f)||Number.isNaN(m)||f<r.min||m>r.max)throw new Error("Constraint error, got range "+f+"-"+m+" expected range "+r.min+"-"+r.max);if(f>m)throw new Error("Invalid range: "+c);var g=+u;if(Number.isNaN(g)||g<=0)throw new Error("Constraint error, cannot repeat at every "+g+" time.");t==="dayOfWeek"&&m%7===0&&d.push(0);for(var x=f,b=m;x<=b;x++){var y=d.indexOf(x)!==-1;!y&&g>0&&g%u===0?(g=1,d.push(x)):g++}return d}return Number.isNaN(+c)?c:+c}return i(n)};Be._sortCompareFn=function(e,t){var n=typeof e=="number",r=typeof t=="number";return n&&r?e-t:!n&&r?1:n&&!r?-1:e.localeCompare(t)};Be._handleMaxDaysInMonth=function(e){if(e.month.length===1){var t=Be.daysInMonth[e.month[0]-1];if(e.dayOfMonth[0]>t)throw new Error("Invalid explicit day of month definition");return e.dayOfMonth.filter(function(n){return n==="L"?!0:n<=t}).sort(Be._sortCompareFn)}};Be._freezeFields=function(e){for(var t=0,n=Be.map.length;t<n;++t){var r=Be.map[t],s=e[r];e[r]=Object.freeze(s)}return Object.freeze(e)};Be.prototype._applyTimezoneShift=function(e,t,n){if(n==="Month"||n==="Day"){var r=e.getTime();e[t+n]();var s=e.getTime();r===s&&(e.getMinutes()===0&&e.getSeconds()===0?e.addHour():e.getMinutes()===59&&e.getSeconds()===59&&e.subtractHour())}else{var i=e.getHours();e[t+n]();var o=e.getHours(),l=o-i;l===2?this.fields.hour.length!==24&&(this._dstStart=o):l===0&&e.getMinutes()===0&&e.getSeconds()===0&&this.fields.hour.length!==24&&(this._dstEnd=o)}};Be.prototype._findSchedule=function(t){function n(y,v){for(var w=0,_=v.length;w<_;w++)if(v[w]>=y)return v[w]===y;return v[0]===y}function r(y,v){if(v<6){if(y.getDate()<8&&v===1)return!0;var w=y.getDate()%7?1:0,_=y.getDate()-y.getDate()%7,S=Math.floor(_/7)+w;return S===v}return!1}function s(y){return y.length>0&&y.some(function(v){return typeof v=="string"&&v.indexOf("L")>=0})}t=t||!1;var i=t?"subtract":"add",o=new au(this._currentDate,this._tz),l=this._startDate,c=this._endDate,u=o.getTime(),d=0;function h(y){return y.some(function(v){if(!s([v]))return!1;var w=Number.parseInt(v[0])%7;if(Number.isNaN(w))throw new Error("Invalid last weekday of the month expression: "+v);return o.getDay()===w&&o.isLastWeekdayOfMonth()})}for(;d<LL;){if(d++,t){if(l&&o.getTime()-l.getTime()<0)throw new Error("Out of the timespan range")}else if(c&&c.getTime()-o.getTime()<0)throw new Error("Out of the timespan range");var f=n(o.getDate(),this.fields.dayOfMonth);s(this.fields.dayOfMonth)&&(f=f||o.isLastDayOfMonth());var m=n(o.getDay(),this.fields.dayOfWeek);s(this.fields.dayOfWeek)&&(m=m||h(this.fields.dayOfWeek));var g=this.fields.dayOfMonth.length>=Be.daysInMonth[o.getMonth()],x=this.fields.dayOfWeek.length===Be.constraints[5].max-Be.constraints[5].min+1,b=o.getHours();if(!f&&(!m||x)){this._applyTimezoneShift(o,i,"Day");continue}if(!g&&x&&!f){this._applyTimezoneShift(o,i,"Day");continue}if(g&&!x&&!m){this._applyTimezoneShift(o,i,"Day");continue}if(this._nthDayOfWeek>0&&!r(o,this._nthDayOfWeek)){this._applyTimezoneShift(o,i,"Day");continue}if(!n(o.getMonth()+1,this.fields.month)){this._applyTimezoneShift(o,i,"Month");continue}if(n(b,this.fields.hour)){if(this._dstEnd===b&&!t){this._dstEnd=null,this._applyTimezoneShift(o,"add","Hour");continue}}else if(this._dstStart!==b){this._dstStart=null,this._applyTimezoneShift(o,i,"Hour");continue}else if(!n(b-1,this.fields.hour)){o[i+"Hour"]();continue}if(!n(o.getMinutes(),this.fields.minute)){this._applyTimezoneShift(o,i,"Minute");continue}if(!n(o.getSeconds(),this.fields.second)){this._applyTimezoneShift(o,i,"Second");continue}if(u===o.getTime()){i==="add"||o.getMilliseconds()===0?this._applyTimezoneShift(o,i,"Second"):o.setMilliseconds(0);continue}break}if(d>=LL)throw new Error("Invalid expression, loop limit exceeded");return this._currentDate=new au(o,this._tz),this._hasIterated=!0,o};Be.prototype.next=function(){var t=this._findSchedule();return this._isIterator?{value:t,done:!this.hasNext()}:t};Be.prototype.prev=function(){var t=this._findSchedule(!0);return this._isIterator?{value:t,done:!this.hasPrev()}:t};Be.prototype.hasNext=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.hasPrev=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(!0),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.iterate=function(t,n){var r=[];if(t>=0)for(var s=0,i=t;s<i;s++)try{var o=this.next();r.push(o),n&&n(o,s)}catch{break}else for(var s=0,i=t;s>i;s--)try{var o=this.prev();r.push(o),n&&n(o,s)}catch{break}return r};Be.prototype.reset=function(t){this._currentDate=new au(t||this._options.currentDate)};Be.prototype.stringify=function(t){for(var n=[],r=t?0:1,s=Be.map.length;r<s;++r){var i=Be.map[r],o=this.fields[i],l=Be.constraints[r];i==="dayOfMonth"&&this.fields.month.length===1?l={min:1,max:Be.daysInMonth[this.fields.month[0]-1]}:i==="dayOfWeek"&&(l={min:0,max:6},o=o[o.length-1]===7?o.slice(0,-1):o),n.push(k$e(o,l.min,l.max))}return n.join(" ")};Be.parse=function(t,n){var r=this;typeof n=="function"&&(n={});function s(i,o){o||(o={}),typeof o.currentDate>"u"&&(o.currentDate=new au(void 0,r._tz)),Be.predefined[i]&&(i=Be.predefined[i]);var l=[],c=(i+"").trim().split(/\s+/);if(c.length>6)throw new Error("Invalid cron expression");for(var u=Be.map.length-c.length,d=0,h=Be.map.length;d<h;++d){var f=Be.map[d],m=c[c.length>h?d:d-u];if(d<u||!m)l.push(Be._parseField(f,Be.parseDefaults[d],Be.constraints[d]));else{var g=f==="dayOfWeek"?v(m):m;l.push(Be._parseField(f,g,Be.constraints[d]))}}for(var x={},d=0,h=Be.map.length;d<h;d++){var b=Be.map[d];x[b]=l[d]}var y=Be._handleMaxDaysInMonth(x);return x.dayOfMonth=y||x.dayOfMonth,new Be(x,o);function v(w){var _=w.split("#");if(_.length>1){var S=+_[_.length-1];if(/,/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible");if(/\//.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible");if(/-/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible");if(_.length>2||Number.isNaN(S)||S<1||S>5)throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return o.nthDayOfWeek=S,_[0]}return w}}return s(t,n)};Be.fieldsToExpression=function(t,n){function r(f,m,g){if(!m)throw new Error("Validation error, Field "+f+" is missing");if(m.length===0)throw new Error("Validation error, Field "+f+" contains no values");for(var x=0,b=m.length;x<b;x++){var y=m[x];if(!Be._isValidConstraintChar(g,y)&&(typeof y!="number"||Number.isNaN(y)||y<g.min||y>g.max))throw new Error("Constraint error, got value "+y+" expected range "+g.min+"-"+g.max)}}for(var s={},i=0,o=Be.map.length;i<o;++i){var l=Be.map[i],c=t[l];r(l,c,Be.constraints[i]);for(var u=[],d=-1;++d<c.length;)u[d]=c[d];if(c=u.sort(Be._sortCompareFn).filter(function(f,m,g){return!m||f!==g[m-1]}),c.length!==u.length)throw new Error("Validation error, Field "+l+" contains duplicate values");s[l]=c}var h=Be._handleMaxDaysInMonth(s);return s.dayOfMonth=h||s.dayOfMonth,new Be(s,n||{})};var C$e=Be;const N$e={},j$e=Object.freeze(Object.defineProperty({__proto__:null,default:N$e},Symbol.toStringTag,{value:"Module"})),E$e=Rne(j$e);var d1=C$e;function fc(){}fc._parseEntry=function(t){var n=t.split(" ");if(n.length===6)return{interval:d1.parse(t)};if(n.length>6)return{interval:d1.parse(n.slice(0,6).join(" ")),command:n.slice(6,n.length)};throw new Error("Invalid entry: "+t)};fc.parseExpression=function(t,n){return d1.parse(t,n)};fc.fieldsToExpression=function(t,n){return d1.fieldsToExpression(t,n)};fc.parseString=function(t){for(var n=t.split(`
915
+ `)}function UPe(e){const t=e.prompt??"hello";if(!e.gatewayUrl)return a.jsxs(uC,{children:["中心还没配调用地址(",a.jsx("code",{className:"font-mono",children:"PERSONA_CLOUD_GATEWAY_URL"}),"), 这里就给不出能跑的命令。persona 已经在云上了,派活不受影响。"]});if(e.apiKey===void 0)return a.jsx(uC,{children:"正在读你的调用 key…"});if(e.apiKey===null)return a.jsxs(uC,{children:["你还没有调用 key。去",e.onOpenSettings?a.jsx("button",{onClick:e.onOpenSettings,className:"mx-1 cursor-pointer text-accent hover:underline",children:"设置 → 账号"}):a.jsx("span",{className:"mx-1",children:"设置 → 账号"}),"生成一把,这里就会给出填好的命令。"]});const{gatewayUrl:n,apiKey:r,personaId:s}=e,i=d_(n,s),o=l=>dE({gatewayUrl:n,personaId:s,apiKey:r,prompt:t,entry:l});return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:"base_url"}),a.jsx("code",{className:"min-w-0 truncate font-mono text-text-200",children:i}),a.jsx(bX,{text:i,label:"复制"})]}),a.jsx(s1,{label:"chat curl",curl:o("chat")}),a.jsx(s1,{label:"task curl",curl:o("task")})]})}function s1(e){return a.jsxs("div",{className:"space-y-1 text-xs",children:[a.jsx("span",{className:"text-text-400",children:e.label}),a.jsxs("div",{className:"relative rounded-md border border-border bg-surface-page",children:[a.jsx("pre",{"data-testid":e.testId,className:"overflow-x-auto px-3 py-2.5 pr-24 font-mono text-[11px] leading-relaxed text-text-200",children:e.curl}),a.jsx("div",{className:"absolute right-2 top-2",children:a.jsx(bX,{text:e.curl,label:"复制 curl"})})]})]})}function uC(e){return a.jsx("div",{className:"text-[13px] leading-relaxed text-text-400",children:e.children})}function bX(e){const[t,n]=p.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(e.text),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return a.jsxs("button",{onClick:()=>void r(),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-surface-card px-2 py-1 text-[11px] font-medium text-text-300 transition-colors hover:border-accent/50 hover:text-accent",children:[t?a.jsx(Jt,{className:"size-3 text-success"}):a.jsx(ma,{className:"size-3"}),t?"已复制":e.label]})}const WPe={build:"构建镜像",smoke:"云上试跑",deploy:"登记上线",[mo]:"自动验证"};function Mi(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[13px] text-accent hover:underline",children:[e.children,a.jsx(Fr,{className:"size-3"})]})}function VPe(e){return a.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-[13px]",children:e.rows.map(([t,n])=>a.jsxs("div",{className:"contents",children:[a.jsx("dt",{className:"text-text-400",children:t}),a.jsx("dd",{className:"min-w-0 truncate font-mono text-[12px] text-text-200",children:n})]},t))})}function i1(e){return a.jsx("div",{className:"text-xs text-text-400",children:e.children})}function o1(e,t){if(e===void 0||t===void 0)return;const n=Math.round((t-e)/1e3);if(!(n<0))return n<60?`${n}s`:`${Math.floor(n/60)}m${String(n%60).padStart(2,"0")}s`}function qPe(e){if(e.status!=="pending")return e.status==="waiting"?"等审批":e.status==="running"&&e.startedAt!==void 0?"进行中":o1(e.startedAt,e.completedAt)}function dC(e){return a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{children:"前面那一段挂了,这一段没有跑。云上跑的还是上一版。"}),a.jsxs("div",{className:"text-text-400",children:["修好重发之后,它会:",e.children]})]})}function hC(e){return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:e.what}),a.jsx(i1,{children:e.impact}),e.url&&a.jsx(Mi,{href:e.url,children:"看这一段的完整日志"})]})}function KPe(e,t){const n=t.url,r=n?a.jsx(Mi,{href:n,children:t.status==="running"?"看实时日志":"看这一段的日志"}):null;if(e==="build")switch(t.status){case"pending":return a.jsx("div",{children:"会在 runner 上按清单把要装的东西装进底座镜像,构出一层 persona 镜像推到 ACR。镜像 tag 带 commit sha,不可变。"});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在按清单装东西,然后构镜像。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"镜像构出来了,清单里要装的都在、都报得出版本,persona 目录也在。已经推到 ACR。"}),r]});case"failed":return a.jsx(hC,{what:"构镜像这一步挂了。",url:n,impact:"云上跑的还是上一版,没被动过"});default:return a.jsx(dC,{children:"按清单装好东西、构出 persona 镜像推到 ACR。"})}if(e==="smoke")switch(t.status){case"pending":return a.jsxs("div",{children:["会拿刚构出来的镜像在集群上",a.jsx("b",{children:"临时登记一次"}),"、真起一个 Pod、投一句「只回复 ok」,验的是拉得到镜像、容器起得来、卷挂得上、codex 回得了话。验完就撤销。"]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"临时登记好了,在等集群拉镜像、起 Pod。第一次拉几百 MB 的镜像会慢一些。"}),r]});case"done":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"集群拉到了镜像、容器起来了、codex 回了话。临时登记已经撤销,没有残留。"}),r]});case"failed":return a.jsx(hC,{what:"镜像在集群上没跑起来,或者跑起来了但没回话。",url:n,impact:"镜像构出来了,但没敢登记;云上跑的还是上一版"});default:return a.jsx(dC,{children:"拿新构出来的镜像在集群上临时起一次,验拉得到、起得来、回得了话。"})}switch(t.status){case"pending":return a.jsxs("div",{children:["会把这份镜像在 gateway 上登记成",a.jsx("b",{children:"正式"}),"。从这一刻起,别人派活过来起的就是这一版。同一台 gateway 上挂着别的 persona 不受影响,重新登记只覆盖自己那一行。"]});case"waiting":return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["仓库给 ",a.jsx("code",{className:"font-mono",children:"production"})," 环境配了审核人,这一步停在这里等人点。批了才会登记成正式,云上现在跑的还是上一版。"]}),n&&a.jsx(Mi,{href:n,children:"去 GitHub 批准"})]});case"running":return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{children:"正在往 gateway 写这一版的登记(镜像地址 + 部署者提供的那几条凭据)。"}),r]});case"failed":return a.jsx(hC,{what:"gateway 没收下这次登记。",url:n,impact:"云上跑的还是上一版,没被动过"});case"done":return null;default:return a.jsx(dC,{children:"把这份镜像在 gateway 上登记成正式,别人派活过来就起这一版。"})}}function GPe(e,t,n){const r=n?"后来下线了,现在线上没有它。":t?"现在线上跑的就是它。":"后来被更新的发布覆盖了,线上跑的是标「线上」那条。";return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:["这一版在 gateway 上登记成了正式。",r]}),e.url&&a.jsx(Mi,{href:e.url,children:"看这一段的日志"})]})}const YPe=(e,t)=>()=>e(t);function Rn(e){return a.jsx("div",{className:"space-y-3",children:e.children})}function XPe(e){const t={key:"scan",label:"扫描"},{latest:n}=e;if(e.frozen){if(!n)return{...t,status:"done",meta:"记录已丢",detail:a.jsx("div",{children:"这次发布对应的扫描记录找不到了(可能是旧版 clawd 留下的)。"})};const s=o1(n.startedAt,n.finishedAt);return{...t,status:"done",...s?{meta:s}:{},detail:a.jsx("div",{children:"清单是这次扫描的,在下面的卡片里。"})}}if(e.starting)return{...t,status:"running",meta:"进行中",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:e.repo?"正在把 persona 目录落存、起管家会话…":"正在建仓库、把 persona 提交进去、起管家会话…"}),e.actions]})};if(!n)return{...t,status:"pending",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"还没扫过。扫描会把 persona 整个读一遍,列出它挪到云上要预备什么:镜像里要装的东西、要连的连接器、要填的凭据。"}),e.actions]})};if(n.status==="scanning")return{...t,status:"running",meta:"进行中",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"管家在读 persona,清单在下面一条条长出来。右上角「管家分析中」能看它读了什么。"}),e.actions]})};if(n.status==="failed")return{...t,status:"failed",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:n.error??"扫描没跑完。"}),a.jsx(i1,{children:"云上跑的还是上一版,没被动过。"}),e.actions]}),...e.onRescan?{onRetry:e.onRescan}:{}};const r=o1(n.startedAt,n.finishedAt);return lw(n,e.repo,e.lastRelease)?!e.anchored&&e.blockers.length>0?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(Rn,{children:[a.jsxs("div",{children:["扫完了,还差 ",a.jsxs("span",{className:"font-medium text-warning",children:[e.blockers.length," 项必填"]}),",填好就能发布。"]}),e.actions]})}:{...t,status:"done",...r?{meta:r}:{},detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"清单是这一版扫的,在下面的卡片里。"}),e.actions]})}:{...t,status:"waiting",meta:"已过时",detail:a.jsxs(Rn,{children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-warning",children:"有未提交的改动"}),",最新这份清单是改动前扫的。要上云的话重新扫一遍。"]}),e.actions]})}}function fC(e){return a.jsx("ul",{className:"list-disc space-y-0.5 pl-5",children:e.lines.map(t=>a.jsx("li",{children:t},t))})}function ZPe(e){const t={key:"config",label:"配置"},n=e.current&&e.tested?CPe(e.tested,e.current):[],r=e.runUrl?a.jsx(Mi,{href:e.runUrl,children:"在 GitHub 看应用配置的流水线"}):null;switch(e.phase.kind){case"editing":return e.blocker&&e.scanDone?{...t,status:"waiting",meta:"等你处理",detail:a.jsxs(Rn,{children:[a.jsx("div",{className:"text-warning",children:e.blocker}),e.actions]})}:{...t,status:e.scanDone?"done":"pending",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"引擎、模型和资源在下面定,随下一次「发测试环境」一起生效。发测试环境之后再改它们,不用重新扫描。"}),e.actions]})};case"synced":return{...t,status:"done",meta:"与测试一致",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"测试环境用的就是当前配置。之后改了引擎、模型或资源,回到这里「应用到测试环境」就行,不用重新扫描、重新构建。"}),e.actions]})};case"pending":return{...t,status:"waiting",meta:`改了 ${e.phase.keys.length} 项`,detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"测试环境还是旧配置,已改:"}),a.jsx(fC,{lines:n}),a.jsx(i1,{children:"只重新登记并验证,不重新构建,几分钟;线上不受影响。应用并确认之前不能上线。"}),e.actions]})};case"needsRepublish":return{...t,status:"waiting",meta:"需重发",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"配置改了:"}),a.jsx(fC,{lines:n}),a.jsx("div",{children:"但这个仓库的发布流水线是旧版本,不认单独应用的配置。重新扫描、再发一次测试环境(会重新构建),之后就能直接应用配置了。"}),e.actions]})};case"applying":return{...t,status:"running",meta:"应用中",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"正在把新配置登记到测试环境,并重新验证真实对话(不重新构建)。"}),n.length>0&&a.jsx(fC,{lines:n}),r,e.actions]})};case"failed":return{...t,status:"failed",meta:"没通过",detail:a.jsxs(Rn,{children:[a.jsx("div",{className:"text-error",children:"应用配置没通过。"}),a.jsx(i1,{children:"测试环境里可能已经是新配置但没验证过,线上没有被动过。看日志找原因,改好配置后重新应用。"}),r,e.actions]})};case"unknown":return{...t,status:"done",meta:"无法比较",detail:a.jsxs(Rn,{children:[a.jsx("div",{children:"读不到测试环境当时用的配置,没法比较有没有改过。"}),e.actions]})}}}function QPe(e){const t={key:"push",label:"推送"};if(e.releasing)return{...t,status:"running",meta:"进行中",detail:a.jsxs(Rn,{children:[a.jsxs("div",{children:["正在把这次扫描的清单写进仓库、提交并推送到 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),"…"]}),e.actions]})};if(!e.anchored||!e.released)return{...t,status:"pending",detail:a.jsx(Rn,{children:e.actions})};const n=e.released.head.slice(0,7);return{...t,status:"done",meta:n,detail:a.jsxs(Rn,{children:[e.run?a.jsxs(a.Fragment,{children:[e.released.reconfigOf?a.jsx("div",{children:"这一轮最近一次是「应用配置」:没有新的提交,复用上一次测试验证过的镜像,只换了配置。"}):a.jsxs("div",{children:["persona 目录和这次扫描的清单一起提交并推到了 ",a.jsx("code",{className:"font-mono",children:e.environment??"main"}),",下面这条流水线由这次推送触发。"]}),a.jsx(VPe,{rows:[["提交",n],["流水线",`#${e.run.runId}`]]}),a.jsx(Mi,{href:e.run.htmlUrl,children:"在 GitHub 看这次流水线"})]}):e.awaitingRun?a.jsx("div",{children:"提交推上去了,GitHub 那边还没把这次流水线列出来。通常几秒。"}):a.jsx("div",{children:"提交推上去了,但 GitHub 上没列出这一版的流水线:查不到 GitHub(没网 / 授权失效)、仓库的 Actions 没开、或者这条 run 已经被 GitHub 清掉了。刷新看看,或者去 GitHub 看。"}),e.actions]})}}const JPe={deploy:"应用配置后,会把新配置重新发到测试环境。",[mo]:"发到测试环境后,流水线会重新验证真实对话。",production:"新配置在测试环境验证通过后才能上线。"};function eOe(e,t){const n=t.kind;if(n!=="pending"&&n!=="applying"&&n!=="failed"&&n!=="needsRepublish")return;const r=d=>{d.status="pending",delete d.meta,delete d.onRetry,delete d.next;const h=JPe[d.key];h?d.detail=a.jsx("div",{children:h}):delete d.detail},s=e.findIndex(d=>d.key==="config");if(s<0)return;if(n==="needsRepublish"){for(const d of e.slice(s+1))r(d);return}const i=e.find(d=>d.key==="build"),o=e[s],l=e.filter(d=>d.key!=="scan"&&d.key!=="config"&&d.key!=="push"&&d.key!=="smoke"&&d.key!=="build"),c=i?[i.status!=="done"?i:{...i,status:"done",meta:"复用上次镜像",detail:a.jsx("div",{children:"只应用配置,不重新构建:用的是上一次测试验证过的镜像。"})}]:[];if(n==="pending")for(const d of l)r(d);else(n==="applying"||l.some(d=>d.status==="failed"))&&(o.status="done",o.meta="已提交");const u=l.findIndex(d=>d.status==="failed");if(u>=0)for(const d of l.slice(u+1))r(d);e.splice(0,e.length,e[0],...c,o,...l)}function wX(e){var y,v,w,_;const t=!!e.frozen,{released:n}=e,r=n1(e.scans,n),s=!!e.releasing&&!t,i=!!e.awaitingRun&&!t,o=t?n!==void 0:km(r,n),l=o&&!s&&Ru(n,e.run)?e.run:void 0,c=!t&&o&&e.retry&&e.retry.headSha===(n==null?void 0:n.head)&&(!e.run||e.run.runId===e.retry.runId)?e.retry:void 0,u=c?dm.indexOf(c.key):-1,d=[XPe({...r?{latest:r}:{},...e.repo?{repo:e.repo}:{},...e.lastRelease??n?{lastRelease:e.lastRelease??n}:{},blockers:e.blockers,starting:!!e.starting&&!t,anchored:o,frozen:t,...e.scanActions!==void 0&&!t?{actions:e.scanActions}:{},...e.onRescan&&!t?{onRescan:e.onRescan}:{}}),...e.config?[ZPe({phase:e.config.phase,...e.config.current?{current:e.config.current}:{},...e.config.tested?{tested:e.config.tested}:{},...e.config.blocker?{blocker:e.config.blocker}:{},scanDone:!!r&&r.status==="done"&&lw(r,e.repo,e.lastRelease??n),...l!=null&&l.htmlUrl?{runUrl:l.htmlUrl}:{},...e.config.actions!==void 0?{actions:e.config.actions}:{}})]:[],QPe({...e.flow?{environment:"integration"}:{},...n?{released:n}:{},...l?{run:l}:{},releasing:s,anchored:o,awaitingRun:i,...e.releaseActions!==void 0?{actions:e.releaseActions}:{}})],h=!s&&o&&(l?l.status!=="completed":i),f=new Map((l==null?void 0:l.jobs.map(S=>[S.key,S]))??[]),m=!!e.flow&&(l==null?void 0:l.status)==="completed"&&!e.flow.confirmed&&!(n!=null&&n.reconfigOf);let g=!0;for(const S of dm){if(S===mo&&!e.flow&&!f.has(S))continue;const k=c&&dm.indexOf(S)>u,N=(c==null?void 0:c.key)===S,j=k?void 0:f.get(S),R=!c&&!j&&h&&g,E=!c&&h&&g&&((j==null?void 0:j.status)==="pending"||R&&(l==null?void 0:l.status)==="queued"),I=k?{status:"pending"}:N?{jobId:c.jobId,status:c.phase==="submitting"?"running":c.phase==="failed"?"failed":"waiting"}:j??{status:"pending"};g=g&&I.status==="done";const M=N?S==="build"?"等待构建开始":"等待这一步开始":"等待开始",P=N?c.phase==="submitting"?"正在重试":c.phase==="failed"?"重试请求失败":c.phase==="unknown"?"状态待确认":M:E?"排队中":R?M:qPe(I),D=N?a.jsxs(Rn,{children:[a.jsx("div",{children:c.phase==="submitting"?"正在提交重试请求,请不要重复点击。":c.phase==="failed"?"重试请求失败,请核实原因后重试。":c.phase==="unknown"?"暂时无法确认这次重试的状态。":"重试请求已返回,正在等待新一轮的执行状态。"}),c.error&&a.jsx("div",{className:"text-error",children:c.error}),(l==null?void 0:l.htmlUrl)&&a.jsx(Mi,{href:l.htmlUrl,children:"查看这次发布"}),c.phase==="unknown"&&e.onRefreshRetry&&a.jsx("button",{className:"text-accent hover:underline",onClick:e.onRefreshRetry,children:"刷新状态"})]}):E||R?a.jsxs(Rn,{children:[a.jsx("div",{children:E?"GitHub 已将这一步排队,等待开始执行。":"正在等待这一步的执行状态;尚未确认开始。"}),(l==null?void 0:l.htmlUrl)&&a.jsx(Mi,{href:l.htmlUrl,children:"查看这次发布"})]}):n!=null&&n.reconfigOf&&S==="build"&&I.status==="done"?a.jsxs(Rn,{children:[a.jsx("div",{children:"这次只应用配置,没有重新构建:用的是上一次测试验证过的镜像。"}),I.url&&a.jsx(Mi,{href:I.url,children:"看这一段的日志"})]}):e.flow&&S==="deploy"?a.jsxs(Rn,{children:[a.jsx("div",{children:I.status==="done"?"已发到测试环境,流水线接着自动验证真实对话。":"这一步会把本次版本发到测试环境。"}),I.url&&a.jsx(Mi,{href:I.url,children:"查看这一步的日志"})]}):S===mo?a.jsxs(Rn,{children:[a.jsx("div",{children:I.status==="running"?"流水线正在用测试账号验证真实对话,收到有效回复并正常结束才算通过。":I.status==="failed"?"自动对话验证失败,线上没有改动。查看日志后重试。":(y=e.flow)!=null&&y.confirmed?"测试通过,已收到有效回复并正常结束。上线将使用同一个版本。":I.status==="done"?"正在核对验证结果和测试环境版本;版本变化时需要重新发布测试。":(l==null?void 0:l.status)==="completed"?"这次发布没有通过自动对话验证,请重新扫描并发布测试环境。":"测试环境发布后,流水线会自动验证真实对话。"}),I.url&&a.jsx(Mi,{href:I.url,children:"查看这一步的日志"}),(v=e.flow)==null?void 0:v.testActions]}):S==="deploy"&&I.status==="done"&&t?GPe(I,e.live,!!e.offline):S==="deploy"&&I.status==="done"&&e.offline?a.jsx("div",{children:"这一版登记上线过,后来下线了:gateway 上已经没有它,别人看不到、用不了。重新扫描、发布就能再上线。"}):S==="deploy"&&I.status==="done"?a.jsx(UPe,{gatewayUrl:((w=e.cloud)==null?void 0:w.gatewayUrl)??null,personaId:e.personaId,apiKey:(_=e.cloud)==null?void 0:_.apiKey,...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{}}):KPe(S,I);d.push({key:S,label:e.flow?{build:"构建",smoke:"自动试跑",deploy:"发测试环境",[mo]:"自动验证"}[S]:WPe[S],status:E||R||S===mo&&e.flow&&!c&&!e.flow.confirmed&&(I.status==="done"||(l==null?void 0:l.status)==="completed"&&!j)?"waiting":I.status,...P?{meta:P}:{},...D?{detail:D}:{},...(I.status==="failed"||m&&S==="build"&&I.status==="done")&&I.jobId!==void 0&&e.onRetry&&!t&&(!c||c.phase==="failed")?{onRetry:YPe(e.onRetry,I.jobId)}:{}})}if(e.flow){const{confirmed:S,promotion:k,productionActions:N,submissionError:j}=e.flow,R=!!e.flow.promoting&&!t,E=R?"正在提交上线":j?"上线请求失败":void 0,I=R?"正在核对测试版本并提交上线,请不要重复点击。":j?"上线请求失败,请核实原因后再继续。":(k==null?void 0:k.phase)==="completed"?"这一版已上线。":(k==null?void 0:k.phase)==="failed"?"上线失败,请查看原因后再继续。":k!=null&&k.error?"上线已暂停,请处理下面的问题后再继续。":(k==null?void 0:k.phase)==="main-pushed"?"已推送到线上分支,正在提交上线任务。":(k==null?void 0:k.phase)==="dispatching"?"正在向 GitHub 提交上线任务。":(k==null?void 0:k.phase)==="dispatched"?"上线任务已提交,正在等待执行结果。":(k==null?void 0:k.phase)==="prepared"?"正在准备上线已测试的版本。":S?"把已测试的提交推到线上分支,上线同一个版本。":"先等待自动对话验证通过。",M=e.repo&&(k!=null&&k.runId)?`${e.repo.url.replace(/\.git$/,"")}/actions/runs/${k.runId}`:void 0;d.push({key:"production",label:"发线上环境",status:R?"running":j?"failed":(k==null?void 0:k.phase)==="completed"?"done":(k==null?void 0:k.phase)==="failed"?"failed":k!=null&&k.error?"waiting":k?"running":"pending",...E?{meta:E}:{},detail:a.jsxs(Rn,{children:[a.jsx("div",{children:I}),!R&&(j||(k==null?void 0:k.error))&&a.jsx("div",{className:"text-error",children:j??(k==null?void 0:k.error)}),!R&&M&&a.jsx(Mi,{href:M,children:"查看上线进度"}),N]})})}e.config&&eOe(d,e.config.phase);const b=d.some(S=>S.status==="failed"||S.status==="running"||S.status==="waiting")?void 0:d.find(S=>S.status==="pending");return b&&(b.next=!0),d}function tOe(e,t,n){if(!e)return{kind:"missing"};const r=e.indexOf(":");if(r===-1)return{kind:"raw",text:e};const s=e.slice(0,r),i=e.slice(r+1);if(!i)return{kind:"raw",text:e};switch(s){case"npm":return{kind:"known",text:`npm i -g ${i}${t?`@${t}`:""}`};case"apt":return{kind:"known",text:`apt-get install -y ${i}`};case"pip":return{kind:"known",text:`pip install ${i}${t?`==${t}`:""}`};case"github":return n?{kind:"known",text:`从 GitHub release 拉二进制 · ${n.url.split("?")[0].split("/").pop()||n.url}`}:{kind:"known",text:`从 GitHub release 拉二进制 · ${i}${t?` v${t}`:""}`};default:return{kind:"raw",text:e}}}function nOe(e,t){if(e)return`= ${e}`;if(t)return`≥ ${t}`}function rOe(e){var r;if(!((r=e.from)!=null&&r.startsWith("apt:")))return;const t=e.localVersion?`(本机 ${e.localVersion})`:"",n=Kle.label;return e.name&&Q9.includes(e.name)?{tone:"info",text:`云上底座自带,不从 ${n} 装${t}`}:e.aptMissing?{tone:"error",text:`${n} 没有这个包,云上装不了${t}`}:e.aptVersion?e.version?e.localVersion&&e.localVersion!==e.version?{tone:"warn",text:`云上装 ${n} 的 ${e.version},本机 ${e.localVersion}`}:{tone:"info",text:`云上装 ${n} 的 ${e.version}`}:{tone:e.min?"error":"warn",text:`云上是 ${n} 的 ${e.aptVersion}${e.min?`,不满足要求 ≥ ${e.min}`:",没按它钉版本"}${t}`}:{tone:"warn",text:`没查到 ${n} 里的版本,云上装它自带的${t}`}}function sOe(e,t){if(!t)return{tone:"warn",text:"本机未探到"};if(e!==t)return{tone:"error",text:`本机 ${t} ≠ 云上 ${e??"—"}`}}function iOe(e){const t=tOe(e.from,e.version,e.artifact);return a.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[a.jsx("span",{className:"shrink-0 text-text-500",children:"装法:"}),t.kind==="missing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-warning",children:"没查到"}),a.jsx("span",{className:"text-text-500",children:"· 见存疑项"})]}):a.jsx("code",{className:"rounded-sm border border-border bg-bg-100 px-1.5 py-0.5 text-text-400",children:t.text})]})}function _X(e){const t=nOe(e.version,e.min),n=rOe(e)??sOe(e.version,e.localVersion),r=e.blockers??[];return a.jsxs("div",{className:"border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:e.name}),r.length>0&&a.jsx(kx,{}),t&&a.jsx("span",{className:"font-mono text-xs text-text-400",children:t}),n&&a.jsx("span",{className:`text-xs ${n.tone==="error"?"text-error":n.tone==="warn"?"text-warning":"text-text-400"}`,children:n.text})]}),r.map(s=>a.jsx("div",{className:"mt-1 text-xs text-error",children:s},s)),a.jsx(iOe,{from:e.from,version:e.version,artifact:e.artifact}),e.evidence&&a.jsx(TR,{evidence:e.evidence})]})}const hE={none:{label:"不用账号",hint:e=>`${e} 是公开服务,不用登录就能用`},shared:{label:"发布者的账号",hint:e=>`用户用发布者的账号使用 ${e}:发布者在这一页填好自己的 key,所有人共用这一份`},personal:{label:"用户自己的账号",hint:e=>`用户用自己的账号使用 ${e}:每个用户第一次用时自己关联一次`}},ky={oauth:{label:"OAuth",hint:e=>`用户点链接跳到 ${e} 的授权页登录,不用碰 key`},fields:{label:"粘贴 API key",hint:()=>"用户把自己的 API key 粘进表单"}},SX=e=>e.runner==="cli"?f5(e)?"CLI · Lark App Bot":e.protocol==="lark-sidecar"?"CLI · 飞书 sidecar":"CLI":e.kind==="proxy"?"http MCP":"stdio MCP",oOe=e=>e.kind==="env"||e.fields.length>0?"fields":"oauth",aOe=/^[A-Z][A-Z0-9_]*$/;function lOe(e){const t=e.connector,[n,r]=p.useState(""),[s,i]=p.useState(null),o=t.name==="feishu"&&t.runner==="cli",l=f5(t),c=o,u=s7(t),d=!t.credentialSource,h=t.credentialSource==="personal"&&!t.auth,f=u.length>0&&!d&&!h,m=t.credentialSource==="personal",g=!o&&(t.credentialSource==="shared"||t.credentialSource==="personal"&&t.auth==="fields"),x=v=>{const{publisherUnionId:w,..._}=t;e.onChange({..._,kind:v==="bot"?"env":"proxy",protocol:v==="bot"?void 0:"lark-sidecar",credentialSource:v==="user"?"personal":"shared",auth:v==="bot"?"fields":"oauth",fields:v==="bot"?[...r7]:[]})},b=v=>{e.onChange({...t,credentialSource:v,...v==="personal"&&!t.auth?{auth:oOe(t)}:{}})},y=()=>{const v=n.trim();if(!aOe.test(v)){i("变量名只能是大写字母、数字、下划线,且以字母开头");return}t.fields.includes(v)||e.onChange({...t,fields:[...t.fields,v]}),r(""),i(null)};return a.jsxs("div",{className:"border-b border-border-card px-5 py-4 last:border-b-0","data-testid":`connector-row-${t.name}`,"data-required":u.length>0||void 0,children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[a.jsx("span",{className:"font-mono text-[15px] font-semibold text-text-100",children:t.name}),a.jsx("span",{className:"rounded-sm bg-text-100-dim px-1.5 py-px text-[11px] text-text-400",children:SX(t)}),a.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-text-500",title:t.id,children:t.id})]}),e.evidence&&a.jsx(TR,{evidence:e.evidence}),a.jsx(ui,{delayDuration:120,children:a.jsxs("div",{className:"mt-3 space-y-2",children:[o?a.jsx(Cm,{label:"用谁的账号",name:"feishu-source",value:l?"bot":t.credentialSource==="shared"?"publisher":"user",options:[{value:"publisher",label:"发布者账号",hint:"所有使用者共用发布者的飞书 OAuth 权限;发布者需先关联飞书账号"},{value:"user",label:"用户自己的账号",hint:"每个使用者关联自己的飞书账号,使用本人权限"},{value:"bot",label:"Lark App Bot",hint:"发布者填写 App ID 和 App Secret,所有使用者共用这个应用的机器人身份"}],onPick:x}):a.jsx(Cm,{label:"用谁的账号",required:d,name:`${t.name}-source`,value:t.credentialSource,options:t7.map(v=>({value:v,label:hE[v].label,hint:hE[v].hint(t.name)})),disabled:c,onPick:v=>b(v)}),m&&a.jsx(Cm,{label:"关联方式",required:h,name:`${t.name}-auth`,value:t.auth,options:d5.filter(v=>t.kind==="proxy"||v==="fields").map(v=>({value:v,label:ky[v].label,hint:t.kind==="env"?`${ky[v].hint(t.name)}。进程型(stdio MCP / CLI)没有登录页,只有这一种`:ky[v].hint(t.name)})),disabled:c,onPick:v=>e.onChange({...t,auth:v})}),g&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"要填的变量:"}),f&&a.jsx(kx,{}),t.fields.map(v=>a.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-xs text-text-200",children:[v,a.jsx("button",{type:"button","aria-label":`去掉 ${v}`,className:"text-text-400 hover:text-error",onClick:()=>e.onChange({...t,fields:t.fields.filter(w=>w!==v)}),children:a.jsx(Xt,{className:"size-3"})})]},v)),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(qn,{"aria-label":`${t.name} 新增一个变量`,className:"h-7 w-44 font-mono text-xs",placeholder:"变量名,如 GH_TOKEN",value:n,onChange:v=>r(v.target.value.toUpperCase()),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),y())}}),a.jsx("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:y,children:"添加"})]}),s&&a.jsx("span",{className:"w-full text-xs text-error",children:s}),t.fields.length===0&&a.jsx("span",{className:"w-full text-xs text-text-500",children:t.runner==="cli"?"这个工具从哪个环境变量读凭据,查清楚填这里":"扫描没在 .mcp.json 里找到 ${VAR} 占位;它要什么就填什么"})]})]})}),o&&!l&&t.credentialSource==="shared"&&a.jsxs("div",{className:"mt-3 space-y-2 text-xs text-text-300",children:[a.jsx("p",{children:"所有使用者将使用你的飞书权限。请先关联发布者账号:"}),["integration","production"].map(v=>{var S;const w=(S=e.publisherAuth)==null?void 0:S[v],_=v==="integration"?"测试环境":"线上环境";return a.jsx("div",{children:w!=null&&w.connected?a.jsxs("span",{children:[_,":已关联"]}):w!=null&&w.authUrl?a.jsxs("a",{className:"text-accent underline",href:w.authUrl,target:"_blank",rel:"noopener noreferrer",children:["关联",_,"飞书账号"]}):a.jsxs("span",{children:[_,":",(w==null?void 0:w.error)??"请刷新授权状态"]})},v)}),a.jsx("button",{type:"button",className:"text-accent underline",onClick:e.onRefreshPublisherAuth,children:"刷新授权状态"})]}),e.secretCard&&(!o||l)&&a.jsx("div",{className:"mt-3 rounded-md border border-border-card bg-bg-50",children:e.secretCard})]})}function Cm(e){return a.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"radiogroup","aria-label":e.label,children:[a.jsxs("span",{className:"w-20 shrink-0 text-xs text-text-400",children:[e.label,":"]}),e.required&&a.jsx(kx,{}),e.options.map(t=>{const n=t.value===e.value,r=a.jsx("button",{type:"button",role:"radio","aria-checked":n,disabled:e.disabled,"data-testid":`${e.name}-${t.value}`,onClick:()=>e.onPick(t.value),className:J("rounded-full border px-2.5 py-0.5 text-xs transition-colors",n?"border-accent bg-accent text-accent-contrast":"border-border text-text-300 hover:border-accent/50 hover:text-accent",e.disabled&&"cursor-default opacity-70 hover:border-border hover:text-text-300"),children:t.label});return a.jsxs(Xi,{children:[a.jsx(Zi,{asChild:!0,children:r}),a.jsx(pi,{side:"top",className:"max-w-[360px]",children:t.hint})]},t.value)})]})}const Xh=e=>new Date(e).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});function cOe(e){const t=e.manifest,n=[t.packages.length?`镜像 ${t.packages.length}`:null,t.connectors.length?`连接器 ${t.connectors.length}`:null,t.secrets.length?`凭据 ${t.secrets.length}`:null,e.notes.length?`存疑项 ${e.notes.length}`:null].filter(r=>r!==null);return n.length?n.join(" · "):e.status==="scanning"?"…":"什么都不需要"}function uOe(e){const t=e.scans.map((l,c)=>({s:l,n:c+1})).reverse(),[n,r]=p.useState(!1),s=(l,c)=>{var u;return c===e.scans.length||((u=e.released)==null?void 0:u.scanId)===l.id||l.status==="scanning"||l.id===e.selectedId},i=n?t:t.filter(({s:l,n:c})=>s(l,c)),o=t.length-i.length;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(L5,{className:"size-[18px]"}),title:"扫描历史",count:`${e.scans.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"scan-history",children:[i.map(({s:l,n:c})=>{var g;const u=l.id===e.selectedId,d=c===e.scans.length,h=e.online!==!1&&((g=e.released)==null?void 0:g.scanId)===l.id,f=Sce(l,e.released),m=(l.head??"").slice(0,7);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(l.id),"aria-current":u,"aria-label":`第 ${c} 次扫描`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${u?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",c]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:Xh(l.startedAt)}),e.repo&&f&&m?a.jsxs("a",{href:`https://github.com/${Rh(e.repo.url)}/commit/${l.head}`,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m,a.jsx(Fr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",title:"还没推到 GitHub,发布之后才会有",children:m||"—"}),a.jsx("span",{className:"shrink-0 rounded-full bg-text-100-dim px-1.5 py-0.5 text-[11px] text-text-400",children:l.baseKind==="soft"?"软扫":"硬扫"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-text-300",children:cOe(l)}),d&&a.jsx("span",{className:"shrink-0 rounded-full bg-accent-dim px-1.5 py-0.5 text-[11px] font-medium text-accent",children:"最新"}),h&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx(dOe,{s:l})]})},l.id)}),o>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>r(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Yt,{className:"size-3.5"}),"还有 ",o," 次扫描"]})})]})]})}function dOe({s:e}){return e.status==="scanning"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):e.status==="failed"?a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-xs text-error",children:[a.jsx(Xt,{className:"size-3"}),"失败"]}):a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-text-400",children:[a.jsx(Jt,{className:"size-3 text-success"}),o1(e.startedAt,e.finishedAt)??"完成"]})}const jp={tiny:{label:"微",mem:"256 MB",hint:"纯对话、查资料"},small:{label:"小",mem:"512 MB",hint:"调 MCP、读写文件"},medium:{label:"中",mem:"1 GB",hint:"跑脚本、python / jq 这类"},large:{label:"大",mem:"2 GB",hint:"装依赖、构建、开浏览器"},xlarge:{label:"超大",mem:"4 GB",hint:"较大构建、内存密集任务"}},hOe=e=>e!==void 0&&m5.includes(e);function fOe(e){const t=p.useId(),n=e.taskConcurrency,r=e.size===void 0||e.size==="",s=r?wb:e.size,i=hOe(s),o=e.cpu===void 0,l=o?i?$N[s]:void 0:e.cpu,c=l!==void 0&&_b.includes(l),u=!!e.disabled||!!e.saving;return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"resource-estimate",children:[a.jsx(Qr,{icon:a.jsx(D5,{className:"size-[18px]"}),title:"资源预估"}),a.jsxs("div",{className:"px-5 py-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"内存:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的内存预留与上限"}),r&&a.jsx("span",{children:"(没选过,按默认)"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-2 gap-2 sm:grid-cols-5",role:"radiogroup","aria-label":"内存",children:m5.map(d=>{const h=d===s;return a.jsxs("button",{type:"button",role:"radio","aria-checked":h,"aria-label":`${jp[d].label} · ${jp[d].mem}`,disabled:u||!e.onChange,onClick:()=>{var f;h||(f=e.onChange)==null||f.call(e,d)},className:J("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[a.jsx("span",{className:J("text-base font-semibold",h?"text-accent":"text-text-100"),children:jp[d].label}),a.jsx("span",{className:"font-mono text-xs text-text-300",children:jp[d].mem}),d===wb&&a.jsx("span",{className:"ml-auto text-[11px] text-text-400",children:"默认"})]}),a.jsx("div",{className:"mt-0.5 text-xs text-text-400",children:jp[d].hint})]},d)})}),!i&&a.jsxs("div",{className:"mt-2 text-xs text-warning",children:["persona.json 里写的是 ",a.jsx("code",{className:"font-mono",children:s}),",不是支持的内存档,发布会被拒;点一档换掉"]}),a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-400",children:[a.jsx("span",{children:"CPU:"}),a.jsx("span",{className:"text-text-300",children:"每 Pod 的 CPU 预留与上限"})]}),a.jsx("div",{className:"mt-2.5 grid grid-cols-3 gap-2",role:"radiogroup","aria-label":"CPU",children:_b.map(d=>{const h=d===l;return a.jsxs("button",{type:"button",role:"radio","aria-label":`${d} 核`,"aria-checked":h,disabled:u||!e.onChangeCpu,onClick:()=>{var f;(o||!h)&&((f=e.onChangeCpu)==null||f.call(e,d))},className:J("rounded-md border px-3 py-2.5 text-left transition-colors",h?"border-accent bg-accent-dim":"border-border-card hover:border-accent/60"),children:[a.jsx("span",{className:J("text-base font-semibold",h?"text-accent":"text-text-100"),children:d}),a.jsx("span",{className:"ml-1.5 text-xs text-text-300",children:"核"})]},d)})}),o&&c&&a.jsxs("div",{className:"mt-2 text-xs text-text-400",children:["未单独配置,暂按内存档位取 ",l," 核;点选任意 CPU 档位后独立保存(也可点当前档位)。"]}),!c&&a.jsx("div",{className:"mt-2 text-xs text-warning",children:o?"内存档位未知,无法确定默认 CPU;请选择 CPU 和内存后发布。":`CPU 配置 ${String(e.cpu)} 不在支持范围内,发布会被拒;请选择一档修复。`}),a.jsx("div",{role:"status",className:"mt-2 text-xs text-text-400",children:e.saving?"正在保存资源设置…":"资源设置保存后,下次发布生效;运行中的 Pod 不变。预留不是独占物理核心。"}),e.error&&a.jsx("div",{role:"alert",className:"mt-2 text-xs text-error",children:e.error})]}),n&&a.jsxs("div",{className:"mt-5 border-t border-border-card pt-4",children:[a.jsx("label",{htmlFor:t,className:"text-sm font-medium text-text-100",children:"单 Pod 任务并发数"}),a.jsxs("div",{id:`${t}-hint`,className:"mt-1 text-xs leading-relaxed text-text-400",children:["每个 task Pod 最多同时运行的任务数,仅影响 task 调用。默认 4,保存后下次发布生效。",n.defaulted&&a.jsx("span",{children:"(未配置,按默认)"})]}),a.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[a.jsx(qn,{id:t,inputMode:"numeric",className:"w-28",value:n.value,disabled:n.disabled||n.saving,"aria-describedby":`${t}-hint${n.error?` ${t}-error`:""}`,"aria-invalid":!!n.error,onChange:d=>n.onChange(d.target.value)}),a.jsx(Le,{size:"sm","aria-label":"保存并发数",disabled:n.disabled||n.saving||!n.dirty||!n.valid,onClick:n.onSave,children:n.saving?"保存中…":"保存"})]}),n.error&&a.jsx("div",{id:`${t}-error`,role:"alert",className:"mt-2 text-xs text-error",children:n.error}),!n.error&&a.jsx("div",{role:"status",className:"mt-2 text-xs text-text-400",children:n.saving?"正在保存任务并发数…":n.dirty?"有未保存的修改,请先保存再发布":n.saved?"已保存,下次发布生效":"修改后保存,再发布到云上"})]})]})]})}function Cx(e,t,n){var i;const r=n.find(o=>o.name==="effort"),s=e?t.find(o=>o.id===e):void 0;if(s!=null&&s.efforts&&s.efforts.length>0){const o=(i=r==null?void 0:r.options)==null?void 0:i.find(c=>c.value==="none");return{options:o?[o,...s.efforts.filter(c=>c.value!=="none")]:s.efforts,defaultValue:s.defaultEffort??""}}return{options:(r==null?void 0:r.options)??[],defaultValue:typeof(r==null?void 0:r.default)=="string"?r.default:""}}function kX(e,t){var r;const n=t.options.some(s=>s.value===e)?e:t.defaultValue;return{value:n,label:((r=t.options.find(s=>s.value===n))==null?void 0:r.label)??"默认"}}function h_(e,t,n){var c;if(!t)return((c=(e??[]).find(u=>u.id===""))==null?void 0:c.label)??"未指定";const r=t.toLowerCase(),s=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[u,d]of s){if(!r.includes(u))continue;const h=r.match(new RegExp(`${u}-(\\d+)(?:-(\\d+))?`));return h?h[2]?`${d} ${h[1]}.${h[2]}`:`${d} ${h[1]}`:d}const i=e??[],o=i.find(u=>u.id===t);if(o)return o.label;const l=i.find(u=>u.id&&t.toLowerCase().includes(u.id.toLowerCase()));return l?l.label:t}function $R(e){let t;return e.map(n=>{const r=n.group&&n.group!==t?n.group:null;return n.group&&(t=n.group),{...n,groupHeading:r}})}function CX({testid:e,label:t,current:n,items:r,onSelect:s,needsAttention:i=!1,disabled:o=!1,align:l="end"}){return a.jsxs(ls,{children:[a.jsx(cs,{asChild:!0,children:a.jsx(f_,{testid:e,label:t,needsAttention:i,disabled:o})}),a.jsx(Ur,{align:l,className:"max-h-[420px] overflow-y-auto",children:$R(r).map((c,u)=>a.jsxs(G.Fragment,{children:[c.groupHeading?a.jsxs(a.Fragment,{children:[u>0?a.jsx(ha,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:c.groupHeading})]}):null,a.jsxs(Tt,{onSelect:()=>s(c.value),children:[a.jsx(Jt,{className:J("mr-2 h-3.5 w-3.5",n===c.value?"opacity-100":"opacity-0")}),a.jsx("span",{className:"flex-1",children:c.label}),c.description?a.jsx("span",{className:"ml-3 text-[11px] text-text-400",children:c.description}):null]})]},c.value||"default"))})]})}const f_=G.forwardRef(function({testid:t,label:n,needsAttention:r=!1,disabled:s=!1,...i},o){return a.jsxs("button",{ref:o,type:"button",disabled:s,"data-testid":t,"data-needs-attention":r?"":void 0,className:J("flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-50",r?"border-warning/30 bg-warning-dim text-warning hover:bg-warning/20":"border-border bg-bg-50 text-text-200 hover:bg-text-100/5 hover:text-text-100"),...i,children:[n,a.jsx(Yt,{className:J("h-3 w-3",r?"text-warning":"text-text-400")})]})});function pOe(e){return e.map(t=>({value:t.id,label:t.label,...t.description?{description:t.description}:{},...t.group?{group:t.group}:{}}))}function NX({testid:e,list:t,options:n,current:r,onSelect:s}){if(t.loading)return a.jsx(Tt,{disabled:!0,"data-testid":`${e}-loading`,className:"text-[12px] text-text-400",children:"正在读取最新模型…"});if(t.error)return a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":`${e}-error`,className:"px-2 py-1.5 text-[11px] text-warning",children:t.error}),a.jsx(Tt,{"data-testid":`${e}-retry`,className:"text-[12px]",onSelect:o=>{o.preventDefault(),t.load()},children:"重试"})]});const i=n??pOe(t.models);return i.length===0?a.jsx(Tt,{disabled:!0,"data-testid":`${e}-empty`,className:"text-[12px] text-text-400",children:"没有可选模型"}):a.jsx(a.Fragment,{children:$R(i).map((o,l)=>{const c=o.value===r;return a.jsxs(G.Fragment,{children:[o.groupHeading?a.jsxs(a.Fragment,{children:[l>0?a.jsx(ha,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:o.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${o.value||"default"}`,onSelect:()=>s(o.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:J("block text-[12px]",c?"font-medium text-text-100":"text-text-300"),children:o.label}),o.description?a.jsx("span",{className:"mt-0.5 block text-[11px] text-text-400",children:o.description}):null]}),c?a.jsx(Jt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent"}):null]})]},o.value||"default")})})}function p_({testid:e,list:t,options:n,current:r,onSelect:s,trigger:i,align:o="start",side:l,contentClassName:c}){const[u,d]=p.useState(!1),h=f=>{f&&!u&&t.load(),d(f)};return a.jsxs(ls,{open:u,onOpenChange:h,children:[a.jsx(cs,{asChild:!0,children:typeof i=="function"?i(()=>h(!0)):i}),a.jsx(Ur,{align:o,...l?{side:l}:{},className:J("max-h-[420px] w-[260px] overflow-y-auto",c),"data-testid":`${e}-menu`,children:a.jsx(NX,{testid:e,list:t,...n?{options:n}:{},current:r,onSelect:s})})]})}const mOe={codex:"Codex",pi:"pi",claude:"Claude"},gOe={codex:"Codex",pi:"pi",claude:"Claude Agent SDK"},Jd="[1m]",xOe=e=>e.endsWith(Jd)?e.slice(0,-Jd.length):e;function vOe(e){const[t,n]=p.useState(!1),r=ol(e.tool),s=e.tool||"claude",i=s==="claude",o=i?xOe(e.model):e.model,l=i&&e.model.endsWith(Jd),c=e.modelList.models,u=c.filter(g=>g.id!=="").map(g=>({value:g.id,label:g.label,...g.description?{description:g.description}:{},...g.group?{group:g.group}:{}})),d=!e.model,h=Cx(o,c,e.configSchema),{value:f,label:m}=kX(e.effort,h);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card","data-testid":"deploy-engine-card",children:[a.jsx(Qr,{icon:a.jsx(O5,{className:"size-[18px]"}),title:"引擎与模型"}),a.jsx(ui,{delayDuration:120,children:a.jsxs("div",{className:"space-y-2.5 px-5 py-4",children:[a.jsx("div",{className:"text-xs text-text-400",children:i?"只影响云上:本机 Claude 的模型不变":"本地 persona 也会改变"}),a.jsx(Cm,{label:"引擎",required:!r,name:"deploy-engine",value:r?s:void 0,options:w7.map(g=>({value:g,label:mOe[g],hint:`云上跑 ${gOe[g]} ${_7[g]}`})),onPick:g=>{g!==s&&e.onChange({tool:g})}}),!r&&a.jsxs("div",{className:"pl-[88px] text-xs text-warning",children:["现在是 ",s,",云上只跑 Codex、pi 或 Claude,选一个"]}),r&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"模型:"}),d&&a.jsx(kx,{}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[a.jsx(p_,{testid:"deploy-engine-model",list:e.modelList,options:u,current:o,onSelect:g=>{g!==o&&e.onChange({model:l?`${g}${Jd}`:g})},trigger:a.jsx(f_,{testid:"deploy-engine-model",label:d?"选一个模型":h_(c,o),needsAttention:d,disabled:e.allowManualModel})}),e.allowManualModel&&a.jsx("div",{className:"text-xs text-warning",children:"请先在上方选择并保存模型订阅,再从下拉框选择模型"}),e.allowManualModel&&a.jsxs("div",{className:"space-y-1",children:[a.jsx(Le,{size:"sm",variant:"ghost","aria-expanded":t,onClick:()=>n(g=>!g),children:"高级:指定模型 ID"}),t&&a.jsx(qn,{defaultValue:o,"aria-label":"云端模型 ID",placeholder:"模型 ID(高级)",onBlur:g=>{const x=g.target.value.trim();x&&x!==o&&e.onChange({model:l?x+Jd:x})},onKeyDown:g=>{g.key==="Enter"&&g.currentTarget.blur()}},o)]})]})]}),r&&i&&!d&&a.jsx(Cm,{label:"上下文",name:"deploy-engine-context",value:l?"1m":"default",options:[{value:"default",label:"默认",hint:"Claude 模型用它自己的窗口;号池里别的模型 Claude Code 不知道窗口多大,按 200K 用"},{value:"1m",label:"1M",hint:"模型 id 带 [1m]:Claude Code 按 1M 窗口用(模型本身和号池都要支持 1M,号池不报这个,要你自己确认)"}],onPick:g=>{g==="1m"!==l&&e.onChange({model:g==="1m"?`${o}${Jd}`:o})}}),r&&!d&&h.options.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"w-20 shrink-0 text-xs text-text-400",children:"推理强度:"}),a.jsx(CX,{align:"start",testid:"deploy-engine-effort",label:m,current:f,items:h.options.map(g=>({value:g.value,label:g.label})),onSelect:g=>{g!==f&&e.onChange({effort:g})}})]})]})})]})}function jX(e){const[t,n]=p.useState(""),[r,s]=p.useState(!1),[i,o]=p.useState(!1),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[h,f]=p.useState(null),{status:m}=e;if(!m)return null;const g=async()=>{if(!(!e.onAuthorize||t.trim().length===0)){c(!0),f(null);try{await e.onAuthorize(t.trim()),n(""),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{c(!1)}}},x=async()=>{if(e.onStartOauth){d(!0),f(null);try{const v=await e.onStartOauth();v&&window.open(v,"_blank","noopener"),s(!1)}catch(v){f(v instanceof Error?v.message:String(v))}finally{d(!1)}}},b=e.onAuthorize&&a.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:v=>{v.preventDefault(),g()},children:[a.jsx(qn,{type:"password",autoComplete:"off",placeholder:"ghp_… 或 github_pat_…","aria-label":"GitHub token",value:t,onChange:v=>n(v.target.value),className:"min-w-0 flex-1 font-mono text-xs",disabled:l||e.busy}),a.jsx(Le,{type:"submit",size:"sm",variant:"outline",disabled:l||e.busy||t.trim().length===0,children:l?"正在核对…":"用这个 token"}),a.jsxs("div",{className:"w-full text-xs text-text-400",children:["去 GitHub 建一个 classic personal access token,勾 ",a.jsx("code",{className:"font-mono",children:"repo"})," 和"," ",a.jsx("code",{className:"font-mono",children:"workflow"}),",账号要在 ",N7," 组织里。"]})]});if(m.status==="authorized"&&!r)return a.jsxs("div",{"data-testid":"github-account-card",className:"flex items-center gap-2 rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx(Jt,{className:"size-3.5 shrink-0 text-success"}),a.jsxs("span",{children:["GitHub 已关联 ",a.jsxs("span",{className:"font-mono text-text-100",children:["@",m.login]}),a.jsxs("span",{className:"text-text-400",children:[" · ",m.source==="git"?"来自本机 git 的凭据":"来自本机凭据表"]})]}),(e.onStartOauth||e.onAuthorize)&&a.jsx("button",{type:"button",onClick:()=>s(!0),className:"ml-auto cursor-pointer whitespace-nowrap text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"换一个"})]});if(m.status==="pending")return a.jsxs("div",{"data-testid":"github-account-card",className:"rounded-lg border border-border bg-surface-card",children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:a.jsx(st,{className:"size-4 animate-spin"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"等你在 GitHub 那页点「Authorize」"})]}),a.jsxs("div",{className:"space-y-2 px-4 py-3 text-[13px] leading-snug text-text-200",children:[a.jsx("div",{children:"已经在新标签页打开了 GitHub 的授权页。点同意之后会自动回到这里,这张卡会自己变绿。"}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs("a",{href:m.authUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-accent underline underline-offset-4",children:[a.jsx(Fr,{className:"size-3"}),"没打开的话点这里"]}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),i&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h})]})]});const y=m.status==="invalid";return a.jsxs("div",{"data-testid":"github-account-card",className:`rounded-lg border bg-surface-card ${y?"border-error/40":m.status==="missing"?"border-warning/50":"border-border"}`,children:[a.jsxs("div",{className:"flex items-baseline gap-2 border-b border-border px-4 py-2.5",children:[a.jsx("span",{className:"self-center text-text-400",children:y?a.jsx(lg,{className:"size-4 text-error"}):a.jsx(og,{className:"size-4"})}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:y?"GitHub 授权失效":m.status==="missing"?"先关联 GitHub":"换一个 GitHub 账号"})]}),a.jsxs("div",{className:"space-y-3 px-4 py-3",children:[y?a.jsx("div",{className:"text-[13px] leading-snug text-text-200",children:m.message}):a.jsxs("div",{className:"text-[13px] leading-snug text-text-200",children:["关联一次,app-builder 建仓推代码、persona 上云、PR 收件箱、persona 里的 git push 都用它。",m.status==="missing"&&" 本机 git 里没有 github.com 的凭据。","存在本机 git 里,clawd 不另存。"]}),e.onStartOauth&&a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(Le,{type:"button",size:"sm",onClick:()=>void x(),disabled:u||e.busy,children:u?"正在打开 GitHub…":"关联 GitHub"}),e.onAuthorize&&!i&&a.jsx("button",{type:"button",onClick:()=>o(!0),className:"cursor-pointer text-xs text-text-400 underline decoration-dotted underline-offset-4 hover:text-accent",children:"或手动粘一个 token"})]}),(i||!e.onStartOauth)&&b,h&&a.jsx("div",{className:"text-xs text-error",children:h}),r&&!l&&!u&&a.jsx("button",{type:"button",onClick:()=>{s(!1),o(!1)},className:"cursor-pointer text-xs text-text-400 hover:text-accent",children:"算了,还用原来的"})]})]})}function tL(e){return a.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer",className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-accent hover:underline",children:[e.children,a.jsx(Fr,{className:"size-3"})]})}function yOe(e){const[t,n]=p.useState(!1),{status:r}=e,s=()=>{var o;n(!1),(o=e.onUnpublish)==null||o.call(e)},i=(()=>{switch(r.kind){case"online":return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"size-2 shrink-0 rounded-full bg-success"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"在线上"}),a.jsx("span",{className:"text-text-400",children:" · 别人能看到、能用"})]}),e.onUnpublish&&a.jsx(Le,{size:"sm",variant:"outline",className:"ml-auto h-7",disabled:e.busy,onClick:()=>n(!0),children:"下线"})]});case"unpublishing":return a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"size-3.5 shrink-0 animate-spin text-text-300"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"正在下线…"}),r.runUrl&&a.jsx("span",{className:"ml-auto",children:a.jsx(tL,{href:r.runUrl,children:"查看流水线"})})]});case"failed":return a.jsxs(a.Fragment,{children:[a.jsx(yn,{className:"size-3.5 shrink-0 text-error"}),a.jsx("span",{className:"min-w-0 truncate text-text-100",children:"下线没成功"}),a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-3",children:[r.runUrl&&a.jsx(tL,{href:r.runUrl,children:"看日志"}),e.onUnpublish&&a.jsx(Le,{size:"sm",variant:"outline",className:"h-7",disabled:e.busy,onClick:()=>n(!0),children:"重试"})]})]});case"offline":return a.jsxs(a.Fragment,{children:[a.jsx(Qde,{className:"size-3.5 shrink-0 text-text-400"}),a.jsxs("span",{className:"min-w-0 truncate",children:[a.jsx("span",{className:"text-text-100",children:"已下线"}),a.jsx("span",{className:"text-text-400",children:" · 别人看不到、用不了。重新扫描、发布就能再上线"})]})]});case"unknown":return a.jsxs(a.Fragment,{children:[a.jsx(sH,{className:"size-3.5 shrink-0 text-text-400"}),a.jsx("span",{className:"min-w-0 truncate text-text-400",children:"查不到现在在不在线上"})]})}})();return a.jsxs("div",{"data-testid":"deploy-live-card",className:"rounded-lg border border-border-card bg-surface-card px-4 py-2 text-xs text-text-300",children:[a.jsx("div",{className:"flex min-h-7 items-center gap-2",children:i}),e.error&&a.jsx("div",{className:"mt-1 text-error",children:e.error}),a.jsx(bs,{open:t,onOpenChange:n,children:a.jsxs(ss,{children:[a.jsxs(zs,{children:[a.jsx(is,{children:"下线这个 persona?"}),a.jsx(Ui,{children:"下线后别人看不到、也用不了它。正在进行的对话会继续到结束,聊天记录不会丢。以后重新扫描、发布就能再上线。"})]}),a.jsxs(el,{children:[a.jsx(Le,{variant:"outline",onClick:()=>n(!1),children:"取消"}),a.jsx(Le,{variant:"destructive",onClick:s,children:"确认下线"})]})]})})]})}function EX({test:e}){return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(Jt,{className:"size-[18px]"}),title:"发布者验收",count:`${e.checks.length} 项必验`}),a.jsxs("div",{className:"space-y-2 px-5 py-4 text-[13px] text-text-300",children:[a.jsx("div",{className:"font-mono",children:e.entry}),a.jsx("div",{children:e.checks.join(" / ")}),a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境候选镜像中执行 · 最长 ",e.timeoutSeconds," 秒 · 全部通过才可上线"]})]})]})}function bOe(e){var hn,En,Mt,lr,In,Dt,Bt,mn,Tn,Rr,Ji,xr,vr,us,qs,vi;const t=e.state.targets?{...e.state,run:(hn=e.state.targets.integration)==null?void 0:hn.run,secrets:(En=e.state.targets.integration)==null?void 0:En.secrets}:e.state,{repo:n}=t,r=t.releases.find(ve=>{var ae;return ve.head===((ae=t.repo)==null?void 0:ae.head)})??ba(t.releases),s=hX(t,e.roundIdx??Sy(t)),i=e.starting?[]:s.scans,o=e.starting?void 0:s.release,l=((Mt=e.retry)==null?void 0:Mt.headSha)===(o==null?void 0:o.head)?e.retry:void 0,c=!!e.promoting&&!!o&&km(n1(i,o),o),u=e.busy||c||!!l&&l.phase!=="failed",d=kc(i),h=n1(i,o),f=!!e.starting,m=!!e.releasing,g=!!e.awaitingRun&&!!o,x=(d==null?void 0:d.status)==="scanning",b=t.run!==void 0&&t.run.status!=="completed",y=km(h,o),v=!t.github||t.github.status==="authorized",w=!e.engine||ol(e.engine.tool),[_,S]=p.useState(null),[k,N]=p.useState(!1),[j,R]=p.useState(null),[E,I]=p.useState(!1),M=p.useRef(!1),P=_??String(e.taskConcurrency??4),D=Number(P.trim()),F=/^\d+$/.test(P.trim())&&Number.isInteger(D)&&D>0,B=_!==null&&(!F||D!==(e.taskConcurrency??4)),U=e.onSaveTaskConcurrency?k?"正在保存任务并发数,请等待保存完成":B?"先在「资源预估」中保存任务并发数":void 0:void 0,$=e.resourceSaving?"正在保存资源设置,请等待保存完成":e.cpu!==void 0&&!_b.includes(e.cpu)?"先在「资源预估」中修复 CPU 配置":void 0,O=async()=>{if(!(!e.onSaveTaskConcurrency||M.current||!B||!F||m||g||e.resourceSaving)){M.current=!0,N(!0),R(null),I(!1);try{await e.onSaveTaskConcurrency(D),S(null),I(!0)}catch(ve){R(ve instanceof Error?ve.message:String(ve))}finally{M.current=!1,N(!1)}}},T=mX({current:e.currentConfig,release:o,run:t.run,anchored:y}),V=pX(e.engine)[0],H=$??U??V,[L,q]=p.useState(!1),[K,X]=p.useState(null),te=p.useRef(!1),oe=async()=>{if(!(!e.onApplyConfig||!(o!=null&&o.id)||te.current)){te.current=!0,q(!0),X(null);try{await e.onApplyConfig(o.id)}catch(ve){X(ve instanceof Error?ve.message:String(ve))}finally{te.current=!1,q(!1)}}},[Q,he]=p.useState(null),be=ve=>he({latestId:d==null?void 0:d.id,id:ve}),Z=(Q&&Q.latestId===(d==null?void 0:d.id)?t.scans.find(ve=>ve.id===Q.id):void 0)??h,ce=Z?t.scans.indexOf(Z)+1:0,se=Z$(t,h),fe=Z$(t,Z),xe=XP(Z,n,r),Me=b7(Z,n,r),Xe=km(Z,o),[me,Ce]=p.useState(null),je=me?t.scans.find(ve=>ve.id===me):void 0,Se=`${(d==null?void 0:d.id)??""}-${(o==null?void 0:o.head)??""}`,[ut,ot]=p.useState(null),[yt,re]=p.useState(x),ue=v&&w&&!f&&!x&&!m&&!u&&!!e.onScan,Te=v?w?f?n?"正在落存、起管家会话…":"正在建仓库…":x?"管家在读 persona…":n?(d==null?void 0:d.status)==="done"&&!XP(d,n,r)?a.jsx("span",{className:"text-warning",children:"有未提交的改动,清单是改动前扫的"}):d?"再扫一遍会新增一条记录;发布默认用最新那次":"让管家读一遍 persona,列出它需要什么":`会先在 ${N7} 建一个私有仓库、把 persona 提交进去,再让管家读一遍它需要什么`:"云上只跑 Codex、pi 或 Claude,在「引擎与模型」里选一个":"先在上面那张卡里关联 GitHub",Ze=!!Z&&Z.status==="done"&&xe&&fe.length===0&&!x&&!f,at=Ze,et=f||x?"等扫描结束":Z?Z.status==="failed"?"扫描失败了,重新扫描":xe?fe.length>0?`还差 ${fe.length} 项,按下面标「必填」的那几行处理`:void 0:"有未提交的改动,先重新扫描":"先扫描",tt=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"inline-flex",children:[a.jsxs(Le,{size:"sm",className:"rounded-r-none",onClick:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e)},disabled:!ue,children:[f||x?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(zfe,{className:"size-4"}),d?"重新扫描":"开始扫描"]}),a.jsxs(ls,{children:[a.jsx(cs,{asChild:!0,disabled:!ue,children:a.jsx(Le,{size:"sm","aria-label":"选扫描方式",className:"rounded-l-none border-l border-accent-contrast/30 px-2",children:a.jsx(Yt,{className:"size-4"})})}),a.jsxs(Ur,{align:"start",children:[a.jsx(Tt,{onSelect:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e,"soft")},children:a.jsxs("div",{children:[a.jsx("div",{children:"软扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"只重看跟线上正跑那版有差别的部分;不成立会自动改硬扫"})]})}),a.jsx(Tt,{onSelect:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e,"hard")},children:a.jsxs("div",{children:[a.jsx("div",{children:"硬扫"}),a.jsx("div",{className:"text-xs text-text-400",children:"从零把 persona 整个读一遍"})]})})]})]})]}),a.jsxs(Le,{size:"sm",className:"shrink-0",disabled:!Ze,onClick:()=>ot({attempt:Se,key:"config"}),title:Ze?"扫描这一段过了,去配置引擎、模型和资源":et,children:["下一步:配置 ",a.jsx(sO,{className:"size-4"})]})]}),a.jsx("div",{className:"text-xs text-text-400",children:Te}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]}),Lt=i.filter(ve=>ve.status==="done"),wt=g?"刚推上去,等流水线跑起来":b?"上一次还在跑,等它走完":void 0,we=!!Z&&Z.status==="done"&&xe&&fe.length===0&&!wt&&!m&&!f&&!u&&!!e.onRelease&&!H&&!(Me&&x),He=H??(m?"正在提交并推送…":Lt.length===0&&(Z==null?void 0:Z.status)!=="done"?"先扫描":!Z||Z.status!=="done"?"这次扫描没扫完,换一次":Me&&x?"有一次扫描正在跑,等它扫完再回到旧版本":xe?fe.length>0?`还差 ${fe.length} 项必填,回「扫描」段标「必填」的位置填`:wt||(Xe?"这一版已推到测试分支,继续查看测试结果":Me?"会先把本机 persona 回到这次扫描时的内容,再推到测试分支,构建、自动试跑,再发到测试环境":"把这次扫描推到测试分支,构建、自动试跑,再发到测试环境"):"有未提交的改动,这次扫描之后内容变过;重新扫描,或在上面的扫描历史里换一次"),ct=Cce((lr=e.engine)==null?void 0:lr.tool,e.localEngineVersion),Ot=a.jsxs("div",{className:"space-y-3",children:[e.integrationLogin,ct&&a.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/50 bg-warning/10 px-3 py-2 text-[13px] text-warning",role:"status",children:[a.jsx(yn,{className:"mt-0.5 size-4 shrink-0"}),a.jsxs("div",{children:["本机 ",ct.tool," ",ct.local,",云上底座清单指定 ",ct.tool," ",ct.cloud,"。已发布 persona 的实际版本以其镜像为准;本机验过的行为不保证云上一样。"]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"text-text-400",children:"发布的扫描:"}),Z&&Z.status==="done"?a.jsx(wOe,{s:Z,n:ce,latest:Z===d}):a.jsx("span",{className:"text-text-400",children:"—"}),a.jsx("span",{className:"text-xs text-text-400",children:"想发别的版本,在「扫描」段的扫描历史里点那一次"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsxs(Le,{size:"sm",onClick:()=>{var ve;!Z||!we||M.current||(Me?Ce(Z.id):(ve=e.onRelease)==null||ve.call(e,Z.id))},disabled:!we,children:[m?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(iy,{className:"size-4"}),Xe?"查看测试发布":Me?"回到这个版本并发测试环境":"发测试环境"]}),a.jsx("span",{className:"text-xs text-text-400",children:He}),e.releaseError&&a.jsx("div",{className:"w-full text-xs text-error",children:e.releaseError})]}),a.jsx(bs,{open:!!je,onOpenChange:ve=>{ve||Ce(null)},children:a.jsxs(ss,{children:[a.jsxs(zs,{children:[a.jsxs(is,{children:["回到第 ",je?t.scans.indexOf(je)+1:0," 次扫描的版本?"]}),a.jsxs(Ui,{children:["本机 persona 的文件会回到这次扫描时的样子(",((je==null?void 0:je.head)??"").slice(0,7),"),作为一个新提交,再推到测试分支。 没提交的改动会先自动保存;现在这一版仍留在 git 历史里(推送失败时这个回退提交会留在本机,重试即可)。引擎、模型和凭据用现在的设置,不跟着回去。"]})]}),a.jsxs(el,{children:[a.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>Ce(null),children:"取消"}),a.jsx(Le,{size:"sm",onClick:()=>{var ae;const ve=me;Ce(null),ve&&((ae=e.onRelease)==null||ae.call(e,ve))},children:"回到这个版本并发布"})]})]})}),y&&o&&n&&a.jsxs("div",{className:"text-xs text-text-400",children:["这一轮发的:第 ",t.scans.findIndex(ve=>ve.id===o.scanId)+1," 次扫描的清单 ·"," ",a.jsxs("a",{href:`https://github.com/${Rh(n.url)}/commit/${o.head}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 font-mono text-accent hover:underline",children:[o.head.slice(0,7),a.jsx(Fr,{className:"size-3"})]})]})]}),on=L||T.kind==="applying",Ne=(T.kind==="pending"||T.kind==="failed")&&!!e.onApplyConfig&&!H&&!on&&!u&&!b&&!g&&!m&&!f,ne=(at||y)&&!H&&!f&&!m,De=a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[T.kind==="pending"||T.kind==="failed"||T.kind==="applying"?a.jsxs(Le,{size:"sm",onClick:()=>void oe(),disabled:!Ne,children:[on?a.jsx(st,{className:"size-4 animate-spin"}):a.jsx(iy,{className:"size-4"}),T.kind==="applying"||L?"应用中":T.kind==="failed"?"重新应用":"应用到测试环境"]}):T.kind==="needsRepublish"?a.jsx(Le,{size:"sm",onClick:()=>ot({attempt:Se,key:"scan"}),children:"去重新扫描"}):a.jsxs(Le,{size:"sm",disabled:!ne,onClick:()=>ot({attempt:Se,key:"push"}),title:ne?void 0:H,children:["下一步:发测试环境 ",a.jsx(sO,{className:"size-4"})]}),H&&a.jsx("span",{className:"text-xs text-text-400",children:H})]}),K&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:K})]}),Je=wX({personaId:t.personaId,flow:{ready:!!(o!=null&&o.verified)&&Ru(o,t.run)&&sc(t.run)&&((Dt=(In=t.targets)==null?void 0:In.integration)==null?void 0:Dt.image)===o.verified.image,confirmed:Ru(o,t.run)&&sc(t.run)&&!!((Bt=o==null?void 0:o.verified)!=null&&Bt.verification.checks.includes("persona-dialogue"))&&((mn=t.run)==null?void 0:mn.jobs.some(ve=>ve.key===mo&&ve.status==="done"))===!0&&o.runId===t.run.runId&&o.runAttempt===t.run.runAttempt&&((Rr=(Tn=t.targets)==null?void 0:Tn.integration)==null?void 0:Rr.image)===((Ji=o.verified)==null?void 0:Ji.image),promotion:[...t.promotions??[]].reverse().find(ve=>ve.releaseId===(o==null?void 0:o.id)),testActions:e.testActions,productionActions:e.productionActions,promoting:c,submissionError:o&&!e.starting?e.productionError:void 0},...n?{repo:n}:{},scans:i,...o?{released:o}:{},...r?{lastRelease:r}:{},...t.run?{run:t.run}:{},blockers:se,starting:f,releasing:m,awaitingRun:g,...l?{retry:l}:{},...e.onRefreshRetry?{onRefreshRetry:e.onRefreshRetry}:{},...e.cloud?{cloud:e.cloud}:{},config:{phase:T,...e.currentConfig?{current:e.currentConfig}:{},...o!=null&&o.config?{tested:o.config}:{},...H?{blocker:H}:{},actions:De},scanActions:tt,releaseActions:Ot,...e.onRetryJob?{onRetry:e.onRetryJob}:{},...e.onScan&&!u?{onRescan:()=>{var ve;return(ve=e.onScan)==null?void 0:ve.call(e)}}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},offline:t.online===!1&&sc(t.run)}),dt=p.useRef({attempt:Se,key:r1(Je)??"scan"});dt.current.attempt!==Se&&(dt.current={attempt:Se,key:r1(Je)??"scan"});const Nt=FPe(Je);Nt&&(dt.current.key=Nt);const St=ut&&ut.attempt===Se?ut.key:dt.current.key,dn=kb(t.secrets),Dn=(vr=(xr=t.secrets)==null?void 0:xr.find(ve=>ve.env===LN.apiKey))==null?void 0:vr.setAt,Jn=ve=>Z==null?void 0:Z.evidence.find(ae=>ae.target===ve),ht=Z==null?void 0:Z.manifest,Ht=(()=>{if(!ht)return[];const ve=new Set(aw(ht).flatMap(ae=>ae.env));return ht.secrets.map(ae=>({...ae,env:ae.env.filter(Ue=>!ve.has(Ue))})).filter(ae=>ae.env.length>0)})();return a.jsxs("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:[a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(uw,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布到云上"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(_Oe,{state:t,starting:f,scanBase:SOe(d)})]})]}),a.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.workPanel&&a.jsxs("button",{onClick:()=>re(ve=>!ve),"aria-expanded":yt,className:"group inline-flex cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-accent/50 bg-accent-dim px-2.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent hover:text-accent-contrast",children:[x?a.jsx(st,{className:"size-3 animate-spin"}):a.jsx(Jt,{className:"size-3"}),a.jsx("span",{children:x?"管家分析中":"管家的分析过程"}),a.jsx(Yt,{className:`size-3 transition-transform ${yt?"-rotate-90":"rotate-90"}`})]})})]})}),a.jsx(jX,{status:t.github,onAuthorize:e.onAuthorizeGithub,onStartOauth:e.onStartGithubOauth,busy:u}),e.live&&a.jsx(yOe,{status:e.live.status,busy:u,...e.live.error?{error:e.live.error}:{},...e.live.onUnpublish?{onUnpublish:e.live.onUnpublish}:{}}),a.jsxs(Sd,{className:"border-accent/40",children:[a.jsx(Qr,{icon:a.jsx(iy,{className:"size-[18px]"}),title:"上云流程",tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(yX,{stages:Je,activeKey:St,onPick:ve=>ot({attempt:Se,key:ve})},Se)})]}),St==="scan"&&a.jsxs(a.Fragment,{children:[t.historyError&&a.jsx(Sd,{className:"border-error/40",children:a.jsxs("div",{className:"px-4 py-3 text-[13px] leading-snug text-text-200",children:["扫描记录读不出来:",t.historyError,"。重新扫描会重建它。"]})}),!f&&t.scans.length>0&&a.jsx(uOe,{scans:t.scans,...n?{repo:n}:{},...r?{released:r}:{},...Z?{selectedId:Z.id}:{},...t.online!==void 0?{online:t.online}:{},onSelect:be}),ht&&Z&&ht.packages.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(dw,{className:"size-[18px]"}),title:"镜像",count:Z.status==="scanning"?"还在长…":`${ht.packages.length} 项`}),ht.packages.map(ve=>a.jsx(_X,{name:ve.name,version:ve.version,min:ve.min,localVersion:ve.localVersion,from:ve.from,aptVersion:ve.aptVersion,aptMissing:ve.aptMissing,artifact:ve.artifact,evidence:Jn(`package:${ve.name}`),blockers:i7(ve)},ve.name))]}),ht&&Z&&ht.connectors.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(hw,{className:"size-[18px]"}),title:"连接器",count:`${ht.connectors.length} 个`}),ht.connectors.map(ve=>a.jsx(lOe,{connector:ve,publisherAuth:t.publisherFeishuAuth,onRefreshPublisherAuth:e.onRefreshPublisherAuth,evidence:Jn(`connector:${ve.name}`),onChange:ae=>{var Ue;return(Ue=e.onPatchConnector)==null?void 0:Ue.call(e,Z.id,ae)},...ve.credentialSource==="shared"&&ve.fields.length>0?{secretCard:a.jsx(cE,{embedded:!0,secret:{name:ve.name,env:ve.fields},presence:t.secrets?t.secrets.filter(ae=>ve.fields.includes(ae.env)):void 0,onSubmitValues:ae=>e.onPutSecret(Z.id,ve.name,ae)})}:{}},ve.name))]}),ht&&Z&&Ht.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(og,{className:"size-[18px]"}),title:"凭据",count:`${Ht.length} 条`}),Ht.map(ve=>a.jsx(cE,{secret:ve,evidence:Jn(`secret:${ve.name}`),presence:t.secrets?t.secrets.filter(ae=>ve.env.includes(ae.env)):void 0,onSubmitValues:ae=>e.onPutSecret(Z.id,ve.name,ae)},ve.name))]}),(ht==null?void 0:ht.test)&&a.jsx(EX,{test:ht.test}),Z&&Z.notes.length>0&&a.jsxs(Sd,{children:[a.jsx(Qr,{icon:a.jsx(yn,{className:"size-[18px]"}),title:"存疑项",count:`${Z.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:Z.notes.map((ve,ae)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),ve]},ae))})]})]}),St==="config"&&a.jsxs(a.Fragment,{children:[e.onSetEngineAuth&&a.jsx(dX,{createRepoOnSave:!n,...dn?{state:dn}:{},...Dn?{setAt:Dn}:{},channels:e.channels,channelId:((us=e.state.engineChannels)==null?void 0:us.integration)===null?null:(vi=(qs=e.state.engineChannels)==null?void 0:qs.integration)==null?void 0:vi.channelId,onRefreshChannels:e.onRefreshChannels,onSave:e.onSetEngineAuth}),e.engine&&e.engineEditor&&a.jsx(vOe,{tool:e.engine.tool,model:e.engine.model,effort:e.engine.effort??"",...e.engineEditor}),(e.onChangeSize||e.onChangeCpu)&&a.jsx(fOe,{size:e.size,cpu:e.cpu,onChange:e.onChangeSize,onChangeCpu:e.onChangeCpu,saving:e.resourceSaving,disabled:m||g||u||k||on,taskConcurrency:e.onSaveTaskConcurrency?{value:P,defaulted:e.taskConcurrency===void 0,dirty:B,valid:F,saving:k,disabled:m||g||!!e.resourceSaving,error:F?j:"请输入大于 0 的整数",saved:E,onChange:ve=>{S(ve),R(null),I(!1)},onSave:()=>void O()}:void 0}),e.scanError&&a.jsx("div",{className:"whitespace-pre-wrap text-xs text-error",children:e.scanError})]})]})}),e.workPanel&&a.jsx("div",{className:`shrink-0 overflow-hidden transition-[width] duration-300 ease-out ${yt?"w-[380px]":"w-0"}`,children:a.jsx("div",{className:"h-full w-[380px] border-l border-border bg-surface-card",children:e.workPanel})})]})}function wOe(e){return a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsxs("span",{children:["第 ",e.n," 次"]}),a.jsx("span",{className:"text-text-400",children:Xh(e.s.startedAt)}),a.jsx("span",{className:"font-mono text-xs text-text-400",children:(e.s.head??"").slice(0,7)}),a.jsx("span",{className:"text-xs text-text-400",children:e.s.baseKind==="soft"?"软扫":"硬扫"}),e.latest&&a.jsx("span",{className:"rounded-full bg-text-100-dim px-1.5 text-[11px] text-text-400",children:"最新"})]})}function _Oe(e){const{repo:t}=e.state;if(!t)return a.jsx("span",{children:e.starting?"正在建仓库…":"还没有仓库"});const n=t.dirty?"有未提交的改动":t.ahead>0?`有 ${t.ahead} 个提交没推`:"已同步";return a.jsxs(a.Fragment,{children:[a.jsx(yu,{className:"size-3 shrink-0"}),a.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",title:Rh(t.url),className:"truncate hover:text-accent hover:underline",children:Rh(t.url)}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:t.branch}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:`shrink-0 ${t.dirty||t.ahead>0?"text-warning":""}`,children:n}),e.scanBase&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",title:e.scanBase.title,children:e.scanBase.label})]})]})}function SOe(e){if(e)return e.baseKind==="soft"?{label:"软扫",title:"只重看了跟线上正跑那版有差别的部分"}:{label:"硬扫",title:"从零把 persona 整个读了一遍"}}const Sd=p.forwardRef(function(t,n){return a.jsx("div",{ref:n,className:`rounded-lg border border-border-card bg-surface-card ${t.className??""}`,children:t.children})});function kOe(e){const t=ua("sessions"),n=t==null?void 0:t.find(r=>r.sessionId===e.sessionId);return a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-2.5",children:[e.live?a.jsx(st,{className:"size-3.5 animate-spin text-accent"}):a.jsx(Jt,{className:"size-3.5 text-success"}),a.jsx("span",{className:"text-sm font-medium text-text-100",children:"管家在读这个 persona"}),a.jsx("span",{className:"text-xs text-text-400",children:e.live?"进行中":"可以接着问它"})]}),a.jsx("div",{className:"min-h-0 flex-1",children:n?a.jsx(c_,{extras:{session:n,api:e.api,hideHeader:!0,flatProcess:!0}},n.sessionId):a.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-xs text-text-400",children:[a.jsx(st,{className:"size-3.5 animate-spin"}),"正在接上管家的会话"]})})]})}function COe(e){var lr,In,Dt,Bt,mn,Tn,Rr,Ji,xr,vr,us,qs,vi,ve,ae,Ue,ze,Ut,cr,eo,Kx,ed,Gx,Wf;const{state:t,remoteReady:n,remoteError:r,loading:s,error:i,refresh:o,awaitingRun:l,retry:c,scan:u,patch:d,putSecret:h,setEngineAuth:f,release:m,rerunJob:g,applyConfig:x,unpublishFrom:b,unpublish:y,promote:v,openTest:w}=AR(e.personaId,{mode:"staged"}),_=Kn(),S=$V(_,"integration"),[k,N]=p.useState(null),[j,R]=p.useState(null),[E,I]=p.useState(!1),[M,P]=p.useState(null),[D,F]=p.useState(!1),B=p.useRef(null),U=p.useRef(null),[$,O]=p.useState(!1);p.useEffect(()=>{B.current=null,U.current=null,O(!1),F(!1),P(null)},[e.personaId]);const[T,V]=p.useState(!1),H=p.useRef(e.personaId),L=p.useRef(null);H.current!==e.personaId&&(H.current=e.personaId,L.current=null),t&&n&&L.current===null&&(L.current=Sy(t));const q=t?hX(t,L.current??Sy(t)):void 0,K=!T&&km(n1(q==null?void 0:q.scans,q==null?void 0:q.release),q==null?void 0:q.release)?q==null?void 0:q.release:void 0,X=((Dt=(In=(lr=t==null?void 0:t.targets)==null?void 0:lr.integration)==null?void 0:In.run)==null?void 0:Dt.status)==="completed"&&t.targets.integration.run.conclusion==="success"&&!!(K!=null&&K.verified)&&((mn=(Bt=t==null?void 0:t.targets)==null?void 0:Bt.integration)==null?void 0:mn.image)===K.verified.image&&((Ji=(Rr=(Tn=t==null?void 0:t.targets)==null?void 0:Tn.integration)==null?void 0:Rr.run)==null?void 0:Ji.runId)===K.runId&&((us=(vr=(xr=t.targets)==null?void 0:xr.integration)==null?void 0:vr.run)==null?void 0:us.runAttempt)===K.runAttempt,te=X&&!!((qs=K==null?void 0:K.verified)!=null&&qs.verification.checks.includes("persona-dialogue"))&&((ae=(ve=(vi=t==null?void 0:t.targets)==null?void 0:vi.integration)==null?void 0:ve.run)==null?void 0:ae.jobs.some(Oe=>Oe.key===mo&&Oe.status==="done")),oe=t==null?void 0:t.scans.find(Oe=>Oe.id===(K==null?void 0:K.scanId)),Q=(ze=(Ue=t==null?void 0:t.targets)==null?void 0:Ue.production)==null?void 0:ze.secrets,he=!!oe&&!!Q&&Jle(oe.manifest).every(Oe=>Q.some(jt=>jt.env===Oe&&jt.setAt))&&kb(Q)!=="partial",be=[...(t==null?void 0:t.promotions)??[]].reverse().find(Oe=>Oe.releaseId===(K==null?void 0:K.id)),Z=PR(be),ce=(be==null?void 0:be.phase)==="completed";p.useEffect(()=>{let Oe=!1;return N(null),K!=null&&K.id&&e.api.sessionList().then(({sessions:jt})=>{Oe||N(jt.find(yr=>{var Wr;return yr.testReleaseId===K.id&&yr.cloudExpectedImage===((Wr=K.verified)==null?void 0:Wr.image)})??null)}).catch(()=>{}),()=>{Oe=!0}},[e.api,K==null?void 0:K.id,(Ut=K==null?void 0:K.verified)==null?void 0:Ut.image]);const se=async()=>{if(K!=null&&K.id){I(!0),R(null);try{const Oe=await w(K.id),Wr=(await e.api.sessionList()).sessions.find(hl=>hl.testReleaseId===K.id&&hl.cloudExpectedImage===Oe.expectedImage&&hl.ownerPersonaId===Oe.personaId)??await e.api.sessionCreate({ownerPersonaId:Oe.personaId,label:"测试 · "+e.personaId});N(Wr)}catch(Oe){R(Oe instanceof Error?Oe.message:String(Oe))}finally{I(!1)}}},fe=async()=>{if(!(K!=null&&K.id)||B.current||Z||ce||U.current)return;const Oe={releaseId:K.id};B.current=Oe,F(!0),P(null);try{await v(K.id)}catch(jt){B.current===Oe&&P({releaseId:Oe.releaseId,message:jt instanceof Error?jt.message:String(jt)})}finally{B.current===Oe&&(B.current=null,F(!1))}},{status:xe,startOauth:Me,authorize:Xe}=gX(),me=p.useCallback(async()=>{const Oe=await Me();return await o(),Oe},[Me,o]),Ce=p.useCallback(async Oe=>{await Xe(Oe),await o()},[Xe,o]),je=(xe==null?void 0:xe.status)==="authorized";p.useEffect(()=>{je&&o()},[je,o]);const{persona:Se,refresh:ut}=NR(e.personaId),ot=Se?S7(Se):void 0,yt=Se?Ice(Se):void 0,re=NPe(mX({current:yt,release:q==null?void 0:q.release,run:((eo=(cr=t==null?void 0:t.targets)==null?void 0:cr.integration)==null?void 0:eo.run)??(t==null?void 0:t.run),anchored:!!K})),ue=(ot==null?void 0:ot.tool)==="claude",{capabilities:Te}=si(ot&&ol(ot.tool)?ot.tool:null),Ze=MPe(e.api,ot==null?void 0:ot.tool),[at,et]=p.useState([]),tt=p.useRef(0),Lt=p.useCallback(async()=>{const Oe=++tt.current,jt=await e.api.subscriptionChannelGet();tt.current===Oe&&et(jt.channels)},[e.api]);p.useEffect(()=>(Lt().catch(()=>{}),()=>{tt.current++}),[Lt]);const wt=(Kx=t==null?void 0:t.engineChannels)==null?void 0:Kx.integration,we=DPe(e.api,wt),[He,ct]=p.useState(!1),[Ot,on]=p.useState(!1),[Ne,ne]=p.useState(null),[De,Je]=p.useState(null),[dt,Nt]=p.useState(null),St=Oe=>Oe instanceof Error?Oe.message:String(Oe),dn=async Oe=>{const jt=L.current;t&&(L.current=t.releases.length),V(!0),ne(null),Je(null),R(null),P(null);try{await u(Oe)}catch(yr){L.current=jt,ne(St(yr))}finally{V(!1)}},Dn=async Oe=>{if(!U.current){ct(!0),Je(null),Nt(null);try{await m(Oe)}catch(jt){Je(St(jt))}finally{ct(!1)}}},Jn=async Oe=>{var jt,yr,Wr,hl;Je(null);try{await g(Oe)}catch(Yx){!((Wr=(yr=(jt=t==null?void 0:t.targets)==null?void 0:jt.integration)==null?void 0:yr.run)!=null&&Wr.jobs.some(Ec=>Ec.jobId===Oe))&&!((hl=t==null?void 0:t.run)!=null&&hl.jobs.some(Ec=>Ec.jobId===Oe))&&Je(St(Yx))}},ht=async()=>{on(!0),Nt(null);try{await y()}catch(Oe){Nt(St(Oe).replace(/^[A-Z_]+: /,""))}finally{on(!1)}},Ht=async Oe=>{ne(null);try{const jt=ue&&!("tool"in Oe)?{cloudEngine:{...Se==null?void 0:Se.cloudEngine,...Oe}}:Oe,yr=await e.api.personaUpdate(e.personaId,jt);ut(yr).catch(()=>{})}catch(jt){ne(St(jt))}},hn=async Oe=>{if(U.current)throw new Error("资源设置正在保存,请稍后重试");const jt={};U.current=jt;try{await e.api.personaUpdate(e.personaId,{taskConcurrency:Oe}),await ut()}finally{U.current===jt&&(U.current=null)}},En=async Oe=>{if(U.current||He||l)return;const jt={};U.current=jt,O(!0),ne(null);try{const yr=await e.api.personaUpdate(e.personaId,Oe);if(U.current!==jt)return;await ut(yr)}catch(yr){U.current===jt&&ne(St(yr))}finally{U.current===jt&&(U.current=null,O(!1))}};if(s&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(i&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:i});if(!t)return null;const Mt=kc(t.scans);return a.jsx(bOe,{state:t,...yt?{currentConfig:yt}:{},onApplyConfig:x,integrationLogin:S.identity?a.jsxs("div",{className:"text-xs text-text-400",children:["测试环境 · 已登录 ",S.identity.displayName]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(Le,{size:"sm",onClick:()=>{S.login().then(Oe=>window.open(Oe,"_blank","noopener,noreferrer")).catch(Oe=>R(Oe instanceof Error?Oe.message:String(Oe)))},children:"用当前飞书账号登录测试环境"}),S.error&&a.jsx("div",{className:"text-error",children:S.error})]}),testActions:a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex flex-wrap gap-2",children:a.jsx(Le,{size:"sm",onClick:()=>void se(),disabled:!X||E,children:"打开测试对话(可选)"})}),j&&a.jsx("div",{className:"text-error",children:j}),k&&k.testReleaseId===(K==null?void 0:K.id)&&a.jsx("div",{className:"h-[480px] overflow-hidden rounded-lg border border-border",children:a.jsx(c_,{extras:{session:k,api:e.api,hideHeader:!0}},k.sessionId)})]}),productionActions:a.jsxs("div",{className:"space-y-3",children:[oe&&a.jsxs("details",{children:[a.jsx("summary",{className:"cursor-pointer",children:"线上环境的凭据"}),a.jsx("div",{className:"text-xs text-text-400",children:"在这里填写线上使用的账号。测试环境的账号单独保存。"}),[...oe.manifest.secrets,...aw(oe.manifest)].map(Oe=>a.jsx(cE,{secret:Oe,presence:Q,onSubmitValues:jt=>h(oe.id,Oe.name,jt,"production")},Oe.name)),a.jsx(dX,{state:Q?kb(Q):void 0,channels:at,channelId:((ed=t.engineChannels)==null?void 0:ed.production)===null?null:(Wf=(Gx=t.engineChannels)==null?void 0:Gx.production)==null?void 0:Wf.channelId,onRefreshChannels:Lt,onSave:Oe=>f(Oe,"production")})]}),re&&a.jsx("div",{className:"text-warning",children:re}),!re&&!he&&te&&a.jsx("div",{className:"text-warning",children:"先填齐线上环境的凭据,再上线。"}),a.jsx(Le,{size:"sm",onClick:()=>void fe(),disabled:!te||!!re||!he||D||Z||ce||$,children:D?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在提交上线"]}):Z?a.jsxs(a.Fragment,{children:[a.jsx(st,{className:"mr-1.5 size-3.5 animate-spin"}),"正在上线"]}):ce?"已上线":"上线"})]}),starting:T,releasing:He,awaitingRun:l,retry:c,promoting:D,productionError:(M==null?void 0:M.releaseId)===(K==null?void 0:K.id)&&!Z&&!ce?M==null?void 0:M.message:void 0,onRefreshRetry:()=>void o(),busy:Ot||D||Z,scanError:Ne??(!n&&r?`读不到线上状态(${r}),先只显示本机已知的内容;关掉再打开发布页可重试。`:null),releaseError:De,onScan:Oe=>void dn(Oe),onRelease:Oe=>void Dn(Oe),onRetryJob:Oe=>void Jn(Oe),onPutSecret:h,onSetEngineAuth:f,channels:at,onRefreshChannels:Lt,onRefreshPublisherAuth:()=>void o(),onPatchConnector:(Oe,jt)=>{ne(null),d(Oe,{connector:jt}).then(()=>jt.protocol==="lark-sidecar"&&jt.credentialSource==="shared"?o():void 0).catch(yr=>ne(St(yr)))},onAuthorizeGithub:Ce,onStartGithubOauth:me,...ot?{engine:ot}:{},localEngineVersion:Ze,...(Se==null?void 0:Se.size)!==void 0?{size:Se.size}:{},...(Se==null?void 0:Se.cpu)!==void 0?{cpu:Se.cpu}:{},resourceSaving:$,onChangeSize:Oe=>void En({size:Oe}),onChangeCpu:Oe=>void En({cpu:Oe}),...Se?{taskConcurrency:Se.taskConcurrency,onSaveTaskConcurrency:hn}:{},engineEditor:{modelList:we,...wt?{}:{allowManualModel:!0},configSchema:(Te==null?void 0:Te.configSchema)??[],onChange:Oe=>void Ht(Oe)},roundIdx:L.current??Sy(t),...jPe(t)||b!==void 0?{live:{status:DR(t,b),error:dt,onUnpublish:()=>void ht()}}:{},...e.cloud?{cloud:e.cloud}:{},...e.onOpenSettings?{onOpenSettings:e.onOpenSettings}:{},...Mt!=null&&Mt.scanSessionId?{workPanel:a.jsx(kOe,{api:e.api,sessionId:Mt.scanSessionId,live:Mt.status==="scanning"})}:{}},e.personaId)}function IX(e,t,n){const r=Kn(),[s,i]=p.useState({}),o=p.useRef(0),l=p.useRef(new Set);return p.useEffect(()=>{o.current++,l.current=new Set,i({})},[e]),p.useEffect(()=>{if(!n||!e)return;const c=t.filter(h=>!l.current.has(cn(h)));if(c.length===0)return;for(const h of c)l.current.add(cn(h));i(h=>({...h,...Object.fromEntries(c.map(f=>[cn(f),"loading"]))}));const u=o.current,d=new Vt(r);for(const h of c)d.deployGet(e,h.id?{releaseId:h.id,environment:h.environment}:{releaseHead:h.head}).then(f=>u===o.current&&i(m=>({...m,[cn(h)]:f.run})),()=>u===o.current&&i(f=>({...f,[cn(h)]:void 0})))},[r,e,t,n]),s}function TX(e){const{slot:t}=e;return t==="loading"?a.jsx(st,{className:"size-3 animate-spin text-text-400","aria-label":"查流水线"}):t===void 0?a.jsx("span",{className:"text-text-400",children:"查不到"}):t.status!=="completed"?a.jsxs("span",{className:"inline-flex items-center gap-1 text-accent",children:[a.jsx(st,{className:"size-3 animate-spin"}),"进行中"]}):sc(t)?a.jsxs("span",{className:"inline-flex items-center gap-1 text-success",children:[a.jsx(Jt,{className:"size-3"}),"成功"]}):a.jsxs("span",{className:"inline-flex items-center gap-1 text-error",children:[a.jsx(Xt,{className:"size-3"}),"失败"]})}function NOe(e){const{releases:t,scans:n}=e,[r,s]=p.useState(!1),i=OR(t,e.runs,e.online),o=ba(t),l=m=>m===o||m===i||fX(m,e.runs)||cn(m)===e.selectedHead,c=t.map((m,g)=>({r:m,n:g+1})).reverse(),u=r?c:c.filter(({r:m})=>l(m)),d=c.length-u.length,h=e.repo?Rh(e.repo.url):void 0,f=m=>n.find(g=>g.id===m.scanId);return a.jsxs("div",{className:"rounded-lg border border-border-card bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(L5,{className:"size-[18px]"}),title:"发布历史",count:`${t.length} 次`}),a.jsxs("ul",{className:"divide-y divide-border-card","data-testid":"release-history",children:[u.map(({r:m,n:g})=>{const x=cn(m)===e.selectedHead,b=f(m);return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>e.onSelect(cn(m)),"aria-current":x,"aria-label":`第 ${g} 次发布`,className:`flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left text-[13px] transition-colors ${x?"bg-accent-dim/60":"hover:bg-text-100-dim/40"}`,children:[a.jsxs("span",{className:"w-8 shrink-0 font-mono text-xs text-text-400",children:["#",g]}),a.jsx("span",{className:"shrink-0 tabular-nums text-text-200",children:Xh(m.at)}),h?a.jsxs("a",{href:`https://github.com/${h}/commit/${m.head}`,target:"_blank",rel:"noreferrer",onClick:y=>y.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 font-mono text-xs text-accent hover:underline",children:[m.head.slice(0,7),a.jsx(Fr,{className:"size-3"})]}):a.jsx("span",{className:"shrink-0 font-mono text-xs text-text-400",children:m.head.slice(0,7)}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-text-400",children:b?`${b.baseKind==="soft"?"软扫":"硬扫"} · ${Xh(b.startedAt)}`:"扫描记录已丢"}),m.environment&&a.jsx("span",{className:"shrink-0 text-xs text-text-400",children:m.environment==="integration"?"测试":"线上发布"}),i&&cn(i)===cn(m)&&a.jsx("span",{className:"shrink-0 rounded-full bg-success-dim px-1.5 py-0.5 text-[11px] font-medium text-success",children:"线上"}),a.jsx("span",{className:"w-28 shrink-0 text-right text-xs",children:a.jsx(TX,{slot:e.runs[cn(m)]})})]})},cn(m))}),d>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>s(!0),className:"flex w-full cursor-pointer items-center gap-1.5 px-4 py-2 text-xs text-text-400 hover:bg-text-100-dim/40 hover:text-text-200",children:[a.jsx(Yt,{className:"size-3.5"}),"还有 ",d," 次发布"]})})]})]})}function y0(e){return a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card",children:e.children})}function jOe(e){const{scan:t}=e,n=t.manifest,r=s=>t.evidence.find(i=>i.target===s);return a.jsxs(a.Fragment,{children:[n.packages.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(dw,{className:"size-[18px]"}),title:"镜像",count:`${n.packages.length} 项`}),n.packages.map(s=>a.jsx(_X,{name:s.name,version:s.version,min:s.min,localVersion:s.localVersion,from:s.from,aptVersion:s.aptVersion,aptMissing:s.aptMissing,artifact:s.artifact,evidence:r(`package:${s.name}`)},s.name))]}),n.connectors.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(hw,{className:"size-[18px]"}),title:"连接器",count:`${n.connectors.length} 个`}),n.connectors.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"text-xs text-text-400",children:SX(s)}),a.jsxs("span",{className:"ml-auto text-xs text-text-300",children:[s.credentialSource?hE[s.credentialSource].label:"—",s.credentialSource==="personal"&&s.auth?` · ${ky[s.auth].label}`:"",s.fields.length>0&&(s.credentialSource==="shared"||s.auth==="fields")?` · ${s.fields.join(" / ")}`:""]})]},s.name))]}),n.secrets.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(og,{className:"size-[18px]"}),title:"凭据",count:`${n.secrets.length} 条`}),n.secrets.map(s=>a.jsxs("div",{className:"flex items-baseline gap-3 border-b border-border-card px-5 py-3 last:border-b-0",children:[a.jsx("span",{className:"text-[15px] font-semibold",children:s.name}),a.jsx("span",{className:"ml-auto font-mono text-xs text-text-300",children:s.env.join(" / ")})]},s.name))]}),n.test&&a.jsx(EX,{test:n.test}),t.notes.length>0&&a.jsxs(y0,{children:[a.jsx(Qr,{icon:a.jsx(yn,{className:"size-[18px]"}),title:"存疑项",count:`${t.notes.length} 条`,tone:"warning"}),a.jsx("div",{className:"space-y-2 px-5 py-4",children:t.notes.map((s,i)=>a.jsxs("div",{className:"flex gap-2 text-[13px] leading-snug text-text-300",children:[a.jsx("span",{className:"shrink-0 text-warning",children:"•"}),s]},i))})]})]})}function EOe(e){const{state:t,runs:n}=e,{releases:r,scans:s,repo:i}=t,[o,l]=p.useState(e.initialHead??null),c=(o?r.find(w=>cn(w)===o):void 0)??ba(r),u=c?r.indexOf(c)+1:0,d=OR(r,n,t.online),h=i?Rh(i.url):void 0,f=c?s.find(w=>w.id===c.scanId):void 0,m=c?n[cn(c)]:void 0,g=m==="loading"?void 0:m,x=c?wX({personaId:t.personaId,frozen:!0,live:d!==void 0&&cn(d)===cn(c),offline:t.online===!1,scans:f?[f]:[],released:c,...g?{run:g}:{},blockers:[]}):[],[b,y]=p.useState(null),v=b&&c&&b.head===cn(c)?b.key:r1(x)??"scan";return a.jsx("div",{className:"flex h-full overflow-hidden bg-surface-page text-text-100",children:a.jsx("div",{className:"min-w-0 flex-1 overflow-y-auto",children:a.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 px-6 py-8",children:[a.jsx("div",{className:"sticky top-0 z-10 -mx-6 bg-surface-page/95 px-6 py-2 backdrop-blur",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(L5,{className:"size-5 text-accent"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-medium",children:"发布历史"}),a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-text-400",children:[a.jsx("span",{className:"truncate",title:t.personaId,children:t.personaId}),h&&i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx(yu,{className:"size-3 shrink-0"}),a.jsx("a",{href:i.url,target:"_blank",rel:"noreferrer",className:"truncate hover:text-accent hover:underline",children:h})]}),a.jsx("span",{className:"shrink-0",children:"·"}),a.jsx("span",{className:"shrink-0",children:"只读"})]})]})]})}),r.length===0&&a.jsx("div",{className:"rounded-lg border border-border-card bg-surface-card px-5 py-6 text-[13px] text-text-300",children:"还没发布过。去 persona 卡片上点「发布到云上」,从扫描开始。"}),r.length>0&&a.jsx(NOe,{releases:r,scans:s,runs:n,...i?{repo:i}:{},...c?{selectedHead:cn(c)}:{},...t.online!==void 0?{online:t.online}:{},onSelect:w=>{l(w),y(null)}}),c&&a.jsxs("div",{className:"rounded-lg border border-accent/40 bg-surface-card",children:[a.jsx(Qr,{icon:a.jsx(iy,{className:"size-[18px]"}),title:`第 ${u} 次发布`,count:Xh(c.at),tone:"accent"}),a.jsx("div",{className:"px-5 py-4",children:a.jsx(yX,{stages:x,activeKey:v,onPick:w=>y({head:cn(c),key:w})},cn(c))})]}),f&&a.jsx(jOe,{scan:f})]})})})}function IOe(e){const{state:t,loading:n,error:r}=AR(e.personaId),s=(t==null?void 0:t.releases)??[],i=IX(e.personaId,s,t!==null);if(n&&!t)return a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-text-400",children:[a.jsx(st,{className:"size-4 animate-spin"}),"正在打开"]});if(r&&!t)return a.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-error",children:r});if(!t)return null;const o=ba(s),l=o&&Ru(o,t.run)?{...i,[cn(o)]:t.run}:i;return a.jsx(EOe,{state:t,runs:l,...e.initialHead?{initialHead:e.initialHead}:{}})}const pC=10*60*1e3,nL=["bg-rose-500","bg-orange-500","bg-amber-500","bg-lime-500","bg-emerald-500","bg-cyan-500","bg-blue-500","bg-violet-500","bg-fuchsia-500"];function TOe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return nL[Math.abs(t)%nL.length]}function ROe(e){const t=e.trim();if(!t)return"?";const n=t.split(/\s+/);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():t.slice(0,2).toUpperCase()}function fE(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function MOe(e){const t=new Date(e),n=new Date,r=t.toDateString()===n.toDateString(),s=new Date(n);s.setDate(s.getDate()-1);const i=t.toDateString()===s.toDateString();return r?`今天 ${fE(e)}`:i?`昨天 ${fE(e)}`:t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function POe(e){const t=[];let n;for(let r=0;r<e.length;r++){const s=e[r];(!n||s.createdAt-n.createdAt>=pC)&&t.push({kind:"divider",divider:s.createdAt});const i=!!n&&n.fromOwner===s.fromOwner&&s.createdAt-n.createdAt<pC,o=e[r+1],l=o&&o.fromOwner===s.fromOwner&&o.createdAt-s.createdAt<pC;t.push({kind:"bubble",msg:s,showAvatar:!i,isLast:!l}),n=s}return t}function OOe({thread:e,messages:t,selfDisplayName:n,onSend:r,readOnlyHint:s}){const[i,o]=p.useState(""),l=p.useRef(null),c=p.useRef(null),u=p.useMemo(()=>POe(t),[t]);p.useEffect(()=>{const m=c.current;m&&(m.scrollTop=m.scrollHeight)},[t.length]);const d=()=>{const m=l.current;m&&(m.style.height="auto",m.style.height=Math.min(m.scrollHeight,160)+"px")};p.useEffect(()=>{d()},[i]);const h=()=>{const m=i.trim();m&&(r==null||r(m),o(""),l.current&&(l.current.value=""))},f=mi(h);return a.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full bg-bg-100",children:[a.jsxs("header",{className:"px-4 py-3 border-b border-border bg-elevated flex items-center gap-3 shrink-0",children:[a.jsx(LR,{name:e.peerDisplayName,size:"md"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h2",{className:"text-sm font-semibold text-text-100 leading-tight",children:e.peerDisplayName}),a.jsx("p",{className:"text-[11px] text-text-400 mt-0.5 flex items-center gap-1.5",children:s?a.jsx("span",{children:"访客"}):e.peerOnline?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-emerald-500"}),a.jsx("span",{children:"在线"})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-text-400"}),a.jsx("span",{children:"离线"})]})})]}),a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("button",{className:"p-2 rounded text-text-400 hover:bg-bg-200 hover:text-text-100 transition-colors",children:a.jsx(ihe,{className:"h-4 w-4"})})})]}),a.jsx("div",{ref:c,className:"flex-1 overflow-auto px-4 py-3 flex flex-col gap-1",children:t.length===0?a.jsx(DOe,{peerName:e.peerDisplayName}):u.map((m,g)=>m.kind==="divider"?a.jsx("div",{className:"flex items-center justify-center my-3",children:a.jsx("span",{className:"text-[10px] text-text-400 bg-bg-100 px-2 py-0.5 rounded-full",children:MOe(m.divider)})},`d-${g}`):a.jsx(AOe,{msg:m.msg,peerName:e.peerDisplayName,selfName:n,showAvatar:m.showAvatar,isLast:m.isLast},m.msg.id))}),!e.peerOnline&&!s&&a.jsxs("div",{className:"px-4 py-1.5 bg-amber-50 border-t border-amber-100 text-[11px] text-amber-900 shrink-0",children:[e.peerDisplayName," 离线,发出的消息会标记为失败"]}),s?a.jsx("footer",{"data-testid":"dm-readonly-hint",className:"px-4 py-3 border-t border-border bg-elevated shrink-0 text-[12px] text-text-400 text-center",children:s}):a.jsxs("footer",{className:"px-4 py-3 border-t border-border bg-elevated shrink-0",children:[a.jsxs("div",{className:"flex items-end gap-2 rounded-lg border border-border bg-bg-50 focus-within:border-accent focus-within:ring-1 focus-within:ring-accent transition-colors px-3 py-2",children:[a.jsx("textarea",{ref:l,rows:1,placeholder:`给 ${e.peerDisplayName} 发消息...`,value:i,onChange:m=>o(m.target.value),...f,className:"flex-1 resize-none bg-transparent text-sm text-text-100 placeholder:text-text-400 focus:outline-none leading-relaxed py-0.5",style:{maxHeight:160}}),a.jsx(Le,{size:"sm",variant:i.trim()?"default":"ghost",disabled:!i.trim(),onClick:h,className:"h-8 w-8 p-0 shrink-0",children:a.jsx(fw,{className:"h-4 w-4"})})]}),a.jsxs("p",{className:"text-[10px] text-text-400 mt-1.5 px-1",children:[a.jsx("kbd",{className:"font-mono",children:"Enter"})," 发送 · ",a.jsx("kbd",{className:"font-mono",children:"Shift"}),"+",a.jsx("kbd",{className:"font-mono",children:"Enter"})," 换行"]})]})]})}function DOe({peerName:e}){return a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-4 py-8",children:[a.jsx(LR,{name:e,size:"xl"}),a.jsx("p",{className:"text-sm text-text-200 mt-4",children:e}),a.jsx("p",{className:"text-xs text-text-400 mt-1",children:"这是你们之间的开始 — 打个招呼吧"})]})}function AOe({msg:e,peerName:t,selfName:n,showAvatar:r,isLast:s}){const i=e.fromOwner,o=i?n:t;return a.jsxs("div",{className:J("group flex items-start gap-2",i?"flex-row-reverse":"flex-row",r?"mt-2":"mt-0.5"),children:[a.jsx("div",{className:"w-7 shrink-0",children:r&&o?a.jsx(LR,{name:o,size:"sm"}):null}),a.jsxs("div",{className:J("flex flex-col max-w-[70%] min-w-0",i?"items-end":"items-start"),children:[a.jsxs("div",{className:J("px-3 py-1.5 break-words",i?"bg-accent text-accent-contrast":"bg-bg-200 text-text-100",i?J("rounded-2xl",s?"rounded-br-md":"rounded-br-2xl",r?"rounded-tr-2xl":"rounded-tr-md"):J("rounded-2xl",s?"rounded-bl-md":"rounded-bl-2xl",r?"rounded-tl-2xl":"rounded-tl-md")),children:[e.personaOrigin&&a.jsx("span",{"data-testid":"dm-persona-origin",className:J("block text-[10px] mb-0.5 opacity-80",i?"text-accent-contrast":"text-text-300"),children:`${e.personaOrigin} 助手代发`}),a.jsx("p",{className:"text-[13.5px] leading-relaxed whitespace-pre-wrap",children:e.text})]}),a.jsxs("div",{className:J("flex items-center gap-1 px-1 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity",i?"flex-row-reverse":""),children:[a.jsx("span",{className:"text-[10px] text-text-400",children:fE(e.createdAt)}),i&&a.jsx($Oe,{status:e.deliveryStatus})]})]})]})}function $Oe({status:e}){return e==="sending"?a.jsx(M5,{className:"h-3 w-3 text-text-400"}):e==="sent"?a.jsx(Jt,{className:"h-3 w-3 text-text-400"}):e==="delivered"?a.jsx(Pde,{className:"h-3 w-3 text-text-400"}):e==="failed"?a.jsx(pa,{className:"h-3 w-3 text-destructive"}):null}function LR({name:e,size:t="sm"}){const n=t==="xl"?"h-16 w-16 text-xl":t==="md"?"h-9 w-9 text-sm":"h-7 w-7 text-[11px]";return a.jsx("div",{className:J("rounded-full flex items-center justify-center text-white font-semibold shrink-0",TOe(e),n),children:ROe(e)})}const LOe="访客消息由 persona 代发,这里不能回复——请到对应会话里处理";function BOe(e,t,n){var s;const r=e.senderDeviceId===t;return{id:e.id,threadId:e.peerDeviceId,fromOwner:r,fromDisplayName:r?void 0:n,text:e.text,createdAt:e.createdAt,deliveryStatus:r?"delivered":void 0,personaOrigin:((s=e.origin)==null?void 0:s.kind)==="persona"?e.origin.personaId:void 0}}function FOe({contact:e,im:t,selfPrincipalId:n,selfDisplayName:r,readOnly:s}){const i=t.ensurePeerLoaded;p.useEffect(()=>{i(e.deviceId)},[e.deviceId,i]);const o=p.useRef(new Map),l=t.messagesByPeerDeviceId.get(e.deviceId)??[],c=l.length>0?l[l.length-1].createdAt:0;p.useEffect(()=>{c===0||(o.current.get(e.deviceId)??0)>=c||(o.current.set(e.deviceId,c),t.markRead(e.deviceId,c))},[e.deviceId,c,t]);const u=p.useMemo(()=>(t.messagesByPeerDeviceId.get(e.deviceId)??[]).map(m=>BOe(m,n,e.displayName)),[t.messagesByPeerDeviceId,e.deviceId,e.displayName,n]),d=t.statusByPeerDeviceId.get(e.deviceId)==="connected",h={threadId:e.deviceId,peerAlias:e.deviceId,peerDisplayName:e.displayName,lastMessageAt:u.length>0?u[u.length-1].createdAt:0,lastMessagePreview:u.length>0?u[u.length-1].text:"",unreadCount:0,peerOnline:d};return a.jsx(OOe,{thread:h,messages:u,selfDisplayName:r,onSend:s?void 0:f=>void t.sendMessage(e.deviceId,f),readOnlyHint:s?LOe:void 0})}function zOe({status:e,onRetry:t,topBanner:n}){if(e.kind==="starting")return a.jsxs("div",{"data-testid":"extension-iframe-starting",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50",children:[a.jsx(st,{className:"w-6 h-6 text-text-300 animate-spin"}),a.jsxs("div",{className:"text-[13px] text-text-200",children:["Starting ",e.name,"…"]}),a.jsx("div",{className:"text-[11px] text-text-400/80",children:"spawning child process"})]});if(e.kind==="error")return a.jsxs("div",{"data-testid":"extension-iframe-error",className:"flex-1 flex flex-col items-center justify-center gap-3 bg-bg-50 px-8",children:[a.jsx(yn,{className:"w-6 h-6 text-red-400"}),a.jsxs("div",{className:"text-[13px] text-text-100",children:["Failed to start ",e.name]}),a.jsx("div",{className:"text-[11px] text-text-400/90 max-w-md text-center font-mono",children:e.message}),a.jsxs("button",{type:"button",onClick:t,"data-testid":"extension-iframe-retry",className:J("mt-1 flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[12px]","border border-border text-text-200 hover:text-text-100 hover:bg-text-100/5 transition-colors"),children:[a.jsx(mf,{className:"w-3.5 h-3.5"}),"Retry"]})]});const r=e.target.kind==="local"?`http://127.0.0.1:${e.target.port}/`:e.target.url;return a.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n,a.jsx("iframe",{"data-testid":"extension-iframe-running","data-target-kind":e.target.kind,title:e.name,src:r,className:"flex-1 w-full h-full border-0 bg-bg-50",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"})]})}function HOe({state:e,onUpdate:t,onDismiss:n,onViewLogs:r}){if(e.kind==="idle")return null;const s=VOe(e.kind);return a.jsxs("div",{"data-testid":"update-available-banner","data-state":e.kind,className:J("flex items-center gap-2 px-4 h-9 shrink-0 text-[12px] border-b",s.className),children:[a.jsx(s.Icon,{className:J("w-3.5 h-3.5 shrink-0",s.iconClassName),"aria-hidden":!0}),a.jsx("span",{className:"truncate flex-1",children:UOe(e)}),WOe(e,{onUpdate:t,onDismiss:n,onViewLogs:r})]})}function UOe(e){switch(e.kind){case"available":return`${e.extName} 有新版 v${e.toVersion}(当前 v${e.fromVersion})`;case"updating":{const t={fetching:"拉取中",extracting:"应用中",restarting:"重启中"}[e.step];return`正在更新 ${e.extName} → v${e.toVersion}(${t}…)`}case"success":return`${e.extName} 已更新到 v${e.toVersion}`;case"failed-rollback":return`${e.extName} v${e.attemptedVersion} 启动失败,已回退到 v${e.rolledBackTo}`}}function WOe(e,{onUpdate:t,onDismiss:n,onViewLogs:r}){return e.kind==="available"?a.jsxs(a.Fragment,{children:[a.jsx(rL,{tone:"accent",onClick:t,testId:"update-banner-update",children:"更新"}),a.jsx(mC,{onClick:n})]}):e.kind==="success"?a.jsx(mC,{onClick:n}):e.kind==="failed-rollback"?a.jsxs(a.Fragment,{children:[r?a.jsx(rL,{tone:"error",onClick:r,testId:"update-banner-view-logs",children:"查看日志"}):null,a.jsx(mC,{onClick:n})]}):null}function rL({tone:e,onClick:t,testId:n,children:r}){const s=e==="accent"?"bg-accent/10 hover:bg-accent/20 text-accent border border-accent/30":"bg-error/10 hover:bg-error/20 text-error border border-error/30";return a.jsx("button",{type:"button",onClick:t,"data-testid":n,className:J("inline-flex items-center gap-1 px-2 h-6 rounded-sm text-[11px] font-medium transition-colors",s),children:r})}function mC({onClick:e}){return a.jsx("button",{type:"button",onClick:e,"data-testid":"update-banner-dismiss",className:"inline-flex items-center justify-center w-5 h-5 text-text-400 hover:text-text-100 rounded-sm","aria-label":"dismiss",children:a.jsx(Xt,{className:"w-3 h-3"})})}function VOe(e){switch(e){case"available":return{Icon:rH,iconClassName:"",className:"bg-accent-dim text-accent border-accent/30"};case"updating":return{Icon:st,iconClassName:"animate-spin",className:"bg-warning-dim text-warning border-warning/30"};case"success":return{Icon:li,iconClassName:"",className:"bg-success-dim text-success border-success/30"};case"failed-rollback":return{Icon:yn,iconClassName:"",className:"bg-error-dim text-error border-error/30"}}}function qOe({client:e,extId:t,updateInfo:n,onApplyUpdate:r}){const[s,i]=p.useState({kind:"starting",name:t}),[o,l]=p.useState(null),[c,u]=p.useState(!1);p.useEffect(()=>{l(null),u(!1)},[t]);const d=p.useCallback(async()=>{let g=t;try{const b=(await e.request("extension.list",{})).extensions.find(y=>y.extId===t);b&&b.state!=="invalid"&&(g=b.manifest.name)}catch{}i({kind:"starting",name:g});try{const x=await e.request("extension.open",{extId:t});i({kind:"running",name:g,target:x})}catch(x){i({kind:"error",name:g,message:x.message})}},[e,t]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async()=>{if(!(!n||!r)){l({kind:"updating",extName:n.extName,toVersion:n.toVersion,step:"fetching"});try{const g=await r(n);g.kind==="updated"?(l({kind:"success",extName:n.extName,toVersion:g.installedVersion}),d()):l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:g.rolledBackTo,reason:g.reason})}catch(g){l({kind:"failed-rollback",extName:n.extName,attemptedVersion:n.toVersion,rolledBackTo:n.fromVersion,reason:g.message})}}},[n,r,d]);let f={kind:"idle"};o?f=o:n&&!c&&(f={kind:"available",extName:n.extName,fromVersion:n.fromVersion,toVersion:n.toVersion});const m=f.kind==="idle"?null:a.jsx(HOe,{state:f,onUpdate:()=>void h(),onDismiss:()=>{l(null),u(!0)}});return a.jsx(zOe,{status:s,onRetry:()=>void d(),topBanner:m})}function KOe(e){const t=new Map;return{observe(n,r){let s=t.get(n);s||(s={data:void 0,hasData:!1,listeners:new Set},t.set(n,s));const i=c=>r(c);s.listeners.add(i);const o=s.listeners.size===1;i(s.hasData?s.data:void 0),o&&e.onFirstObserver(n);let l=!1;return()=>{if(l)return;l=!0;const c=t.get(n);c&&(c.listeners.delete(i),c.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const s=t.get(n);if(!s)return;const i=s.hasData?s.data:void 0,o=r(i);s.data=o,s.hasData=!0;for(const l of s.listeners)l(o)}}}function GOe(){const e=[],t=new Map,n=r=>{for(const s of e)if(s.pattern.test(r))return s.source;return null};return{register(r,s){e.push({pattern:r,source:s})},activate(r){if(t.has(r))return;const s=n(r);if(!s)throw new Error(`no source registered for key: ${r}`);t.set(r,s.start(r))},deactivate(r){const s=t.get(r);s&&(t.delete(r),s())}}}function YOe(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of F7)n.push(e.on(r,s=>t(r,s)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}const XOe=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:uG(e)});function ZOe(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let s=!1;const i=async()=>{try{const l=await e.request("capabilities:get",{tool:r});if(s)return;t(n,()=>l)}catch{if(s)return;t(n,()=>XOe(r))}},o=e.onConnect(()=>{i()});return i(),()=>{s=!0,o()}}}}function QOe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("session:list",void 0);if(r)return;t(n,()=>l.sessions??[])}catch{}},i=e.onFrame((l,c)=>{if(l==="session:info"){const u=c;if(u.chatId!==void 0)return;t(n,d=>[u,...(d??[]).filter(h=>h.sessionId!==u.sessionId)])}else if(l==="session:deleted"){const u=c;t(n,d=>(d??[]).filter(h=>h.sessionId!==u.sessionId))}}),o=e.onConnect(()=>{s()});return s(),()=>{r=!0,i(),o()}}}}const JOe="session/";function eDe(e){return{sid:e.slice(JOe.length)}}const tDe=new Set(E5);function RX(e){return tDe.has(e)}function sL(e){return RX(e)?e:"idle"}function nDe(e,t){return{start(n){const{sid:r}=eDe(n);let s=!1,i=-1;const o=f=>{t(n,m=>zV(m??vg,f,r))},l=async f=>{const m=f==="baseline"?-1:i;try{const g=await e.request("session:events",{sessionId:r,afterSeq:m});if(s)return;const x=g.events??[],b=g.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:x,latestSeq:b}),i=b;else{const y=g.bufferStartSeq??0,v=b<m||y>m+1;o({type:v?"session:events":"session:events:append",sessionId:r,events:x,latestSeq:b}),i=Math.max(i,b)}}catch{}},c=async()=>{try{const f=await e.request("info");if(s)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(m=>({sessionId:m.sessionId,freshSpawn:m.freshSpawn,status:sL(m.status)}))})}catch{}},u=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}s||(await l(i<0?"baseline":"delta"),!s&&await c())},d=e.onFrame((f,m)=>{if(!s)if(f==="session:event"){const g=m;if(g.sessionId!==r)return;const x=g.event.seq;Pe("session-events","push session:event",{sid:r,kind:g.event.kind,seq:x,lastSeqBefore:i}),o({type:"session:event",sessionId:g.sessionId,event:g.event}),typeof x=="number"&&x>i&&(i=x)}else if(f==="session:status"){const g=m;if(g.sessionId!==r)return;if(!RX(g.status)){Pe("session-events","push session:status drop",{sid:r,status:g.status});return}Pe("session-events","push session:status",{sid:r,status:g.status}),o({type:"session:status",sessionId:g.sessionId,status:g.status})}else if(f==="session:cleared"){if(m.sessionId!==r)return;Pe("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),i=-1}else if(f==="session:queue"){const g=m;if(g.sessionId!==r)return;Pe("session-events","push session:queue",{sid:r,count:g.items.length}),o({type:"session:queue",sessionId:g.sessionId,items:g.items})}else if(f==="permission:request"){const g=m;if(g.sessionId!==r)return;o({type:"permission:request",sessionId:g.sessionId,requestId:g.requestId,tool:g.tool,input:g.input,...typeof g.toolUseId=="string"&&g.toolUseId?{toolUseId:g.toolUseId}:{}})}else if(f==="session:question"){const g=m;if(g.sessionId!==r)return;o({type:"session:question",sessionId:g.sessionId,toolUseId:g.toolUseId,requestId:g.requestId,questions:g.questions})}else if(f==="session:question:cleared"){const g=m;if(g.sessionId!==r)return;g.answers&&Object.keys(g.answers).length>0?o({type:"session:question:submitted",sessionId:g.sessionId,toolUseId:g.toolUseId,answers:g.answers}):o({type:"session:question:clear",sessionId:g.sessionId,toolUseId:g.toolUseId})}else if(f==="session:rewound"){const g=m;if(g.sessionId!==r)return;o({type:"session:rewound",sessionId:g.sessionId,userMessageId:g.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(m.runningSessions??[]).map(x=>({sessionId:x.sessionId,freshSpawn:x.freshSpawn,status:sL(x.status)}))})}),h=e.onConnect(()=>{u()});return e.isConnected&&u(),()=>{s=!0,d(),h(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const rDe=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function sDe(e,t){return{start(n){let r=!1;const s=async()=>{try{const l=await e.request("info",void 0);if(r)return;t(n,()=>l)}catch{}},i=e.onConnect(()=>{s()}),o=e.onFrame(l=>{rDe.has(l)&&s()});return s(),()=>{r=!0,i(),o()}}}}function iDe(){return{start(){return()=>{}}}}function oDe(e,t){return{start(n){let r=!1;const s=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},i=e.onConnect(()=>{s()});return s(),()=>{r=!0,i()}}}}function MX(e){const t=YOe(e),n=GOe();let r=null;const s=(o,l)=>{r==null||r.setData(o,l)};n.register(/^capabilities\//,ZOe(t,s)),n.register(/^sessions$/,QOe(t,s)),n.register(/^session\//,nDe(t,s)),n.register(/^personas$/,oDe(t,s)),n.register(/^persona-detail\//,iDe()),n.register(/^daemon-info$/,sDe(t,s));const i=KOe({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=i,{cache:i,channel:t}}function aDe({client:e,children:t}){const n=p.useMemo(()=>MX(e),[e]);return p.useEffect(()=>()=>{},[n]),a.jsx(cxe,{client:e,children:a.jsx(FV,{cache:n.cache,children:a.jsx($K,{children:t})})})}function lDe(e,t){var g,x,b,y;const{models:n,modes:r,configSchema:s}=t,i=e.resolvedModel??e.model,o=Cx(i,n,s),l=o.options,c=l.some(v=>v.value===e.effort)?e.effort:o.defaultValue,u=e.effort===""&&e.resolvedEffort?((g=l.find(v=>v.value===e.resolvedEffort))==null?void 0:g.label)??e.resolvedEffort:((x=l.find(v=>v.value===c))==null?void 0:x.label)??null,d=((b=s.find(v=>v.name==="permissionMode"))==null?void 0:b.default)??"",h=r.some(v=>v.id===e.permissionMode)?e.permissionMode:d,m=h===d?null:((y=r.find(v=>v.id===h))==null?void 0:y.label)??null;return{modelLabel:h_(n,i),effortOptions:l,effortValue:c,effortLabel:u,modeValue:h,modeLabel:m,modeTone:m===null?null:h==="bypassPermissions"?"danger":"info"}}function PX({models:e,modelList:t,modes:n=[],configSchema:r=[],model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c,onPatch:u}){var b;const d=t??PPe(e??[]),h=d.models,f=lDe({model:s,resolvedModel:i,resolvedEffort:o,effort:l,permissionMode:c},{models:h,modes:n,configSchema:r}),m=i??s,g=h.map(y=>{const v=y.id===""&&i?`${y.description?`${y.description};`:""}当前:${i}`:y.description;return{value:y.id,label:y.label,...v?{description:v}:{},...y.group?{group:y.group}:{}}}),x=n.map(y=>({value:y.id,label:y.label,...y.description?{description:y.description}:{}}));return a.jsxs(ls,{children:[a.jsx(cs,{asChild:!0,children:a.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[a.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:m||f.modelLabel}),f.effortLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:f.effortLabel})]}):null,f.modeLabel?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-500",children:"·"}),a.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":f.modeTone,className:J("font-semibold",f.modeTone==="danger"?"text-red-400":"text-blue-400"),children:f.modeLabel})]}):null]})}),a.jsxs(Ur,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[a.jsx(cDe,{list:d,current:s,currentLabel:f.modelLabel,options:g,onSelect:y=>u({model:y})}),a.jsx(iL,{testid:"session-config-effort",label:"Reasoning effort",current:f.effortValue,currentLabel:f.effortLabel??"—",options:f.effortOptions,onSelect:y=>u({effort:y})}),x.length>0?a.jsx(iL,{testid:"session-config-mode",label:"Permission mode",current:f.modeValue,currentLabel:((b=n.find(y=>y.id===f.modeValue))==null?void 0:b.label)??"—",currentTone:f.modeTone,options:x,onSelect:y=>u({permissionMode:y})}):null]})]})}function OX({label:e,currentLabel:t,currentTone:n}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"flex-1 text-text-200",children:e}),a.jsx("span",{className:J("truncate max-w-[100px]",n==="danger"?"text-red-400 font-semibold":n==="info"?"text-blue-400 font-semibold":"text-text-400"),children:t}),a.jsx(Qn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]})}function cDe({list:e,current:t,currentLabel:n,options:r,onSelect:s}){const[i,o]=p.useState(!1),l=c=>{c&&!i&&e.load(),o(c)};return a.jsxs(uX,{open:i,onOpenChange:l,children:[a.jsx(RR,{"data-testid":"session-config-model",className:"gap-2 text-[12px]",children:a.jsx(OX,{label:"Model",currentLabel:n})}),a.jsx(MR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:a.jsx(NX,{testid:"session-config-model",list:e,options:r,current:t,onSelect:s})})]})}function iL({testid:e,label:t,current:n,currentLabel:r,currentTone:s,options:i,onSelect:o}){const l=i.length===0;return a.jsxs(uX,{children:[a.jsx(RR,{"data-testid":e,disabled:l,className:"gap-2 text-[12px]",children:a.jsx(OX,{label:t,currentLabel:r,currentTone:s??null})}),a.jsx(MR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:$R(i).map((c,u)=>{const d=c.value===n;return a.jsxs(G.Fragment,{children:[c.groupHeading?a.jsxs(a.Fragment,{children:[u>0?a.jsx(ha,{}):null,a.jsx(rc,{"data-testid":`${e}-group`,children:c.groupHeading})]}):null,a.jsxs(Tt,{"data-testid":`${e}-option-${c.value||"default"}`,onSelect:()=>o(c.value),className:"items-start gap-2",children:[a.jsxs("span",{className:"flex-1 min-w-0",children:[a.jsx("span",{className:J("block text-[12px]",d?"text-text-100 font-medium":"text-text-300"),children:c.label}),c.description?a.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:c.description}):null]}),d?a.jsx(Jt,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},c.value||"default")})})]})}function uDe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitBranch(t);s(c.branch??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{branch:r,loading:i,refresh:()=>void l()}}function dDe(e,t,n=0){const[r,s]=p.useState(null),[i,o]=p.useState(!1),l=p.useCallback(async()=>{if(!t){s(null);return}o(!0);try{const c=await e.getGitRoot(t);s(c.gitRoot??null)}catch{s(null)}finally{o(!1)}},[e,t]);return p.useEffect(()=>{l()},[l,n]),{worktreeRoot:r,loading:i,refresh:()=>void l()}}const hDe=5e3;function fDe(e,t,n=0){const[r,s]=p.useState(null);return p.useEffect(()=>{if(!t){s(null);return}let i=!1;const o=async()=>{try{const c=await e.cloudVolumeGet();i||s(c.volume??null)}catch{i||s(null)}},l=n>0?setTimeout(()=>void o(),hDe):null;return l||o(),()=>{i=!0,l&&clearTimeout(l)}},[e,t,n]),{volume:r}}const pDe=90;function mDe(e){return e.sizeBytes>0?Math.min(100,Math.max(0,Math.round(e.usedBytes/e.sizeBytes*100))):0}function oL(e){const t=e/1073741824;return t>=.1?`${t.toFixed(1)} GB`:`${Math.max(1,Math.round(e/1024**2))} MB`}function gDe({volume:e}){if(!e)return null;const t=mDe(e),n=t>=pDe?"warn":"ok",r=new Date(e.measuredAt).toLocaleString(),s=n==="ok"?"上一次任务结束时量的。":"盘快满了:在会话里说「清理一下云盘」,persona 会分析工作区里哪些能删、列给你确认后清掉。";return a.jsxs("span",{"data-testid":"chat-header-cloud-volume","data-tone":n,title:`云盘已用 ${oL(e.usedBytes)} / ${oL(e.sizeBytes)}(${r})。${s}`,className:J("ml-1.5 inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded text-[11px] tabular-nums",n==="ok"&&"bg-text-100/10 text-text-400",n==="warn"&&"bg-warning-dim text-warning"),children:[a.jsx("span",{className:"relative inline-block w-8 h-1 rounded-full bg-current/20 overflow-hidden","aria-hidden":!0,children:a.jsx("span",{className:"absolute inset-y-0 left-0 rounded-full bg-current",style:{width:`${t}%`}})}),"云盘 ",t,"%"]})}function BR({api:e,session:t,focused:n,totalPanes:r,onFocus:s,onClose:i,onNewSession:o,onOpenConfig:l,onFork:c,onQuickAsk:u,className:d,viewerRole:h="owner",hideHeader:f}){const{capabilities:m}=si(t.tool),g=gh(t.tool),[x,b]=p.useState(0),[y,v]=p.useState(n);G.useEffect(()=>{n&&v(!0)},[n]);const w=bb(t.tool),_=w?void 0:t.cwd,{branch:S}=uDe(e,_,x),{worktreeRoot:k}=dDe(e,_,x),{volume:N}=fDe(e,w,x),j=r>1,R=E=>{e.sessionUpdate(t.sessionId,E).catch(I=>{console.error("[session-config] session:update failed",t.sessionId,I)})};return a.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${j?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:s,"data-testid":`session-pane-${t.sessionId}`,children:[a.jsx(Fw,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:a.jsx(Fh,{id:"chat",minSize:"400px",children:a.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:(n||y)&&a.jsx(xDe,{api:e,session:t,focused:n,liveGitBranch:S,liveWorktreeRoot:k,...w&&N?{cloudVolume:a.jsx(gDe,{volume:N})}:{},onNewSession:o,onTurnEnd:()=>b(E=>E+1),onOpenConfig:l,onFork:c,onQuickAsk:u,viewerRole:h,hideHeader:f,configSlot:m?a.jsx(PX,{modelList:g,modes:m.permissionModes,configSchema:m.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:R}):null})})})}),j&&a.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),i()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:a.jsx(Xt,{className:"w-3.5 h-3.5"})})]})}function xDe({api:e,session:t,focused:n,liveGitBranch:r,liveWorktreeRoot:s,cloudVolume:i,onNewSession:o,onTurnEnd:l,onOpenConfig:c,onFork:u,onQuickAsk:d,viewerRole:h,configSlot:f,hideHeader:m}){return a.jsx(c_,{extras:{session:t,api:e,focused:n,...r!==void 0?{liveGitBranch:r}:{},...s!==void 0?{liveWorktreeRoot:s}:{},...i!==void 0?{cloudVolume:i}:{},onNewSession:o,onTurnEnd:l,onOpenConfig:c,...u?{onFork:g=>{u(g)}}:{},...d?{onQuickAsk:g=>{d(g)}}:{},...h?{viewerRole:h}:{},...f?{configSlot:f}:{},...m?{hideHeader:m}:{}}})}function vDe({client:e,session:t,remoteSessions:n,hasLoadedForOwner:r,focused:s,totalPanes:i,onFocus:o,onClose:l,onMirrorOrphan:c,className:u}){const d=p.useMemo(()=>new Vt(e),[e]),h=t.originOwnerPrincipalId,f=t.sessionId,m=p.useMemo(()=>n.some(g=>g.sessionId===f),[n,f]);return p.useEffect(()=>{!r||!c||m||c(f,h)},[r,m,f,h,c]),a.jsx(aDe,{client:e,children:a.jsx(BR,{api:d,session:t,focused:s,totalPanes:i,onFocus:o,onClose:l,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest",...u!==void 0?{className:u}:{}})})}function yDe(){const e=Kn(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(null),l=p.useCallback(async()=>{s(!0),o(null);try{const u=await new Vt(e).shiftList();n(u.shifts)}catch(c){o(c instanceof Error?c.message:String(c))}finally{s(!1)}},[e]);return p.useEffect(()=>{l()},[l]),{shifts:t,loading:r,error:i,refresh:l}}var xi={};Object.defineProperty(xi,"__esModule",{value:!0});class Zu extends Error{}class bDe extends Zu{constructor(t){super(`Invalid DateTime: ${t.toMessage()}`)}}class wDe extends Zu{constructor(t){super(`Invalid Interval: ${t.toMessage()}`)}}class _De extends Zu{constructor(t){super(`Invalid Duration: ${t.toMessage()}`)}}class eh extends Zu{}class DX extends Zu{constructor(t){super(`Invalid unit ${t}`)}}class Xr extends Zu{}class El extends Zu{constructor(){super("Zone is an abstract class")}}const Ae="numeric",Io="short",ii="long",a1={year:Ae,month:Ae,day:Ae},AX={year:Ae,month:Io,day:Ae},SDe={year:Ae,month:Io,day:Ae,weekday:Io},$X={year:Ae,month:ii,day:Ae},LX={year:Ae,month:ii,day:Ae,weekday:ii},BX={hour:Ae,minute:Ae},FX={hour:Ae,minute:Ae,second:Ae},zX={hour:Ae,minute:Ae,second:Ae,timeZoneName:Io},HX={hour:Ae,minute:Ae,second:Ae,timeZoneName:ii},UX={hour:Ae,minute:Ae,hourCycle:"h23"},WX={hour:Ae,minute:Ae,second:Ae,hourCycle:"h23"},VX={hour:Ae,minute:Ae,second:Ae,hourCycle:"h23",timeZoneName:Io},qX={hour:Ae,minute:Ae,second:Ae,hourCycle:"h23",timeZoneName:ii},KX={year:Ae,month:Ae,day:Ae,hour:Ae,minute:Ae},GX={year:Ae,month:Ae,day:Ae,hour:Ae,minute:Ae,second:Ae},YX={year:Ae,month:Io,day:Ae,hour:Ae,minute:Ae},XX={year:Ae,month:Io,day:Ae,hour:Ae,minute:Ae,second:Ae},kDe={year:Ae,month:Io,day:Ae,weekday:Io,hour:Ae,minute:Ae},ZX={year:Ae,month:ii,day:Ae,hour:Ae,minute:Ae,timeZoneName:Io},QX={year:Ae,month:ii,day:Ae,hour:Ae,minute:Ae,second:Ae,timeZoneName:Io},JX={year:Ae,month:ii,day:Ae,weekday:ii,hour:Ae,minute:Ae,timeZoneName:ii},eZ={year:Ae,month:ii,day:Ae,weekday:ii,hour:Ae,minute:Ae,second:Ae,timeZoneName:ii};class If{get type(){throw new El}get name(){throw new El}get ianaName(){return this.name}get isUniversal(){throw new El}offsetName(t,n){throw new El}formatOffset(t,n){throw new El}offset(t){throw new El}equals(t){throw new El}get isValid(){throw new El}}let gC=null;class Nx extends If{static get instance(){return gC===null&&(gC=new Nx),gC}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return hZ(t,n,r)}formatOffset(t,n){return Nm(this.offset(t),n)}offset(t){return-new Date(t).getTimezoneOffset()}equals(t){return t.type==="system"}get isValid(){return!0}}const pE=new Map;function CDe(e){let t=pE.get(e);return t===void 0&&(t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),pE.set(e,t)),t}const NDe={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function jDe(e,t){const n=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,s,i,o,l,c,u,d]=r;return[o,s,i,l,c,u,d]}function EDe(e,t){const n=e.formatToParts(t),r=[];for(let s=0;s<n.length;s++){const{type:i,value:o}=n[s],l=NDe[i];i==="era"?r[l]=o:ft(l)||(r[l]=parseInt(o,10))}return r}const xC=new Map;class fa extends If{static create(t){let n=xC.get(t);return n===void 0&&xC.set(t,n=new fa(t)),n}static resetCache(){xC.clear(),pE.clear()}static isValidSpecifier(t){return this.isValidZone(t)}static isValidZone(t){if(!t)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:t}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=fa.isValidZone(t)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(t,{format:n,locale:r}){return hZ(t,n,r,this.name)}formatOffset(t,n){return Nm(this.offset(t),n)}offset(t){if(!this.valid)return NaN;const n=new Date(t);if(isNaN(n))return NaN;const r=CDe(this.name);let[s,i,o,l,c,u,d]=r.formatToParts?EDe(r,n):jDe(r,n);l==="BC"&&(s=-Math.abs(s)+1);const f=g_({year:s,month:i,day:o,hour:c===24?0:c,minute:u,second:d,millisecond:0});let m=+n;const g=m%1e3;return m-=g>=0?g:1e3+g,(f-m)/(60*1e3)}equals(t){return t.type==="iana"&&t.name===this.name}get isValid(){return this.valid}}let aL={};function IDe(e,t={}){const n=JSON.stringify([e,t]);let r=aL[n];return r||(r=new Intl.ListFormat(e,t),aL[n]=r),r}const mE=new Map;function gE(e,t={}){const n=JSON.stringify([e,t]);let r=mE.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),mE.set(n,r)),r}const xE=new Map;function TDe(e,t={}){const n=JSON.stringify([e,t]);let r=xE.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),xE.set(n,r)),r}const vE=new Map;function RDe(e,t={}){const{base:n,...r}=t,s=JSON.stringify([e,r]);let i=vE.get(s);return i===void 0&&(i=new Intl.RelativeTimeFormat(e,t),vE.set(s,i)),i}let Gp=null;function MDe(){return Gp||(Gp=new Intl.DateTimeFormat().resolvedOptions().locale,Gp)}const yE=new Map;function tZ(e){let t=yE.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),yE.set(e,t)),t}const bE=new Map;function PDe(e){let t=bE.get(e);if(!t){const n=new Intl.Locale(e);t="getWeekInfo"in n?n.getWeekInfo():n.weekInfo,"minimalDays"in t||(t={...nZ,...t}),bE.set(e,t)}return t}function ODe(e){const t=e.indexOf("-x-");t!==-1&&(e=e.substring(0,t));const n=e.indexOf("-u-");if(n===-1)return[e];{let r,s;try{r=gE(e).resolvedOptions(),s=e}catch{const c=e.substring(0,n);r=gE(c).resolvedOptions(),s=c}const{numberingSystem:i,calendar:o}=r;return[s,i,o]}}function DDe(e,t,n){return(n||t)&&(e.includes("-u-")||(e+="-u"),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`)),e}function ADe(e){const t=[];for(let n=1;n<=12;n++){const r=xt.utc(2009,n,1);t.push(e(r))}return t}function $De(e){const t=[];for(let n=1;n<=7;n++){const r=xt.utc(2016,11,13+n);t.push(e(r))}return t}function b0(e,t,n,r){const s=e.listingMode();return s==="error"?null:s==="en"?n(t):r(t)}function LDe(e){return e.numberingSystem&&e.numberingSystem!=="latn"?!1:e.numberingSystem==="latn"||!e.locale||e.locale.startsWith("en")||tZ(e.locale).numberingSystem==="latn"}class BDe{constructor(t,n,r){this.padTo=r.padTo||0,this.floor=r.floor||!1;const{padTo:s,floor:i,...o}=r;if(!n||Object.keys(o).length>0){const l={useGrouping:!1,...r};r.padTo>0&&(l.minimumIntegerDigits=r.padTo),this.inf=TDe(t,l)}}format(t){if(this.inf){const n=this.floor?Math.floor(t):t;return this.inf.format(n)}else{const n=this.floor?Math.floor(t):WR(t,3);return rr(n,this.padTo)}}}class FDe{constructor(t,n,r){this.opts=r,this.originalZone=void 0;let s;if(this.opts.timeZone)this.dt=t;else if(t.zone.type==="fixed"){const o=-1*(t.offset/60),l=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;t.offset!==0&&fa.create(l).valid?(s=l,this.dt=t):(s="UTC",this.dt=t.offset===0?t:t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone)}else t.zone.type==="system"?this.dt=t:t.zone.type==="iana"?(this.dt=t,s=t.zone.name):(s="UTC",this.dt=t.setZone("UTC").plus({minutes:t.offset}),this.originalZone=t.zone);const i={...this.opts};i.timeZone=i.timeZone||s,this.dtf=gE(n,i)}format(){return this.originalZone?this.formatToParts().map(({value:t})=>t).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){const t=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?t.map(n=>{if(n.type==="timeZoneName"){const r=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...n,value:r}}else return n}):t}resolvedOptions(){return this.dtf.resolvedOptions()}}class zDe{constructor(t,n,r){this.opts={style:"long",...r},!n&&uZ()&&(this.rtf=RDe(t,r))}format(t,n){return this.rtf?this.rtf.format(t,n):lAe(n,t,this.opts.numeric,this.opts.style!=="long")}formatToParts(t,n){return this.rtf?this.rtf.formatToParts(t,n):[]}}const nZ={firstDay:1,minimalDays:4,weekend:[6,7]};class en{static fromOpts(t){return en.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,s,i=!1){const o=t||Bn.defaultLocale,l=o||(i?"en-US":MDe()),c=n||Bn.defaultNumberingSystem,u=r||Bn.defaultOutputCalendar,d=_E(s)||Bn.defaultWeekSettings;return new en(l,c,u,d,o)}static resetCache(){Gp=null,mE.clear(),xE.clear(),vE.clear(),yE.clear(),bE.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:s}={}){return en.create(t,n,r,s)}constructor(t,n,r,s,i){const[o,l,c]=ODe(t);this.locale=o,this.numberingSystem=n||l||null,this.outputCalendar=r||c||null,this.weekSettings=s,this.intl=DDe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=LDe(this)),this.fastNumbersCached}listingMode(){const t=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return t&&n?"en":"intl"}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:en.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,_E(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(t={}){return this.clone({...t,defaultToEN:!0})}redefaultToSystem(t={}){return this.clone({...t,defaultToEN:!1})}months(t,n=!1){return b0(this,t,mZ,()=>{const r=this.intl==="ja"||this.intl.startsWith("ja-");n&=!r;const s=n?{month:t,day:"numeric"}:{month:t},i=n?"format":"standalone";if(!this.monthsCache[i][t]){const o=r?l=>this.dtFormatter(l,s).format():l=>this.extract(l,s,"month");this.monthsCache[i][t]=ADe(o)}return this.monthsCache[i][t]})}weekdays(t,n=!1){return b0(this,t,vZ,()=>{const r=n?{weekday:t,year:"numeric",month:"long",day:"numeric"}:{weekday:t},s=n?"format":"standalone";return this.weekdaysCache[s][t]||(this.weekdaysCache[s][t]=$De(i=>this.extract(i,r,"weekday"))),this.weekdaysCache[s][t]})}meridiems(){return b0(this,void 0,()=>yZ,()=>{if(!this.meridiemCache){const t={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[xt.utc(2016,11,13,9),xt.utc(2016,11,13,19)].map(n=>this.extract(n,t,"dayperiod"))}return this.meridiemCache})}eras(t){return b0(this,t,bZ,()=>{const n={era:t};return this.eraCache[t]||(this.eraCache[t]=[xt.utc(-40,1,1),xt.utc(2017,1,1)].map(r=>this.extract(r,n,"era"))),this.eraCache[t]})}extract(t,n,r){const s=this.dtFormatter(t,n),i=s.formatToParts(),o=i.find(l=>l.type.toLowerCase()===r);return o?o.value:null}numberFormatter(t={}){return new BDe(this.intl,t.forceSimple||this.fastNumbers,t)}dtFormatter(t,n={}){return new FDe(t,this.intl,n)}relFormatter(t={}){return new zDe(this.intl,this.isEnglish(),t)}listFormatter(t={}){return IDe(this.intl,t)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||tZ(this.intl).locale.startsWith("en-us")}getWeekSettings(){return this.weekSettings?this.weekSettings:dZ()?PDe(this.locale):nZ}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(t){return this.locale===t.locale&&this.numberingSystem===t.numberingSystem&&this.outputCalendar===t.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}}let vC=null;class ns extends If{static get utcInstance(){return vC===null&&(vC=new ns(0)),vC}static instance(t){return t===0?ns.utcInstance:new ns(t)}static parseSpecifier(t){if(t){const n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new ns(x_(n[1],n[2]))}return null}constructor(t){super(),this.fixed=t}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Nm(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Nm(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(t,n){return Nm(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(t){return t.type==="fixed"&&t.fixed===this.fixed}get isValid(){return!0}}class rZ extends If{constructor(t){super(),this.zoneName=t}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function Fl(e,t){if(ft(e)||e===null)return t;if(e instanceof If)return e;if(KDe(e)){const n=e.toLowerCase();return n==="default"?t:n==="local"||n==="system"?Nx.instance:n==="utc"||n==="gmt"?ns.utcInstance:ns.parseSpecifier(n)||fa.create(e)}else return ic(e)?ns.instance(e):typeof e=="object"&&"offset"in e&&typeof e.offset=="function"?e:new rZ(e)}const FR={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},lL={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},HDe=FR.hanidec.replace(/[\[|\]]/g,"").split("");function UDe(e){let t=parseInt(e,10);if(isNaN(t)){t="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(e[n].search(FR.hanidec)!==-1)t+=HDe.indexOf(e[n]);else for(const s in lL){const[i,o]=lL[s];r>=i&&r<=o&&(t+=r-i)}}return parseInt(t,10)}else return t}const wE=new Map;function WDe(){wE.clear()}function io({numberingSystem:e},t=""){const n=e||"latn";let r=wE.get(n);r===void 0&&(r=new Map,wE.set(n,r));let s=r.get(t);return s===void 0&&(s=new RegExp(`${FR[n]}${t}`),r.set(t,s)),s}let cL=()=>Date.now(),uL="system",dL=null,hL=null,fL=null,pL=60,mL,gL=null;class Bn{static get now(){return cL}static set now(t){cL=t}static set defaultZone(t){uL=t}static get defaultZone(){return Fl(uL,Nx.instance)}static get defaultLocale(){return dL}static set defaultLocale(t){dL=t}static get defaultNumberingSystem(){return hL}static set defaultNumberingSystem(t){hL=t}static get defaultOutputCalendar(){return fL}static set defaultOutputCalendar(t){fL=t}static get defaultWeekSettings(){return gL}static set defaultWeekSettings(t){gL=_E(t)}static get twoDigitCutoffYear(){return pL}static set twoDigitCutoffYear(t){pL=t%100}static get throwOnInvalid(){return mL}static set throwOnInvalid(t){mL=t}static resetCaches(){en.resetCache(),fa.resetCache(),xt.resetCache(),WDe()}}class go{constructor(t,n){this.reason=t,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}const sZ=[0,31,59,90,120,151,181,212,243,273,304,334],iZ=[0,31,60,91,121,152,182,213,244,274,305,335];function Oi(e,t){return new go("unit out of range",`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function zR(e,t,n){const r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const s=r.getUTCDay();return s===0?7:s}function oZ(e,t,n){return n+(jx(e)?iZ:sZ)[t-1]}function aZ(e,t){const n=jx(e)?iZ:sZ,r=n.findIndex(i=>i<t),s=t-n[r];return{month:r+1,day:s}}function HR(e,t){return(e-t+7)%7+1}function l1(e,t=4,n=1){const{year:r,month:s,day:i}=e,o=oZ(r,s,i),l=HR(zR(r,s,i),n);let c=Math.floor((o-l+14-t)/7),u;return c<1?(u=r-1,c=Eg(u,t,n)):c>Eg(r,t,n)?(u=r+1,c=1):u=r,{weekYear:u,weekNumber:c,weekday:l,...v_(e)}}function xL(e,t=4,n=1){const{weekYear:r,weekNumber:s,weekday:i}=e,o=HR(zR(r,1,t),n),l=xh(r);let c=s*7+i-o-7+t,u;c<1?(u=r-1,c+=xh(u)):c>l?(u=r+1,c-=xh(r)):u=r;const{month:d,day:h}=aZ(u,c);return{year:u,month:d,day:h,...v_(e)}}function yC(e){const{year:t,month:n,day:r}=e,s=oZ(t,n,r);return{year:t,ordinal:s,...v_(e)}}function vL(e){const{year:t,ordinal:n}=e,{month:r,day:s}=aZ(t,n);return{year:t,month:r,day:s,...v_(e)}}function yL(e,t){if(!ft(e.localWeekday)||!ft(e.localWeekNumber)||!ft(e.localWeekYear)){if(!ft(e.weekday)||!ft(e.weekNumber)||!ft(e.weekYear))throw new eh("Cannot mix locale-based week fields with ISO-based week fields");return ft(e.localWeekday)||(e.weekday=e.localWeekday),ft(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),ft(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function VDe(e,t=4,n=1){const r=m_(e.weekYear),s=Di(e.weekNumber,1,Eg(e.weekYear,t,n)),i=Di(e.weekday,1,7);return r?s?i?!1:Oi("weekday",e.weekday):Oi("week",e.weekNumber):Oi("weekYear",e.weekYear)}function qDe(e){const t=m_(e.year),n=Di(e.ordinal,1,xh(e.year));return t?n?!1:Oi("ordinal",e.ordinal):Oi("year",e.year)}function lZ(e){const t=m_(e.year),n=Di(e.month,1,12),r=Di(e.day,1,c1(e.year,e.month));return t?n?r?!1:Oi("day",e.day):Oi("month",e.month):Oi("year",e.year)}function cZ(e){const{hour:t,minute:n,second:r,millisecond:s}=e,i=Di(t,0,23)||t===24&&n===0&&r===0&&s===0,o=Di(n,0,59),l=Di(r,0,59),c=Di(s,0,999);return i?o?l?c?!1:Oi("millisecond",s):Oi("second",r):Oi("minute",n):Oi("hour",t)}function ft(e){return typeof e>"u"}function ic(e){return typeof e=="number"}function m_(e){return typeof e=="number"&&e%1===0}function KDe(e){return typeof e=="string"}function GDe(e){return Object.prototype.toString.call(e)==="[object Date]"}function uZ(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function dZ(){try{return typeof Intl<"u"&&!!Intl.Locale&&("weekInfo"in Intl.Locale.prototype||"getWeekInfo"in Intl.Locale.prototype)}catch{return!1}}function YDe(e){return Array.isArray(e)?e:[e]}function bL(e,t,n){if(e.length!==0)return e.reduce((r,s)=>{const i=[t(s),s];return r&&n(r[0],i[0])===r[0]?r:i},null)[1]}function XDe(e,t){return t.reduce((n,r)=>(n[r]=e[r],n),{})}function Zh(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function _E(e){if(e==null)return null;if(typeof e!="object")throw new Xr("Week settings must be an object");if(!Di(e.firstDay,1,7)||!Di(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(t=>!Di(t,1,7)))throw new Xr("Invalid week settings");return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Di(e,t,n){return m_(e)&&e>=t&&e<=n}function ZDe(e,t){return e-t*Math.floor(e/t)}function rr(e,t=2){const n=e<0;let r;return n?r="-"+(""+-e).padStart(t,"0"):r=(""+e).padStart(t,"0"),r}function $l(e){if(!(ft(e)||e===null||e===""))return parseInt(e,10)}function Lc(e){if(!(ft(e)||e===null||e===""))return parseFloat(e)}function UR(e){if(!(ft(e)||e===null||e==="")){const t=parseFloat("0."+e)*1e3;return Math.floor(t)}}function WR(e,t,n="round"){const r=10**t;switch(n){case"expand":return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case"trunc":return Math.trunc(e*r)/r;case"round":return Math.round(e*r)/r;case"floor":return Math.floor(e*r)/r;case"ceil":return Math.ceil(e*r)/r;default:throw new RangeError(`Value rounding ${n} is out of range`)}}function jx(e){return e%4===0&&(e%100!==0||e%400===0)}function xh(e){return jx(e)?366:365}function c1(e,t){const n=ZDe(t-1,12)+1,r=e+(t-n)/12;return n===2?jx(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function g_(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function wL(e,t,n){return-HR(zR(e,1,t),n)+t-1}function Eg(e,t=4,n=1){const r=wL(e,t,n),s=wL(e+1,t,n);return(xh(e)-r+s)/7}function SE(e){return e>99?e:e>Bn.twoDigitCutoffYear?1900+e:2e3+e}function hZ(e,t,n,r=null){const s=new Date(e),i={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(i.timeZone=r);const o={timeZoneName:t,...i},l=new Intl.DateTimeFormat(n,o).formatToParts(s).find(c=>c.type.toLowerCase()==="timezonename");return l?l.value:null}function x_(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);const r=parseInt(t,10)||0,s=n<0||Object.is(n,-0)?-r:r;return n*60+s}function fZ(e){const t=Number(e);if(typeof e=="boolean"||e===""||!Number.isFinite(t))throw new Xr(`Invalid unit value ${e}`);return t}function u1(e,t){const n={};for(const r in e)if(Zh(e,r)){const s=e[r];if(s==null)continue;n[t(r)]=fZ(s)}return n}function Nm(e,t){const n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),s=e>=0?"+":"-";switch(t){case"short":return`${s}${rr(n,2)}:${rr(r,2)}`;case"narrow":return`${s}${n}${r>0?`:${r}`:""}`;case"techie":return`${s}${rr(n,2)}${rr(r,2)}`;default:throw new RangeError(`Value format ${t} is out of range for property format`)}}function v_(e){return XDe(e,["hour","minute","second","millisecond"])}const QDe=["January","February","March","April","May","June","July","August","September","October","November","December"],pZ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],JDe=["J","F","M","A","M","J","J","A","S","O","N","D"];function mZ(e){switch(e){case"narrow":return[...JDe];case"short":return[...pZ];case"long":return[...QDe];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const gZ=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],xZ=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],eAe=["M","T","W","T","F","S","S"];function vZ(e){switch(e){case"narrow":return[...eAe];case"short":return[...xZ];case"long":return[...gZ];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const yZ=["AM","PM"],tAe=["Before Christ","Anno Domini"],nAe=["BC","AD"],rAe=["B","A"];function bZ(e){switch(e){case"narrow":return[...rAe];case"short":return[...nAe];case"long":return[...tAe];default:return null}}function sAe(e){return yZ[e.hour<12?0:1]}function iAe(e,t){return vZ(t)[e.weekday-1]}function oAe(e,t){return mZ(t)[e.month-1]}function aAe(e,t){return bZ(t)[e.year<0?0:1]}function lAe(e,t,n="always",r=!1){const s={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},i=["hours","minutes","seconds"].indexOf(e)===-1;if(n==="auto"&&i){const h=e==="days";switch(t){case 1:return h?"tomorrow":`next ${s[e][0]}`;case-1:return h?"yesterday":`last ${s[e][0]}`;case 0:return h?"today":`this ${s[e][0]}`}}const o=Object.is(t,-0)||t<0,l=Math.abs(t),c=l===1,u=s[e],d=r?c?u[1]:u[2]||u[1]:c?s[e][0]:e;return o?`${l} ${d} ago`:`in ${l} ${d}`}function _L(e,t){let n="";for(const r of e)r.literal?n+=r.val:n+=t(r.val);return n}const cAe={D:a1,DD:AX,DDD:$X,DDDD:LX,t:BX,tt:FX,ttt:zX,tttt:HX,T:UX,TT:WX,TTT:VX,TTTT:qX,f:KX,ff:YX,fff:ZX,ffff:JX,F:GX,FF:XX,FFF:QX,FFFF:eZ};class Jr{static create(t,n={}){return new Jr(t,n)}static parseFormat(t){let n=null,r="",s=!1;const i=[];for(let o=0;o<t.length;o++){const l=t.charAt(o);l==="'"?((r.length>0||s)&&i.push({literal:s||/^\s+$/.test(r),val:r===""?"'":r}),n=null,r="",s=!s):s||l===n?r+=l:(r.length>0&&i.push({literal:/^\s+$/.test(r),val:r}),r=l,n=l)}return r.length>0&&i.push({literal:s||/^\s+$/.test(r),val:r}),i}static macroTokenToFormatOpts(t){return cAe[t]}constructor(t,n){this.opts=n,this.loc=t,this.systemLoc=null}formatWithSystemDefault(t,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(t,{...this.opts,...n}).format()}dtFormatter(t,n={}){return this.loc.dtFormatter(t,{...this.opts,...n})}formatDateTime(t,n){return this.dtFormatter(t,n).format()}formatDateTimeParts(t,n){return this.dtFormatter(t,n).formatToParts()}formatInterval(t,n){return this.dtFormatter(t.start,n).dtf.formatRange(t.start.toJSDate(),t.end.toJSDate())}resolvedOptions(t,n){return this.dtFormatter(t,n).resolvedOptions()}num(t,n=0,r=void 0){if(this.opts.forceSimple)return rr(t,n);const s={...this.opts};return n>0&&(s.padTo=n),r&&(s.signDisplay=r),this.loc.numberFormatter(s).format(t)}formatDateTimeFromString(t,n){const r=this.loc.listingMode()==="en",s=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",i=(m,g)=>this.loc.extract(t,m,g),o=m=>t.isOffsetFixed&&t.offset===0&&m.allowZ?"Z":t.isValid?t.zone.formatOffset(t.ts,m.format):"",l=()=>r?sAe(t):i({hour:"numeric",hourCycle:"h12"},"dayperiod"),c=(m,g)=>r?oAe(t,m):i(g?{month:m}:{month:m,day:"numeric"},"month"),u=(m,g)=>r?iAe(t,m):i(g?{weekday:m}:{weekday:m,month:"long",day:"numeric"},"weekday"),d=m=>{const g=Jr.macroTokenToFormatOpts(m);return g?this.formatWithSystemDefault(t,g):m},h=m=>r?aAe(t,m):i({era:m},"era"),f=m=>{switch(m){case"S":return this.num(t.millisecond);case"u":case"SSS":return this.num(t.millisecond,3);case"s":return this.num(t.second);case"ss":return this.num(t.second,2);case"uu":return this.num(Math.floor(t.millisecond/10),2);case"uuu":return this.num(Math.floor(t.millisecond/100));case"m":return this.num(t.minute);case"mm":return this.num(t.minute,2);case"h":return this.num(t.hour%12===0?12:t.hour%12);case"hh":return this.num(t.hour%12===0?12:t.hour%12,2);case"H":return this.num(t.hour);case"HH":return this.num(t.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return t.zone.offsetName(t.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return t.zone.offsetName(t.ts,{format:"long",locale:this.loc.locale});case"z":return t.zoneName;case"a":return l();case"d":return s?i({day:"numeric"},"day"):this.num(t.day);case"dd":return s?i({day:"2-digit"},"day"):this.num(t.day,2);case"c":return this.num(t.weekday);case"ccc":return u("short",!0);case"cccc":return u("long",!0);case"ccccc":return u("narrow",!0);case"E":return this.num(t.weekday);case"EEE":return u("short",!1);case"EEEE":return u("long",!1);case"EEEEE":return u("narrow",!1);case"L":return s?i({month:"numeric",day:"numeric"},"month"):this.num(t.month);case"LL":return s?i({month:"2-digit",day:"numeric"},"month"):this.num(t.month,2);case"LLL":return c("short",!0);case"LLLL":return c("long",!0);case"LLLLL":return c("narrow",!0);case"M":return s?i({month:"numeric"},"month"):this.num(t.month);case"MM":return s?i({month:"2-digit"},"month"):this.num(t.month,2);case"MMM":return c("short",!1);case"MMMM":return c("long",!1);case"MMMMM":return c("narrow",!1);case"y":return s?i({year:"numeric"},"year"):this.num(t.year);case"yy":return s?i({year:"2-digit"},"year"):this.num(t.year.toString().slice(-2),2);case"yyyy":return s?i({year:"numeric"},"year"):this.num(t.year,4);case"yyyyyy":return s?i({year:"numeric"},"year"):this.num(t.year,6);case"G":return h("short");case"GG":return h("long");case"GGGGG":return h("narrow");case"kk":return this.num(t.weekYear.toString().slice(-2),2);case"kkkk":return this.num(t.weekYear,4);case"W":return this.num(t.weekNumber);case"WW":return this.num(t.weekNumber,2);case"n":return this.num(t.localWeekNumber);case"nn":return this.num(t.localWeekNumber,2);case"ii":return this.num(t.localWeekYear.toString().slice(-2),2);case"iiii":return this.num(t.localWeekYear,4);case"o":return this.num(t.ordinal);case"ooo":return this.num(t.ordinal,3);case"q":return this.num(t.quarter);case"qq":return this.num(t.quarter,2);case"X":return this.num(Math.floor(t.ts/1e3));case"x":return this.num(t.ts);default:return d(m)}};return _L(Jr.parseFormat(n),f)}formatDurationFromString(t,n){const r=this.opts.signMode==="negativeLargestOnly"?-1:1,s=d=>{switch(d[0]){case"S":return"milliseconds";case"s":return"seconds";case"m":return"minutes";case"h":return"hours";case"d":return"days";case"w":return"weeks";case"M":return"months";case"y":return"years";default:return null}},i=(d,h)=>f=>{const m=s(f);if(m){const g=h.isNegativeDuration&&m!==h.largestUnit?r:1;let x;return this.opts.signMode==="negativeLargestOnly"&&m!==h.largestUnit?x="never":this.opts.signMode==="all"?x="always":x="auto",this.num(d.get(m)*g,f.length,x)}else return f},o=Jr.parseFormat(n),l=o.reduce((d,{literal:h,val:f})=>h?d:d.concat(f),[]),c=t.shiftTo(...l.map(s).filter(d=>d)),u={isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]};return _L(o,i(c,u))}}const wZ=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Tf(...e){const t=e.reduce((n,r)=>n+r.source,"");return RegExp(`^${t}$`)}function Rf(...e){return t=>e.reduce(([n,r,s],i)=>{const[o,l,c]=i(t,s);return[{...n,...o},l||r,c]},[{},null,1]).slice(0,2)}function Mf(e,...t){if(e==null)return[null,null];for(const[n,r]of t){const s=n.exec(e);if(s)return r(s)}return[null,null]}function _Z(...e){return(t,n)=>{const r={};let s;for(s=0;s<e.length;s++)r[e[s]]=$l(t[n+s]);return[r,null,n+s]}}const SZ=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,uAe=`(?:${SZ.source}?(?:\\[(${wZ.source})\\])?)?`,VR=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,kZ=RegExp(`${VR.source}${uAe}`),qR=RegExp(`(?:[Tt]${kZ.source})?`),dAe=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,hAe=/(\d{4})-?W(\d\d)(?:-?(\d))?/,fAe=/(\d{4})-?(\d{3})/,pAe=_Z("weekYear","weekNumber","weekDay"),mAe=_Z("year","ordinal"),gAe=/(\d{4})-(\d\d)-(\d\d)/,CZ=RegExp(`${VR.source} ?(?:${SZ.source}|(${wZ.source}))?`),xAe=RegExp(`(?: ${CZ.source})?`);function vh(e,t,n){const r=e[t];return ft(r)?n:$l(r)}function vAe(e,t){return[{year:vh(e,t),month:vh(e,t+1,1),day:vh(e,t+2,1)},null,t+3]}function Pf(e,t){return[{hours:vh(e,t,0),minutes:vh(e,t+1,0),seconds:vh(e,t+2,0),milliseconds:UR(e[t+3])},null,t+4]}function Ex(e,t){const n=!e[t]&&!e[t+1],r=x_(e[t+1],e[t+2]),s=n?null:ns.instance(r);return[{},s,t+3]}function Ix(e,t){const n=e[t]?fa.create(e[t]):null;return[{},n,t+1]}const yAe=RegExp(`^T?${VR.source}$`),bAe=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function wAe(e){const[t,n,r,s,i,o,l,c,u]=e,d=t[0]==="-",h=c&&c[0]==="-",f=(m,g=!1)=>m!==void 0&&(g||m&&d)?-m:m;return[{years:f(Lc(n)),months:f(Lc(r)),weeks:f(Lc(s)),days:f(Lc(i)),hours:f(Lc(o)),minutes:f(Lc(l)),seconds:f(Lc(c),c==="-0"),milliseconds:f(UR(u),h)}]}const _Ae={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function KR(e,t,n,r,s,i,o){const l={year:t.length===2?SE($l(t)):$l(t),month:pZ.indexOf(n)+1,day:$l(r),hour:$l(s),minute:$l(i)};return o&&(l.second=$l(o)),e&&(l.weekday=e.length>3?gZ.indexOf(e)+1:xZ.indexOf(e)+1),l}const SAe=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function kAe(e){const[,t,n,r,s,i,o,l,c,u,d,h]=e,f=KR(t,s,r,n,i,o,l);let m;return c?m=_Ae[c]:u?m=0:m=x_(d,h),[f,new ns(m)]}function CAe(e){return e.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const NAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,jAe=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,EAe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function SL(e){const[,t,n,r,s,i,o,l]=e;return[KR(t,s,r,n,i,o,l),ns.utcInstance]}function IAe(e){const[,t,n,r,s,i,o,l]=e;return[KR(t,l,n,r,s,i,o),ns.utcInstance]}const TAe=Tf(dAe,qR),RAe=Tf(hAe,qR),MAe=Tf(fAe,qR),PAe=Tf(kZ),NZ=Rf(vAe,Pf,Ex,Ix),OAe=Rf(pAe,Pf,Ex,Ix),DAe=Rf(mAe,Pf,Ex,Ix),AAe=Rf(Pf,Ex,Ix);function $Ae(e){return Mf(e,[TAe,NZ],[RAe,OAe],[MAe,DAe],[PAe,AAe])}function LAe(e){return Mf(CAe(e),[SAe,kAe])}function BAe(e){return Mf(e,[NAe,SL],[jAe,SL],[EAe,IAe])}function FAe(e){return Mf(e,[bAe,wAe])}const zAe=Rf(Pf);function HAe(e){return Mf(e,[yAe,zAe])}const UAe=Tf(gAe,xAe),WAe=Tf(CZ),VAe=Rf(Pf,Ex,Ix);function qAe(e){return Mf(e,[UAe,NZ],[WAe,VAe])}const kL="Invalid Duration",jZ={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},KAe={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...jZ},ki=146097/400,kd=146097/4800,GAe={years:{quarters:4,months:12,weeks:ki/7,days:ki,hours:ki*24,minutes:ki*24*60,seconds:ki*24*60*60,milliseconds:ki*24*60*60*1e3},quarters:{months:3,weeks:ki/28,days:ki/4,hours:ki*24/4,minutes:ki*24*60/4,seconds:ki*24*60*60/4,milliseconds:ki*24*60*60*1e3/4},months:{weeks:kd/7,days:kd,hours:kd*24,minutes:kd*24*60,seconds:kd*24*60*60,milliseconds:kd*24*60*60*1e3},...jZ},nu=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],YAe=nu.slice(0).reverse();function Ea(e,t,n=!1){const r={values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix};return new Wt(r)}function EZ(e,t){var n;let r=(n=t.milliseconds)!=null?n:0;for(const s of YAe.slice(1))t[s]&&(r+=t[s]*e[s].milliseconds);return r}function CL(e,t){const n=EZ(e,t)<0?-1:1;nu.reduceRight((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]*n,o=e[s][r],l=Math.floor(i/o);t[s]+=l*n,t[r]-=l*o*n}return s},null),nu.reduce((r,s)=>{if(ft(t[s]))return r;if(r){const i=t[r]%1;t[r]-=i,t[s]+=i*e[r][s]}return s},null)}function NL(e){const t={};for(const[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}class Wt{constructor(t){const n=t.conversionAccuracy==="longterm"||!1;let r=n?GAe:KAe;t.matrix&&(r=t.matrix),this.values=t.values,this.loc=t.loc||en.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=t.invalid||null,this.matrix=r,this.isLuxonDuration=!0}static fromMillis(t,n){return Wt.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(t==null||typeof t!="object")throw new Xr(`Duration.fromObject: argument expected to be an object, got ${t===null?"null":typeof t}`);return new Wt({values:u1(t,Wt.normalizeUnit),loc:en.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(ic(t))return Wt.fromMillis(t);if(Wt.isDuration(t))return t;if(typeof t=="object")return Wt.fromObject(t);throw new Xr(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){const[r]=FAe(t);return r?Wt.fromObject(r,n):Wt.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){const[r]=HAe(t);return r?Wt.fromObject(r,n):Wt.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new Xr("need to specify a reason the Duration is invalid");const r=t instanceof go?t:new go(t,n);if(Bn.throwOnInvalid)throw new _De(r);return new Wt({invalid:r})}static normalizeUnit(t){const n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[t&&t.toLowerCase()];if(!n)throw new DX(t);return n}static isDuration(t){return t&&t.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(t,n={}){const r={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?Jr.create(this.loc,r).formatDurationFromString(this,t):kL}toHuman(t={}){if(!this.isValid)return kL;const n=t.showZeros!==!1,r=nu.map(s=>{const i=this.values[s];return ft(i)||i===0&&!n?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...t,unit:s.slice(0,-1)}).format(i)}).filter(s=>s);return this.loc.listFormatter({type:"conjunction",style:t.listStyle||"narrow",...t}).format(r)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let t="P";return this.years!==0&&(t+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(t+=this.months+this.quarters*3+"M"),this.weeks!==0&&(t+=this.weeks+"W"),this.days!==0&&(t+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(t+="T"),this.hours!==0&&(t+=this.hours+"H"),this.minutes!==0&&(t+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(t+=WR(this.seconds+this.milliseconds/1e3,3)+"S"),t==="P"&&(t+="T0S"),t}toISOTime(t={}){if(!this.isValid)return null;const n=this.toMillis();return n<0||n>=864e5?null:(t={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...t,includeOffset:!1},xt.fromMillis(n,{zone:"UTC"}).toISOTime(t))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?EZ(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t),r={};for(const s of nu)(Zh(n.values,s)||Zh(this.values,s))&&(r[s]=n.get(s)+this.get(s));return Ea(this,{values:r},!0)}minus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t);return this.plus(n.negate())}mapUnits(t){if(!this.isValid)return this;const n={};for(const r of Object.keys(this.values))n[r]=fZ(t(this.values[r],r));return Ea(this,{values:n},!0)}get(t){return this[Wt.normalizeUnit(t)]}set(t){if(!this.isValid)return this;const n={...this.values,...u1(t,Wt.normalizeUnit)};return Ea(this,{values:n})}reconfigure({locale:t,numberingSystem:n,conversionAccuracy:r,matrix:s}={}){const o={loc:this.loc.clone({locale:t,numberingSystem:n}),matrix:s,conversionAccuracy:r};return Ea(this,o)}as(t){return this.isValid?this.shiftTo(t).get(t):NaN}normalize(){if(!this.isValid)return this;const t=this.toObject();return CL(this.matrix,t),Ea(this,{values:t},!0)}rescale(){if(!this.isValid)return this;const t=NL(this.normalize().shiftToAll().toObject());return Ea(this,{values:t},!0)}shiftTo(...t){if(!this.isValid)return this;if(t.length===0)return this;t=t.map(o=>Wt.normalizeUnit(o));const n={},r={},s=this.toObject();let i;for(const o of nu)if(t.indexOf(o)>=0){i=o;let l=0;for(const u in r)l+=this.matrix[u][o]*r[u],r[u]=0;ic(s[o])&&(l+=s[o]);const c=Math.trunc(l);n[o]=c,r[o]=(l*1e3-c*1e3)/1e3}else ic(s[o])&&(r[o]=s[o]);for(const o in r)r[o]!==0&&(n[i]+=o===i?r[o]:r[o]/this.matrix[i][o]);return CL(this.matrix,n),Ea(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;const t={};for(const n of Object.keys(this.values))t[n]=this.values[n]===0?0:-this.values[n];return Ea(this,{values:t},!0)}removeZeros(){if(!this.isValid)return this;const t=NL(this.values);return Ea(this,{values:t},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(t){if(!this.isValid||!t.isValid||!this.loc.equals(t.loc))return!1;function n(r,s){return r===void 0||r===0?s===void 0||s===0:r===s}for(const r of nu)if(!n(this.values[r],t.values[r]))return!1;return!0}}const Cd="Invalid Interval";function XAe(e,t){return!e||!e.isValid?$n.invalid("missing or invalid start"):!t||!t.isValid?$n.invalid("missing or invalid end"):t<e?$n.invalid("end before start",`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}class $n{constructor(t){this.s=t.start,this.e=t.end,this.invalid=t.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new Xr("need to specify a reason the Interval is invalid");const r=t instanceof go?t:new go(t,n);if(Bn.throwOnInvalid)throw new wDe(r);return new $n({invalid:r})}static fromDateTimes(t,n){const r=Ep(t),s=Ep(n),i=XAe(r,s);return i??new $n({start:r,end:s})}static after(t,n){const r=Wt.fromDurationLike(n),s=Ep(t);return $n.fromDateTimes(s,s.plus(r))}static before(t,n){const r=Wt.fromDurationLike(n),s=Ep(t);return $n.fromDateTimes(s.minus(r),s)}static fromISO(t,n){const[r,s]=(t||"").split("/",2);if(r&&s){let i,o;try{i=xt.fromISO(r,n),o=i.isValid}catch{o=!1}let l,c;try{l=xt.fromISO(s,n),c=l.isValid}catch{c=!1}if(o&&c)return $n.fromDateTimes(i,l);if(o){const u=Wt.fromISO(s,n);if(u.isValid)return $n.after(i,u)}else if(c){const u=Wt.fromISO(r,n);if(u.isValid)return $n.before(l,u)}}return $n.invalid("unparsable",`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(t){return t&&t.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(t="milliseconds"){return this.isValid?this.toDuration(t).get(t):NaN}count(t="milliseconds",n){if(!this.isValid)return NaN;const r=this.start.startOf(t,n);let s;return n!=null&&n.useLocaleWeeks?s=this.end.reconfigure({locale:r.locale}):s=this.end,s=s.startOf(t,n),Math.floor(s.diff(r,t).get(t))+(s.valueOf()!==this.end.valueOf())}hasSame(t){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,t):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(t){return this.isValid?this.s>t:!1}isBefore(t){return this.isValid?this.e<=t:!1}contains(t){return this.isValid?this.s<=t&&this.e>t:!1}set({start:t,end:n}={}){return this.isValid?$n.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];const n=t.map(Ep).filter(o=>this.contains(o)).sort((o,l)=>o.toMillis()-l.toMillis()),r=[];let{s}=this,i=0;for(;s<this.e;){const o=n[i]||this.e,l=+o>+this.e?this.e:o;r.push($n.fromDateTimes(s,l)),s=l,i+=1}return r}splitBy(t){const n=Wt.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:r}=this,s=1,i;const o=[];for(;r<this.e;){const l=this.start.plus(n.mapUnits(c=>c*s));i=+l>+this.e?this.e:l,o.push($n.fromDateTimes(r,i)),r=i,s+=1}return o}divideEqually(t){return this.isValid?this.splitBy(this.length()/t).slice(0,t):[]}overlaps(t){return this.e>t.s&&this.s<t.e}abutsStart(t){return this.isValid?+this.e==+t.s:!1}abutsEnd(t){return this.isValid?+t.e==+this.s:!1}engulfs(t){return this.isValid?this.s<=t.s&&this.e>=t.e:!1}equals(t){return!this.isValid||!t.isValid?!1:this.s.equals(t.s)&&this.e.equals(t.e)}intersection(t){if(!this.isValid)return this;const n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:$n.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;const n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return $n.fromDateTimes(n,r)}static merge(t){const[n,r]=t.sort((s,i)=>s.s-i.s).reduce(([s,i],o)=>i?i.overlaps(o)||i.abutsStart(o)?[s,i.union(o)]:[s.concat([i]),o]:[s,o],[[],null]);return r&&n.push(r),n}static xor(t){let n=null,r=0;const s=[],i=t.map(c=>[{time:c.s,type:"s"},{time:c.e,type:"e"}]),o=Array.prototype.concat(...i),l=o.sort((c,u)=>c.time-u.time);for(const c of l)r+=c.type==="s"?1:-1,r===1?n=c.time:(n&&+n!=+c.time&&s.push($n.fromDateTimes(n,c.time)),n=null);return $n.merge(s)}difference(...t){return $n.xor([this].concat(t)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Cd}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(t=a1,n={}){return this.isValid?Jr.create(this.s.loc.clone(n),t).formatInterval(this):Cd}toISO(t){return this.isValid?`${this.s.toISO(t)}/${this.e.toISO(t)}`:Cd}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Cd}toISOTime(t){return this.isValid?`${this.s.toISOTime(t)}/${this.e.toISOTime(t)}`:Cd}toFormat(t,{separator:n=" – "}={}){return this.isValid?`${this.s.toFormat(t)}${n}${this.e.toFormat(t)}`:Cd}toDuration(t,n){return this.isValid?this.e.diff(this.s,t,n):Wt.invalid(this.invalidReason)}mapEndpoints(t){return $n.fromDateTimes(t(this.s),t(this.e))}}class Yp{static hasDST(t=Bn.defaultZone){const n=xt.now().setZone(t).set({month:12});return!t.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(t){return fa.isValidZone(t)}static normalizeZone(t){return Fl(t,Bn.defaultZone)}static getStartOfWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:t=null,locObj:n=null}={}){return(n||en.create(t)).getWeekendDays().slice()}static months(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t)}static monthsFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null,outputCalendar:i="gregory"}={}){return(s||en.create(n,r,i)).months(t,!0)}static weekdays(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t)}static weekdaysFormat(t="long",{locale:n=null,numberingSystem:r=null,locObj:s=null}={}){return(s||en.create(n,r,null)).weekdays(t,!0)}static meridiems({locale:t=null}={}){return en.create(t).meridiems()}static eras(t="short",{locale:n=null}={}){return en.create(n,null,"gregory").eras(t)}static features(){return{relative:uZ(),localeWeek:dZ()}}}function jL(e,t){const n=s=>s.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(t)-n(e);return Math.floor(Wt.fromMillis(r).as("days"))}function ZAe(e,t,n){const r=[["years",(c,u)=>u.year-c.year],["quarters",(c,u)=>u.quarter-c.quarter+(u.year-c.year)*4],["months",(c,u)=>u.month-c.month+(u.year-c.year)*12],["weeks",(c,u)=>{const d=jL(c,u);return(d-d%7)/7}],["days",jL]],s={},i=e;let o,l;for(const[c,u]of r)n.indexOf(c)>=0&&(o=c,s[c]=u(e,t),l=i.plus(s),l>t?(s[c]--,e=i.plus(s),e>t&&(l=e,s[c]--,e=i.plus(s))):e=l);return[e,s,l,o]}function QAe(e,t,n,r){let[s,i,o,l]=ZAe(e,t,n);const c=t-s,u=n.filter(h=>["hours","minutes","seconds","milliseconds"].indexOf(h)>=0);u.length===0&&(o<t&&(o=s.plus({[l]:1})),o!==s&&(i[l]=(i[l]||0)+c/(o-s)));const d=Wt.fromObject(i,r);return u.length>0?Wt.fromMillis(c,r).shiftTo(...u).plus(d):d}const JAe="missing Intl.DateTimeFormat.formatToParts support";function Zt(e,t=n=>n){return{regex:e,deser:([n])=>t(UDe(n))}}const e$e=" ",IZ=`[ ${e$e}]`,TZ=new RegExp(IZ,"g");function t$e(e){return e.replace(/\./g,"\\.?").replace(TZ,IZ)}function EL(e){return e.replace(/\./g,"").replace(TZ," ").toLowerCase()}function oo(e,t){return e===null?null:{regex:RegExp(e.map(t$e).join("|")),deser:([n])=>e.findIndex(r=>EL(n)===EL(r))+t}}function IL(e,t){return{regex:e,deser:([,n,r])=>x_(n,r),groups:t}}function w0(e){return{regex:e,deser:([t])=>t}}function n$e(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r$e(e,t){const n=io(t),r=io(t,"{2}"),s=io(t,"{3}"),i=io(t,"{4}"),o=io(t,"{6}"),l=io(t,"{1,2}"),c=io(t,"{1,3}"),u=io(t,"{1,6}"),d=io(t,"{1,9}"),h=io(t,"{2,4}"),f=io(t,"{4,6}"),m=b=>({regex:RegExp(n$e(b.val)),deser:([y])=>y,literal:!0}),x=(b=>{if(e.literal)return m(b);switch(b.val){case"G":return oo(t.eras("short"),0);case"GG":return oo(t.eras("long"),0);case"y":return Zt(u);case"yy":return Zt(h,SE);case"yyyy":return Zt(i);case"yyyyy":return Zt(f);case"yyyyyy":return Zt(o);case"M":return Zt(l);case"MM":return Zt(r);case"MMM":return oo(t.months("short",!0),1);case"MMMM":return oo(t.months("long",!0),1);case"L":return Zt(l);case"LL":return Zt(r);case"LLL":return oo(t.months("short",!1),1);case"LLLL":return oo(t.months("long",!1),1);case"d":return Zt(l);case"dd":return Zt(r);case"o":return Zt(c);case"ooo":return Zt(s);case"HH":return Zt(r);case"H":return Zt(l);case"hh":return Zt(r);case"h":return Zt(l);case"mm":return Zt(r);case"m":return Zt(l);case"q":return Zt(l);case"qq":return Zt(r);case"s":return Zt(l);case"ss":return Zt(r);case"S":return Zt(c);case"SSS":return Zt(s);case"u":return w0(d);case"uu":return w0(l);case"uuu":return Zt(n);case"a":return oo(t.meridiems(),0);case"kkkk":return Zt(i);case"kk":return Zt(h,SE);case"W":return Zt(l);case"WW":return Zt(r);case"E":case"c":return Zt(n);case"EEE":return oo(t.weekdays("short",!1),1);case"EEEE":return oo(t.weekdays("long",!1),1);case"ccc":return oo(t.weekdays("short",!0),1);case"cccc":return oo(t.weekdays("long",!0),1);case"Z":case"ZZ":return IL(new RegExp(`([+-]${l.source})(?::(${r.source}))?`),2);case"ZZZ":return IL(new RegExp(`([+-]${l.source})(${r.source})?`),2);case"z":return w0(/[a-z_+-/]{1,256}?/i);case" ":return w0(/[^\S\n\r]/);default:return m(b)}})(e)||{invalidReason:JAe};return x.token=e,x}const s$e={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function i$e(e,t,n){const{type:r,value:s}=e;if(r==="literal"){const c=/^\s+$/.test(s);return{literal:!c,val:c?" ":s}}const i=t[r];let o=r;r==="hour"&&(t.hour12!=null?o=t.hour12?"hour12":"hour24":t.hourCycle!=null?t.hourCycle==="h11"||t.hourCycle==="h12"?o="hour12":o="hour24":o=n.hour12?"hour12":"hour24");let l=s$e[o];if(typeof l=="object"&&(l=l[i]),l)return{literal:!1,val:l}}function o$e(e){return[`^${e.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,e]}function a$e(e,t,n){const r=e.match(t);if(r){const s={};let i=1;for(const o in n)if(Zh(n,o)){const l=n[o],c=l.groups?l.groups+1:1;!l.literal&&l.token&&(s[l.token.val[0]]=l.deser(r.slice(i,i+c))),i+=c}return[r,s]}else return[r,{}]}function l$e(e){const t=i=>{switch(i){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let n=null,r;return ft(e.z)||(n=fa.create(e.z)),ft(e.Z)||(n||(n=new ns(e.Z)),r=e.Z),ft(e.q)||(e.M=(e.q-1)*3+1),ft(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),ft(e.u)||(e.S=UR(e.u)),[Object.keys(e).reduce((i,o)=>{const l=t(o);return l&&(i[l]=e[o]),i},{}),n,r]}let bC=null;function c$e(){return bC||(bC=xt.fromMillis(1555555555555)),bC}function u$e(e,t){if(e.literal)return e;const n=Jr.macroTokenToFormatOpts(e.val),r=OZ(n,t);return r==null||r.includes(void 0)?e:r}function RZ(e,t){return Array.prototype.concat(...e.map(n=>u$e(n,t)))}class MZ{constructor(t,n){if(this.locale=t,this.format=n,this.tokens=RZ(Jr.parseFormat(n),t),this.units=this.tokens.map(r=>r$e(r,t)),this.disqualifyingUnit=this.units.find(r=>r.invalidReason),!this.disqualifyingUnit){const[r,s]=o$e(this.units);this.regex=RegExp(r,"i"),this.handlers=s}}explainFromTokens(t){if(this.isValid){const[n,r]=a$e(t,this.regex,this.handlers),[s,i,o]=r?l$e(r):[null,null,void 0];if(Zh(r,"a")&&Zh(r,"H"))throw new eh("Can't include meridiem when specifying 24-hour format");return{input:t,tokens:this.tokens,regex:this.regex,rawMatches:n,matches:r,result:s,zone:i,specificOffset:o}}else return{input:t,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}}function PZ(e,t,n){return new MZ(e,n).explainFromTokens(t)}function d$e(e,t,n){const{result:r,zone:s,specificOffset:i,invalidReason:o}=PZ(e,t,n);return[r,s,i,o]}function OZ(e,t){if(!e)return null;const r=Jr.create(t,e).dtFormatter(c$e()),s=r.formatToParts(),i=r.resolvedOptions();return s.map(o=>i$e(o,e,i))}const wC="Invalid DateTime",TL=864e13;function Xp(e){return new go("unsupported zone",`the zone "${e.name}" is not supported`)}function _C(e){return e.weekData===null&&(e.weekData=l1(e.c)),e.weekData}function SC(e){return e.localWeekData===null&&(e.localWeekData=l1(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Bc(e,t){const n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new xt({...n,...t,old:n})}function DZ(e,t,n){let r=e-t*60*1e3;const s=n.offset(r);if(t===s)return[r,t];r-=(s-t)*60*1e3;const i=n.offset(r);return s===i?[r,s]:[e-Math.min(s,i)*60*1e3,Math.max(s,i)]}function _0(e,t){e+=t*60*1e3;const n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Cy(e,t,n){return DZ(g_(e),t,n)}function RL(e,t){const n=e.o,r=e.c.year+Math.trunc(t.years),s=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,i={...e.c,year:r,month:s,day:Math.min(e.c.day,c1(r,s))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=Wt.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as("milliseconds"),l=g_(i);let[c,u]=DZ(l,n,e.zone);return o!==0&&(c+=o,u=e.zone.offset(c)),{ts:c,o:u}}function Nd(e,t,n,r,s,i){const{setZone:o,zone:l}=n;if(e&&Object.keys(e).length!==0||t){const c=t||l,u=xt.fromObject(e,{...n,zone:c,specificOffset:i});return o?u:u.setZone(l)}else return xt.invalid(new go("unparsable",`the input "${s}" can't be parsed as ${r}`))}function S0(e,t,n=!0){return e.isValid?Jr.create(en.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function kC(e,t,n){const r=e.c.year>9999||e.c.year<0;let s="";if(r&&e.c.year>=0&&(s+="+"),s+=rr(e.c.year,r?6:4),n==="year")return s;if(t){if(s+="-",s+=rr(e.c.month),n==="month")return s;s+="-"}else if(s+=rr(e.c.month),n==="month")return s;return s+=rr(e.c.day),s}function ML(e,t,n,r,s,i,o){let l=!n||e.c.millisecond!==0||e.c.second!==0,c="";switch(o){case"day":case"month":case"year":break;default:if(c+=rr(e.c.hour),o==="hour")break;if(t){if(c+=":",c+=rr(e.c.minute),o==="minute")break;l&&(c+=":",c+=rr(e.c.second))}else{if(c+=rr(e.c.minute),o==="minute")break;l&&(c+=rr(e.c.second))}if(o==="second")break;l&&(!r||e.c.millisecond!==0)&&(c+=".",c+=rr(e.c.millisecond,3))}return s&&(e.isOffsetFixed&&e.offset===0&&!i?c+="Z":e.o<0?(c+="-",c+=rr(Math.trunc(-e.o/60)),c+=":",c+=rr(Math.trunc(-e.o%60))):(c+="+",c+=rr(Math.trunc(e.o/60)),c+=":",c+=rr(Math.trunc(e.o%60)))),i&&(c+="["+e.zone.ianaName+"]"),c}const AZ={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},h$e={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},f$e={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Ny=["year","month","day","hour","minute","second","millisecond"],p$e=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],m$e=["year","ordinal","hour","minute","second","millisecond"];function jy(e){const t={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[e.toLowerCase()];if(!t)throw new DX(e);return t}function PL(e){switch(e.toLowerCase()){case"localweekday":case"localweekdays":return"localWeekday";case"localweeknumber":case"localweeknumbers":return"localWeekNumber";case"localweekyear":case"localweekyears":return"localWeekYear";default:return jy(e)}}function g$e(e){if(Zp===void 0&&(Zp=Bn.now()),e.type!=="iana")return e.offset(Zp);const t=e.name;let n=kE.get(t);return n===void 0&&(n=e.offset(Zp),kE.set(t,n)),n}function OL(e,t){const n=Fl(t.zone,Bn.defaultZone);if(!n.isValid)return xt.invalid(Xp(n));const r=en.fromObject(t);let s,i;if(ft(e.year))s=Bn.now();else{for(const c of Ny)ft(e[c])&&(e[c]=AZ[c]);const o=lZ(e)||cZ(e);if(o)return xt.invalid(o);const l=g$e(n);[s,i]=Cy(e,l,n)}return new xt({ts:s,zone:n,loc:r,o:i})}function DL(e,t,n){const r=ft(n.round)?!0:n.round,s=ft(n.rounding)?"trunc":n.rounding,i=(l,c)=>(l=WR(l,r||n.calendary?0:2,n.calendary?"round":s),t.loc.clone(n).relFormatter(n).format(l,c)),o=l=>n.calendary?t.hasSame(e,l)?0:t.startOf(l).diff(e.startOf(l),l).get(l):t.diff(e,l).get(l);if(n.unit)return i(o(n.unit),n.unit);for(const l of n.units){const c=o(l);if(Math.abs(c)>=1)return i(c,l)}return i(e>t?-0:0,n.units[n.units.length-1])}function AL(e){let t={},n;return e.length>0&&typeof e[e.length-1]=="object"?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}let Zp;const kE=new Map;class xt{constructor(t){const n=t.zone||Bn.defaultZone;let r=t.invalid||(Number.isNaN(t.ts)?new go("invalid input"):null)||(n.isValid?null:Xp(n));this.ts=ft(t.ts)?Bn.now():t.ts;let s=null,i=null;if(!r)if(t.old&&t.old.ts===this.ts&&t.old.zone.equals(n))[s,i]=[t.old.c,t.old.o];else{const l=ic(t.o)&&!t.old?t.o:n.offset(this.ts);s=_0(this.ts,l),r=Number.isNaN(s.year)?new go("invalid input"):null,s=r?null:s,i=r?null:l}this._zone=n,this.loc=t.loc||en.create(),this.invalid=r,this.weekData=null,this.localWeekData=null,this.c=s,this.o=i,this.isLuxonDateTime=!0}static now(){return new xt({})}static local(){const[t,n]=AL(arguments),[r,s,i,o,l,c,u]=n;return OL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static utc(){const[t,n]=AL(arguments),[r,s,i,o,l,c,u]=n;return t.zone=ns.utcInstance,OL({year:r,month:s,day:i,hour:o,minute:l,second:c,millisecond:u},t)}static fromJSDate(t,n={}){const r=GDe(t)?t.valueOf():NaN;if(Number.isNaN(r))return xt.invalid("invalid input");const s=Fl(n.zone,Bn.defaultZone);return s.isValid?new xt({ts:r,zone:s,loc:en.fromObject(n)}):xt.invalid(Xp(s))}static fromMillis(t,n={}){if(ic(t))return t<-TL||t>TL?xt.invalid("Timestamp out of range"):new xt({ts:t,zone:Fl(n.zone,Bn.defaultZone),loc:en.fromObject(n)});throw new Xr(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(ic(t))return new xt({ts:t*1e3,zone:Fl(n.zone,Bn.defaultZone),loc:en.fromObject(n)});throw new Xr("fromSeconds requires a numerical input")}static fromObject(t,n={}){t=t||{};const r=Fl(n.zone,Bn.defaultZone);if(!r.isValid)return xt.invalid(Xp(r));const s=en.fromObject(n),i=u1(t,PL),{minDaysInFirstWeek:o,startOfWeek:l}=yL(i,s),c=Bn.now(),u=ft(n.specificOffset)?r.offset(c):n.specificOffset,d=!ft(i.ordinal),h=!ft(i.year),f=!ft(i.month)||!ft(i.day),m=h||f,g=i.weekYear||i.weekNumber;if((m||d)&&g)throw new eh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(f&&d)throw new eh("Can't mix ordinal dates with month/day");const x=g||i.weekday&&!m;let b,y,v=_0(c,u);x?(b=p$e,y=h$e,v=l1(v,o,l)):d?(b=m$e,y=f$e,v=yC(v)):(b=Ny,y=AZ);let w=!1;for(const E of b){const I=i[E];ft(I)?w?i[E]=y[E]:i[E]=v[E]:w=!0}const _=x?VDe(i,o,l):d?qDe(i):lZ(i),S=_||cZ(i);if(S)return xt.invalid(S);const k=x?xL(i,o,l):d?vL(i):i,[N,j]=Cy(k,u,r),R=new xt({ts:N,zone:r,o:j,loc:s});return i.weekday&&m&&t.weekday!==R.weekday?xt.invalid("mismatched weekday",`you can't specify both a weekday of ${i.weekday} and a date of ${R.toISO()}`):R.isValid?R:xt.invalid(R.invalid)}static fromISO(t,n={}){const[r,s]=$Ae(t);return Nd(r,s,n,"ISO 8601",t)}static fromRFC2822(t,n={}){const[r,s]=LAe(t);return Nd(r,s,n,"RFC 2822",t)}static fromHTTP(t,n={}){const[r,s]=BAe(t);return Nd(r,s,n,"HTTP",n)}static fromFormat(t,n,r={}){if(ft(t)||ft(n))throw new Xr("fromFormat requires an input string and a format");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0}),[l,c,u,d]=d$e(o,t,n);return d?xt.invalid(d):Nd(l,c,r,`format ${n}`,t,u)}static fromString(t,n,r={}){return xt.fromFormat(t,n,r)}static fromSQL(t,n={}){const[r,s]=qAe(t);return Nd(r,s,n,"SQL",t)}static invalid(t,n=null){if(!t)throw new Xr("need to specify a reason the DateTime is invalid");const r=t instanceof go?t:new go(t,n);if(Bn.throwOnInvalid)throw new bDe(r);return new xt({invalid:r})}static isDateTime(t){return t&&t.isLuxonDateTime||!1}static parseFormatForOpts(t,n={}){const r=OZ(t,en.fromObject(n));return r?r.map(s=>s?s.val:null).join(""):null}static expandFormat(t,n={}){return RZ(Jr.parseFormat(t),en.fromObject(n)).map(s=>s.val).join("")}static resetCache(){Zp=void 0,kE.clear()}get(t){return this[t]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?_C(this).weekYear:NaN}get weekNumber(){return this.isValid?_C(this).weekNumber:NaN}get weekday(){return this.isValid?_C(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?SC(this).weekday:NaN}get localWeekNumber(){return this.isValid?SC(this).weekNumber:NaN}get localWeekYear(){return this.isValid?SC(this).weekYear:NaN}get ordinal(){return this.isValid?yC(this.c).ordinal:NaN}get monthShort(){return this.isValid?Yp.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Yp.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Yp.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Yp.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];const t=864e5,n=6e4,r=g_(this.c),s=this.zone.offset(r-t),i=this.zone.offset(r+t),o=this.zone.offset(r-s*n),l=this.zone.offset(r-i*n);if(o===l)return[this];const c=r-o*n,u=r-l*n,d=_0(c,o),h=_0(u,l);return d.hour===h.hour&&d.minute===h.minute&&d.second===h.second&&d.millisecond===h.millisecond?[Bc(this,{ts:c}),Bc(this,{ts:u})]:[this]}get isInLeapYear(){return jx(this.year)}get daysInMonth(){return c1(this.year,this.month)}get daysInYear(){return this.isValid?xh(this.year):NaN}get weeksInWeekYear(){return this.isValid?Eg(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Eg(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(t={}){const{locale:n,numberingSystem:r,calendar:s}=Jr.create(this.loc.clone(t),t).resolvedOptions(this);return{locale:n,numberingSystem:r,outputCalendar:s}}toUTC(t=0,n={}){return this.setZone(ns.instance(t),n)}toLocal(){return this.setZone(Bn.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=Fl(t,Bn.defaultZone),t.equals(this.zone))return this;if(t.isValid){let s=this.ts;if(n||r){const i=t.offset(this.ts),o=this.toObject();[s]=Cy(o,i,t)}return Bc(this,{ts:s,zone:t})}else return xt.invalid(Xp(t))}reconfigure({locale:t,numberingSystem:n,outputCalendar:r}={}){const s=this.loc.clone({locale:t,numberingSystem:n,outputCalendar:r});return Bc(this,{loc:s})}setLocale(t){return this.reconfigure({locale:t})}set(t){if(!this.isValid)return this;const n=u1(t,PL),{minDaysInFirstWeek:r,startOfWeek:s}=yL(n,this.loc),i=!ft(n.weekYear)||!ft(n.weekNumber)||!ft(n.weekday),o=!ft(n.ordinal),l=!ft(n.year),c=!ft(n.month)||!ft(n.day),u=l||c,d=n.weekYear||n.weekNumber;if((u||o)&&d)throw new eh("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&o)throw new eh("Can't mix ordinal dates with month/day");let h;i?h=xL({...l1(this.c,r,s),...n},r,s):ft(n.ordinal)?(h={...this.toObject(),...n},ft(n.day)&&(h.day=Math.min(c1(h.year,h.month),h.day))):h=vL({...yC(this.c),...n});const[f,m]=Cy(h,this.o,this.zone);return Bc(this,{ts:f,o:m})}plus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t);return Bc(this,RL(this,n))}minus(t){if(!this.isValid)return this;const n=Wt.fromDurationLike(t).negate();return Bc(this,RL(this,n))}startOf(t,{useLocaleWeeks:n=!1}={}){if(!this.isValid)return this;const r={},s=Wt.normalizeUnit(t);switch(s){case"years":r.month=1;case"quarters":case"months":r.day=1;case"weeks":case"days":r.hour=0;case"hours":r.minute=0;case"minutes":r.second=0;case"seconds":r.millisecond=0;break}if(s==="weeks")if(n){const i=this.loc.getStartOfWeek(),{weekday:o}=this;o<i&&(r.weekNumber=this.weekNumber-1),r.weekday=i}else r.weekday=1;if(s==="quarters"){const i=Math.ceil(this.month/3);r.month=(i-1)*3+1}return this.set(r)}endOf(t,n){return this.isValid?this.plus({[t]:1}).startOf(t,n).minus(1):this}toFormat(t,n={}){return this.isValid?Jr.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,t):wC}toLocaleString(t=a1,n={}){return this.isValid?Jr.create(this.loc.clone(n),t).formatDateTime(this):wC}toLocaleParts(t={}){return this.isValid?Jr.create(this.loc.clone(t),t).formatDateTimeParts(this):[]}toISO({format:t="extended",suppressSeconds:n=!1,suppressMilliseconds:r=!1,includeOffset:s=!0,extendedZone:i=!1,precision:o="milliseconds"}={}){if(!this.isValid)return null;o=jy(o);const l=t==="extended";let c=kC(this,l,o);return Ny.indexOf(o)>=3&&(c+="T"),c+=ML(this,l,n,r,s,i,o),c}toISODate({format:t="extended",precision:n="day"}={}){return this.isValid?kC(this,t==="extended",jy(n)):null}toISOWeekDate(){return S0(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:t=!1,suppressSeconds:n=!1,includeOffset:r=!0,includePrefix:s=!1,extendedZone:i=!1,format:o="extended",precision:l="milliseconds"}={}){return this.isValid?(l=jy(l),(s&&Ny.indexOf(l)>=3?"T":"")+ML(this,o==="extended",n,t,r,i,l)):null}toRFC2822(){return S0(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return S0(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?kC(this,!0):null}toSQLTime({includeOffset:t=!0,includeZone:n=!1,includeOffsetSpace:r=!0}={}){let s="HH:mm:ss.SSS";return(n||t)&&(r&&(s+=" "),n?s+="z":t&&(s+="ZZ")),S0(this,s,!0)}toSQL(t={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(t)}`:null}toString(){return this.isValid?this.toISO():wC}[Symbol.for("nodejs.util.inspect.custom")](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(t={}){if(!this.isValid)return{};const n={...this.c};return t.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(t,n="milliseconds",r={}){if(!this.isValid||!t.isValid)return Wt.invalid("created by diffing an invalid DateTime");const s={locale:this.locale,numberingSystem:this.numberingSystem,...r},i=YDe(n).map(Wt.normalizeUnit),o=t.valueOf()>this.valueOf(),l=o?this:t,c=o?t:this,u=QAe(l,c,i,s);return o?u.negate():u}diffNow(t="milliseconds",n={}){return this.diff(xt.now(),t,n)}until(t){return this.isValid?$n.fromDateTimes(this,t):this}hasSame(t,n,r){if(!this.isValid)return!1;const s=t.valueOf(),i=this.setZone(t.zone,{keepLocalTime:!0});return i.startOf(n,r)<=s&&s<=i.endOf(n,r)}equals(t){return this.isValid&&t.isValid&&this.valueOf()===t.valueOf()&&this.zone.equals(t.zone)&&this.loc.equals(t.loc)}toRelative(t={}){if(!this.isValid)return null;const n=t.base||xt.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0;let s=["years","months","days","hours","minutes","seconds"],i=t.unit;return Array.isArray(t.unit)&&(s=t.unit,i=void 0),DL(n,this.plus(r),{...t,numeric:"always",units:s,unit:i})}toRelativeCalendar(t={}){return this.isValid?DL(t.base||xt.fromObject({},{zone:this.zone}),this,{...t,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...t){if(!t.every(xt.isDateTime))throw new Xr("min requires all arguments be DateTimes");return bL(t,n=>n.valueOf(),Math.min)}static max(...t){if(!t.every(xt.isDateTime))throw new Xr("max requires all arguments be DateTimes");return bL(t,n=>n.valueOf(),Math.max)}static fromFormatExplain(t,n,r={}){const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});return PZ(o,t,n)}static fromStringExplain(t,n,r={}){return xt.fromFormatExplain(t,n,r)}static buildFormatParser(t,n={}){const{locale:r=null,numberingSystem:s=null}=n,i=en.fromOpts({locale:r,numberingSystem:s,defaultToEN:!0});return new MZ(i,t)}static fromFormatParser(t,n,r={}){if(ft(t)||ft(n))throw new Xr("fromFormatParser requires an input string and a format parser");const{locale:s=null,numberingSystem:i=null}=r,o=en.fromOpts({locale:s,numberingSystem:i,defaultToEN:!0});if(!o.equals(n.locale))throw new Xr(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);const{result:l,zone:c,specificOffset:u,invalidReason:d}=n.explainFromTokens(t);return d?xt.invalid(d):Nd(l,c,r,`format ${n.format}`,t,u)}static get DATE_SHORT(){return a1}static get DATE_MED(){return AX}static get DATE_MED_WITH_WEEKDAY(){return SDe}static get DATE_FULL(){return $X}static get DATE_HUGE(){return LX}static get TIME_SIMPLE(){return BX}static get TIME_WITH_SECONDS(){return FX}static get TIME_WITH_SHORT_OFFSET(){return zX}static get TIME_WITH_LONG_OFFSET(){return HX}static get TIME_24_SIMPLE(){return UX}static get TIME_24_WITH_SECONDS(){return WX}static get TIME_24_WITH_SHORT_OFFSET(){return VX}static get TIME_24_WITH_LONG_OFFSET(){return qX}static get DATETIME_SHORT(){return KX}static get DATETIME_SHORT_WITH_SECONDS(){return GX}static get DATETIME_MED(){return YX}static get DATETIME_MED_WITH_SECONDS(){return XX}static get DATETIME_MED_WITH_WEEKDAY(){return kDe}static get DATETIME_FULL(){return ZX}static get DATETIME_FULL_WITH_SECONDS(){return QX}static get DATETIME_HUGE(){return JX}static get DATETIME_HUGE_WITH_SECONDS(){return eZ}}function Ep(e){if(xt.isDateTime(e))return e;if(e&&e.valueOf&&ic(e.valueOf()))return xt.fromJSDate(e);if(e&&typeof e=="object")return xt.fromObject(e);throw new Xr(`Unknown datetime argument: ${e}, of type ${typeof e}`)}const x$e="3.7.2";xi.DateTime=xt;xi.Duration=Wt;xi.FixedOffsetZone=ns;xi.IANAZone=fa;xi.Info=Yp;xi.Interval=$n;xi.InvalidZone=rZ;xi.Settings=Bn;xi.SystemZone=Nx;xi.VERSION=x$e;xi.Zone=If;var Fc=xi;vt.prototype.addYear=function(){this._date=this._date.plus({years:1})};vt.prototype.addMonth=function(){this._date=this._date.plus({months:1}).startOf("month")};vt.prototype.addDay=function(){this._date=this._date.plus({days:1}).startOf("day")};vt.prototype.addHour=function(){var e=this._date;this._date=this._date.plus({hours:1}).startOf("hour"),this._date<=e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addMinute=function(){var e=this._date;this._date=this._date.plus({minutes:1}).startOf("minute"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.addSecond=function(){var e=this._date;this._date=this._date.plus({seconds:1}).startOf("second"),this._date<e&&(this._date=this._date.plus({hours:1}))};vt.prototype.subtractYear=function(){this._date=this._date.minus({years:1})};vt.prototype.subtractMonth=function(){this._date=this._date.minus({months:1}).endOf("month").startOf("second")};vt.prototype.subtractDay=function(){this._date=this._date.minus({days:1}).endOf("day").startOf("second")};vt.prototype.subtractHour=function(){var e=this._date;this._date=this._date.minus({hours:1}).endOf("hour").startOf("second"),this._date>=e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractMinute=function(){var e=this._date;this._date=this._date.minus({minutes:1}).endOf("minute").startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.subtractSecond=function(){var e=this._date;this._date=this._date.minus({seconds:1}).startOf("second"),this._date>e&&(this._date=this._date.minus({hours:1}))};vt.prototype.getDate=function(){return this._date.day};vt.prototype.getFullYear=function(){return this._date.year};vt.prototype.getDay=function(){var e=this._date.weekday;return e==7?0:e};vt.prototype.getMonth=function(){return this._date.month-1};vt.prototype.getHours=function(){return this._date.hour};vt.prototype.getMinutes=function(){return this._date.minute};vt.prototype.getSeconds=function(){return this._date.second};vt.prototype.getMilliseconds=function(){return this._date.millisecond};vt.prototype.getTime=function(){return this._date.valueOf()};vt.prototype.getUTCDate=function(){return this._getUTC().day};vt.prototype.getUTCFullYear=function(){return this._getUTC().year};vt.prototype.getUTCDay=function(){var e=this._getUTC().weekday;return e==7?0:e};vt.prototype.getUTCMonth=function(){return this._getUTC().month-1};vt.prototype.getUTCHours=function(){return this._getUTC().hour};vt.prototype.getUTCMinutes=function(){return this._getUTC().minute};vt.prototype.getUTCSeconds=function(){return this._getUTC().second};vt.prototype.toISOString=function(){return this._date.toUTC().toISO()};vt.prototype.toJSON=function(){return this._date.toJSON()};vt.prototype.setDate=function(e){this._date=this._date.set({day:e})};vt.prototype.setFullYear=function(e){this._date=this._date.set({year:e})};vt.prototype.setDay=function(e){this._date=this._date.set({weekday:e})};vt.prototype.setMonth=function(e){this._date=this._date.set({month:e+1})};vt.prototype.setHours=function(e){this._date=this._date.set({hour:e})};vt.prototype.setMinutes=function(e){this._date=this._date.set({minute:e})};vt.prototype.setSeconds=function(e){this._date=this._date.set({second:e})};vt.prototype.setMilliseconds=function(e){this._date=this._date.set({millisecond:e})};vt.prototype._getUTC=function(){return this._date.toUTC()};vt.prototype.toString=function(){return this.toDate().toString()};vt.prototype.toDate=function(){return this._date.toJSDate()};vt.prototype.isLastDayOfMonth=function(){var e=this._date.plus({days:1}).startOf("day");return this._date.month!==e.month};vt.prototype.isLastWeekdayOfMonth=function(){var e=this._date.plus({days:7}).startOf("day");return this._date.month!==e.month};function vt(e,t){var n={zone:t};if(e?e instanceof vt?this._date=e._date:e instanceof Date?this._date=Fc.DateTime.fromJSDate(e,n):typeof e=="number"?this._date=Fc.DateTime.fromMillis(e,n):typeof e=="string"&&(this._date=Fc.DateTime.fromISO(e,n),this._date.isValid||(this._date=Fc.DateTime.fromRFC2822(e,n)),this._date.isValid||(this._date=Fc.DateTime.fromSQL(e,n)),this._date.isValid||(this._date=Fc.DateTime.fromFormat(e,"EEE, d MMM yyyy HH:mm:ss",n))):this._date=Fc.DateTime.local(),!this._date||!this._date.isValid)throw new Error("CronDate: unhandled timestamp: "+JSON.stringify(e));t&&t!==this._date.zoneName&&(this._date=this._date.setZone(t))}var v$e=vt;function Xc(e){return{start:e,count:1}}function $L(e,t){e.end=t,e.step=t-e.start,e.count=2}function CC(e,t,n){t&&(t.count===2?(e.push(Xc(t.start)),e.push(Xc(t.end))):e.push(t)),n&&e.push(n)}function y$e(e){for(var t=[],n=void 0,r=0;r<e.length;r++){var s=e[r];typeof s!="number"?(CC(t,n,Xc(s)),n=void 0):n?n.count===1?$L(n,s):n.step===s-n.end?(n.count++,n.end=s):n.count===2?(t.push(Xc(n.start)),n=Xc(n.end),$L(n,s)):(CC(t,n),n=Xc(s)):n=Xc(s)}return CC(t,n),t}var b$e=y$e,w$e=b$e;function _$e(e,t,n){var r=w$e(e);if(r.length===1){var s=r[0],i=s.step;if(i===1&&s.start===t&&s.end===n)return"*";if(i!==1&&s.start===t&&s.end===n-i+1)return"*/"+i}for(var o=[],l=0,c=r.length;l<c;++l){var u=r[l];if(u.count===1){o.push(u.start);continue}var i=u.step;if(u.step===1){o.push(u.start+"-"+u.end);continue}var d=u.start==0?u.count-1:u.count;u.step*d>u.end?o=o.concat(Array.from({length:u.end-u.start+1}).map(function(f,m){var g=u.start+m;return(g-u.start)%u.step===0?g:null}).filter(function(f){return f!=null})):u.end===n-u.step+1?o.push(u.start+"/"+u.step):o.push(u.start+"-"+u.end+"/"+u.step)}return o.join(",")}var S$e=_$e,au=v$e,k$e=S$e,LL=1e4;function Be(e,t){this._options=t,this._utc=t.utc||!1,this._tz=this._utc?"UTC":t.tz,this._currentDate=new au(t.currentDate,this._tz),this._startDate=t.startDate?new au(t.startDate,this._tz):null,this._endDate=t.endDate?new au(t.endDate,this._tz):null,this._isIterator=t.iterator||!1,this._hasIterated=!1,this._nthDayOfWeek=t.nthDayOfWeek||0,this.fields=Be._freezeFields(e)}Be.map=["second","minute","hour","dayOfMonth","month","dayOfWeek"];Be.predefined={"@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *"};Be.constraints=[{min:0,max:59,chars:[]},{min:0,max:59,chars:[]},{min:0,max:23,chars:[]},{min:1,max:31,chars:["L"]},{min:1,max:12,chars:[]},{min:0,max:7,chars:["L"]}];Be.daysInMonth=[31,29,31,30,31,30,31,31,30,31,30,31];Be.aliases={month:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},dayOfWeek:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}};Be.parseDefaults=["0","*","*","*","*","*"];Be.standardValidCharacters=/^[,*\d/-]+$/;Be.dayOfWeekValidCharacters=/^[?,*\dL#/-]+$/;Be.dayOfMonthValidCharacters=/^[?,*\dL/-]+$/;Be.validCharacters={second:Be.standardValidCharacters,minute:Be.standardValidCharacters,hour:Be.standardValidCharacters,dayOfMonth:Be.dayOfMonthValidCharacters,month:Be.standardValidCharacters,dayOfWeek:Be.dayOfWeekValidCharacters};Be._isValidConstraintChar=function(t,n){return typeof n!="string"?!1:t.chars.some(function(r){return n.indexOf(r)>-1})};Be._parseField=function(t,n,r){switch(t){case"month":case"dayOfWeek":var s=Be.aliases[t];n=n.replace(/[a-z]{3}/gi,function(c){if(c=c.toLowerCase(),typeof s[c]<"u")return s[c];throw new Error('Validation error, cannot resolve alias "'+c+'"')});break}if(!Be.validCharacters[t].test(n))throw new Error("Invalid characters, got value: "+n);n.indexOf("*")!==-1?n=n.replace(/\*/g,r.min+"-"+r.max):n.indexOf("?")!==-1&&(n=n.replace(/\?/g,r.min+"-"+r.max));function i(c){var u=[];function d(g){if(g instanceof Array)for(var x=0,b=g.length;x<b;x++){var y=g[x];if(Be._isValidConstraintChar(r,y)){u.push(y);continue}if(typeof y!="number"||Number.isNaN(y)||y<r.min||y>r.max)throw new Error("Constraint error, got value "+y+" expected range "+r.min+"-"+r.max);u.push(y)}else{if(Be._isValidConstraintChar(r,g)){u.push(g);return}var v=+g;if(Number.isNaN(v)||v<r.min||v>r.max)throw new Error("Constraint error, got value "+g+" expected range "+r.min+"-"+r.max);t==="dayOfWeek"&&(v=v%7),u.push(v)}}var h=c.split(",");if(!h.every(function(g){return g.length>0}))throw new Error("Invalid list value format");if(h.length>1)for(var f=0,m=h.length;f<m;f++)d(o(h[f]));else d(o(c));return u.sort(Be._sortCompareFn),u}function o(c){var u=1,d=c.split("/");if(d.length>2)throw new Error("Invalid repeat: "+c);return d.length>1?(d[0]==+d[0]&&(d=[d[0]+"-"+r.max,d[1]]),l(d[0],d[d.length-1])):l(c,u)}function l(c,u){var d=[],h=c.split("-");if(h.length>1){if(h.length<2)return+c;if(!h[0].length){if(!h[1].length)throw new Error("Invalid range: "+c);return+c}var f=+h[0],m=+h[1];if(Number.isNaN(f)||Number.isNaN(m)||f<r.min||m>r.max)throw new Error("Constraint error, got range "+f+"-"+m+" expected range "+r.min+"-"+r.max);if(f>m)throw new Error("Invalid range: "+c);var g=+u;if(Number.isNaN(g)||g<=0)throw new Error("Constraint error, cannot repeat at every "+g+" time.");t==="dayOfWeek"&&m%7===0&&d.push(0);for(var x=f,b=m;x<=b;x++){var y=d.indexOf(x)!==-1;!y&&g>0&&g%u===0?(g=1,d.push(x)):g++}return d}return Number.isNaN(+c)?c:+c}return i(n)};Be._sortCompareFn=function(e,t){var n=typeof e=="number",r=typeof t=="number";return n&&r?e-t:!n&&r?1:n&&!r?-1:e.localeCompare(t)};Be._handleMaxDaysInMonth=function(e){if(e.month.length===1){var t=Be.daysInMonth[e.month[0]-1];if(e.dayOfMonth[0]>t)throw new Error("Invalid explicit day of month definition");return e.dayOfMonth.filter(function(n){return n==="L"?!0:n<=t}).sort(Be._sortCompareFn)}};Be._freezeFields=function(e){for(var t=0,n=Be.map.length;t<n;++t){var r=Be.map[t],s=e[r];e[r]=Object.freeze(s)}return Object.freeze(e)};Be.prototype._applyTimezoneShift=function(e,t,n){if(n==="Month"||n==="Day"){var r=e.getTime();e[t+n]();var s=e.getTime();r===s&&(e.getMinutes()===0&&e.getSeconds()===0?e.addHour():e.getMinutes()===59&&e.getSeconds()===59&&e.subtractHour())}else{var i=e.getHours();e[t+n]();var o=e.getHours(),l=o-i;l===2?this.fields.hour.length!==24&&(this._dstStart=o):l===0&&e.getMinutes()===0&&e.getSeconds()===0&&this.fields.hour.length!==24&&(this._dstEnd=o)}};Be.prototype._findSchedule=function(t){function n(y,v){for(var w=0,_=v.length;w<_;w++)if(v[w]>=y)return v[w]===y;return v[0]===y}function r(y,v){if(v<6){if(y.getDate()<8&&v===1)return!0;var w=y.getDate()%7?1:0,_=y.getDate()-y.getDate()%7,S=Math.floor(_/7)+w;return S===v}return!1}function s(y){return y.length>0&&y.some(function(v){return typeof v=="string"&&v.indexOf("L")>=0})}t=t||!1;var i=t?"subtract":"add",o=new au(this._currentDate,this._tz),l=this._startDate,c=this._endDate,u=o.getTime(),d=0;function h(y){return y.some(function(v){if(!s([v]))return!1;var w=Number.parseInt(v[0])%7;if(Number.isNaN(w))throw new Error("Invalid last weekday of the month expression: "+v);return o.getDay()===w&&o.isLastWeekdayOfMonth()})}for(;d<LL;){if(d++,t){if(l&&o.getTime()-l.getTime()<0)throw new Error("Out of the timespan range")}else if(c&&c.getTime()-o.getTime()<0)throw new Error("Out of the timespan range");var f=n(o.getDate(),this.fields.dayOfMonth);s(this.fields.dayOfMonth)&&(f=f||o.isLastDayOfMonth());var m=n(o.getDay(),this.fields.dayOfWeek);s(this.fields.dayOfWeek)&&(m=m||h(this.fields.dayOfWeek));var g=this.fields.dayOfMonth.length>=Be.daysInMonth[o.getMonth()],x=this.fields.dayOfWeek.length===Be.constraints[5].max-Be.constraints[5].min+1,b=o.getHours();if(!f&&(!m||x)){this._applyTimezoneShift(o,i,"Day");continue}if(!g&&x&&!f){this._applyTimezoneShift(o,i,"Day");continue}if(g&&!x&&!m){this._applyTimezoneShift(o,i,"Day");continue}if(this._nthDayOfWeek>0&&!r(o,this._nthDayOfWeek)){this._applyTimezoneShift(o,i,"Day");continue}if(!n(o.getMonth()+1,this.fields.month)){this._applyTimezoneShift(o,i,"Month");continue}if(n(b,this.fields.hour)){if(this._dstEnd===b&&!t){this._dstEnd=null,this._applyTimezoneShift(o,"add","Hour");continue}}else if(this._dstStart!==b){this._dstStart=null,this._applyTimezoneShift(o,i,"Hour");continue}else if(!n(b-1,this.fields.hour)){o[i+"Hour"]();continue}if(!n(o.getMinutes(),this.fields.minute)){this._applyTimezoneShift(o,i,"Minute");continue}if(!n(o.getSeconds(),this.fields.second)){this._applyTimezoneShift(o,i,"Second");continue}if(u===o.getTime()){i==="add"||o.getMilliseconds()===0?this._applyTimezoneShift(o,i,"Second"):o.setMilliseconds(0);continue}break}if(d>=LL)throw new Error("Invalid expression, loop limit exceeded");return this._currentDate=new au(o,this._tz),this._hasIterated=!0,o};Be.prototype.next=function(){var t=this._findSchedule();return this._isIterator?{value:t,done:!this.hasNext()}:t};Be.prototype.prev=function(){var t=this._findSchedule(!0);return this._isIterator?{value:t,done:!this.hasPrev()}:t};Be.prototype.hasNext=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.hasPrev=function(){var e=this._currentDate,t=this._hasIterated;try{return this._findSchedule(!0),!0}catch{return!1}finally{this._currentDate=e,this._hasIterated=t}};Be.prototype.iterate=function(t,n){var r=[];if(t>=0)for(var s=0,i=t;s<i;s++)try{var o=this.next();r.push(o),n&&n(o,s)}catch{break}else for(var s=0,i=t;s>i;s--)try{var o=this.prev();r.push(o),n&&n(o,s)}catch{break}return r};Be.prototype.reset=function(t){this._currentDate=new au(t||this._options.currentDate)};Be.prototype.stringify=function(t){for(var n=[],r=t?0:1,s=Be.map.length;r<s;++r){var i=Be.map[r],o=this.fields[i],l=Be.constraints[r];i==="dayOfMonth"&&this.fields.month.length===1?l={min:1,max:Be.daysInMonth[this.fields.month[0]-1]}:i==="dayOfWeek"&&(l={min:0,max:6},o=o[o.length-1]===7?o.slice(0,-1):o),n.push(k$e(o,l.min,l.max))}return n.join(" ")};Be.parse=function(t,n){var r=this;typeof n=="function"&&(n={});function s(i,o){o||(o={}),typeof o.currentDate>"u"&&(o.currentDate=new au(void 0,r._tz)),Be.predefined[i]&&(i=Be.predefined[i]);var l=[],c=(i+"").trim().split(/\s+/);if(c.length>6)throw new Error("Invalid cron expression");for(var u=Be.map.length-c.length,d=0,h=Be.map.length;d<h;++d){var f=Be.map[d],m=c[c.length>h?d:d-u];if(d<u||!m)l.push(Be._parseField(f,Be.parseDefaults[d],Be.constraints[d]));else{var g=f==="dayOfWeek"?v(m):m;l.push(Be._parseField(f,g,Be.constraints[d]))}}for(var x={},d=0,h=Be.map.length;d<h;d++){var b=Be.map[d];x[b]=l[d]}var y=Be._handleMaxDaysInMonth(x);return x.dayOfMonth=y||x.dayOfMonth,new Be(x,o);function v(w){var _=w.split("#");if(_.length>1){var S=+_[_.length-1];if(/,/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible");if(/\//.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible");if(/-/.test(w))throw new Error("Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible");if(_.length>2||Number.isNaN(S)||S<1||S>5)throw new Error("Constraint error, invalid dayOfWeek occurrence number (#)");return o.nthDayOfWeek=S,_[0]}return w}}return s(t,n)};Be.fieldsToExpression=function(t,n){function r(f,m,g){if(!m)throw new Error("Validation error, Field "+f+" is missing");if(m.length===0)throw new Error("Validation error, Field "+f+" contains no values");for(var x=0,b=m.length;x<b;x++){var y=m[x];if(!Be._isValidConstraintChar(g,y)&&(typeof y!="number"||Number.isNaN(y)||y<g.min||y>g.max))throw new Error("Constraint error, got value "+y+" expected range "+g.min+"-"+g.max)}}for(var s={},i=0,o=Be.map.length;i<o;++i){var l=Be.map[i],c=t[l];r(l,c,Be.constraints[i]);for(var u=[],d=-1;++d<c.length;)u[d]=c[d];if(c=u.sort(Be._sortCompareFn).filter(function(f,m,g){return!m||f!==g[m-1]}),c.length!==u.length)throw new Error("Validation error, Field "+l+" contains duplicate values");s[l]=c}var h=Be._handleMaxDaysInMonth(s);return s.dayOfMonth=h||s.dayOfMonth,new Be(s,n||{})};var C$e=Be;const N$e={},j$e=Object.freeze(Object.defineProperty({__proto__:null,default:N$e},Symbol.toStringTag,{value:"Module"})),E$e=Rne(j$e);var d1=C$e;function fc(){}fc._parseEntry=function(t){var n=t.split(" ");if(n.length===6)return{interval:d1.parse(t)};if(n.length>6)return{interval:d1.parse(n.slice(0,6).join(" ")),command:n.slice(6,n.length)};throw new Error("Invalid entry: "+t)};fc.parseExpression=function(t,n){return d1.parse(t,n)};fc.fieldsToExpression=function(t,n){return d1.fieldsToExpression(t,n)};fc.parseString=function(t){for(var n=t.split(`
916
916
  `),r={variables:{},expressions:[],errors:{}},s=0,i=n.length;s<i;s++){var o=n[s],l=null,c=o.trim();if(c.length>0){if(c.match(/^#/))continue;if(l=c.match(/^(.*)=(.*)$/))r.variables[l[1]]=l[2];else{var u=null;try{u=fc._parseEntry("0 "+c),r.expressions.push(u.interval)}catch(d){r.errors[c]=d}}}}return r};fc.parseFile=function(t,n){E$e.readFile(t,function(r,s){if(r){n(r);return}return n(null,fc.parseString(s.toString()))})};var I$e=fc;const T$e=pn(I$e),R$e=5*6e4;function M$e(e,t){if(!(!e||e.length===0)){for(const n of e)if(n.startedAtMs>=t&&n.startedAtMs<t+R$e)return n}}const P$e=30*6e4,O$e=30*24*36e5;function D$e(e,t,n,r=new Date){const s=r.getTime(),i=s-O$e,o=[];for(const l of e){const c=n(l.agentId);switch(l.schedule.kind){case"at":{const u=new Date(l.schedule.at);if(Number.isNaN(u.getTime())||u<t.from||u>=t.to||u.getTime()<i)break;o.push(NC(l,c,u,"once",s));break}case"cron":{const u=T$e.parseExpression(l.schedule.expr,{currentDate:t.from,endDate:t.to,tz:l.schedule.tz});for(;u.hasNext();){const d=u.next().toDate();d.getTime()<i||o.push(NC(l,c,d,d.toISOString(),s))}break}case"every":{const u=l.schedule.everyMs;if(u<=0)break;const d=t.from.getTime(),h=t.to.getTime(),f=l.schedule.anchorMs??d;let m;if(f>=d)m=f;else{const g=Math.ceil((d-f)/u);m=f+g*u}for(;m<h;)m>=i&&o.push(NC(l,c,new Date(m),new Date(m).toISOString(),s)),m+=u;break}}}return o}function NC(e,t,n,r,s){const i=n.getTime(),o=i<=s,l=o?M$e(e.runs,i):void 0;return{id:`${e.id}:${r}`,shiftId:e.id,agentId:e.agentId,title:t.name,start:n,end:new Date(i+P$e),resourceColor:t.color,note:e.note,isPast:o,...l!=null&&l.sessionId?{sessionId:l.sessionId}:{}}}var $Z={exports:{}},A$e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",$$e=A$e,L$e=$$e;function LZ(){}function BZ(){}BZ.resetWarningCache=LZ;var B$e=function(){function e(r,s,i,o,l,c){if(c!==L$e){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:BZ,resetWarningCache:LZ};return n.PropTypes=n,n};$Z.exports=B$e();var F$e=$Z.exports;const Ee=pn(F$e);var z$e=function(e,t,n,r,s,i,o,l){if(!e){var c;if(t===void 0)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,s,i,o,l],d=0;c=new Error(t.replace(/%s/g,function(){return u[d++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},H$e=z$e;const Ig=pn(H$e);var U$e=function(){};function W$e(e,t){var n={};return Object.keys(e).forEach(function(r){n[Ey(r)]=U$e}),n}function BL(e,t){return e[t]!==void 0}function Ey(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function V$e(e){return!!e&&(typeof e!="function"||e.prototype&&e.prototype.isReactComponent)}function q$e(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ib(e,t)}function FZ(){var e=this.constructor.getDerivedStateFromProps(this.props,this.state);e!=null&&this.setState(e)}function zZ(e){function t(n){var r=this.constructor.getDerivedStateFromProps(e,n);return r??null}this.setState(t.bind(this))}function HZ(e,t){try{var n=this.props,r=this.state;this.props=e,this.state=t,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,r)}finally{this.props=n,this.state=r}}FZ.__suppressDeprecationWarning=!0;zZ.__suppressDeprecationWarning=!0;HZ.__suppressDeprecationWarning=!0;function K$e(e){var t=e.prototype;if(!t||!t.isReactComponent)throw new Error("Can only polyfill class components");if(typeof e.getDerivedStateFromProps!="function"&&typeof t.getSnapshotBeforeUpdate!="function")return e;var n=null,r=null,s=null;if(typeof t.componentWillMount=="function"?n="componentWillMount":typeof t.UNSAFE_componentWillMount=="function"&&(n="UNSAFE_componentWillMount"),typeof t.componentWillReceiveProps=="function"?r="componentWillReceiveProps":typeof t.UNSAFE_componentWillReceiveProps=="function"&&(r="UNSAFE_componentWillReceiveProps"),typeof t.componentWillUpdate=="function"?s="componentWillUpdate":typeof t.UNSAFE_componentWillUpdate=="function"&&(s="UNSAFE_componentWillUpdate"),n!==null||r!==null||s!==null){var i=e.displayName||e.name,o=typeof e.getDerivedStateFromProps=="function"?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error(`Unsafe legacy lifecycles will not be called for components using new component APIs.
917
917
 
918
918
  `+i+" uses "+o+" but also contains the following legacy lifecycles:"+(n!==null?`