@hyperdrive.bot/fleet-server 0.3.154 → 0.3.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/web-ui/_expo/static/js/web/{index-72ad07eafa55ee66087be0522317d047.js → index-81ee92214133211579a50ef5c84491cf.js} +13 -13
- package/dist/server/web-ui/_expo/static/js/web/index-81ee92214133211579a50ef5c84491cf.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/{index-72ad07eafa55ee66087be0522317d047.js.gz → index-81ee92214133211579a50ef5c84491cf.js.gz} +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-81ee92214133211579a50ef5c84491cf.js.map.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/{index-72ad07eafa55ee66087be0522317d047.js.map.gz → index-81ee92214133211579a50ef5c84491cf.js.map.gz} +0 -0
- package/dist/server/web-ui/index.html +1 -1
- package/dist/server/web-ui/index.html.br +0 -0
- package/dist/server/web-ui/index.html.gz +0 -0
- package/package.json +6 -6
- package/dist/server/web-ui/_expo/static/js/web/index-72ad07eafa55ee66087be0522317d047.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-72ad07eafa55ee66087be0522317d047.js.map.br +0 -0
|
@@ -849,7 +849,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v
|
|
|
849
849
|
__d(function(g,r,i,a,m,e,d){"use strict";var t=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.shouldAppendSitemap=u,e.shouldAppendNotFound=s,e.getRootStackRouteNames=function(){const t=[n.INTERNAL_SLOT_NAME];s()&&t.push(n.NOT_FOUND_ROUTE_NAME);u()&&t.push(n.SITEMAP_ROUTE_NAME);return t};const o=t(r(d[0])),n=r(d[1]);function u(){const t=o.default.expoConfig?.extra?.router;return!1!==t?.sitemap}function s(){const t=o.default.expoConfig?.extra?.router;return!1!==t?.notFound}},717,[718,721]);
|
|
850
850
|
__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"AppOwnership",{enumerable:!0,get:function(){return l.AppOwnership}}),Object.defineProperty(_e,"ExecutionEnvironment",{enumerable:!0,get:function(){return l.ExecutionEnvironment}}),Object.defineProperty(_e,"UserInterfaceIdiom",{enumerable:!0,get:function(){return l.UserInterfaceIdiom}});var n=e(r(d[0])),t=r(d[1]);r(d[2]);var u=e(r(d[3])),l=r(d[4]),o=e(r(d[5]));o.default||console.warn("No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?");const s=(0,t.requireOptionalNativeModule)('ExpoUpdates');let f=null;if(s){let e;s.manifest?e=s.manifest:s.manifestString&&(e=JSON.parse(s.manifestString)),e&&Object.keys(e).length>0&&(f=e)}let c=null;if(u.default.EXDevLauncher){let e;u.default.EXDevLauncher.manifestString&&(e=JSON.parse(u.default.EXDevLauncher.manifestString)),e&&Object.keys(e).length>0&&(c=e)}let p=null;if(o.default&&o.default.manifest){const e=o.default.manifest;p='string'==typeof e?JSON.parse(e):e}let b=f??c??p;const E=o.default||{},{appOwnership:O}=E,x=(0,n.default)(E,["name","appOwnership"]),v=Object.assign({},x,{appOwnership:O??null});function _(e){return!h(e)}function h(e){return'metadata'in e}function S(e=!1){if(!b){const e=null===b?'null':'undefined';if(x.executionEnvironment,l.ExecutionEnvironment.Bare,x.executionEnvironment===l.ExecutionEnvironment.StoreClient||x.executionEnvironment===l.ExecutionEnvironment.Standalone)throw new t.CodedError('ERR_CONSTANTS_MANIFEST_UNAVAILABLE',`Constants.manifest is ${e}, must be an object.`)}return b}Object.defineProperties(v,{__unsafeNoWarnManifest:{get(){const e=S(!0);return e&&_(e)?e:null},enumerable:!1},__unsafeNoWarnManifest2:{get(){const e=S(!0);return e&&h(e)?e:null},enumerable:!1},manifest:{get(){const e=S();return e&&_(e)?e:null},enumerable:!0},manifest2:{get(){const e=S();return e&&h(e)?e:null},enumerable:!0},expoConfig:{get(){const e=S(!0);return e?s&&s.isEmbeddedLaunch?p:h(e)?e.extra?.expoClient??null:_(e)?e:null:null},enumerable:!0},expoGoConfig:{get(){const e=S(!0);return e?h(e)?e.extra?.expoGo??null:_(e)?e:null:null},enumerable:!0},easConfig:{get(){const e=S(!0);return e?h(e)?e.extra?.eas??null:_(e)?e:null:null},enumerable:!0},__rawManifest_TEST:{get:()=>b,set(e){b=e},enumerable:!1}});var N=v},718,[35,4,25,637,719,720]);
|
|
851
851
|
__d(function(g,r,i,a,m,e,d){"use strict";var t,n,o;Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AppOwnership",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ExecutionEnvironment",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UserInterfaceIdiom",{enumerable:!0,get:function(){return o}}),(function(t){t.Expo="expo"})(t||(t={})),(function(t){t.Bare="bare",t.Standalone="standalone",t.StoreClient="storeClient"})(n||(n={})),(function(t){t.Handset="handset",t.Tablet="tablet",t.Desktop="desktop",t.TV="tv",t.Unsupported="unsupported"})(o||(o={}))},719,[]);
|
|
852
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(Date.now()+'-'+Math.floor(1e9*Math.random())).toString();function o(){if('undefined'!=typeof navigator&&'string'==typeof navigator.userAgent){const t=navigator.userAgent.toLowerCase();if(t.includes('edge'))return'Edge';if(t.includes('edg'))return'Chromium Edge';if(t.includes('opr')&&'opr'in window&&window.opr)return'Opera';if(t.includes('chrome')&&'chrome'in window&&window.chrome)return'Chrome';if(t.includes('trident'))return'IE';if(t.includes('firefox'))return'Firefox';if(t.includes('safari'))return'Safari'}}var s={get appOwnership(){return null},get executionEnvironment(){return t.ExecutionEnvironment.Bare},get sessionId(){return n},get isHeadless(){return'undefined'==typeof navigator||/\bHeadlessChrome\//.test(navigator.userAgent)},get expoVersion(){return this.manifest.sdkVersion||null},get linkingUri(){return'undefined'!=typeof location?location.origin:''},get expoRuntimeVersion(){return this.expoVersion},get deviceName(){return o()},get systemFonts(){return[]},get statusBarHeight(){return 0},get deviceYearClass(){return null},get manifest(){return"{\"name\":\"Paseo\",\"slug\":\"paseo-hyperdrive\",\"version\":\"0.3.
|
|
852
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(Date.now()+'-'+Math.floor(1e9*Math.random())).toString();function o(){if('undefined'!=typeof navigator&&'string'==typeof navigator.userAgent){const t=navigator.userAgent.toLowerCase();if(t.includes('edge'))return'Edge';if(t.includes('edg'))return'Chromium Edge';if(t.includes('opr')&&'opr'in window&&window.opr)return'Opera';if(t.includes('chrome')&&'chrome'in window&&window.chrome)return'Chrome';if(t.includes('trident'))return'IE';if(t.includes('firefox'))return'Firefox';if(t.includes('safari'))return'Safari'}}var s={get appOwnership(){return null},get executionEnvironment(){return t.ExecutionEnvironment.Bare},get sessionId(){return n},get isHeadless(){return'undefined'==typeof navigator||/\bHeadlessChrome\//.test(navigator.userAgent)},get expoVersion(){return this.manifest.sdkVersion||null},get linkingUri(){return'undefined'!=typeof location?location.origin:''},get expoRuntimeVersion(){return this.expoVersion},get deviceName(){return o()},get systemFonts(){return[]},get statusBarHeight(){return 0},get deviceYearClass(){return null},get manifest(){return"{\"name\":\"Paseo\",\"slug\":\"paseo-hyperdrive\",\"version\":\"0.3.155\",\"orientation\":\"portrait\",\"icon\":\"./assets/images/icon.png\",\"scheme\":\"paseo\",\"userInterfaceStyle\":\"automatic\",\"newArchEnabled\":true,\"web\":{\"output\":\"single\",\"favicon\":\"./assets/images/favicon.png\",\"shortName\":\"Paseo\",\"orientation\":\"portrait\",\"name\":\"Paseo\"},\"autolinking\":{\"searchPaths\":[\"../../node_modules\",\"./node_modules\"]},\"experiments\":{\"typedRoutes\":true,\"reactCompiler\":true,\"autolinkingModuleResolution\":true},\"extra\":{\"router\":{},\"eas\":{\"build\":{\"experimental\":{\"ios\":{\"appExtensions\":[{\"bundleIdentifier\":\"bot.hyperdrive.paseo.AgentActivity\",\"targetName\":\"AgentActivity\"}]}}}}},\"sdkVersion\":\"54.0.0\",\"platforms\":[\"ios\",\"android\",\"web\"]}"},get manifest2(){return null},get experienceUrl(){return'undefined'!=typeof location?location.origin:''},get debugMode(){return!1},getWebViewUserAgentAsync:async()=>'undefined'!=typeof navigator?navigator.userAgent:null}},720,[719]);
|
|
853
853
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SITEMAP_ROUTE_NAME=e.NOT_FOUND_ROUTE_NAME=e.INTERNAL_SLOT_NAME=void 0,e.INTERNAL_SLOT_NAME='__root',e.NOT_FOUND_ROUTE_NAME='+not-found',e.SITEMAP_ROUTE_NAME='_sitemap'},721,[]);
|
|
854
854
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.resolveHref=void 0,e.resolveHrefStringWithSegments=function(t,{segments:n=[],params:s={}}={},{relativeToDirectory:o}={}){if(t.startsWith('.')){let c=n?.map(t=>{if(!t.startsWith('['))return t;if(t.startsWith('[...')){t=t.slice(4,-1);const n=s[t];return Array.isArray(n)?n.join('/'):n?.split(',')?.join('/')??''}return t=t.slice(1,-1),s[t]}).filter(Boolean).join('/')??'/';o&&(c=`${c}/`);const f=new URL(t,`http://hostname/${c}`);t=`${f.pathname}${f.search}`}return t};function t(t,s){for(const[o,c=""]of Object.entries(s)){const f=`[${o}]`,l=`[...${o}]`;if(t.includes(f))t=t.replace(f,n(c));else{if(!t.includes(l))continue;t=t.replace(l,n(c))}delete s[o]}return{pathname:t,params:s}}function n(t){return Array.isArray(t)?t.map(t=>n(t)).join('/'):encodeURIComponent(t.toString())}function s(t){return Object.entries(t).filter(([,t])=>null!=t).map(([t,n])=>`${t}=${encodeURIComponent(n.toString())}`).join('&')}e.resolveHref=n=>{if('string'==typeof n)return(0,e.resolveHref)({pathname:n});const o=n.pathname??'';if(!n?.params)return o;const{pathname:c,params:f}=t(o,Object.assign({},n.params)),l=s(f);return c+(l?`?${l}`:'')}},722,[]);
|
|
855
855
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isRoutePreloadedInStack=function(t,o){if(!t||'stack'!==t.type)return!1;return t.preloadedRoutes.some(t=>t.key===o.key)}},723,[]);
|
|
@@ -14092,7 +14092,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";const e=["color","size","strokeWidth"
|
|
|
14092
14092
|
__d(function(g,r,i,a,m,_e,d){"use strict";const e=["children","variant","size","leftIcon","trailing","style","textStyle","disabled","loading","accessibilityRole"];Object.defineProperty(_e,'__esModule',{value:!0}),_e.Button=function(o){const t=(0,p.c)(58);let h,v,C,j,z,R,S,H,V,M,k;if(t[0]!==o){var w=o;({children:v,variant:S,size:H,leftIcon:j,trailing:k,style:R,textStyle:M,disabled:C,loading:V,accessibilityRole:h}=w),z=(0,n.default)(w,e),t[0]=o,t[1]=h,t[2]=v,t[3]=C,t[4]=j,t[5]=z,t[6]=R,t[7]=S,t[8]=H,t[9]=V,t[10]=M,t[11]=k}else h=t[1],v=t[2],C=t[3],j=t[4],z=t[5],R=t[6],S=t[7],H=t[8],V=t[9],M=t[10],k=t[11];const D=void 0===S?"secondary":S,F=void 0===H?"md":H,I=void 0!==V&&V,[G,O]=(0,f.useState)(!1),{theme:W}=(0,_.useUnistyles)(),A=C||I;let P,X;t[12]!==D?(P="default"===D?y.default:"secondary"===D?y.secondary:"outline"===D?y.outline:"ghost"===D?y.ghost:y.destructive,t[12]=D,t[13]=P):P=t[13];t[14]!==F?(X="xs"===F?y.xs:"sm"===F?y.sm:"lg"===F?y.lg:y.md,t[14]=F,t[15]=X):X=t[15];const B=G&&"ghost"===D;let T;t[16]===Symbol.for("react.memo_cache_sentinel")?(T=()=>O(!0),t[16]=T):T=t[16];const U=T;let q;t[17]===Symbol.for("react.memo_cache_sentinel")?(q=()=>O(!1),t[17]=q):q=t[17];const E=q;let J;t[18]!==A||t[19]!==X||t[20]!==R||t[21]!==P?(J=e=>{const{pressed:o}=e;return[y.base,X,P,o?y.pressed:null,A?y.disabled:null,R]},t[18]=A,t[19]=X,t[20]=R,t[21]=P,t[22]=J):J=t[22];const K=J,L="xs"===F?y.textXs:null,N="default"===D?y.textDefault:null,Q="destructive"===D?y.textDestructive:null,Y="ghost"===D?y.textGhost:null,Z=B?y.textGhostHovered:null;let $;t[23]!==Y||t[24]!==Z||t[25]!==L||t[26]!==N||t[27]!==Q||t[28]!==M?($=[y.text,L,N,Q,Y,M,Z],t[23]=Y,t[24]=Z,t[25]=L,t[26]=N,t[27]=Q,t[28]=M,t[29]=$):$=t[29];const ee=$;let oe;t[30]!==A||t[31]!==I?(oe={disabled:A,busy:I},t[30]=A,t[31]=I,t[32]=oe):oe=t[32];const te=oe;let ne;t[33]!==B||t[34]!==W.colors.accentForeground||t[35]!==W.colors.foreground||t[36]!==W.colors.foregroundMuted||t[37]!==D?(ne=function(){return"default"===D?W.colors.accentForeground:"ghost"===D?B?W.colors.foreground:W.colors.foregroundMuted:W.colors.foreground},t[33]=B,t[34]=W.colors.accentForeground,t[35]=W.colors.foreground,t[36]=W.colors.foregroundMuted,t[37]=D,t[38]=ne):ne=t[38];const re=ne;let se;t[39]!==j||t[40]!==I||t[41]!==re||t[42]!==F?(se=function(){if(I)return(0,b.jsx)(s.View,{children:(0,b.jsx)(u.ActivityIndicator,{size:"small",color:re()})});if(!j)return null;if("object"==typeof j&&"type"in j)return(0,b.jsx)(s.View,{children:j});const e=re(),o=x[F];if("function"==typeof j&&!j.prototype?.isReactComponent&&j.length>0)return(0,b.jsx)(s.View,{children:j(e)});const t=j;return(0,b.jsx)(s.View,{children:(0,b.jsx)(t,{color:e,size:o})})},t[39]=j,t[40]=I,t[41]=re,t[42]=F,t[43]=se):se=t[43];const ie=se,de=h??"button";let ce,le,ae;t[44]!==ie?(ce=ie(),t[44]=ie,t[45]=ce):ce=t[45];t[46]!==v||t[47]!==ee?(le=null!=v?(0,b.jsx)(c.Text,{style:ee,children:v}):null,t[46]=v,t[47]=ee,t[48]=le):le=t[48];t[49]!==te||t[50]!==A||t[51]!==K||t[52]!==z||t[53]!==de||t[54]!==ce||t[55]!==le||t[56]!==k?(ae=(0,b.jsxs)(l.Pressable,Object.assign({},z,{accessibilityRole:de,accessibilityState:te,disabled:A,onHoverIn:U,onHoverOut:E,style:K,children:[ce,le,k]})),t[49]=te,t[50]=A,t[51]=K,t[52]=z,t[53]=de,t[54]=ce,t[55]=le,t[56]=k,t[57]=ae):ae=t[57];return ae};var o,t=r(d[0]),n=(o=t)&&o.__esModule?o:{default:o},s=r(d[1]),c=r(d[2]),l=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]);r(d[7]),r(d[8]),r(d[9]),r(d[10]);var _=r(d[11]),b=r(d[12]);const x={xs:12,sm:14,md:16,lg:20},y=_.StyleSheet.create(e=>({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.spacing[2],borderRadius:e.borderRadius.lg,borderWidth:1,borderColor:"transparent",uni__dependencies:[0]},md:{paddingVertical:e.spacing[3],paddingHorizontal:e.spacing[4],uni__dependencies:[0]},xs:{minHeight:28,paddingVertical:e.spacing[1],paddingHorizontal:e.spacing[3],borderRadius:e.borderRadius.md,uni__dependencies:[0]},sm:{paddingVertical:e.spacing[1.5],paddingHorizontal:e.spacing[3],borderRadius:e.borderRadius.md,uni__dependencies:[0]},lg:{paddingVertical:e.spacing[4],paddingHorizontal:e.spacing[6],borderRadius:e.borderRadius.xl,uni__dependencies:[0]},default:{backgroundColor:e.colors.accent,borderColor:e.colors.accent,uni__dependencies:[0]},secondary:{backgroundColor:e.colors.surface3,borderColor:e.colors.surface3,uni__dependencies:[0]},outline:{backgroundColor:"transparent",borderColor:e.colors.borderAccent,uni__dependencies:[0]},ghost:{backgroundColor:"transparent",borderColor:"transparent"},destructive:{backgroundColor:e.colors.destructive,borderColor:e.colors.destructive,uni__dependencies:[0]},pressed:{opacity:.85,transform:[{scale:.97}]},disabled:{opacity:e.opacity[50],uni__dependencies:[0]},text:{color:e.colors.foreground,fontSize:e.fontSize.sm,fontWeight:e.fontWeight.normal,uni__dependencies:[0]},textXs:{fontSize:e.fontSize.xs,uni__dependencies:[0]},textDefault:{color:e.colors.accentForeground,uni__dependencies:[0]},textDestructive:{color:e.colors.destructiveForeground,uni__dependencies:[0]},textGhost:{color:e.colors.foregroundMuted,uni__dependencies:[0]},textGhostHovered:{color:e.colors.foreground,uni__dependencies:[0]}}))},2475,[35,348,349,2476,2477,350,36,654,546,234,146,56,279]);
|
|
14093
14093
|
__d(function(g,r,i,a,m,_e,d){"use strict";const e=["style"];function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"Pressable",{enumerable:!0,get:function(){return h}});var s=t(r(d[0])),n=r(d[1]),o=t(r(d[2])),l=r(d[3]),y=r(d[4]),u=r(d[5]),c=r(d[6]);const h=(0,n.forwardRef)((t,n)=>{let{style:h}=t,f=(0,s.default)(t,e);const S=y.UnistylesShadowRegistry.getScopedTheme();let p,w=null;return(0,c.jsx)(o.default,Object.assign({},f,{ref:(0,u.isServer)()?void 0:e=>{if(w=e,y.UnistylesShadowRegistry.add(w,p?.hash),'function'==typeof n)return n(e);n&&(n.current=e)},style:e=>{const t='function'==typeof h?h(e):h,s=y.UnistylesShadowRegistry.getScopedTheme();return y.UnistylesShadowRegistry.setScopedTheme(S),y.UnistylesShadowRegistry.remove(w,p?.hash),p=(0,l.getClassName)(t),y.UnistylesShadowRegistry.add(w,p?.hash),y.UnistylesShadowRegistry.setScopedTheme(s),p}}))})},2476,[35,36,546,274,57,137,279]);
|
|
14094
14094
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityIndicator",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e};const u=(0,r(d[1]).createUnistylesElement)(n.default)},2477,[654,274]);
|
|
14095
|
-
__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}),t.default=e,t}function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return Gt}}),_e.useEarliestOnlineHostServerId=Ne,_e.useStoreReady=Qe,_e.useHostRuntimeBootstrapState=function(){return(0,S.useContext)(Ge)};var n=r(_d[0]),o=r(_d[1]);r(_d[2]);var s=r(_d[3]),c=r(_d[4]),l=r(_d[5]),u=e(r(_d[6])),d=e(r(_d[7])),h=r(_d[8]),S=r(_d[9]),f=(t(r(_d[10])),t(r(_d[11])));r(_d[12]);var _=r(_d[13]),p=r(_d[14]),v=r(_d[15]),b=r(_d[16]),y=r(_d[17]),x=r(_d[18]),k=r(_d[19]),j=r(_d[20]),w=r(_d[21]),O=r(_d[22]),E=r(_d[23]),P=r(_d[24]),I=r(_d[25]),T=r(_d[26]),D=r(_d[27]),F=r(_d[28]),W=r(_d[29]),C=r(_d[30]),R=r(_d[31]),A=r(_d[32]),H=r(_d[33]),G=r(_d[34]),L=r(_d[35]),X=r(_d[36]),M=r(_d[37]),B=r(_d[38]),z=r(_d[39]),N=r(_d[40]),Y=r(_d[41]),U=r(_d[42]),J=r(_d[43]),V=r(_d[44]),K=r(_d[45]),$=r(_d[46]),q=r(_d[47]),Q=r(_d[48]),Z=r(_d[49]),ee=r(_d[50]),te=r(_d[51]),ne=r(_d[52]),oe=r(_d[53]),re=r(_d[54]),se=r(_d[55]),ae=r(_d[56]),ie=r(_d[57]),ce=r(_d[58]),le=r(_d[59]),ue=r(_d[60]),de=r(_d[61]),he=r(_d[62]),Se=r(_d[63]),me=r(_d[64]),fe=r(_d[65]),pe=r(_d[66]),ge=r(_d[67]),ve=r(_d[68]),be=r(_d[69]),ye=r(_d[70]),xe=r(_d[71]),ke=r(_d[72]),je=r(_d[73]),we=r(_d[74]),Oe=r(_d[75]),Ee=r(_d[76]),Pe=r(_d[77]),Ie=r(_d[78]),Te=r(_d[79]),De=r(_d[80]),Fe=r(_d[81]),We=r(_d[82]),Ce=r(_d[83]),Re=r(_d[84]),Ae=r(_d[85]),He=r(_d[86]);(0,be.polyfillCrypto)(),(0,Re.initializeDatadog)(),(0,Ae.initializePostHog)();const Ge=(0,S.createContext)({splashError:null,retry:()=>{},hasGivenUpWaitingForHost:!1,storeReady:!1,startupBlocker:{kind:"none"}});function Le(){const e=(0,o.c)(5),t=(0,h.useRouter)(),n=(0,S.useRef)(null);let s;(0,Z.useDatadogViewTracking)(),e[0]!==t?(s=e=>{const n=(0,Fe.resolveNotificationTarget)(e),o=n.serverId,s=n.agentId;o&&s?(0,We.navigateToAgent)({serverId:o,agentId:s,pin:!0}):t.navigate((0,Fe.buildNotificationRoute)(e))},e[0]=t,e[1]=s):s=e[1];const c=(0,pe.useStableEvent)(s);let l,u;return e[2]!==c?(l=()=>{if(L.isWeb){let e=null,t=!1;if((0,G.getIsElectronRuntime)()){(0,Ce.ensureOsNotificationPermission)();const n=(0,oe.getDesktopHost)()?.events?.on?.("notification-click",e=>{const t="object"==typeof e&&null!==e&&"data"in e&&"object"==typeof e.data&&null!==e.data?e.data:void 0;c(t)});Promise.resolve(n).then(n=>{"function"==typeof n&&(t?n():e=n)})}const n=e=>{const t=e;e.preventDefault(),c(t.detail?.data)};return window.addEventListener(Ce.WEB_NOTIFICATION_CLICK_EVENT,n),()=>{t=!0,e?.(),window.removeEventListener(Ce.WEB_NOTIFICATION_CLICK_EVENT,n)}}d.setNotificationHandler({handleNotification:Xe}),(0,Q.registerNotificationCategories)(),(0,$.registerBackgroundAgentStateFetch)(),(0,q.registerLiveActivities)();const e=e=>{const t=e.notification.request.identifier;n.current!==t&&(n.current=t,(0,K.handlePermissionNotificationResponse)(e).then(t=>{if(t.handled)return;const n=e.notification.request.content.data;c(n)}))},t=d.addNotificationResponseReceivedListener(e);return d.getLastNotificationResponseAsync().then(t=>{t&&e(t)}),()=>{t.remove()}},u=[c],e[2]=c,e[3]=l,e[4]=u):(l=e[3],u=e[4]),(0,S.useEffect)(l,u),null}async function Xe(){return{shouldShowAlert:!1,shouldShowBanner:!1,shouldShowList:!1,shouldPlaySound:!1,shouldSetBadge:!1}}function Me(e){const t=(0,o.c)(3),{daemon:n}=e,s=(0,ke.useHostRuntimeClient)(n.serverId);if(!s)return null;let c;return t[0]!==s||t[1]!==n.serverId?(c=(0,He.jsx)(M.SessionProvider,{serverId:n.serverId,client:s,children:null},n.serverId),t[0]=s,t[1]=n.serverId,t[2]=c):c=t[2],c}function Be(){const e=(0,o.c)(4),t=(0,ke.useHosts)();if(0===t.length)return null;let n,s;return e[0]!==t?(n=t.map(ze),e[0]=t,e[1]=n):n=e[1],e[2]!==n?(s=(0,He.jsx)(He.Fragment,{children:n}),e[2]=n,e[3]=s):s=e[3],s}function ze(e){return(0,He.jsx)(Me,{daemon:e},e.serverId)}function Ne(){const e=(0,o.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,ke.getHostRuntimeStore)(),e[0]=t):t=e[0];const n=t;let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{const t=n.subscribeAll(e),o=n.subscribeHostList(e);return()=>{t(),o()}},e[1]=s):s=e[1];const c=s;let l,u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>n.getEarliestOnlineHostServerId(),u=()=>n.getEarliestOnlineHostServerId(),e[2]=l,e[3]=u):(l=e[2],u=e[3]),(0,S.useSyncExternalStore)(c,l,u)}function Ye(){const e=(0,o.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,je.getDaemonStartService)({store:(0,ke.getHostRuntimeStore)()}),e[0]=t):t=e[0];const n=t;let s,c,l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>n.subscribe(e),c=()=>n.getLastError(),l=()=>n.getLastError(),e[1]=s,e[2]=c,e[3]=l):(s=e[1],c=e[2],l=e[3]),(0,S.useSyncExternalStore)(s,c,l)}function Ue(){const e=(0,o.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,je.getDaemonStartService)({store:(0,ke.getHostRuntimeStore)()}),e[0]=t):t=e[0];const n=t;let s,c,l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>n.subscribe(e),c=()=>n.isRunning(),l=()=>n.isRunning(),e[1]=s,e[2]=c,e[3]=l):(s=e[1],c=e[2],l=e[3]),(0,S.useSyncExternalStore)(s,c,l)}const Je=5e3;async function Ve(){if(!(0,ee.shouldUseDesktopDaemon)())return!1;if((0,ke.hasConfiguredLocalDaemonOverride)())return!1;return(await(0,re.loadDesktopSettings)()).daemon.manageBuiltInDaemon}function Ke(e){const t=(0,o.c)(23),{children:n}=e;let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],t[0]=s):s=t[0],(0,S.useEffect)(qe,s);const c=Ne(),l=Ye(),u=Ue(),[d,h]=(0,S.useState)(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=(0,ee.shouldUseDesktopDaemon)(),t[1]=f):f=t[1];const _=f;let p;t[2]!==c||t[3]!==l||t[4]!==u?(p=(0,J.resolveStartupBlocker)({isDesktopRuntime:_,anyOnlineHostServerId:c,daemonStartIsRunning:u,daemonStartError:l}),t[2]=c,t[3]=l,t[4]=u,t[5]=p):p=t[5];const v=p;let b;t[6]!==c||t[7]!==d||t[8]!==v?(b=(0,J.shouldRunStartupGiveUpTimer)({startupBlocker:v,anyOnlineHostServerId:c,hasGivenUpWaitingForHost:d}),t[6]=c,t[7]=d,t[8]=v,t[9]=b):b=t[9];const y=b;let x,k;t[10]!==y?(x=()=>{if(!y)return;const e=setTimeout(()=>{h(!0)},Je);return()=>{clearTimeout(e)}},k=[y],t[10]=y,t[11]=x,t[12]=k):(x=t[11],k=t[12]),(0,S.useEffect)(x,k);const j=$e,w="managed-daemon-error"===v.kind?v.message:null;let O;t[13]!==v?(O=(0,J.resolveStartupNavigationReady)({startupBlocker:v}),t[13]=v,t[14]=O):O=t[14];const E=O;let P;t[15]!==d||t[16]!==w||t[17]!==v||t[18]!==E?(P={splashError:w,retry:j,hasGivenUpWaitingForHost:d,storeReady:E,startupBlocker:v},t[15]=d,t[16]=w,t[17]=v,t[18]=E,t[19]=P):P=t[19];const I=P;let T;return t[20]!==n||t[21]!==I?(T=(0,He.jsx)(Ge.Provider,{value:I,children:n}),t[20]=n,t[21]=I,t[22]=T):T=t[22],T}function $e(){const e=(0,je.getDaemonStartService)({store:(0,ke.getHostRuntimeStore)()});(0,J.startDaemonIfGateAllows)({daemonStartService:e,shouldStartDaemon:Ve,onGateError:t=>e.recordError(t)})}function qe(){const e=(0,ke.getHostRuntimeStore)(),t=(0,je.getDaemonStartService)({store:e});(0,J.startHostRuntimeBootstrap)({store:e,daemonStartService:t,shouldStartDaemon:Ve,onGateError:e=>t.recordError(e)})}function Qe(){return(0,S.useContext)(Ge).storeReady}function Ze(e){const t=(0,o.c)(2),{children:n}=e;let s;return t[0]!==n?(s=(0,He.jsx)(l.QueryClientProvider,{client:xe.queryClient,children:n}),t[0]=n,t[1]=s):s=t[1],s}const et={flex:1,flexDirection:"row"},tt={flex:1},nt=32,ot=L.isWeb?"auto":"pan-y",rt=["dark","zinc","midnight","claude","ghostty","light"];function st(e){const t=(0,o.c)(58),{children:s,selectedAgentId:c,chromeEnabled:l}=e,u=(0,ke.useHosts)(),{settings:d,updateSettings:S}=(0,fe.useAppSettings)(),_=(0,Ee.usePanelStore)(ft),p=(0,Ee.usePanelStore)(mt),v=(0,Ee.usePanelStore)(St),b=(0,Ee.usePanelStore)(ht),y=(0,Ee.usePanelStore)(dt),w=(0,Ee.usePanelStore)(ut),L=(0,Ee.usePanelStore)(lt);(0,Se.useForegroundReconnect)();const X=it;let M;t[0]!==d.theme||t[1]!==S?(M=()=>{const e=(rt.indexOf(d.theme)+1)%rt.length;S({theme:rt[e]})},t[0]=d.theme,t[1]=S,t[2]=M):M=t[2];const z=M,N=(0,G.useIsCompactFormFactor)(),Y=(0,f.default)(),U=!1;let J;t[3]!==Y.height||t[4]!==Y.width?(J=(0,x.resolveColumnMode)({width:Y.width,height:Y.height,isTablet:U}),t[3]=Y.height,t[4]=Y.width,t[5]=J):J=t[5];const V=N||U;(0,he.useCompactWebViewportZoomLock)(V);const K=(0,h.usePathname)(),$=l??u.length>0,q=V?_:p;let Q;t[6]!==b||t[7]!==y||t[8]!==v?(Q=()=>{const{desktop:e}=Ee.usePanelStore.getState();(0,Ie.toggleDesktopSidebarsWithCheckoutIntent)({isAgentListOpen:e.agentListOpen,isFileExplorerOpen:e.fileExplorerOpen,openAgentList:v,closeAgentList:b,closeFileExplorer:y,toggleFocusedFileExplorer:at})},t[6]=b,t[7]=y,t[8]=v,t[9]=Q):Q=t[9];const Z=Q;let ee;t[10]!==$||t[11]!==K?(ee=$||K.startsWith("/settings"),t[10]=$,t[11]=K,t[12]=ee):ee=t[12];const te=ee;let ne,oe,re,le;t[13]!==z||t[14]!==V||t[15]!==te||t[16]!==q||t[17]!==Z||t[18]!==w?(ne={enabled:te,isMobile:V,toggleAgentList:q,toggleBothSidebars:Z,toggleFocusMode:w,cycleTheme:z},t[13]=z,t[14]=V,t[15]=te,t[16]=q,t[17]=Z,t[18]=w,t[19]=ne):ne=t[19],(0,ue.useKeyboardShortcuts)(ne),(0,ie.useActiveWorktreeNewAction)(),(0,ce.useGlobalNewWorkspaceAction)(),t[20]!==$||t[21]!==V||t[22]!==L||t[23]!==c?(oe=!V&&$&&!L&&(0,He.jsx)(T.LeftSidebar,{selectedAgentId:c}),t[20]=$,t[21]=V,t[22]=L,t[23]=c,t[24]=oe):oe=t[24],t[25]!==s||t[26]!==$||t[27]!==V?(re=V&&$?(0,He.jsx)(B.ExplorerSidebarAnimationProvider,{children:(0,He.jsx)(D.CompactExplorerSidebarHost,{enabled:$,children:(0,He.jsx)(n.View,{style:tt,children:s})})}):(0,He.jsx)(n.View,{style:tt,children:s}),t[25]=s,t[26]=$,t[27]=V,t[28]=re):re=t[28],t[29]!==oe||t[30]!==re?(le=(0,He.jsxs)(n.View,{style:et,children:[oe,re]}),t[29]=oe,t[30]=re,t[31]=le):le=t[31];const de=le;let me,pe,ge,ve,be,ye,xe,je,we,Oe,Pe,Te,De,Fe,We,Ce;t[32]===Symbol.for("react.memo_cache_sentinel")?(me=(0,He.jsx)(j.DaemonConnectionBanner,{onRetry:X}),t[32]=me):me=t[32],t[33]===Symbol.for("react.memo_cache_sentinel")?(pe=(0,He.jsx)(A.FloatingPanelPortalHost,{}),t[33]=pe):pe=t[33],t[34]!==$||t[35]!==V||t[36]!==c?(ge=V&&$&&(0,He.jsx)(T.LeftSidebar,{selectedAgentId:c}),t[34]=$,t[35]=V,t[36]=c,t[37]=ge):ge=t[37],t[38]===Symbol.for("react.memo_cache_sentinel")?(ve=(0,He.jsx)(E.DownloadToast,{}),be=(0,He.jsx)(se.RosettaCalloutSource,{}),ye=(0,He.jsx)(ae.UpdateCalloutSource,{}),xe=(0,He.jsx)(O.WorktreeSetupCalloutSource,{}),je=(0,He.jsx)(k.CommandCenter,{}),we=(0,He.jsx)(H.HostChooserModal,{}),Oe=(0,He.jsx)(F.ProjectPickerModal,{}),Pe=(0,He.jsx)(W.ProviderSettingsHost,{}),t[38]=ve,t[39]=be,t[40]=ye,t[41]=xe,t[42]=je,t[43]=we,t[44]=Oe,t[45]=Pe):(ve=t[38],be=t[39],ye=t[40],xe=t[41],je=t[42],we=t[43],Oe=t[44],Pe=t[45]),t[46]!==te?(Te=(0,He.jsx)(R.WorkspaceShortcutTargetsSubscriber,{enabled:te}),t[46]=te,t[47]=Te):Te=t[47],t[48]===Symbol.for("react.memo_cache_sentinel")?(De=(0,He.jsx)(C.WorkspaceSetupDialog,{}),Fe=(0,He.jsx)(I.KeyboardShortcutsDialog,{}),We=(0,He.jsx)(P.QuittingOverlay,{}),t[48]=De,t[49]=Fe,t[50]=We):(De=t[48],Fe=t[49],We=t[50]),t[51]!==ge||t[52]!==Te||t[53]!==de?(Ce=(0,He.jsxs)(n.View,{style:Lt.surfaceFill,children:[me,de,pe,ge,ve,be,ye,xe,je,we,Oe,Pe,Te,De,Fe,We]}),t[51]=ge,t[52]=Te,t[53]=de,t[54]=Ce):Ce=t[54];const Re=Ce;if(!V)return Re;let Ae;return t[55]!==$||t[56]!==Re?(Ae=(0,He.jsx)(xt,{chromeEnabled:$,children:Re}),t[55]=$,t[56]=Re,t[57]=Ae):Ae=t[57],Ae}function at(){return ve.keyboardActionDispatcher.dispatch({id:"sidebar.toggle.right",scope:"sidebar"})}function it(e){const t=(0,ke.getHostRuntimeStore)();t.ensureConnectedAll(),t.runProbeCycleNow(e).catch(ct)}function ct(){}function lt(e){return e.desktop.focusModeEnabled}function ut(e){return e.toggleFocusMode}function dt(e){return e.closeDesktopFileExplorer}function ht(e){return e.closeDesktopAgentList}function St(e){return e.openDesktopAgentList}function mt(e){return e.toggleDesktopAgentList}function ft(e){return e.toggleMobileAgentList}const _t={code:"function _layoutTsx1(){const{isGesturing,runOnJS,setOverlayPeek}=this.__closure;isGesturing.value=false;runOnJS(setOverlayPeek)(false);}"},pt={code:"function _layoutTsx2(event_2){const{isGesturing,windowWidth,animateToOpen,runOnJS,handleGestureOpen,animateToClose}=this.__closure;isGesturing.value=false;const shouldOpen=event_2.translationX>windowWidth/3||event_2.velocityX>500;if(shouldOpen){animateToOpen();runOnJS(handleGestureOpen)();}else{animateToClose();}}"},gt={code:"function _layoutTsx3(event_1){const{windowWidth,translateX,backdropOpacity,interpolate,Extrapolation}=this.__closure;const newTranslateX=Math.min(0,-windowWidth+event_1.translationX);translateX.value=newTranslateX;backdropOpacity.value=interpolate(newTranslateX,[-windowWidth,0],[0,1],Extrapolation.CLAMP);}"},vt={code:"function _layoutTsx4(){const{isGesturing,runOnJS,setOverlayPeek}=this.__closure;isGesturing.value=true;runOnJS(setOverlayPeek)(true);}"},bt={code:"function _layoutTsx5(event_0,stateManager){const{touchStartX,touchStartY,canOpenLeftSidebarGesture,mobilePanelState,translateX,windowWidth,horizontalScroll,isWeb,MOBILE_WEB_EDGE_SWIPE_WIDTH}=this.__closure;var _horizontalScroll;const touch_0=event_0.changedTouches[0];if(!touch_0||event_0.numberOfTouches!==1)return;const deltaX=touch_0.absoluteX-touchStartX.value;const deltaY=touch_0.absoluteY-touchStartY.value;const absDeltaX=Math.abs(deltaX);const absDeltaY=Math.abs(deltaY);if(!canOpenLeftSidebarGesture(mobilePanelState.value,translateX.value,windowWidth)){stateManager.fail();return;}if((_horizontalScroll=horizontalScroll)!==null&&_horizontalScroll!==void 0&&_horizontalScroll.isAnyScrolledRight.value){stateManager.fail();return;}if(isWeb&&touchStartX.value>MOBILE_WEB_EDGE_SWIPE_WIDTH){stateManager.fail();return;}if(deltaX<=-10){stateManager.fail();return;}if(absDeltaY>10&&absDeltaY>absDeltaX){stateManager.fail();return;}if(deltaX>15&&absDeltaX>absDeltaY){stateManager.activate();}}"},yt={code:"function _layoutTsx6(event){const{touchStartX,touchStartY}=this.__closure;const touch=event.changedTouches[0];if(touch){touchStartX.value=touch.absoluteX;touchStartY.value=touch.absoluteY;}}"};function xt({children:e,chromeEnabled:t}){const n=(0,Ee.usePanelStore)(e=>e.showMobileAgentList),o=(0,X.useHorizontalScrollOptional)(),{translateX:s,backdropOpacity:c,windowWidth:l,animateToOpen:u,animateToClose:d,setOverlayPeek:h,isGesturing:f,mobilePanelState:p,gestureAnimatingRef:b,openGestureRef:y}=(0,z.useSidebarAnimation)(),x=(0,v.useSharedValue)(0),k=(0,v.useSharedValue)(0),j=t,w=(0,S.useCallback)(()=>{b.current=!0,n()},[n,b]),O=(0,S.useMemo)(()=>_.Gesture.Pan().withRef(y).enabled(j).manualActivation(!0).failOffsetY([-10,10]).onTouchesDown((function({_worklet_1615879058013_init_data:e,touchStartX:t,touchStartY:n}){const o=function(e){const o=e.changedTouches[0];o&&(t.value=o.absoluteX,n.value=o.absoluteY)};return o.__closure={touchStartX:t,touchStartY:n},o.__workletHash=1615879058013,o.__initData=e,o})({_worklet_1615879058013_init_data:yt,touchStartX:x,touchStartY:k})).onTouchesMove((function({_worklet_8337771416778_init_data:e,touchStartX:t,touchStartY:n,canOpenLeftSidebarGesture:o,mobilePanelState:s,translateX:c,windowWidth:l,horizontalScroll:u,isWeb:d,MOBILE_WEB_EDGE_SWIPE_WIDTH:h}){const S=function(e,S){const f=e.changedTouches[0];if(!f||1!==e.numberOfTouches)return;const _=f.absoluteX-t.value,p=f.absoluteY-n.value,v=Math.abs(_),b=Math.abs(p);o(s.value,c.value,l)?u?.isAnyScrolledRight.value||d&&t.value>h||_<=-10||b>10&&b>v?S.fail():_>15&&v>b&&S.activate():S.fail()};return S.__closure={touchStartX:t,touchStartY:n,canOpenLeftSidebarGesture:o,mobilePanelState:s,translateX:c,windowWidth:l,horizontalScroll:u,isWeb:d,MOBILE_WEB_EDGE_SWIPE_WIDTH:h},S.__workletHash=8337771416778,S.__initData=e,S})({_worklet_8337771416778_init_data:bt,touchStartX:x,touchStartY:k,canOpenLeftSidebarGesture:Te.canOpenLeftSidebarGesture,mobilePanelState:p,translateX:s,windowWidth:l,horizontalScroll:o,isWeb:L.isWeb,MOBILE_WEB_EDGE_SWIPE_WIDTH:nt})).onStart((function({_worklet_11112183592680_init_data:e,isGesturing:t,runOnJS:n,setOverlayPeek:o}){const s=function(){t.value=!0,n(o)(!0)};return s.__closure={isGesturing:t,runOnJS:n,setOverlayPeek:o},s.__workletHash=0xa1b41c176e8,s.__initData=e,s})({_worklet_11112183592680_init_data:vt,isGesturing:f,runOnJS:v.runOnJS,setOverlayPeek:h})).onUpdate((function({_worklet_4399350013762_init_data:e,windowWidth:t,translateX:n,backdropOpacity:o,interpolate:s,Extrapolation:c}){const l=function(e){const l=Math.min(0,-t+e.translationX);n.value=l,o.value=s(l,[-t,0],[0,1],c.CLAMP)};return l.__closure={windowWidth:t,translateX:n,backdropOpacity:o,interpolate:s,Extrapolation:c},l.__workletHash=4399350013762,l.__initData=e,l})({_worklet_4399350013762_init_data:gt,windowWidth:l,translateX:s,backdropOpacity:c,interpolate:v.interpolate,Extrapolation:v.Extrapolation})).onEnd((function({_worklet_3566839805561_init_data:e,isGesturing:t,windowWidth:n,animateToOpen:o,runOnJS:s,handleGestureOpen:c,animateToClose:l}){const u=function(e){t.value=!1;e.translationX>n/3||e.velocityX>500?(o(),s(c)()):l()};return u.__closure={isGesturing:t,windowWidth:n,animateToOpen:o,runOnJS:s,handleGestureOpen:c,animateToClose:l},u.__workletHash=3566839805561,u.__initData=e,u})({_worklet_3566839805561_init_data:pt,isGesturing:f,windowWidth:l,animateToOpen:u,runOnJS:v.runOnJS,handleGestureOpen:w,animateToClose:d})).onFinalize((function({_worklet_11316004136205_init_data:e,isGesturing:t,runOnJS:n,setOverlayPeek:o}){const s=function(){t.value=!1,n(o)(!1)};return s.__closure={isGesturing:t,runOnJS:n,setOverlayPeek:o},s.__workletHash=0xa4ab668250d,s.__initData=e,s})({_worklet_11316004136205_init_data:_t,isGesturing:f,runOnJS:v.runOnJS,setOverlayPeek:h})),[j,l,s,c,p,u,d,h,w,f,y,o?.isAnyScrolledRight,x,k]);return(0,He.jsx)(_.GestureDetector,{gesture:O,touchAction:ot,children:e})}function kt(e){const t=(0,o.c)(25),{children:n}=e,{settings:s,isLoading:c}=(0,fe.useAppSettings)(),{upsertConnectionFromOfferUrl:l}=(0,ke.useHostMutations)(),{theme:u}=(0,y.useUnistyles)();let d,h,f,_,p,v;t[0]!==s.theme||t[1]!==c?(d=()=>{c||("auto"===s.theme?y.UnistylesRuntime.setAdaptiveThemes(!0):(y.UnistylesRuntime.setAdaptiveThemes(!1),y.UnistylesRuntime.setTheme(Pe.THEME_TO_UNISTYLES[s.theme])))},h=[c,s.theme],t[0]=s.theme,t[1]=c,t[2]=d,t[3]=h):(d=t[2],h=t[3]),(0,S.useEffect)(d,h),t[4]!==u.colors.accent?(f=()=>{(0,Oe.applyFocusRingColor)(u.colors.accent)},_=[u.colors.accent],t[4]=u.colors.accent,t[5]=f,t[6]=_):(f=t[5],_=t[6]),(0,S.useEffect)(f,_),t[7]!==s.codeFontSize||t[8]!==s.monoFontFamily||t[9]!==s.syntaxTheme||t[10]!==s.uiFontFamily||t[11]!==s.uiFontSize||t[12]!==c?(p=()=>{c||(0,we.applyAppearance)({uiFontFamily:s.uiFontFamily,monoFontFamily:s.monoFontFamily,uiFontSize:s.uiFontSize,codeFontSize:s.codeFontSize,syntaxTheme:s.syntaxTheme})},v=[c,s.uiFontFamily,s.monoFontFamily,s.uiFontSize,s.codeFontSize,s.syntaxTheme],t[7]=s.codeFontSize,t[8]=s.monoFontFamily,t[9]=s.syntaxTheme,t[10]=s.uiFontFamily,t[11]=s.uiFontSize,t[12]=c,t[13]=p,t[14]=v):(p=t[13],v=t[14]),(0,S.useEffect)(p,v);const b=!c;let x,k,j,w,O;return t[15]!==b?(x=(0,He.jsx)(jt,{enabled:b}),t[15]=b,t[16]=x):x=t[16],t[17]!==l?(k=(0,He.jsx)(Ot,{upsertDaemonFromOfferUrl:l}),t[17]=l,t[18]=k):k=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(j=(0,He.jsx)(Be,{}),w=(0,He.jsx)(Dt,{}),t[19]=j,t[20]=w):(j=t[19],w=t[20]),t[21]!==n||t[22]!==x||t[23]!==k?(O=(0,He.jsxs)(U.VoiceProvider,{children:[x,k,j,w,n]}),t[21]=n,t[22]=x,t[23]=k,t[24]=O):O=t[24],O}function jt(e){const t=(0,o.c)(5),{enabled:n}=e,{theme:s}=(0,y.useUnistyles)(),c=s.colors.surface0,l=s.colors.foreground;let u,d;return t[0]!==n||t[1]!==l||t[2]!==c?(u=()=>{n&&!L.isNative&&(0,ne.updateDesktopWindowControls)({backgroundColor:c,foregroundColor:l}).catch(wt)},d=[n,c,l],t[0]=n,t[1]=l,t[2]=c,t[3]=u,t[4]=d):(u=t[3],d=t[4]),(0,S.useEffect)(u,d),null}function wt(e){console.warn("[DesktopWindow] Failed to update window controls overlay",e)}function Ot(e){const t=(0,o.c)(4),{upsertDaemonFromOfferUrl:n}=e,s=(0,h.useRouter)();let c,l;return t[0]!==s||t[1]!==n?(c=()=>{let e=!1;const t=t=>{t&&t.includes("#offer=")&&n(t).then(t=>{if(e)return;const n=t?.serverId;"string"==typeof n&&n&&s.replace((0,De.buildOpenProjectRoute)())}).catch(t=>{e||console.warn("[Linking] Failed to import pairing offer",t)})};u.getInitialURL().then(t).catch(Et);const o=u.addEventListener("url",e=>{t(e.url)});return()=>{e=!0,o.remove()}},l=[s,n],t[0]=s,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),(0,S.useEffect)(c,l),null}function Et(){}let Pt=1;function It(){const e=(0,H.useHostChooser)(),t=(0,ke.useHostRegistryLoaded)(),[n,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),l=(0,me.useOpenProject)(n?.serverId??null),u=(0,S.useCallback)(n=>{const s=n.trim();s&&(t?e({title:"Choose host",onChooseHost:e=>{o({id:Pt++,serverId:e,path:s})}}):c(s))},[e,t]);return(0,S.useEffect)(()=>{if(!t||!s)return;const e=s;c(null),u(e)},[t,u,s]),(0,S.useEffect)(()=>{if(!n)return;let e=!1;return l(n.path).then(t=>e?null:t.ok?(o(e=>e?.id===n.id?null:e),null):(o(e=>e?.id===n.id?null:e),null)),()=>{e=!0}},[l,n]),(0,S.useEffect)(()=>{let e=!1,t=null;return(0,oe.getDesktopHost)()?.getPendingOpenProject?.()?.then(t=>{!e&&t&&u(t)}).catch(()=>{}),(0,te.listenToDesktopEvent)("open-project",t=>{if(e)return;const n="string"==typeof t?.path?t.path.trim():"";u(n)}).then(n=>{e?n():t=n}).catch(()=>{}),()=>{e=!0,t?.()}},[u]),null}function Tt(e){const t=(0,o.c)(16),{children:n}=e,s=(0,h.usePathname)(),c=(0,h.useGlobalSearchParams)(),l=(0,ke.useHosts)(),u=Qe();let d;t[0]!==s?(d=(0,De.parseServerIdFromPathname)(s),t[0]=s,t[1]=d):d=t[1];const S=d;let f;t[2]!==l||t[3]!==S?(f=null!==S&&l.some(e=>e.serverId===S),t[2]=l,t[3]=S,t[4]=f):f=t[4];const _=u&&("/open-project"===s||"/new"===s||"/sessions"===s||"/schedules"===s||"/sources"===s||"/loops"===s||"/inbox"===s||f);let p;if(t[5]!==c.open||t[6]!==s){e:{let e;if(t[8]!==s){const n=s.match(/^\/h\/([^/]+)\/workspace\/[^/]+(?:\/|$)/);e=n?.[1]?.trim()??"",t[8]=s,t[9]=e}else e=t[9];const n=e,o=Array.isArray(c.open)?c.open[0]:c.open,l=(0,De.parseWorkspaceOpenIntent)(o);if(n&&"agent"===l?.kind){const e=l.agentId.trim();p=e?`${n}:${e}`:void 0;break e}let u;t[10]!==s?(u=(0,De.parseHostAgentRouteFromPathname)(s),t[10]=s,t[11]=u):u=t[11];const d=u;p=d?`${d.serverId}:${d.agentId}`:void 0}t[5]=c.open,t[6]=s,t[7]=p}else p=t[7];const v=_?p:void 0;let b;return t[12]!==n||t[13]!==_||t[14]!==v?(b=(0,He.jsx)(st,{selectedAgentId:v,chromeEnabled:_,children:n}),t[12]=n,t[13]=_,t[14]=v,t[15]=b):b=t[15],b}function Dt(){return(0,le.useFaviconStatus)(),null}function Ft(){const e=(0,o.c)(25),t=Qe(),{theme:n}=(0,y.useUnistyles)();let s;e[0]!==n.colors.surface0?(s={headerShown:!1,animation:"none",contentStyle:{backgroundColor:n.colors.surface0}},e[0]=n.colors.surface0,e[1]=s):s=e[1];const c=s;let l,u,d,S,f,_,p,v,b,x,k,j,w,O,E,P,I,T,D,F;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,He.jsx)(h.Stack.Screen,{name:"index"}),u=(0,He.jsx)(h.Stack.Screen,{name:"agent/[agentId]"}),e[2]=l,e[3]=u):(l=e[2],u=e[3]),e[4]===Symbol.for("react.memo_cache_sentinel")?(b=(0,He.jsx)(h.Stack.Screen,{name:"welcome"}),x=(0,He.jsx)(h.Stack.Screen,{name:"settings/index"}),k=(0,He.jsx)(h.Stack.Screen,{name:"settings/[section]"}),j=(0,He.jsx)(h.Stack.Screen,{name:"settings/projects/index"}),w=(0,He.jsx)(h.Stack.Screen,{name:"settings/projects/[projectKey]"}),O=(0,He.jsx)(h.Stack.Screen,{name:"new"}),E=(0,He.jsx)(h.Stack.Screen,{name:"open-project"}),d=(0,He.jsx)(h.Stack.Screen,{name:"sessions"}),S=(0,He.jsx)(h.Stack.Screen,{name:"schedules"}),f=(0,He.jsx)(h.Stack.Screen,{name:"sources"}),_=(0,He.jsx)(h.Stack.Screen,{name:"loops"}),p=(0,He.jsx)(h.Stack.Screen,{name:"inbox"}),v=(0,He.jsx)(h.Stack.Screen,{name:"pair-scan"}),e[4]=d,e[5]=S,e[6]=f,e[7]=_,e[8]=p,e[9]=v,e[10]=b,e[11]=x,e[12]=k,e[13]=j,e[14]=w,e[15]=O,e[16]=E):(d=e[4],S=e[5],f=e[6],_=e[7],p=e[8],v=e[9],b=e[10],x=e[11],k=e[12],j=e[13],w=e[14],O=e[15],E=e[16]),e[17]!==t?(P=(0,He.jsxs)(h.Stack.Protected,{guard:t,children:[b,x,k,j,w,O,E,d,S,f,_,p,v]}),e[17]=t,e[18]=P):P=e[18],e[19]===Symbol.for("react.memo_cache_sentinel")?(I=(0,He.jsx)(h.Stack.Screen,{name:"h/[serverId]"}),T=(0,He.jsx)(h.Stack.Screen,{name:"settings/hosts/[serverId]/index"}),D=(0,He.jsx)(h.Stack.Screen,{name:"settings/hosts/[serverId]/[hostSection]"}),e[19]=I,e[20]=T,e[21]=D):(I=e[19],T=e[20],D=e[21]),e[22]!==c||e[23]!==P?(F=(0,He.jsxs)(h.Stack,{screenOptions:c,children:[l,u,P,I,T,D]}),e[22]=c,e[23]=P,e[24]=F):F=e[24],F}function Wt(){const e=(0,o.c)(3),t=(0,h.useNavigationContainerRef)();let n,s;return e[0]!==t?(n=()=>(0,V.registerWorkspaceRouteNavigationRef)(t),s=[t],e[0]=t,e[1]=n,e[2]=s):(n=e[1],s=e[2]),(0,S.useEffect)(n,s),null}function Ct(){const e=(0,o.c)(2);let t,n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,He.jsx)(It,{}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,He.jsx)(z.SidebarAnimationProvider,{children:(0,He.jsxs)(X.HorizontalScrollProvider,{children:[t,(0,He.jsx)(w.DaemonRpcBoundary,{children:(0,He.jsxs)(Tt,{children:[(0,He.jsx)(Wt,{}),(0,He.jsx)(Ft,{})]})})]})}),e[1]=n):n=e[1],n}function Rt(e){const t=(0,o.c)(3),{children:n}=e;let s,c;return t[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,He.jsx)(Le,{}),t[0]=s):s=t[0],t[1]!==n?(c=(0,He.jsxs)(Ke,{children:[s,(0,He.jsx)(N.SidebarCalloutProvider,{children:(0,He.jsx)(kt,{children:n})})]}),t[1]=n,t[2]=c):c=t[2],c}function At(e){const t=(0,o.c)(2),{children:n}=e;let l;return t[0]!==n?(l=(0,He.jsx)(Y.ToastProvider,{children:(0,He.jsx)(c.PortalProvider,{children:(0,He.jsx)(s.BottomSheetModalProvider,{children:n})})}),t[0]=n,t[1]=l):l=t[1],l}function Ht(e){const t=(0,o.c)(2),{children:n}=e;let s;return t[0]!==n?(s=(0,He.jsx)(Ze,{children:(0,He.jsx)(ge.I18nProvider,{children:(0,He.jsx)(b.SafeAreaProvider,{children:(0,He.jsx)(p.KeyboardProvider,{children:(0,He.jsx)(de.KeyboardShiftProvider,{children:(0,He.jsx)(At,{children:n})})})})})}),t[0]=n,t[1]=s):s=t[1],s}function Gt(){const e=(0,o.c)(2);let t,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,He.jsx)(v.ReducedMotionConfig,{mode:v.ReduceMotion.System}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,He.jsxs)(_.GestureHandlerRootView,{style:tt,children:[t,(0,He.jsx)(n.View,{style:Lt.surfaceFill,children:(0,He.jsx)(Ht,{children:(0,He.jsx)(ye.TenantAuthProvider,{children:(0,He.jsx)(ye.TenantAuthGate,{children:(0,He.jsx)(Rt,{children:(0,He.jsx)(Ct,{})})})})})})]}),e[1]=s):s=e[1],s}const Lt=y.StyleSheet.create(e=>({surfaceFill:{flex:1,backgroundColor:e.colors.surface0,uni__dependencies:[0]}}))},2478,[348,350,55,2479,2991,3030,746,3079,379,36,25,686,146,2482,3214,2570,558,56,3265,3266,3533,3534,3535,3559,3578,3581,3582,3717,3918,3926,3937,4159,4086,3468,3472,3420,4160,4161,3872,3596,3536,3514,4060,4196,3507,4197,4198,4205,4208,4209,3416,3580,3627,3417,3591,4211,4213,4217,4218,4219,4227,3910,4230,4231,3920,3590,3538,4232,3272,1,4234,3445,3274,4249,4250,4252,3597,305,4253,3600,3492,4191,3499,4178,4254,4480,279]);
|
|
14095
|
+
__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}),t.default=e,t}function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return Gt}}),_e.useEarliestOnlineHostServerId=Ne,_e.useStoreReady=Qe,_e.useHostRuntimeBootstrapState=function(){return(0,S.useContext)(Ge)};var n=r(_d[0]),o=r(_d[1]);r(_d[2]);var s=r(_d[3]),c=r(_d[4]),l=r(_d[5]),u=e(r(_d[6])),d=e(r(_d[7])),h=r(_d[8]),S=r(_d[9]),f=(t(r(_d[10])),t(r(_d[11])));r(_d[12]);var _=r(_d[13]),p=r(_d[14]),v=r(_d[15]),b=r(_d[16]),y=r(_d[17]),x=r(_d[18]),k=r(_d[19]),j=r(_d[20]),w=r(_d[21]),O=r(_d[22]),E=r(_d[23]),P=r(_d[24]),I=r(_d[25]),T=r(_d[26]),D=r(_d[27]),F=r(_d[28]),W=r(_d[29]),C=r(_d[30]),R=r(_d[31]),A=r(_d[32]),H=r(_d[33]),G=r(_d[34]),L=r(_d[35]),X=r(_d[36]),M=r(_d[37]),B=r(_d[38]),z=r(_d[39]),N=r(_d[40]),Y=r(_d[41]),U=r(_d[42]),J=r(_d[43]),V=r(_d[44]),K=r(_d[45]),$=r(_d[46]),q=r(_d[47]),Q=r(_d[48]),Z=r(_d[49]),ee=r(_d[50]),te=r(_d[51]),ne=r(_d[52]),oe=r(_d[53]),re=r(_d[54]),se=r(_d[55]),ae=r(_d[56]),ie=r(_d[57]),ce=r(_d[58]),le=r(_d[59]),ue=r(_d[60]),de=r(_d[61]),he=r(_d[62]),Se=r(_d[63]),me=r(_d[64]),fe=r(_d[65]),pe=r(_d[66]),ge=r(_d[67]),ve=r(_d[68]),be=r(_d[69]),ye=r(_d[70]),xe=r(_d[71]),ke=r(_d[72]),je=r(_d[73]),we=r(_d[74]),Oe=r(_d[75]),Ee=r(_d[76]),Pe=r(_d[77]),Ie=r(_d[78]),Te=r(_d[79]),De=r(_d[80]),Fe=r(_d[81]),We=r(_d[82]),Ce=r(_d[83]),Re=r(_d[84]),Ae=r(_d[85]),He=r(_d[86]);(0,be.polyfillCrypto)(),(0,Re.initializeDatadog)(),(0,Ae.initializePostHog)();const Ge=(0,S.createContext)({splashError:null,retry:()=>{},hasGivenUpWaitingForHost:!1,storeReady:!1,startupBlocker:{kind:"none"}});function Le(){const e=(0,o.c)(5),t=(0,h.useRouter)(),n=(0,S.useRef)(null);let s;(0,Z.useDatadogViewTracking)(),e[0]!==t?(s=e=>{const n=(0,Fe.resolveNotificationTarget)(e),o=n.serverId,s=n.agentId;o&&s?(0,We.navigateToAgent)({serverId:o,agentId:s,pin:!0}):t.navigate((0,Fe.buildNotificationRoute)(e))},e[0]=t,e[1]=s):s=e[1];const c=(0,pe.useStableEvent)(s);let l,u;return e[2]!==c?(l=()=>{if(L.isWeb){let e=null,t=!1;if((0,G.getIsElectronRuntime)()){(0,Ce.ensureOsNotificationPermission)();const n=(0,oe.getDesktopHost)()?.events?.on?.("notification-click",e=>{const t="object"==typeof e&&null!==e&&"data"in e&&"object"==typeof e.data&&null!==e.data?e.data:void 0;c(t)});Promise.resolve(n).then(n=>{"function"==typeof n&&(t?n():e=n)})}const n=e=>{const t=e;e.preventDefault(),c(t.detail?.data)};return window.addEventListener(Ce.WEB_NOTIFICATION_CLICK_EVENT,n),()=>{t=!0,e?.(),window.removeEventListener(Ce.WEB_NOTIFICATION_CLICK_EVENT,n)}}d.setNotificationHandler({handleNotification:Xe}),(0,Q.registerNotificationCategories)(),(0,$.registerBackgroundAgentStateFetch)(),(0,q.registerLiveActivities)();const e=e=>{const t=e.notification.request.identifier;n.current!==t&&(n.current=t,(0,K.handlePermissionNotificationResponse)(e).then(t=>{if(t.handled)return;const n=e.notification.request.content.data;c(n)}))},t=d.addNotificationResponseReceivedListener(e);return d.getLastNotificationResponseAsync().then(t=>{t&&e(t)}),()=>{t.remove()}},u=[c],e[2]=c,e[3]=l,e[4]=u):(l=e[3],u=e[4]),(0,S.useEffect)(l,u),null}async function Xe(){return{shouldShowAlert:!1,shouldShowBanner:!1,shouldShowList:!1,shouldPlaySound:!1,shouldSetBadge:!1}}function Me(e){const t=(0,o.c)(3),{daemon:n}=e,s=(0,ke.useHostRuntimeClient)(n.serverId);if(!s)return null;let c;return t[0]!==s||t[1]!==n.serverId?(c=(0,He.jsx)(M.SessionProvider,{serverId:n.serverId,client:s,children:null},n.serverId),t[0]=s,t[1]=n.serverId,t[2]=c):c=t[2],c}function Be(){const e=(0,o.c)(4),t=(0,ke.useHosts)();if(0===t.length)return null;let n,s;return e[0]!==t?(n=t.map(ze),e[0]=t,e[1]=n):n=e[1],e[2]!==n?(s=(0,He.jsx)(He.Fragment,{children:n}),e[2]=n,e[3]=s):s=e[3],s}function ze(e){return(0,He.jsx)(Me,{daemon:e},e.serverId)}function Ne(){const e=(0,o.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,ke.getHostRuntimeStore)(),e[0]=t):t=e[0];const n=t;let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{const t=n.subscribeAll(e),o=n.subscribeHostList(e);return()=>{t(),o()}},e[1]=s):s=e[1];const c=s;let l,u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>n.getEarliestOnlineHostServerId(),u=()=>n.getEarliestOnlineHostServerId(),e[2]=l,e[3]=u):(l=e[2],u=e[3]),(0,S.useSyncExternalStore)(c,l,u)}function Ye(){const e=(0,o.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,je.getDaemonStartService)({store:(0,ke.getHostRuntimeStore)()}),e[0]=t):t=e[0];const n=t;let s,c,l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>n.subscribe(e),c=()=>n.getLastError(),l=()=>n.getLastError(),e[1]=s,e[2]=c,e[3]=l):(s=e[1],c=e[2],l=e[3]),(0,S.useSyncExternalStore)(s,c,l)}function Ue(){const e=(0,o.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,je.getDaemonStartService)({store:(0,ke.getHostRuntimeStore)()}),e[0]=t):t=e[0];const n=t;let s,c,l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>n.subscribe(e),c=()=>n.isRunning(),l=()=>n.isRunning(),e[1]=s,e[2]=c,e[3]=l):(s=e[1],c=e[2],l=e[3]),(0,S.useSyncExternalStore)(s,c,l)}const Je=1e4;async function Ve(){if(!(0,ee.shouldUseDesktopDaemon)())return!1;if((0,ke.hasConfiguredLocalDaemonOverride)())return!1;return(await(0,re.loadDesktopSettings)()).daemon.manageBuiltInDaemon}function Ke(e){const t=(0,o.c)(23),{children:n}=e;let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],t[0]=s):s=t[0],(0,S.useEffect)(qe,s);const c=Ne(),l=Ye(),u=Ue(),[d,h]=(0,S.useState)(!1);let f;t[1]===Symbol.for("react.memo_cache_sentinel")?(f=(0,ee.shouldUseDesktopDaemon)(),t[1]=f):f=t[1];const _=f;let p;t[2]!==c||t[3]!==l||t[4]!==u?(p=(0,J.resolveStartupBlocker)({isDesktopRuntime:_,anyOnlineHostServerId:c,daemonStartIsRunning:u,daemonStartError:l}),t[2]=c,t[3]=l,t[4]=u,t[5]=p):p=t[5];const v=p;let b;t[6]!==c||t[7]!==d||t[8]!==v?(b=(0,J.shouldRunStartupGiveUpTimer)({startupBlocker:v,anyOnlineHostServerId:c,hasGivenUpWaitingForHost:d}),t[6]=c,t[7]=d,t[8]=v,t[9]=b):b=t[9];const y=b;let x,k;t[10]!==y?(x=()=>{if(!y)return;const e=setTimeout(()=>{h(!0)},Je);return()=>{clearTimeout(e)}},k=[y],t[10]=y,t[11]=x,t[12]=k):(x=t[11],k=t[12]),(0,S.useEffect)(x,k);const j=$e,w="managed-daemon-error"===v.kind?v.message:null;let O;t[13]!==v?(O=(0,J.resolveStartupNavigationReady)({startupBlocker:v}),t[13]=v,t[14]=O):O=t[14];const E=O;let P;t[15]!==d||t[16]!==w||t[17]!==v||t[18]!==E?(P={splashError:w,retry:j,hasGivenUpWaitingForHost:d,storeReady:E,startupBlocker:v},t[15]=d,t[16]=w,t[17]=v,t[18]=E,t[19]=P):P=t[19];const I=P;let T;return t[20]!==n||t[21]!==I?(T=(0,He.jsx)(Ge.Provider,{value:I,children:n}),t[20]=n,t[21]=I,t[22]=T):T=t[22],T}function $e(){const e=(0,je.getDaemonStartService)({store:(0,ke.getHostRuntimeStore)()});(0,J.startDaemonIfGateAllows)({daemonStartService:e,shouldStartDaemon:Ve,onGateError:t=>e.recordError(t)})}function qe(){const e=(0,ke.getHostRuntimeStore)(),t=(0,je.getDaemonStartService)({store:e});(0,J.startHostRuntimeBootstrap)({store:e,daemonStartService:t,shouldStartDaemon:Ve,onGateError:e=>t.recordError(e)})}function Qe(){return(0,S.useContext)(Ge).storeReady}function Ze(e){const t=(0,o.c)(2),{children:n}=e;let s;return t[0]!==n?(s=(0,He.jsx)(l.QueryClientProvider,{client:xe.queryClient,children:n}),t[0]=n,t[1]=s):s=t[1],s}const et={flex:1,flexDirection:"row"},tt={flex:1},nt=32,ot=L.isWeb?"auto":"pan-y",rt=["dark","zinc","midnight","claude","ghostty","light"];function st(e){const t=(0,o.c)(58),{children:s,selectedAgentId:c,chromeEnabled:l}=e,u=(0,ke.useHosts)(),{settings:d,updateSettings:S}=(0,fe.useAppSettings)(),_=(0,Ee.usePanelStore)(ft),p=(0,Ee.usePanelStore)(mt),v=(0,Ee.usePanelStore)(St),b=(0,Ee.usePanelStore)(ht),y=(0,Ee.usePanelStore)(dt),w=(0,Ee.usePanelStore)(ut),L=(0,Ee.usePanelStore)(lt);(0,Se.useForegroundReconnect)();const X=it;let M;t[0]!==d.theme||t[1]!==S?(M=()=>{const e=(rt.indexOf(d.theme)+1)%rt.length;S({theme:rt[e]})},t[0]=d.theme,t[1]=S,t[2]=M):M=t[2];const z=M,N=(0,G.useIsCompactFormFactor)(),Y=(0,f.default)(),U=!1;let J;t[3]!==Y.height||t[4]!==Y.width?(J=(0,x.resolveColumnMode)({width:Y.width,height:Y.height,isTablet:U}),t[3]=Y.height,t[4]=Y.width,t[5]=J):J=t[5];const V=N||U;(0,he.useCompactWebViewportZoomLock)(V);const K=(0,h.usePathname)(),$=l??u.length>0,q=V?_:p;let Q;t[6]!==b||t[7]!==y||t[8]!==v?(Q=()=>{const{desktop:e}=Ee.usePanelStore.getState();(0,Ie.toggleDesktopSidebarsWithCheckoutIntent)({isAgentListOpen:e.agentListOpen,isFileExplorerOpen:e.fileExplorerOpen,openAgentList:v,closeAgentList:b,closeFileExplorer:y,toggleFocusedFileExplorer:at})},t[6]=b,t[7]=y,t[8]=v,t[9]=Q):Q=t[9];const Z=Q;let ee;t[10]!==$||t[11]!==K?(ee=$||K.startsWith("/settings"),t[10]=$,t[11]=K,t[12]=ee):ee=t[12];const te=ee;let ne,oe,re,le;t[13]!==z||t[14]!==V||t[15]!==te||t[16]!==q||t[17]!==Z||t[18]!==w?(ne={enabled:te,isMobile:V,toggleAgentList:q,toggleBothSidebars:Z,toggleFocusMode:w,cycleTheme:z},t[13]=z,t[14]=V,t[15]=te,t[16]=q,t[17]=Z,t[18]=w,t[19]=ne):ne=t[19],(0,ue.useKeyboardShortcuts)(ne),(0,ie.useActiveWorktreeNewAction)(),(0,ce.useGlobalNewWorkspaceAction)(),t[20]!==$||t[21]!==V||t[22]!==L||t[23]!==c?(oe=!V&&$&&!L&&(0,He.jsx)(T.LeftSidebar,{selectedAgentId:c}),t[20]=$,t[21]=V,t[22]=L,t[23]=c,t[24]=oe):oe=t[24],t[25]!==s||t[26]!==$||t[27]!==V?(re=V&&$?(0,He.jsx)(B.ExplorerSidebarAnimationProvider,{children:(0,He.jsx)(D.CompactExplorerSidebarHost,{enabled:$,children:(0,He.jsx)(n.View,{style:tt,children:s})})}):(0,He.jsx)(n.View,{style:tt,children:s}),t[25]=s,t[26]=$,t[27]=V,t[28]=re):re=t[28],t[29]!==oe||t[30]!==re?(le=(0,He.jsxs)(n.View,{style:et,children:[oe,re]}),t[29]=oe,t[30]=re,t[31]=le):le=t[31];const de=le;let me,pe,ge,ve,be,ye,xe,je,we,Oe,Pe,Te,De,Fe,We,Ce;t[32]===Symbol.for("react.memo_cache_sentinel")?(me=(0,He.jsx)(j.DaemonConnectionBanner,{onRetry:X}),t[32]=me):me=t[32],t[33]===Symbol.for("react.memo_cache_sentinel")?(pe=(0,He.jsx)(A.FloatingPanelPortalHost,{}),t[33]=pe):pe=t[33],t[34]!==$||t[35]!==V||t[36]!==c?(ge=V&&$&&(0,He.jsx)(T.LeftSidebar,{selectedAgentId:c}),t[34]=$,t[35]=V,t[36]=c,t[37]=ge):ge=t[37],t[38]===Symbol.for("react.memo_cache_sentinel")?(ve=(0,He.jsx)(E.DownloadToast,{}),be=(0,He.jsx)(se.RosettaCalloutSource,{}),ye=(0,He.jsx)(ae.UpdateCalloutSource,{}),xe=(0,He.jsx)(O.WorktreeSetupCalloutSource,{}),je=(0,He.jsx)(k.CommandCenter,{}),we=(0,He.jsx)(H.HostChooserModal,{}),Oe=(0,He.jsx)(F.ProjectPickerModal,{}),Pe=(0,He.jsx)(W.ProviderSettingsHost,{}),t[38]=ve,t[39]=be,t[40]=ye,t[41]=xe,t[42]=je,t[43]=we,t[44]=Oe,t[45]=Pe):(ve=t[38],be=t[39],ye=t[40],xe=t[41],je=t[42],we=t[43],Oe=t[44],Pe=t[45]),t[46]!==te?(Te=(0,He.jsx)(R.WorkspaceShortcutTargetsSubscriber,{enabled:te}),t[46]=te,t[47]=Te):Te=t[47],t[48]===Symbol.for("react.memo_cache_sentinel")?(De=(0,He.jsx)(C.WorkspaceSetupDialog,{}),Fe=(0,He.jsx)(I.KeyboardShortcutsDialog,{}),We=(0,He.jsx)(P.QuittingOverlay,{}),t[48]=De,t[49]=Fe,t[50]=We):(De=t[48],Fe=t[49],We=t[50]),t[51]!==ge||t[52]!==Te||t[53]!==de?(Ce=(0,He.jsxs)(n.View,{style:Lt.surfaceFill,children:[me,de,pe,ge,ve,be,ye,xe,je,we,Oe,Pe,Te,De,Fe,We]}),t[51]=ge,t[52]=Te,t[53]=de,t[54]=Ce):Ce=t[54];const Re=Ce;if(!V)return Re;let Ae;return t[55]!==$||t[56]!==Re?(Ae=(0,He.jsx)(xt,{chromeEnabled:$,children:Re}),t[55]=$,t[56]=Re,t[57]=Ae):Ae=t[57],Ae}function at(){return ve.keyboardActionDispatcher.dispatch({id:"sidebar.toggle.right",scope:"sidebar"})}function it(e){const t=(0,ke.getHostRuntimeStore)();t.ensureConnectedAll(),t.runProbeCycleNow(e).catch(ct)}function ct(){}function lt(e){return e.desktop.focusModeEnabled}function ut(e){return e.toggleFocusMode}function dt(e){return e.closeDesktopFileExplorer}function ht(e){return e.closeDesktopAgentList}function St(e){return e.openDesktopAgentList}function mt(e){return e.toggleDesktopAgentList}function ft(e){return e.toggleMobileAgentList}const _t={code:"function _layoutTsx1(){const{isGesturing,runOnJS,setOverlayPeek}=this.__closure;isGesturing.value=false;runOnJS(setOverlayPeek)(false);}"},pt={code:"function _layoutTsx2(event_2){const{isGesturing,windowWidth,animateToOpen,runOnJS,handleGestureOpen,animateToClose}=this.__closure;isGesturing.value=false;const shouldOpen=event_2.translationX>windowWidth/3||event_2.velocityX>500;if(shouldOpen){animateToOpen();runOnJS(handleGestureOpen)();}else{animateToClose();}}"},gt={code:"function _layoutTsx3(event_1){const{windowWidth,translateX,backdropOpacity,interpolate,Extrapolation}=this.__closure;const newTranslateX=Math.min(0,-windowWidth+event_1.translationX);translateX.value=newTranslateX;backdropOpacity.value=interpolate(newTranslateX,[-windowWidth,0],[0,1],Extrapolation.CLAMP);}"},vt={code:"function _layoutTsx4(){const{isGesturing,runOnJS,setOverlayPeek}=this.__closure;isGesturing.value=true;runOnJS(setOverlayPeek)(true);}"},bt={code:"function _layoutTsx5(event_0,stateManager){const{touchStartX,touchStartY,canOpenLeftSidebarGesture,mobilePanelState,translateX,windowWidth,horizontalScroll,isWeb,MOBILE_WEB_EDGE_SWIPE_WIDTH}=this.__closure;var _horizontalScroll;const touch_0=event_0.changedTouches[0];if(!touch_0||event_0.numberOfTouches!==1)return;const deltaX=touch_0.absoluteX-touchStartX.value;const deltaY=touch_0.absoluteY-touchStartY.value;const absDeltaX=Math.abs(deltaX);const absDeltaY=Math.abs(deltaY);if(!canOpenLeftSidebarGesture(mobilePanelState.value,translateX.value,windowWidth)){stateManager.fail();return;}if((_horizontalScroll=horizontalScroll)!==null&&_horizontalScroll!==void 0&&_horizontalScroll.isAnyScrolledRight.value){stateManager.fail();return;}if(isWeb&&touchStartX.value>MOBILE_WEB_EDGE_SWIPE_WIDTH){stateManager.fail();return;}if(deltaX<=-10){stateManager.fail();return;}if(absDeltaY>10&&absDeltaY>absDeltaX){stateManager.fail();return;}if(deltaX>15&&absDeltaX>absDeltaY){stateManager.activate();}}"},yt={code:"function _layoutTsx6(event){const{touchStartX,touchStartY}=this.__closure;const touch=event.changedTouches[0];if(touch){touchStartX.value=touch.absoluteX;touchStartY.value=touch.absoluteY;}}"};function xt({children:e,chromeEnabled:t}){const n=(0,Ee.usePanelStore)(e=>e.showMobileAgentList),o=(0,X.useHorizontalScrollOptional)(),{translateX:s,backdropOpacity:c,windowWidth:l,animateToOpen:u,animateToClose:d,setOverlayPeek:h,isGesturing:f,mobilePanelState:p,gestureAnimatingRef:b,openGestureRef:y}=(0,z.useSidebarAnimation)(),x=(0,v.useSharedValue)(0),k=(0,v.useSharedValue)(0),j=t,w=(0,S.useCallback)(()=>{b.current=!0,n()},[n,b]),O=(0,S.useMemo)(()=>_.Gesture.Pan().withRef(y).enabled(j).manualActivation(!0).failOffsetY([-10,10]).onTouchesDown((function({_worklet_1615879058013_init_data:e,touchStartX:t,touchStartY:n}){const o=function(e){const o=e.changedTouches[0];o&&(t.value=o.absoluteX,n.value=o.absoluteY)};return o.__closure={touchStartX:t,touchStartY:n},o.__workletHash=1615879058013,o.__initData=e,o})({_worklet_1615879058013_init_data:yt,touchStartX:x,touchStartY:k})).onTouchesMove((function({_worklet_8337771416778_init_data:e,touchStartX:t,touchStartY:n,canOpenLeftSidebarGesture:o,mobilePanelState:s,translateX:c,windowWidth:l,horizontalScroll:u,isWeb:d,MOBILE_WEB_EDGE_SWIPE_WIDTH:h}){const S=function(e,S){const f=e.changedTouches[0];if(!f||1!==e.numberOfTouches)return;const _=f.absoluteX-t.value,p=f.absoluteY-n.value,v=Math.abs(_),b=Math.abs(p);o(s.value,c.value,l)?u?.isAnyScrolledRight.value||d&&t.value>h||_<=-10||b>10&&b>v?S.fail():_>15&&v>b&&S.activate():S.fail()};return S.__closure={touchStartX:t,touchStartY:n,canOpenLeftSidebarGesture:o,mobilePanelState:s,translateX:c,windowWidth:l,horizontalScroll:u,isWeb:d,MOBILE_WEB_EDGE_SWIPE_WIDTH:h},S.__workletHash=8337771416778,S.__initData=e,S})({_worklet_8337771416778_init_data:bt,touchStartX:x,touchStartY:k,canOpenLeftSidebarGesture:Te.canOpenLeftSidebarGesture,mobilePanelState:p,translateX:s,windowWidth:l,horizontalScroll:o,isWeb:L.isWeb,MOBILE_WEB_EDGE_SWIPE_WIDTH:nt})).onStart((function({_worklet_11112183592680_init_data:e,isGesturing:t,runOnJS:n,setOverlayPeek:o}){const s=function(){t.value=!0,n(o)(!0)};return s.__closure={isGesturing:t,runOnJS:n,setOverlayPeek:o},s.__workletHash=0xa1b41c176e8,s.__initData=e,s})({_worklet_11112183592680_init_data:vt,isGesturing:f,runOnJS:v.runOnJS,setOverlayPeek:h})).onUpdate((function({_worklet_4399350013762_init_data:e,windowWidth:t,translateX:n,backdropOpacity:o,interpolate:s,Extrapolation:c}){const l=function(e){const l=Math.min(0,-t+e.translationX);n.value=l,o.value=s(l,[-t,0],[0,1],c.CLAMP)};return l.__closure={windowWidth:t,translateX:n,backdropOpacity:o,interpolate:s,Extrapolation:c},l.__workletHash=4399350013762,l.__initData=e,l})({_worklet_4399350013762_init_data:gt,windowWidth:l,translateX:s,backdropOpacity:c,interpolate:v.interpolate,Extrapolation:v.Extrapolation})).onEnd((function({_worklet_3566839805561_init_data:e,isGesturing:t,windowWidth:n,animateToOpen:o,runOnJS:s,handleGestureOpen:c,animateToClose:l}){const u=function(e){t.value=!1;e.translationX>n/3||e.velocityX>500?(o(),s(c)()):l()};return u.__closure={isGesturing:t,windowWidth:n,animateToOpen:o,runOnJS:s,handleGestureOpen:c,animateToClose:l},u.__workletHash=3566839805561,u.__initData=e,u})({_worklet_3566839805561_init_data:pt,isGesturing:f,windowWidth:l,animateToOpen:u,runOnJS:v.runOnJS,handleGestureOpen:w,animateToClose:d})).onFinalize((function({_worklet_11316004136205_init_data:e,isGesturing:t,runOnJS:n,setOverlayPeek:o}){const s=function(){t.value=!1,n(o)(!1)};return s.__closure={isGesturing:t,runOnJS:n,setOverlayPeek:o},s.__workletHash=0xa4ab668250d,s.__initData=e,s})({_worklet_11316004136205_init_data:_t,isGesturing:f,runOnJS:v.runOnJS,setOverlayPeek:h})),[j,l,s,c,p,u,d,h,w,f,y,o?.isAnyScrolledRight,x,k]);return(0,He.jsx)(_.GestureDetector,{gesture:O,touchAction:ot,children:e})}function kt(e){const t=(0,o.c)(25),{children:n}=e,{settings:s,isLoading:c}=(0,fe.useAppSettings)(),{upsertConnectionFromOfferUrl:l}=(0,ke.useHostMutations)(),{theme:u}=(0,y.useUnistyles)();let d,h,f,_,p,v;t[0]!==s.theme||t[1]!==c?(d=()=>{c||("auto"===s.theme?y.UnistylesRuntime.setAdaptiveThemes(!0):(y.UnistylesRuntime.setAdaptiveThemes(!1),y.UnistylesRuntime.setTheme(Pe.THEME_TO_UNISTYLES[s.theme])))},h=[c,s.theme],t[0]=s.theme,t[1]=c,t[2]=d,t[3]=h):(d=t[2],h=t[3]),(0,S.useEffect)(d,h),t[4]!==u.colors.accent?(f=()=>{(0,Oe.applyFocusRingColor)(u.colors.accent)},_=[u.colors.accent],t[4]=u.colors.accent,t[5]=f,t[6]=_):(f=t[5],_=t[6]),(0,S.useEffect)(f,_),t[7]!==s.codeFontSize||t[8]!==s.monoFontFamily||t[9]!==s.syntaxTheme||t[10]!==s.uiFontFamily||t[11]!==s.uiFontSize||t[12]!==c?(p=()=>{c||(0,we.applyAppearance)({uiFontFamily:s.uiFontFamily,monoFontFamily:s.monoFontFamily,uiFontSize:s.uiFontSize,codeFontSize:s.codeFontSize,syntaxTheme:s.syntaxTheme})},v=[c,s.uiFontFamily,s.monoFontFamily,s.uiFontSize,s.codeFontSize,s.syntaxTheme],t[7]=s.codeFontSize,t[8]=s.monoFontFamily,t[9]=s.syntaxTheme,t[10]=s.uiFontFamily,t[11]=s.uiFontSize,t[12]=c,t[13]=p,t[14]=v):(p=t[13],v=t[14]),(0,S.useEffect)(p,v);const b=!c;let x,k,j,w,O;return t[15]!==b?(x=(0,He.jsx)(jt,{enabled:b}),t[15]=b,t[16]=x):x=t[16],t[17]!==l?(k=(0,He.jsx)(Ot,{upsertDaemonFromOfferUrl:l}),t[17]=l,t[18]=k):k=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(j=(0,He.jsx)(Be,{}),w=(0,He.jsx)(Dt,{}),t[19]=j,t[20]=w):(j=t[19],w=t[20]),t[21]!==n||t[22]!==x||t[23]!==k?(O=(0,He.jsxs)(U.VoiceProvider,{children:[x,k,j,w,n]}),t[21]=n,t[22]=x,t[23]=k,t[24]=O):O=t[24],O}function jt(e){const t=(0,o.c)(5),{enabled:n}=e,{theme:s}=(0,y.useUnistyles)(),c=s.colors.surface0,l=s.colors.foreground;let u,d;return t[0]!==n||t[1]!==l||t[2]!==c?(u=()=>{n&&!L.isNative&&(0,ne.updateDesktopWindowControls)({backgroundColor:c,foregroundColor:l}).catch(wt)},d=[n,c,l],t[0]=n,t[1]=l,t[2]=c,t[3]=u,t[4]=d):(u=t[3],d=t[4]),(0,S.useEffect)(u,d),null}function wt(e){console.warn("[DesktopWindow] Failed to update window controls overlay",e)}function Ot(e){const t=(0,o.c)(4),{upsertDaemonFromOfferUrl:n}=e,s=(0,h.useRouter)();let c,l;return t[0]!==s||t[1]!==n?(c=()=>{let e=!1;const t=t=>{t&&t.includes("#offer=")&&n(t).then(t=>{if(e)return;const n=t?.serverId;"string"==typeof n&&n&&s.replace((0,De.buildOpenProjectRoute)())}).catch(t=>{e||console.warn("[Linking] Failed to import pairing offer",t)})};u.getInitialURL().then(t).catch(Et);const o=u.addEventListener("url",e=>{t(e.url)});return()=>{e=!0,o.remove()}},l=[s,n],t[0]=s,t[1]=n,t[2]=c,t[3]=l):(c=t[2],l=t[3]),(0,S.useEffect)(c,l),null}function Et(){}let Pt=1;function It(){const e=(0,H.useHostChooser)(),t=(0,ke.useHostRegistryLoaded)(),[n,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),l=(0,me.useOpenProject)(n?.serverId??null),u=(0,S.useCallback)(n=>{const s=n.trim();s&&(t?e({title:"Choose host",onChooseHost:e=>{o({id:Pt++,serverId:e,path:s})}}):c(s))},[e,t]);return(0,S.useEffect)(()=>{if(!t||!s)return;const e=s;c(null),u(e)},[t,u,s]),(0,S.useEffect)(()=>{if(!n)return;let e=!1;return l(n.path).then(t=>e?null:t.ok?(o(e=>e?.id===n.id?null:e),null):(o(e=>e?.id===n.id?null:e),null)),()=>{e=!0}},[l,n]),(0,S.useEffect)(()=>{let e=!1,t=null;return(0,oe.getDesktopHost)()?.getPendingOpenProject?.()?.then(t=>{!e&&t&&u(t)}).catch(()=>{}),(0,te.listenToDesktopEvent)("open-project",t=>{if(e)return;const n="string"==typeof t?.path?t.path.trim():"";u(n)}).then(n=>{e?n():t=n}).catch(()=>{}),()=>{e=!0,t?.()}},[u]),null}function Tt(e){const t=(0,o.c)(16),{children:n}=e,s=(0,h.usePathname)(),c=(0,h.useGlobalSearchParams)(),l=(0,ke.useHosts)(),u=Qe();let d;t[0]!==s?(d=(0,De.parseServerIdFromPathname)(s),t[0]=s,t[1]=d):d=t[1];const S=d;let f;t[2]!==l||t[3]!==S?(f=null!==S&&l.some(e=>e.serverId===S),t[2]=l,t[3]=S,t[4]=f):f=t[4];const _=u&&("/open-project"===s||"/new"===s||"/sessions"===s||"/schedules"===s||"/sources"===s||"/loops"===s||"/inbox"===s||f);let p;if(t[5]!==c.open||t[6]!==s){e:{let e;if(t[8]!==s){const n=s.match(/^\/h\/([^/]+)\/workspace\/[^/]+(?:\/|$)/);e=n?.[1]?.trim()??"",t[8]=s,t[9]=e}else e=t[9];const n=e,o=Array.isArray(c.open)?c.open[0]:c.open,l=(0,De.parseWorkspaceOpenIntent)(o);if(n&&"agent"===l?.kind){const e=l.agentId.trim();p=e?`${n}:${e}`:void 0;break e}let u;t[10]!==s?(u=(0,De.parseHostAgentRouteFromPathname)(s),t[10]=s,t[11]=u):u=t[11];const d=u;p=d?`${d.serverId}:${d.agentId}`:void 0}t[5]=c.open,t[6]=s,t[7]=p}else p=t[7];const v=_?p:void 0;let b;return t[12]!==n||t[13]!==_||t[14]!==v?(b=(0,He.jsx)(st,{selectedAgentId:v,chromeEnabled:_,children:n}),t[12]=n,t[13]=_,t[14]=v,t[15]=b):b=t[15],b}function Dt(){return(0,le.useFaviconStatus)(),null}function Ft(){const e=(0,o.c)(25),t=Qe(),{theme:n}=(0,y.useUnistyles)();let s;e[0]!==n.colors.surface0?(s={headerShown:!1,animation:"none",contentStyle:{backgroundColor:n.colors.surface0}},e[0]=n.colors.surface0,e[1]=s):s=e[1];const c=s;let l,u,d,S,f,_,p,v,b,x,k,j,w,O,E,P,I,T,D,F;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,He.jsx)(h.Stack.Screen,{name:"index"}),u=(0,He.jsx)(h.Stack.Screen,{name:"agent/[agentId]"}),e[2]=l,e[3]=u):(l=e[2],u=e[3]),e[4]===Symbol.for("react.memo_cache_sentinel")?(b=(0,He.jsx)(h.Stack.Screen,{name:"welcome"}),x=(0,He.jsx)(h.Stack.Screen,{name:"settings/index"}),k=(0,He.jsx)(h.Stack.Screen,{name:"settings/[section]"}),j=(0,He.jsx)(h.Stack.Screen,{name:"settings/projects/index"}),w=(0,He.jsx)(h.Stack.Screen,{name:"settings/projects/[projectKey]"}),O=(0,He.jsx)(h.Stack.Screen,{name:"new"}),E=(0,He.jsx)(h.Stack.Screen,{name:"open-project"}),d=(0,He.jsx)(h.Stack.Screen,{name:"sessions"}),S=(0,He.jsx)(h.Stack.Screen,{name:"schedules"}),f=(0,He.jsx)(h.Stack.Screen,{name:"sources"}),_=(0,He.jsx)(h.Stack.Screen,{name:"loops"}),p=(0,He.jsx)(h.Stack.Screen,{name:"inbox"}),v=(0,He.jsx)(h.Stack.Screen,{name:"pair-scan"}),e[4]=d,e[5]=S,e[6]=f,e[7]=_,e[8]=p,e[9]=v,e[10]=b,e[11]=x,e[12]=k,e[13]=j,e[14]=w,e[15]=O,e[16]=E):(d=e[4],S=e[5],f=e[6],_=e[7],p=e[8],v=e[9],b=e[10],x=e[11],k=e[12],j=e[13],w=e[14],O=e[15],E=e[16]),e[17]!==t?(P=(0,He.jsxs)(h.Stack.Protected,{guard:t,children:[b,x,k,j,w,O,E,d,S,f,_,p,v]}),e[17]=t,e[18]=P):P=e[18],e[19]===Symbol.for("react.memo_cache_sentinel")?(I=(0,He.jsx)(h.Stack.Screen,{name:"h/[serverId]"}),T=(0,He.jsx)(h.Stack.Screen,{name:"settings/hosts/[serverId]/index"}),D=(0,He.jsx)(h.Stack.Screen,{name:"settings/hosts/[serverId]/[hostSection]"}),e[19]=I,e[20]=T,e[21]=D):(I=e[19],T=e[20],D=e[21]),e[22]!==c||e[23]!==P?(F=(0,He.jsxs)(h.Stack,{screenOptions:c,children:[l,u,P,I,T,D]}),e[22]=c,e[23]=P,e[24]=F):F=e[24],F}function Wt(){const e=(0,o.c)(3),t=(0,h.useNavigationContainerRef)();let n,s;return e[0]!==t?(n=()=>(0,V.registerWorkspaceRouteNavigationRef)(t),s=[t],e[0]=t,e[1]=n,e[2]=s):(n=e[1],s=e[2]),(0,S.useEffect)(n,s),null}function Ct(){const e=(0,o.c)(2);let t,n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,He.jsx)(It,{}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,He.jsx)(z.SidebarAnimationProvider,{children:(0,He.jsxs)(X.HorizontalScrollProvider,{children:[t,(0,He.jsx)(w.DaemonRpcBoundary,{children:(0,He.jsxs)(Tt,{children:[(0,He.jsx)(Wt,{}),(0,He.jsx)(Ft,{})]})})]})}),e[1]=n):n=e[1],n}function Rt(e){const t=(0,o.c)(3),{children:n}=e;let s,c;return t[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,He.jsx)(Le,{}),t[0]=s):s=t[0],t[1]!==n?(c=(0,He.jsxs)(Ke,{children:[s,(0,He.jsx)(N.SidebarCalloutProvider,{children:(0,He.jsx)(kt,{children:n})})]}),t[1]=n,t[2]=c):c=t[2],c}function At(e){const t=(0,o.c)(2),{children:n}=e;let l;return t[0]!==n?(l=(0,He.jsx)(Y.ToastProvider,{children:(0,He.jsx)(c.PortalProvider,{children:(0,He.jsx)(s.BottomSheetModalProvider,{children:n})})}),t[0]=n,t[1]=l):l=t[1],l}function Ht(e){const t=(0,o.c)(2),{children:n}=e;let s;return t[0]!==n?(s=(0,He.jsx)(Ze,{children:(0,He.jsx)(ge.I18nProvider,{children:(0,He.jsx)(b.SafeAreaProvider,{children:(0,He.jsx)(p.KeyboardProvider,{children:(0,He.jsx)(de.KeyboardShiftProvider,{children:(0,He.jsx)(At,{children:n})})})})})}),t[0]=n,t[1]=s):s=t[1],s}function Gt(){const e=(0,o.c)(2);let t,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,He.jsx)(v.ReducedMotionConfig,{mode:v.ReduceMotion.System}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,He.jsxs)(_.GestureHandlerRootView,{style:tt,children:[t,(0,He.jsx)(n.View,{style:Lt.surfaceFill,children:(0,He.jsx)(Ht,{children:(0,He.jsx)(ye.TenantAuthProvider,{children:(0,He.jsx)(ye.TenantAuthGate,{children:(0,He.jsx)(Rt,{children:(0,He.jsx)(Ct,{})})})})})})]}),e[1]=s):s=e[1],s}const Lt=y.StyleSheet.create(e=>({surfaceFill:{flex:1,backgroundColor:e.colors.surface0,uni__dependencies:[0]}}))},2478,[348,350,55,2479,2991,3030,746,3079,379,36,25,686,146,2482,3214,2570,558,56,3265,3266,3533,3534,3535,3559,3578,3581,3582,3717,3918,3926,3937,4159,4086,3468,3472,3420,4160,4161,3872,3596,3536,3514,4060,4196,3507,4197,4198,4205,4208,4209,3416,3580,3627,3417,3591,4211,4213,4217,4218,4219,4227,3910,4230,4231,3920,3590,3538,4232,3272,1,4234,3445,3274,4249,4250,4252,3597,305,4253,3600,3492,4191,3499,4178,4254,4480,279]);
|
|
14096
14096
|
__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(_e,"BottomSheetModal",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(_e,"BottomSheetModalProvider",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(_e,"useBottomSheet",{enumerable:!0,get:function(){return u.useBottomSheet}}),Object.defineProperty(_e,"useBottomSheetModal",{enumerable:!0,get:function(){return l.useBottomSheetModal}}),Object.defineProperty(_e,"useBottomSheetSpringConfigs",{enumerable:!0,get:function(){return c.useBottomSheetSpringConfigs}}),Object.defineProperty(_e,"useBottomSheetTimingConfigs",{enumerable:!0,get:function(){return f.useBottomSheetTimingConfigs}}),Object.defineProperty(_e,"useBottomSheetInternal",{enumerable:!0,get:function(){return b.useBottomSheetInternal}}),Object.defineProperty(_e,"useBottomSheetModalInternal",{enumerable:!0,get:function(){return s.useBottomSheetModalInternal}}),Object.defineProperty(_e,"useScrollEventsHandlersDefault",{enumerable:!0,get:function(){return S.useScrollEventsHandlersDefault}}),Object.defineProperty(_e,"useGestureEventsHandlersDefault",{enumerable:!0,get:function(){return h.useGestureEventsHandlersDefault}}),Object.defineProperty(_e,"useBottomSheetGestureHandlers",{enumerable:!0,get:function(){return p.useBottomSheetGestureHandlers}}),Object.defineProperty(_e,"useScrollHandler",{enumerable:!0,get:function(){return B.useScrollHandler}}),Object.defineProperty(_e,"useScrollableSetter",{enumerable:!0,get:function(){return y.useScrollableSetter}}),Object.defineProperty(_e,"useBottomSheetScrollableCreator",{enumerable:!0,get:function(){return O.useBottomSheetScrollableCreator}}),Object.defineProperty(_e,"BottomSheetScrollView",{enumerable:!0,get:function(){return j.BottomSheetScrollView}}),Object.defineProperty(_e,"BottomSheetSectionList",{enumerable:!0,get:function(){return j.BottomSheetSectionList}}),Object.defineProperty(_e,"BottomSheetFlatList",{enumerable:!0,get:function(){return j.BottomSheetFlatList}}),Object.defineProperty(_e,"BottomSheetVirtualizedList",{enumerable:!0,get:function(){return j.BottomSheetVirtualizedList}}),Object.defineProperty(_e,"BottomSheetFlashList",{enumerable:!0,get:function(){return j.BottomSheetFlashList}}),Object.defineProperty(_e,"BottomSheetHandle",{enumerable:!0,get:function(){return P.BottomSheetHandle}}),Object.defineProperty(_e,"BottomSheetDraggableView",{enumerable:!0,get:function(){return H.default}}),Object.defineProperty(_e,"BottomSheetView",{enumerable:!0,get:function(){return C.default}}),Object.defineProperty(_e,"BottomSheetTextInput",{enumerable:!0,get:function(){return F.default}}),Object.defineProperty(_e,"BottomSheetBackdrop",{enumerable:!0,get:function(){return L.BottomSheetBackdrop}}),Object.defineProperty(_e,"BottomSheetFooter",{enumerable:!0,get:function(){return T.BottomSheetFooter}}),Object.defineProperty(_e,"BottomSheetFooterContainer",{enumerable:!0,get:function(){return T.BottomSheetFooterContainer}}),Object.defineProperty(_e,"createBottomSheetScrollableComponent",{enumerable:!0,get:function(){return j.createBottomSheetScrollableComponent}}),Object.defineProperty(_e,"enableLogging",{enumerable:!0,get:function(){return V.enableLogging}}),Object.defineProperty(_e,"TouchableHighlight",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"TouchableOpacity",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"TouchableWithoutFeedback",{enumerable:!0,get:function(){return w}});var t=e(r(d[0])),n=e(r(d[1])),o=e(r(d[2])),u=r(d[3]),l=r(d[4]),c=r(d[5]),f=r(d[6]),b=r(d[7]),s=r(d[8]),S=r(d[9]),h=r(d[10]),p=r(d[11]),B=r(d[12]),y=r(d[13]),O=r(d[14]),j=r(d[15]),P=r(d[16]),H=e(r(d[17])),C=e(r(d[18])),F=e(r(d[19])),L=r(d[20]),T=r(d[21]),v=e(r(d[22])),M=r(d[23]);Object.keys(M).forEach(function(e){'default'===e||Object.prototype.hasOwnProperty.call(_e,e)||Object.defineProperty(_e,e,{enumerable:!0,get:function(){return M[e]}})});var V=r(d[24]);const{TouchableHighlight:_,TouchableOpacity:k,TouchableWithoutFeedback:w}=v.default},2479,[2480,2989,3003,2937,2939,3005,3006,2938,2940,3007,2953,2956,2951,2950,3008,3009,2976,2987,3019,3022,3024,2970,3028,2929,2946]);
|
|
14097
14097
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},2480,[2481]);
|
|
14098
14098
|
__d(function(g,r,i,a,m,_e,d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return tt}});var e=t(r(d[0])),n=r(d[1]),o=t(r(d[2])),s=t(r(d[3])),_=t(r(d[4])),u=r(d[5]),A=r(d[6]),S=t(A),l=r(d[7]),I=r(d[8]),c=r(d[9]),T=r(d[10]),O=r(d[11]),N=r(d[12]),h=t(r(d[13])),E=r(d[14]),P=r(d[15]),D=r(d[16]),f=r(d[17]),C=r(d[18]),U=r(d[19]);S.default.addWhitelistedUIProps({decelerationRate:!0});const R={code:"function gorhom_BottomSheetJs1(){const{animatedLayoutState,animatedDetentsState,INITIAL_LAYOUT_VALUE}=this.__closure;const{containerHeight:containerHeight}=animatedLayoutState.get();const{highestDetentPosition:highestDetentPosition}=animatedDetentsState.get();if(highestDetentPosition===undefined){return INITIAL_LAYOUT_VALUE;}return containerHeight-highestDetentPosition;}"},x={code:"function gorhom_BottomSheetJs2(){const{animatedLayoutState,INITIAL_LAYOUT_VALUE,handleComponent,animatedDetentsState}=this.__closure;let isContainerHeightCalculated=false;const{containerHeight:containerHeight,handleHeight:handleHeight}=animatedLayoutState.get();if(containerHeight!==null&&containerHeight!==undefined&&containerHeight!==INITIAL_LAYOUT_VALUE){isContainerHeightCalculated=true;}let isHandleHeightCalculated=false;if(handleComponent===null){isHandleHeightCalculated=true;}if(handleHeight!==INITIAL_LAYOUT_VALUE){isHandleHeightCalculated=true;}let isSnapPointsNormalized=false;const{detents:detents}=animatedDetentsState.get();if(detents){isSnapPointsNormalized=true;}return isContainerHeightCalculated&&isHandleHeightCalculated&&isSnapPointsNormalized;}"},v={code:"function gorhom_BottomSheetJs3(){const{animatedDetentsState,SHEET_STATE,animatedPosition,animatedLayoutState,animatedSheetHeight,animatedKeyboardState,keyboardBehavior,KEYBOARD_BEHAVIOR,isInTemporaryPosition}=this.__closure;const{detents:detents,closedDetentPosition:closedDetentPosition}=animatedDetentsState.get();if(!detents||detents.length===0||closedDetentPosition===undefined){return SHEET_STATE.CLOSED;}if(animatedPosition.value>=closedDetentPosition){return SHEET_STATE.CLOSED;}const{containerHeight:containerHeight}=animatedLayoutState.get();const extendedPosition=containerHeight-animatedSheetHeight.value;if(animatedPosition.value===extendedPosition){return SHEET_STATE.EXTENDED;}const keyboardHeightInContainer=animatedKeyboardState.get().heightWithinContainer;const extendedPositionWithKeyboard=Math.max(0,containerHeight-(animatedSheetHeight.value+keyboardHeightInContainer));if(keyboardBehavior===KEYBOARD_BEHAVIOR.interactive&&isInTemporaryPosition.value&&animatedPosition.value===extendedPositionWithKeyboard){return SHEET_STATE.EXTENDED;}if(animatedPosition.value===0){return SHEET_STATE.FILL_PARENT;}if(animatedPosition.value<extendedPosition){return SHEET_STATE.OVER_EXTENDED;}return SHEET_STATE.OPENED;}"},p={code:"function gorhom_BottomSheetJs4(){const{animatedDetentsState,animatedLayoutState,isLayoutCalculated,interpolate,animatedPosition,Extrapolation,animatedAnimationState,android_keyboardInputMode,KEYBOARD_INPUT_MODE,ANIMATION_STATUS,ANIMATION_SOURCE,isInTemporaryPosition,animatedCurrentIndex}=this.__closure;const{detents:detents}=animatedDetentsState.get();if(!detents||detents.length===0){return-1;}const adjustedSnapPoints=detents.slice().reverse();const adjustedSnapPointsIndexes=detents.slice().map(function(_,index){return index;}).reverse();const{containerHeight:containerHeight}=animatedLayoutState.get();adjustedSnapPoints.push(containerHeight);adjustedSnapPointsIndexes.push(-1);const currentIndex=isLayoutCalculated.value?interpolate(animatedPosition.value,adjustedSnapPoints,adjustedSnapPointsIndexes,Extrapolation.CLAMP):-1;const{status:animationStatus,source:animationSource,nextIndex:nextIndex,nextPosition:nextPosition}=animatedAnimationState.get();if(android_keyboardInputMode===KEYBOARD_INPUT_MODE.adjustResize&&animationStatus===ANIMATION_STATUS.RUNNING&&animationSource===ANIMATION_SOURCE.KEYBOARD&&isInTemporaryPosition.value){return Math.max(animatedCurrentIndex.value,currentIndex);}if(animationStatus===ANIMATION_STATUS.RUNNING&&animationSource===ANIMATION_SOURCE.SNAP_POINT_CHANGE&&nextIndex!==undefined&&nextPosition!==undefined){return nextIndex;}return currentIndex;}"},B={code:"function gorhom_BottomSheetJs5(){const{cancelAnimation,animatedPosition,animatedAnimationState,ANIMATION_STATUS,ANIMATION_SOURCE}=this.__closure;cancelAnimation(animatedPosition);animatedAnimationState.set({status:ANIMATION_STATUS.STOPPED,source:ANIMATION_SOURCE.NONE});}"},M={code:"function animateToPositionCompleted_Gorhom_BottomSheetJs6(isFinished){const{animatedAnimationState,__DEV__,runOnJS,print,animatedCurrentIndex,handleOnChange,handleOnClose,animatedContainerHeightDidChange,didAnimateOnMount,ANIMATION_STATUS,ANIMATION_SOURCE}=this.__closure;if(!isFinished){return;}const{nextIndex:nextIndex,nextPosition:nextPosition}=animatedAnimationState.get();if(__DEV__){runOnJS(print)({component:'BottomSheet',method:'animateToPositionCompleted',params:{currentIndex:animatedCurrentIndex.value,nextIndex:nextIndex,nextPosition:nextPosition}});}if(nextIndex===undefined||nextPosition===undefined){return;}if(nextIndex!==animatedCurrentIndex.get()){runOnJS(handleOnChange)(nextIndex,nextPosition);}if(nextIndex===-1){runOnJS(handleOnClose)();}animatedCurrentIndex.set(nextIndex);animatedContainerHeightDidChange.set(false);didAnimateOnMount.set(true);animatedAnimationState.set({status:ANIMATION_STATUS.STOPPED,source:ANIMATION_SOURCE.NONE,nextIndex:undefined,nextPosition:undefined,isForcedClosing:undefined});}"},y={code:"function gorhom_BottomSheetJs7(state){const{ANIMATION_STATUS,source,index,position}=this.__closure;return{...state,status:ANIMATION_STATUS.RUNNING,source:source,nextIndex:index,nextPosition:position};}"},H={code:"function animateToPosition_Gorhom_BottomSheetJs8(position,source,velocity=0,configs){const{__DEV__,runOnJS,print,animatedPosition,animatedAnimationState,ANIMATION_STATUS,stopAnimation,animatedKeyboardState,animatedSheetState,KEYBOARD_STATUS,keyboardBehavior,KEYBOARD_BEHAVIOR,ANIMATION_SOURCE,SHEET_STATE,animatedDetentsState,DEFAULT_KEYBOARD_INDEX,_worklet_3054184197869_init_data,handleOnAnimate,animate,_providedAnimationConfigs,_providedOverrideReduceMotion,animateToPositionCompleted}=this.__closure;var _detents$indexOf;if(__DEV__){runOnJS(print)({component:'BottomSheet',method:'animateToPosition',params:{currentPosition:animatedPosition.value,nextPosition:position,source:source}});}if(position===undefined){return;}if(position===animatedPosition.get()){return;}const{status:animationStatus,nextPosition:nextPosition}=animatedAnimationState.get();if(animationStatus===ANIMATION_STATUS.RUNNING&&position===nextPosition){return;}if(animationStatus===ANIMATION_STATUS.RUNNING){stopAnimation();}let offset=0;const{status:status,heightWithinContainer:heightWithinContainer}=animatedKeyboardState.get();const sheetState=animatedSheetState.get();if(status===KEYBOARD_STATUS.SHOWN&&keyboardBehavior!==KEYBOARD_BEHAVIOR.extend&&([ANIMATION_SOURCE.KEYBOARD,ANIMATION_SOURCE.SNAP_POINT_CHANGE].includes(source)||sheetState===SHEET_STATE.OVER_EXTENDED)){offset=heightWithinContainer;}const{detents:detents,closedDetentPosition:closedDetentPosition,highestDetentPosition:highestDetentPosition}=animatedDetentsState.get();let index=(_detents$indexOf=detents===null||detents===void 0?void 0:detents.indexOf(position+offset))!==null&&_detents$indexOf!==void 0?_detents$indexOf:-1;if(index===-1&&status===KEYBOARD_STATUS.SHOWN&&position!==closedDetentPosition){if(detents!==undefined&&highestDetentPosition!==undefined){index=detents.indexOf(highestDetentPosition);}if(index===-1){index=DEFAULT_KEYBOARD_INDEX;}}animatedAnimationState.set(function animateToPosition_Gorhom_BottomSheetJs8({_worklet_3054184197869_init_data:_worklet_3054184197869_init_data,ANIMATION_STATUS:ANIMATION_STATUS,source:source,index:index,position:position}){const gorhom_BottomSheetJs7=function(state){return{...state,status:ANIMATION_STATUS.RUNNING,source:source,nextIndex:index,nextPosition:position};};gorhom_BottomSheetJs7.__closure={ANIMATION_STATUS:ANIMATION_STATUS,source:source,index:index,position:position};gorhom_BottomSheetJs7.__workletHash=3054184197869;gorhom_BottomSheetJs7.__initData=_worklet_3054184197869_init_data;return gorhom_BottomSheetJs7;}({_worklet_3054184197869_init_data:_worklet_3054184197869_init_data,ANIMATION_STATUS:ANIMATION_STATUS,source:source,index:index,position:position}));runOnJS(handleOnAnimate)(index,position);animatedPosition.value=animate({point:position,configs:configs||_providedAnimationConfigs,velocity:velocity,overrideReduceMotion:_providedOverrideReduceMotion,onComplete:animateToPositionCompleted});}"},b={code:"function gorhom_BottomSheetJs9(state){const{targetPosition,index}=this.__closure;return{...state,nextPosition:targetPosition,nextIndex:index};}"},L={code:"function setToPosition_Gorhom_BottomSheetJs10(targetPosition){const{animatedPosition,animatedAnimationState,ANIMATION_STATUS,__DEV__,runOnJS,print,animatedDetentsState,_worklet_3650511913251_init_data,stopAnimation,animatedContainerHeightDidChange}=this.__closure;var _detents$indexOf;if(!targetPosition){return;}if(targetPosition===animatedPosition.get()){return;}const{status:animationStatus,nextPosition:nextPosition}=animatedAnimationState.get();if(animationStatus===ANIMATION_STATUS.RUNNING&&targetPosition===nextPosition){return;}if(__DEV__){runOnJS(print)({component:'BottomSheet',method:'setToPosition',params:{currentPosition:animatedPosition.value,targetPosition:targetPosition}});}const{detents:detents}=animatedDetentsState.get();const index=(_detents$indexOf=detents===null||detents===void 0?void 0:detents.indexOf(targetPosition))!==null&&_detents$indexOf!==void 0?_detents$indexOf:-1;animatedAnimationState.set(function setToPosition_Gorhom_BottomSheetJs10({_worklet_3650511913251_init_data:_worklet_3650511913251_init_data,targetPosition:targetPosition,index:index}){const gorhom_BottomSheetJs9=function(state){return{...state,nextPosition:targetPosition,nextIndex:index};};gorhom_BottomSheetJs9.__closure={targetPosition:targetPosition,index:index};gorhom_BottomSheetJs9.__workletHash=3650511913251;gorhom_BottomSheetJs9.__initData=_worklet_3650511913251_init_data;return gorhom_BottomSheetJs9;}({_worklet_3650511913251_init_data:_worklet_3650511913251_init_data,targetPosition:targetPosition,index:index}));stopAnimation();animatedPosition.value=targetPosition;animatedContainerHeightDidChange.value=false;}"},k={code:"function getEvaluatedPosition_Gorhom_BottomSheetJs11(source){const{animatedCurrentIndex,animatedDetentsState,animatedKeyboardState,ANIMATION_SOURCE,keyboardBlurBehavior,KEYBOARD_BLUR_BEHAVIOR,KEYBOARD_STATUS,animatedContentGestureState,State,animatedHandleGestureState,isInTemporaryPosition,keyboardBehavior,KEYBOARD_BEHAVIOR,Platform,android_keyboardInputMode,animatedPosition,didAnimateOnMount,_providedIndex,animatedAnimationState,ANIMATION_STATUS}=this.__closure;const currentIndex=animatedCurrentIndex.value;const{detents:detents,highestDetentPosition:highestDetentPosition,closedDetentPosition:closedDetentPosition}=animatedDetentsState.get();const keyboardStatus=animatedKeyboardState.get().status;if(detents===undefined||highestDetentPosition===undefined||closedDetentPosition===undefined){return;}if(source===ANIMATION_SOURCE.KEYBOARD&&keyboardBlurBehavior===KEYBOARD_BLUR_BEHAVIOR.restore&&keyboardStatus===KEYBOARD_STATUS.HIDDEN&&animatedContentGestureState.value!==State.ACTIVE&&animatedHandleGestureState.value!==State.ACTIVE){isInTemporaryPosition.value=false;const nextPosition=detents[currentIndex];return nextPosition;}if(keyboardBehavior===KEYBOARD_BEHAVIOR.extend&&keyboardStatus===KEYBOARD_STATUS.SHOWN){return highestDetentPosition;}if(keyboardBehavior===KEYBOARD_BEHAVIOR.fillParent&&keyboardStatus===KEYBOARD_STATUS.SHOWN){isInTemporaryPosition.value=true;return 0;}if(keyboardBehavior===KEYBOARD_BEHAVIOR.interactive&&keyboardStatus===KEYBOARD_STATUS.SHOWN&&!(Platform.OS==='android'&&android_keyboardInputMode==='adjustResize')){isInTemporaryPosition.value=true;const keyboardHeightInContainer=animatedKeyboardState.get().heightWithinContainer;return Math.max(0,highestDetentPosition-keyboardHeightInContainer);}if(isInTemporaryPosition.value){return animatedPosition.value;}if(!didAnimateOnMount.value){return _providedIndex===-1?closedDetentPosition:detents[_providedIndex];}const{status:status,nextIndex:nextIndex,nextPosition:nextPosition}=animatedAnimationState.get();if(source===ANIMATION_SOURCE.SNAP_POINT_CHANGE&&status===ANIMATION_STATUS.RUNNING&&nextIndex!==undefined&&nextPosition!==undefined&&detents[nextIndex]!==nextPosition){return detents[nextIndex];}return detents[currentIndex];}"},K={code:"function evaluatePosition_Gorhom_BottomSheetJs12(source,animationConfigs){const{animatedAnimationState,animatedDetentsState,ANIMATION_SOURCE,isLayoutCalculated,getEvaluatedPosition,didAnimateOnMount,ANIMATION_STATUS,animateOnMount,animateToPosition,setToPosition,INITIAL_VALUE,isInTemporaryPosition,animatedCurrentIndex,reduceMotion,animatedIndex,animatedPosition,animatedContainerHeightDidChange}=this.__closure;const{status:animationStatus,nextIndex:nextIndex,isForcedClosing:isForcedClosing}=animatedAnimationState.get();const{detents:detents,closedDetentPosition:closedDetentPosition}=animatedDetentsState.get();if(detents===undefined||detents.length===0||closedDetentPosition===undefined){return;}if(isForcedClosing&&source!==ANIMATION_SOURCE.USER){return;}if(!isLayoutCalculated.value){return;}const proposedPosition=getEvaluatedPosition(source);if(proposedPosition===undefined){return;}if(!didAnimateOnMount.value){if(animationStatus===ANIMATION_STATUS.RUNNING&&(isForcedClosing||nextIndex===-1)){return;}if(animateOnMount){animateToPosition(proposedPosition,ANIMATION_SOURCE.MOUNT,undefined,animationConfigs);}else{setToPosition(proposedPosition);didAnimateOnMount.value=true;}return;}if(animationStatus===ANIMATION_STATUS.RUNNING){const nextPositionIndex=nextIndex!==null&&nextIndex!==void 0?nextIndex:INITIAL_VALUE;if(nextPositionIndex===-1&&!isInTemporaryPosition.value){setToPosition(closedDetentPosition);return;}if(nextPositionIndex!==animatedCurrentIndex.value){animateToPosition(detents[nextPositionIndex],source,undefined,animationConfigs);return;}}if(animationStatus!==ANIMATION_STATUS.RUNNING&&animatedCurrentIndex.value===-1){if(reduceMotion&&detents[animatedIndex.value]!==animatedPosition.value){return;}setToPosition(closedDetentPosition);return;}if(animatedContainerHeightDidChange.value){setToPosition(proposedPosition);return;}animateToPosition(proposedPosition,source,undefined,animationConfigs);}"},V={code:"function handleSnapToPosition_Gorhom_BottomSheetJs13(position,animationConfigs){const{__DEV__,print,animatedLayoutState,normalizeSnapPoint,animatedAnimationState,isLayoutCalculated,isInTemporaryPosition,runOnUI,animateToPosition,ANIMATION_SOURCE}=this.__closure;if(__DEV__){print({component:'BottomSheet',method:'handleSnapToPosition',params:{position:position}});}const{containerHeight:containerHeight}=animatedLayoutState.get();const targetPosition=normalizeSnapPoint(position,containerHeight);const{nextPosition:nextPosition,isForcedClosing:isForcedClosing}=animatedAnimationState.get();if(!isLayoutCalculated||targetPosition===nextPosition||isForcedClosing){return;}isInTemporaryPosition.value=true;runOnUI(animateToPosition)(targetPosition,ANIMATION_SOURCE.USER,0,animationConfigs);}"},Y={code:"function gorhom_BottomSheetJs14(state){return{...state,isForcedClosing:true};}"},w={code:"function gorhom_BottomSheetJs15(){const{animatedLayoutState}=this.__closure;return animatedLayoutState.get().containerHeight;}"},G={code:"function gorhom_BottomSheetJs16(result,previous){const{INITIAL_LAYOUT_VALUE,animatedContainerHeightDidChange,animatedDetentsState,animatedAnimationState,ANIMATION_STATUS,ANIMATION_SOURCE,animateToPosition}=this.__closure;if(result===INITIAL_LAYOUT_VALUE){return;}animatedContainerHeightDidChange.value=result!==previous;const{closedDetentPosition:closedDetentPosition}=animatedDetentsState.get();if(closedDetentPosition===undefined){return;}const{status:animationStatus,source:animationSource,nextIndex:nextIndex}=animatedAnimationState.get();if(animationStatus===ANIMATION_STATUS.RUNNING&&animationSource===ANIMATION_SOURCE.GESTURE&&nextIndex===-1){animateToPosition(closedDetentPosition,ANIMATION_SOURCE.GESTURE);}}"},J={code:"function gorhom_BottomSheetJs17(){const{animatedDetentsState}=this.__closure;return animatedDetentsState.get().detents;}"},F={code:"function gorhom_BottomSheetJs18(result,previous){const{didAnimateOnMount,isLayoutCalculated,__DEV__,runOnJS,print,evaluatePosition,ANIMATION_SOURCE}=this.__closure;if(JSON.stringify(result)===JSON.stringify(previous)&&didAnimateOnMount.value){return;}if(!isLayoutCalculated.value){return;}if(__DEV__){runOnJS(print)({component:'BottomSheet',method:'useAnimatedReaction::OnSnapPointChange',category:'effect',params:{result:result}});}evaluatePosition(ANIMATION_SOURCE.SNAP_POINT_CHANGE);}"},W={code:"function gorhom_BottomSheetJs19(){const{animatedKeyboardState}=this.__closure;return animatedKeyboardState.get().status+animatedKeyboardState.get().height;}"},j={code:"function gorhom_BottomSheetJs20(result,_previousResult){const{animatedKeyboardState,KEYBOARD_STATUS,animatedAnimationState,ANIMATION_STATUS,ANIMATION_SOURCE,animatedLayoutState,$modal,bottomInset,__DEV__,runOnJS,print,Platform,android_keyboardInputMode,KEYBOARD_INPUT_MODE,keyboardBehavior,KEYBOARD_BEHAVIOR,animatedContentGestureState,State,animatedHandleGestureState,keyboardBlurBehavior,KEYBOARD_BLUR_BEHAVIOR,getKeyboardAnimationConfigs,evaluatePosition}=this.__closure;if(result===_previousResult){return;}const{status:status,height:height,easing:easing,duration:duration,target:target}=animatedKeyboardState.get();if(status===KEYBOARD_STATUS.UNDETERMINED){return;}const{status:animationStatus,source:animationSource}=animatedAnimationState.get();if(status===KEYBOARD_STATUS.HIDDEN&&animationStatus===ANIMATION_STATUS.RUNNING&&animationSource===ANIMATION_SOURCE.GESTURE){return;}const containerOffset=animatedLayoutState.get().containerOffset;let heightWithinContainer=height===0?0:$modal?Math.abs(height-Math.abs(bottomInset-containerOffset.bottom)):Math.abs(height-containerOffset.bottom);if(__DEV__){runOnJS(print)({component:'BottomSheet',method:'useAnimatedReaction::OnKeyboardStateChange',category:'effect',params:{status:status,height:height,heightWithinContainer:heightWithinContainer,containerOffset:containerOffset}});}if(Platform.OS==='android'&&android_keyboardInputMode===KEYBOARD_INPUT_MODE.adjustResize){heightWithinContainer=0;if(keyboardBehavior===KEYBOARD_BEHAVIOR.interactive){animatedKeyboardState.set({target:target,status:status,height:height,easing:easing,duration:duration,heightWithinContainer:heightWithinContainer});return;}}animatedKeyboardState.set(function(state){return{...state,heightWithinContainer:heightWithinContainer};});const hasActiveGesture=animatedContentGestureState.value===State.ACTIVE||animatedContentGestureState.value===State.BEGAN||animatedHandleGestureState.value===State.ACTIVE||animatedHandleGestureState.value===State.BEGAN;if(hasActiveGesture){return;}if(status===KEYBOARD_STATUS.HIDDEN&&keyboardBlurBehavior===KEYBOARD_BLUR_BEHAVIOR.none){return;}const animationConfigs=getKeyboardAnimationConfigs(easing,duration);evaluatePosition(ANIMATION_SOURCE.KEYBOARD,animationConfigs);}"},X={code:"function gorhom_BottomSheetJs21(){const{animatedPosition}=this.__closure;return animatedPosition.value;}"},z={code:"function gorhom_BottomSheetJs22(_animatedPosition){const{_providedAnimatedPosition,topInset}=this.__closure;if(_providedAnimatedPosition){_providedAnimatedPosition.value=_animatedPosition+topInset;}}"},$={code:"function gorhom_BottomSheetJs23(){const{animatedIndex}=this.__closure;return animatedIndex.value;}"},Z={code:"function gorhom_BottomSheetJs24(_animatedIndex){const{_providedAnimatedIndex}=this.__closure;if(_providedAnimatedIndex){_providedAnimatedIndex.value=_animatedIndex;}}"},q=(0,n.forwardRef)(function(t,S){const{animationConfigs:q,index:Q=0,snapPoints:tt,animateOnMount:et=C.DEFAULT_ANIMATE_ON_MOUNT,enableContentPanningGesture:nt=C.DEFAULT_ENABLE_CONTENT_PANNING_GESTURE,enableHandlePanningGesture:it,enableOverDrag:at=C.DEFAULT_ENABLE_OVER_DRAG,enablePanDownToClose:ot=C.DEFAULT_ENABLE_PAN_DOWN_TO_CLOSE,enableDynamicSizing:st=C.DEFAULT_DYNAMIC_SIZING,overDragResistanceFactor:dt=C.DEFAULT_OVER_DRAG_RESISTANCE_FACTOR,overrideReduceMotion:rt,style:_t,containerStyle:ut,backgroundStyle:At,handleStyle:mt,handleIndicatorStyle:St,gestureEventsHandlersHook:lt,keyboardBehavior:It=C.DEFAULT_KEYBOARD_BEHAVIOR,keyboardBlurBehavior:ct=C.DEFAULT_KEYBOARD_BLUR_BEHAVIOR,android_keyboardInputMode:Tt=C.DEFAULT_KEYBOARD_INPUT_MODE,enableBlurKeyboardOnGesture:Ot=C.DEFAULT_ENABLE_BLUR_KEYBOARD_ON_GESTURE,containerLayoutState:Nt,topInset:ht=0,bottomInset:Et=0,maxDynamicContentSize:gt,containerHeight:Pt,containerOffset:Dt,animatedPosition:ft,animatedIndex:Ct,simultaneousHandlers:Ut,waitFor:Rt,activeOffsetX:xt,activeOffsetY:vt,failOffsetX:pt,failOffsetY:Bt,onChange:Mt,onClose:yt,onAnimate:Ht,$modal:bt=!1,detached:Lt=!1,handleComponent:kt=E.BottomSheetHandle,backdropComponent:Kt,backgroundComponent:Vt,footerComponent:Yt,children:wt,accessible:Gt=C.DEFAULT_ACCESSIBLE,accessibilityLabel:Jt=C.DEFAULT_ACCESSIBILITY_LABEL,accessibilityRole:Ft=C.DEFAULT_ACCESSIBILITY_ROLE}=t,Wt=(0,c.useAnimatedLayout)(Nt,ht,Et,bt,null===kt),jt=(0,c.useAnimatedDetents)(tt,Wt,st,gt,Lt,bt,Et),Xt=(0,A.useDerivedValue)((function({_worklet_4739220383715_init_data:t,animatedLayoutState:e,animatedDetentsState:n,INITIAL_LAYOUT_VALUE:o}){const s=function(){const{containerHeight:t}=e.get(),{highestDetentPosition:s}=n.get();return void 0===s?o:t-s};return s.__closure={animatedLayoutState:e,animatedDetentsState:n,INITIAL_LAYOUT_VALUE:o},s.__workletHash=4739220383715,s.__initData=t,s})({_worklet_4739220383715_init_data:R,animatedLayoutState:Wt,animatedDetentsState:jt,INITIAL_LAYOUT_VALUE:l.INITIAL_LAYOUT_VALUE}),[Wt,jt]),zt=(0,c.useReactiveSharedValue)(et?-1:Q),$t=(0,A.useSharedValue)(o.default.get('window').height),Zt=(0,A.useSharedValue)(!et||-1===Q),qt=(0,A.useDerivedValue)((function({_worklet_5675370605537_init_data:t,animatedLayoutState:e,INITIAL_LAYOUT_VALUE:n,handleComponent:o,animatedDetentsState:s}){const _=function(){let t=!1;const{containerHeight:_,handleHeight:u}=e.get();null!=_&&_!==n&&(t=!0);let A=!1;null===o&&(A=!0),u!==n&&(A=!0);let S=!1;const{detents:l}=s.get();return l&&(S=!0),t&&A&&S};return _.__closure={animatedLayoutState:e,INITIAL_LAYOUT_VALUE:n,handleComponent:o,animatedDetentsState:s},_.__workletHash=5675370605537,_.__initData=t,_})({_worklet_5675370605537_init_data:x,animatedLayoutState:Wt,INITIAL_LAYOUT_VALUE:l.INITIAL_LAYOUT_VALUE,handleComponent:kt,animatedDetentsState:jt}),[Wt,jt,kt]),Qt=(0,A.useSharedValue)(!1),te=(0,A.useSharedValue)(!1),ee=(0,A.useSharedValue)(u.State.UNDETERMINED),ne=(0,A.useSharedValue)(u.State.UNDETERMINED),{state:ie,textInputNodesRef:ae}=(0,c.useAnimatedKeyboard)(),oe=(0,A.useReducedMotion)(),se=(0,n.useMemo)(()=>rt&&rt!==A.ReduceMotion.System?rt===A.ReduceMotion.Always:oe,[oe,rt]),de=(0,A.useSharedValue)({status:l.ANIMATION_STATUS.UNDETERMINED,source:l.ANIMATION_SOURCE.MOUNT}),re=(0,A.useDerivedValue)((function({_worklet_13452930535016_init_data:t,animatedDetentsState:e,SHEET_STATE:n,animatedPosition:o,animatedLayoutState:s,animatedSheetHeight:_,animatedKeyboardState:u,keyboardBehavior:A,KEYBOARD_BEHAVIOR:S,isInTemporaryPosition:l}){const I=function(){const{detents:t,closedDetentPosition:I}=e.get();if(!t||0===t.length||void 0===I)return n.CLOSED;if(o.value>=I)return n.CLOSED;const{containerHeight:c}=s.get(),T=c-_.value;if(o.value===T)return n.EXTENDED;const O=u.get().heightWithinContainer,N=Math.max(0,c-(_.value+O));return A===S.interactive&&l.value&&o.value===N?n.EXTENDED:0===o.value?n.FILL_PARENT:o.value<T?n.OVER_EXTENDED:n.OPENED};return I.__closure={animatedDetentsState:e,SHEET_STATE:n,animatedPosition:o,animatedLayoutState:s,animatedSheetHeight:_,animatedKeyboardState:u,keyboardBehavior:A,KEYBOARD_BEHAVIOR:S,isInTemporaryPosition:l},I.__workletHash=0xc3c41254e68,I.__initData=t,I})({_worklet_13452930535016_init_data:v,animatedDetentsState:jt,SHEET_STATE:l.SHEET_STATE,animatedPosition:$t,animatedLayoutState:Wt,animatedSheetHeight:Xt,animatedKeyboardState:ie,keyboardBehavior:It,KEYBOARD_BEHAVIOR:l.KEYBOARD_BEHAVIOR,isInTemporaryPosition:Qt}),[Wt,jt,ie,$t,Xt,Qt,It]),{state:ue,status:Ae,setScrollableRef:me,removeScrollableRef:Se}=(0,c.useScrollable)(nt,re,ie,de),le=(0,A.useDerivedValue)((function({_worklet_14040060957476_init_data:t,animatedDetentsState:e,animatedLayoutState:n,isLayoutCalculated:o,interpolate:s,animatedPosition:_,Extrapolation:u,animatedAnimationState:A,android_keyboardInputMode:S,KEYBOARD_INPUT_MODE:l,ANIMATION_STATUS:I,ANIMATION_SOURCE:c,isInTemporaryPosition:T,animatedCurrentIndex:O}){const N=function(){const{detents:t}=e.get();if(!t||0===t.length)return-1;const N=t.slice().reverse(),h=t.slice().map((t,e)=>e).reverse(),{containerHeight:E}=n.get();N.push(E),h.push(-1);const P=o.value?s(_.value,N,h,u.CLAMP):-1,{status:D,source:f,nextIndex:C,nextPosition:U}=A.get();return S===l.adjustResize&&D===I.RUNNING&&f===c.KEYBOARD&&T.value?Math.max(O.value,P):D===I.RUNNING&&f===c.SNAP_POINT_CHANGE&&void 0!==C&&void 0!==U?C:P};return N.__closure={animatedDetentsState:e,animatedLayoutState:n,isLayoutCalculated:o,interpolate:s,animatedPosition:_,Extrapolation:u,animatedAnimationState:A,android_keyboardInputMode:S,KEYBOARD_INPUT_MODE:l,ANIMATION_STATUS:I,ANIMATION_SOURCE:c,isInTemporaryPosition:T,animatedCurrentIndex:O},N.__workletHash=0xcc4f4d89324,N.__initData=t,N})({_worklet_14040060957476_init_data:p,animatedDetentsState:jt,animatedLayoutState:Wt,isLayoutCalculated:qt,interpolate:A.interpolate,animatedPosition:$t,Extrapolation:A.Extrapolation,animatedAnimationState:de,android_keyboardInputMode:Tt,KEYBOARD_INPUT_MODE:l.KEYBOARD_INPUT_MODE,ANIMATION_STATUS:l.ANIMATION_STATUS,ANIMATION_SOURCE:l.ANIMATION_SOURCE,isInTemporaryPosition:Qt,animatedCurrentIndex:zt}),[Tt,de,Wt,zt,$t,jt,Qt,qt]),Ie=(0,n.useCallback)(function(t,e){if(!Mt)return;const{dynamicDetentIndex:n}=jt.get();Mt(t,e,t===n?l.SNAP_POINT_TYPE.DYNAMIC:l.SNAP_POINT_TYPE.PROVIDED)},[Mt,jt]),ce=(0,n.useCallback)(function(t,e){t!==zt.get()&&Ht&&Ht(zt.value,t,$t.value,e)},[Ht,zt,$t]),Te=(0,n.useCallback)(function(){yt&&yt()},[yt]),Oe=(0,n.useCallback)((function({_worklet_12445268428881_init_data:t,cancelAnimation:e,animatedPosition:n,animatedAnimationState:o,ANIMATION_STATUS:s,ANIMATION_SOURCE:_}){const u=function(){e(n),o.set({status:s.STOPPED,source:_.NONE})};return u.__closure={cancelAnimation:e,animatedPosition:n,animatedAnimationState:o,ANIMATION_STATUS:s,ANIMATION_SOURCE:_},u.__workletHash=0xb51a3cdc851,u.__initData=t,u})({_worklet_12445268428881_init_data:B,cancelAnimation:A.cancelAnimation,animatedPosition:$t,animatedAnimationState:de,ANIMATION_STATUS:l.ANIMATION_STATUS,ANIMATION_SOURCE:l.ANIMATION_SOURCE}),[$t,de]),Ne=(0,n.useCallback)((function({_worklet_6749885698847_init_data:t,animatedAnimationState:e,__DEV__:n,runOnJS:o,print:s,animatedCurrentIndex:_,handleOnChange:u,handleOnClose:A,animatedContainerHeightDidChange:S,didAnimateOnMount:l,ANIMATION_STATUS:I,ANIMATION_SOURCE:c}){const T=function(t){if(!t)return;const{nextIndex:T,nextPosition:O}=e.get();n&&o(s)({component:'BottomSheet',method:'animateToPositionCompleted',params:{currentIndex:_.value,nextIndex:T,nextPosition:O}}),void 0!==T&&void 0!==O&&(T!==_.get()&&o(u)(T,O),-1===T&&o(A)(),_.set(T),S.set(!1),l.set(!0),e.set({status:I.STOPPED,source:c.NONE,nextIndex:void 0,nextPosition:void 0,isForcedClosing:void 0}))};return T.__closure={animatedAnimationState:e,__DEV__:n,runOnJS:o,print:s,animatedCurrentIndex:_,handleOnChange:u,handleOnClose:A,animatedContainerHeightDidChange:S,didAnimateOnMount:l,ANIMATION_STATUS:I,ANIMATION_SOURCE:c},T.__workletHash=6749885698847,T.__initData=t,T})({_worklet_6749885698847_init_data:M,animatedAnimationState:de,__DEV__:!1,runOnJS:A.runOnJS,print:T.print,animatedCurrentIndex:zt,handleOnChange:Ie,handleOnClose:Te,animatedContainerHeightDidChange:te,didAnimateOnMount:Zt,ANIMATION_STATUS:l.ANIMATION_STATUS,ANIMATION_SOURCE:l.ANIMATION_SOURCE}),[Ie,Te,zt,de,te,Zt]),he=(0,n.useCallback)((function({_worklet_7080750884016_init_data:t,__DEV__:e,runOnJS:n,print:o,animatedPosition:s,animatedAnimationState:_,ANIMATION_STATUS:u,stopAnimation:A,animatedKeyboardState:S,animatedSheetState:l,KEYBOARD_STATUS:I,keyboardBehavior:c,KEYBOARD_BEHAVIOR:T,ANIMATION_SOURCE:O,SHEET_STATE:N,animatedDetentsState:h,DEFAULT_KEYBOARD_INDEX:E,_worklet_3054184197869_init_data:P,handleOnAnimate:D,animate:f,_providedAnimationConfigs:C,_providedOverrideReduceMotion:U,animateToPositionCompleted:R}){const x=function(t,x,v=0,p){if(e&&n(o)({component:'BottomSheet',method:'animateToPosition',params:{currentPosition:s.value,nextPosition:t,source:x}}),void 0===t)return;if(t===s.get())return;const{status:B,nextPosition:M}=_.get();if(B===u.RUNNING&&t===M)return;B===u.RUNNING&&A();let y=0;const{status:H,heightWithinContainer:b}=S.get(),L=l.get();H!==I.SHOWN||c===T.extend||![O.KEYBOARD,O.SNAP_POINT_CHANGE].includes(x)&&L!==N.OVER_EXTENDED||(y=b);const{detents:k,closedDetentPosition:K,highestDetentPosition:V}=h.get();let Y=k?.indexOf(t+y)??-1;-1===Y&&H===I.SHOWN&&t!==K&&(void 0!==k&&void 0!==V&&(Y=k.indexOf(V)),-1===Y&&(Y=E)),_.set((function({_worklet_3054184197869_init_data:t,ANIMATION_STATUS:e,source:n,index:o,position:s}){const _=function(t){return Object.assign({},t,{status:e.RUNNING,source:n,nextIndex:o,nextPosition:s})};return _.__closure={ANIMATION_STATUS:e,source:n,index:o,position:s},_.__workletHash=3054184197869,_.__initData=t,_})({_worklet_3054184197869_init_data:P,ANIMATION_STATUS:u,source:x,index:Y,position:t})),n(D)(Y,t),s.value=f({point:t,configs:p||C,velocity:v,overrideReduceMotion:U,onComplete:R})};return x.__closure={__DEV__:e,runOnJS:n,print:o,animatedPosition:s,animatedAnimationState:_,ANIMATION_STATUS:u,stopAnimation:A,animatedKeyboardState:S,animatedSheetState:l,KEYBOARD_STATUS:I,keyboardBehavior:c,KEYBOARD_BEHAVIOR:T,ANIMATION_SOURCE:O,SHEET_STATE:N,animatedDetentsState:h,DEFAULT_KEYBOARD_INDEX:E,_worklet_3054184197869_init_data:P,handleOnAnimate:D,animate:f,_providedAnimationConfigs:C,_providedOverrideReduceMotion:U,animateToPositionCompleted:R},x.__workletHash=7080750884016,x.__initData=t,x})({_worklet_7080750884016_init_data:H,__DEV__:!1,runOnJS:A.runOnJS,print:T.print,animatedPosition:$t,animatedAnimationState:de,ANIMATION_STATUS:l.ANIMATION_STATUS,stopAnimation:Oe,animatedKeyboardState:ie,animatedSheetState:re,KEYBOARD_STATUS:l.KEYBOARD_STATUS,keyboardBehavior:It,KEYBOARD_BEHAVIOR:l.KEYBOARD_BEHAVIOR,ANIMATION_SOURCE:l.ANIMATION_SOURCE,SHEET_STATE:l.SHEET_STATE,animatedDetentsState:jt,DEFAULT_KEYBOARD_INDEX:C.DEFAULT_KEYBOARD_INDEX,_worklet_3054184197869_init_data:y,handleOnAnimate:ce,animate:T.animate,_providedAnimationConfigs:q,_providedOverrideReduceMotion:rt,animateToPositionCompleted:Ne}),[ce,Oe,Ne,It,q,rt,jt,de,ie,$t,re]),Ee=(0,n.useCallback)((function({_worklet_17559292240469_init_data:t,animatedPosition:e,animatedAnimationState:n,ANIMATION_STATUS:o,__DEV__:s,runOnJS:_,print:u,animatedDetentsState:A,_worklet_3650511913251_init_data:S,stopAnimation:l,animatedContainerHeightDidChange:I}){const c=function(t){if(!t)return;if(t===e.get())return;const{status:c,nextPosition:T}=n.get();if(c===o.RUNNING&&t===T)return;s&&_(u)({component:'BottomSheet',method:'setToPosition',params:{currentPosition:e.value,targetPosition:t}});const{detents:O}=A.get(),N=O?.indexOf(t)??-1;n.set((function({_worklet_3650511913251_init_data:t,targetPosition:e,index:n}){const o=function(t){return Object.assign({},t,{nextPosition:e,nextIndex:n})};return o.__closure={targetPosition:e,index:n},o.__workletHash=3650511913251,o.__initData=t,o})({_worklet_3650511913251_init_data:S,targetPosition:t,index:N})),l(),e.value=t,I.value=!1};return c.__closure={animatedPosition:e,animatedAnimationState:n,ANIMATION_STATUS:o,__DEV__:s,runOnJS:_,print:u,animatedDetentsState:A,_worklet_3650511913251_init_data:S,stopAnimation:l,animatedContainerHeightDidChange:I},c.__workletHash=0xff857606255,c.__initData=t,c})({_worklet_17559292240469_init_data:L,animatedPosition:$t,animatedAnimationState:de,ANIMATION_STATUS:l.ANIMATION_STATUS,__DEV__:!1,runOnJS:A.runOnJS,print:T.print,animatedDetentsState:jt,_worklet_3650511913251_init_data:b,stopAnimation:Oe,animatedContainerHeightDidChange:te}),[Oe,$t,te,de,jt]),ge=(0,n.useCallback)((function({_worklet_14289569669057_init_data:t,animatedCurrentIndex:e,animatedDetentsState:n,animatedKeyboardState:o,ANIMATION_SOURCE:s,keyboardBlurBehavior:_,KEYBOARD_BLUR_BEHAVIOR:u,KEYBOARD_STATUS:A,animatedContentGestureState:S,State:l,animatedHandleGestureState:I,isInTemporaryPosition:c,keyboardBehavior:T,KEYBOARD_BEHAVIOR:O,Platform:N,android_keyboardInputMode:h,animatedPosition:E,didAnimateOnMount:P,_providedIndex:D,animatedAnimationState:f,ANIMATION_STATUS:C}){const U=function(t){const N=e.value,{detents:h,highestDetentPosition:U,closedDetentPosition:R}=n.get(),x=o.get().status;if(void 0===h||void 0===U||void 0===R)return;if(t===s.KEYBOARD&&_===u.restore&&x===A.HIDDEN&&S.value!==l.ACTIVE&&I.value!==l.ACTIVE){c.value=!1;return h[N]}if(T===O.extend&&x===A.SHOWN)return U;if(T===O.fillParent&&x===A.SHOWN)return c.value=!0,0;if(T===O.interactive&&x===A.SHOWN){c.value=!0;const t=o.get().heightWithinContainer;return Math.max(0,U-t)}if(c.value)return E.value;if(!P.value)return-1===D?R:h[D];const{status:v,nextIndex:p,nextPosition:B}=f.get();return t===s.SNAP_POINT_CHANGE&&v===C.RUNNING&&void 0!==p&&void 0!==B&&h[p]!==B?h[p]:h[N]};return U.__closure={animatedCurrentIndex:e,animatedDetentsState:n,animatedKeyboardState:o,ANIMATION_SOURCE:s,keyboardBlurBehavior:_,KEYBOARD_BLUR_BEHAVIOR:u,KEYBOARD_STATUS:A,animatedContentGestureState:S,State:l,animatedHandleGestureState:I,isInTemporaryPosition:c,keyboardBehavior:T,KEYBOARD_BEHAVIOR:O,Platform:N,android_keyboardInputMode:h,animatedPosition:E,didAnimateOnMount:P,_providedIndex:D,animatedAnimationState:f,ANIMATION_STATUS:C},U.__workletHash=0xcff0cb95fc1,U.__initData=t,U})({_worklet_14289569669057_init_data:k,animatedCurrentIndex:zt,animatedDetentsState:jt,animatedKeyboardState:ie,ANIMATION_SOURCE:l.ANIMATION_SOURCE,keyboardBlurBehavior:ct,KEYBOARD_BLUR_BEHAVIOR:l.KEYBOARD_BLUR_BEHAVIOR,KEYBOARD_STATUS:l.KEYBOARD_STATUS,animatedContentGestureState:ee,State:u.State,animatedHandleGestureState:ne,isInTemporaryPosition:Qt,keyboardBehavior:It,KEYBOARD_BEHAVIOR:l.KEYBOARD_BEHAVIOR,Platform:s.default,android_keyboardInputMode:Tt,animatedPosition:$t,didAnimateOnMount:Zt,_providedIndex:Q,animatedAnimationState:de,ANIMATION_STATUS:l.ANIMATION_STATUS}),[ee,zt,ne,de,ie,$t,jt,Qt,Zt,It,ct,Q,Tt]),Pe=(0,n.useCallback)((function({_worklet_11430790997000_init_data:t,animatedAnimationState:e,animatedDetentsState:n,ANIMATION_SOURCE:o,isLayoutCalculated:s,getEvaluatedPosition:_,didAnimateOnMount:u,ANIMATION_STATUS:A,animateOnMount:S,animateToPosition:l,setToPosition:I,INITIAL_VALUE:c,isInTemporaryPosition:T,animatedCurrentIndex:O,reduceMotion:N,animatedIndex:h,animatedPosition:E,animatedContainerHeightDidChange:P}){const D=function(t,D){const{status:f,nextIndex:C,isForcedClosing:U}=e.get(),{detents:R,closedDetentPosition:x}=n.get();if(void 0===R||0===R.length||void 0===x)return;if(U&&t!==o.USER)return;if(!s.value)return;const v=_(t);if(void 0!==v)if(u.value){if(f===A.RUNNING){const e=C??c;if(-1===e&&!T.value)return void I(x);if(e!==O.value)return void l(R[e],t,void 0,D)}if(f===A.RUNNING||-1!==O.value)P.value?I(v):l(v,t,void 0,D);else{if(N&&R[h.value]!==E.value)return;I(x)}}else{if(f===A.RUNNING&&(U||-1===C))return;S?l(v,o.MOUNT,void 0,D):(I(v),u.value=!0)}};return D.__closure={animatedAnimationState:e,animatedDetentsState:n,ANIMATION_SOURCE:o,isLayoutCalculated:s,getEvaluatedPosition:_,didAnimateOnMount:u,ANIMATION_STATUS:A,animateOnMount:S,animateToPosition:l,setToPosition:I,INITIAL_VALUE:c,isInTemporaryPosition:T,animatedCurrentIndex:O,reduceMotion:N,animatedIndex:h,animatedPosition:E,animatedContainerHeightDidChange:P},D.__workletHash=0xa65703ca408,D.__initData=t,D})({_worklet_11430790997000_init_data:K,animatedAnimationState:de,animatedDetentsState:jt,ANIMATION_SOURCE:l.ANIMATION_SOURCE,isLayoutCalculated:qt,getEvaluatedPosition:ge,didAnimateOnMount:Zt,ANIMATION_STATUS:l.ANIMATION_STATUS,animateOnMount:et,animateToPosition:he,setToPosition:Ee,INITIAL_VALUE:C.INITIAL_VALUE,isInTemporaryPosition:Qt,animatedCurrentIndex:zt,reduceMotion:se,animatedIndex:le,animatedPosition:$t,animatedContainerHeightDidChange:te}),[ge,he,Ee,se,et,de,te,zt,le,$t,jt,Zt,Qt,qt]),De=(0,c.useStableCallback)(function(t,n){const{detents:o}=jt.get(),s=qt.get();if(void 0===o||0===o.length)return;if(!s)return;(0,e.default)(t>=-1&&t<=o.length-1,"'index' was provided but out of the provided snap points range! expected value to be between -1, "+(o.length-1));const _=o[t],{nextPosition:u,nextIndex:S,isForcedClosing:I}=de.get();qt.value&&t!==S&&_!==u&&!I&&(Qt.value=!1,(0,A.runOnUI)(he)(_,l.ANIMATION_SOURCE.USER,0,n))}),fe=(0,n.useCallback)((function({_worklet_11461861112613_init_data:t,__DEV__:e,print:n,animatedLayoutState:o,normalizeSnapPoint:s,animatedAnimationState:_,isLayoutCalculated:u,isInTemporaryPosition:A,runOnUI:S,animateToPosition:l,ANIMATION_SOURCE:I}){const c=function(t,c){e&&n({component:'BottomSheet',method:'handleSnapToPosition',params:{position:t}});const{containerHeight:T}=o.get(),O=s(t,T),{nextPosition:N,isForcedClosing:h}=_.get();u&&O!==N&&!h&&(A.value=!0,S(l)(O,I.USER,0,c))};return c.__closure={__DEV__:e,print:n,animatedLayoutState:o,normalizeSnapPoint:s,animatedAnimationState:_,isLayoutCalculated:u,isInTemporaryPosition:A,runOnUI:S,animateToPosition:l,ANIMATION_SOURCE:I},c.__workletHash=0xa6cac28fb25,c.__initData=t,c})({_worklet_11461861112613_init_data:V,__DEV__:!1,print:T.print,animatedLayoutState:Wt,normalizeSnapPoint:T.normalizeSnapPoint,animatedAnimationState:de,isLayoutCalculated:qt,isInTemporaryPosition:Qt,runOnUI:A.runOnUI,animateToPosition:he,ANIMATION_SOURCE:l.ANIMATION_SOURCE}),[he,Qt,qt,Wt,de]),Ce=(0,n.useCallback)(function(t){const e=jt.get().closedDetentPosition;if(void 0===e)return;const n=e,{nextPosition:o,isForcedClosing:s}=de.get();qt.value&&n!==o&&!s&&(Qt.value=!1,(0,A.runOnUI)(he)(n,l.ANIMATION_SOURCE.USER,0,t))},[he,qt,Qt,jt,de]),Ue=(0,n.useCallback)(function(t){const e=jt.get().closedDetentPosition;if(void 0===e)return;const n=e,{nextPosition:o,isForcedClosing:s}=de.get();n===o||s||(Qt.value=!1,de.set((function({_worklet_11886015550520_init_data:t}){const e=function(t){return Object.assign({},t,{isForcedClosing:!0})};return e.__closure={},e.__workletHash=0xacf6dbc1438,e.__initData=t,e})({_worklet_11886015550520_init_data:Y})),(0,A.runOnUI)(he)(n,l.ANIMATION_SOURCE.USER,0,t))},[he,Qt,jt,de]),Re=(0,n.useCallback)(function(t){const{detents:e}=jt.get();if(void 0===e||0===e.length)return;const n=e.length-1,o=e[n],{nextPosition:s,nextIndex:_,isForcedClosing:u}=de.get();qt.value&&n!==_&&o!==s&&!u&&(Qt.value=!1,(0,A.runOnUI)(he)(o,l.ANIMATION_SOURCE.USER,0,t))},[he,Qt,qt,jt,de]),xe=(0,n.useCallback)(function(t){const{detents:e}=jt.get();if(void 0===e||0===e.length)return;const n=e[0],{nextPosition:o,nextIndex:s,isForcedClosing:_}=de.get();qt&&0!==s&&n!==o&&!_&&(Qt.value=!1,(0,A.runOnUI)(he)(n,l.ANIMATION_SOURCE.USER,0,t))},[he,qt,Qt,jt,de]);(0,n.useImperativeHandle)(S,()=>({snapToIndex:De,snapToPosition:fe,expand:Re,collapse:xe,close:Ce,forceClose:Ue}));const ve=(0,n.useMemo)(()=>({textInputNodesRef:ae,enableContentPanningGesture:nt,enableDynamicSizing:st,overDragResistanceFactor:dt,enableOverDrag:at,enablePanDownToClose:ot,animatedAnimationState:de,animatedSheetState:re,animatedScrollableState:ue,animatedScrollableStatus:Ae,animatedContentGestureState:ee,animatedHandleGestureState:ne,animatedKeyboardState:ie,animatedLayoutState:Wt,animatedIndex:le,animatedPosition:$t,animatedSheetHeight:Xt,animatedDetentsState:jt,isInTemporaryPosition:Qt,simultaneousHandlers:Ut,waitFor:Rt,activeOffsetX:xt,activeOffsetY:vt,failOffsetX:pt,failOffsetY:Bt,enableBlurKeyboardOnGesture:Ot,animateToPosition:he,stopAnimation:Oe,setScrollableRef:me,removeScrollableRef:Se}),[ae,le,$t,Xt,Wt,ee,ne,de,ie,re,ue,Ae,jt,Qt,nt,dt,at,ot,st,Ot,Ut,Rt,xt,vt,pt,Bt,me,Se,he,Oe]),pe=(0,n.useMemo)(()=>({animatedIndex:le,animatedPosition:$t,snapToIndex:De,snapToPosition:fe,expand:Re,collapse:xe,close:Ce,forceClose:Ue}),[le,$t,De,fe,Re,xe,Ce,Ue]);return(0,A.useAnimatedReaction)((function({_worklet_3740846712338_init_data:t,animatedLayoutState:e}){const n=()=>e.get().containerHeight;return n.__closure={animatedLayoutState:e},n.__workletHash=3740846712338,n.__initData=t,n})({_worklet_3740846712338_init_data:w,animatedLayoutState:Wt}),(function({_worklet_7305691804640_init_data:t,INITIAL_LAYOUT_VALUE:e,animatedContainerHeightDidChange:n,animatedDetentsState:o,animatedAnimationState:s,ANIMATION_STATUS:_,ANIMATION_SOURCE:u,animateToPosition:A}){const S=function(t,S){if(t===e)return;n.value=t!==S;const{closedDetentPosition:l}=o.get();if(void 0===l)return;const{status:I,source:c,nextIndex:T}=s.get();I===_.RUNNING&&c===u.GESTURE&&-1===T&&A(l,u.GESTURE)};return S.__closure={INITIAL_LAYOUT_VALUE:e,animatedContainerHeightDidChange:n,animatedDetentsState:o,animatedAnimationState:s,ANIMATION_STATUS:_,ANIMATION_SOURCE:u,animateToPosition:A},S.__workletHash=7305691804640,S.__initData=t,S})({_worklet_7305691804640_init_data:G,INITIAL_LAYOUT_VALUE:l.INITIAL_LAYOUT_VALUE,animatedContainerHeightDidChange:te,animatedDetentsState:jt,animatedAnimationState:de,ANIMATION_STATUS:l.ANIMATION_STATUS,ANIMATION_SOURCE:l.ANIMATION_SOURCE,animateToPosition:he}),[te,de,jt]),(0,A.useAnimatedReaction)((function({_worklet_2047626166417_init_data:t,animatedDetentsState:e}){const n=()=>e.get().detents;return n.__closure={animatedDetentsState:e},n.__workletHash=2047626166417,n.__initData=t,n})({_worklet_2047626166417_init_data:J,animatedDetentsState:jt}),(function({_worklet_2736065060575_init_data:t,didAnimateOnMount:e,isLayoutCalculated:n,__DEV__:o,runOnJS:s,print:_,evaluatePosition:u,ANIMATION_SOURCE:A}){const S=function(t,S){JSON.stringify(t)===JSON.stringify(S)&&e.value||n.value&&(o&&s(_)({component:'BottomSheet',method:'useAnimatedReaction::OnSnapPointChange',category:'effect',params:{result:t}}),u(A.SNAP_POINT_CHANGE))};return S.__closure={didAnimateOnMount:e,isLayoutCalculated:n,__DEV__:o,runOnJS:s,print:_,evaluatePosition:u,ANIMATION_SOURCE:A},S.__workletHash=2736065060575,S.__initData=t,S})({_worklet_2736065060575_init_data:F,didAnimateOnMount:Zt,isLayoutCalculated:qt,__DEV__:!1,runOnJS:A.runOnJS,print:T.print,evaluatePosition:Pe,ANIMATION_SOURCE:l.ANIMATION_SOURCE}),[qt,Zt,jt]),(0,A.useAnimatedReaction)((function({_worklet_3372124159444_init_data:t,animatedKeyboardState:e}){const n=()=>e.get().status+e.get().height;return n.__closure={animatedKeyboardState:e},n.__workletHash=3372124159444,n.__initData=t,n})({_worklet_3372124159444_init_data:W,animatedKeyboardState:ie}),(function({_worklet_784372441099_init_data:t,animatedKeyboardState:e,KEYBOARD_STATUS:n,animatedAnimationState:o,ANIMATION_STATUS:s,ANIMATION_SOURCE:_,animatedLayoutState:u,$modal:A,bottomInset:S,__DEV__:l,runOnJS:I,print:c,Platform:T,android_keyboardInputMode:O,KEYBOARD_INPUT_MODE:N,keyboardBehavior:h,KEYBOARD_BEHAVIOR:E,animatedContentGestureState:P,State:D,animatedHandleGestureState:f,keyboardBlurBehavior:C,KEYBOARD_BLUR_BEHAVIOR:U,getKeyboardAnimationConfigs:R,evaluatePosition:x}){const v=function(t,T){if(t===T)return;const{status:O,height:N,easing:h,duration:E,target:v}=e.get();if(O===n.UNDETERMINED)return;const{status:p,source:B}=o.get();if(O===n.HIDDEN&&p===s.RUNNING&&B===_.GESTURE)return;const M=u.get().containerOffset;let y=0===N?0:A?Math.abs(N-Math.abs(S-M.bottom)):Math.abs(N-M.bottom);l&&I(c)({component:'BottomSheet',method:'useAnimatedReaction::OnKeyboardStateChange',category:'effect',params:{status:O,height:N,heightWithinContainer:y,containerOffset:M}}),e.set(t=>Object.assign({},t,{heightWithinContainer:y}));if(P.value===D.ACTIVE||P.value===D.BEGAN||f.value===D.ACTIVE||f.value===D.BEGAN)return;if(O===n.HIDDEN&&C===U.none)return;const H=R(h,E);x(_.KEYBOARD,H)};return v.__closure={animatedKeyboardState:e,KEYBOARD_STATUS:n,animatedAnimationState:o,ANIMATION_STATUS:s,ANIMATION_SOURCE:_,animatedLayoutState:u,$modal:A,bottomInset:S,__DEV__:l,runOnJS:I,print:c,Platform:T,android_keyboardInputMode:O,KEYBOARD_INPUT_MODE:N,keyboardBehavior:h,KEYBOARD_BEHAVIOR:E,animatedContentGestureState:P,State:D,animatedHandleGestureState:f,keyboardBlurBehavior:C,KEYBOARD_BLUR_BEHAVIOR:U,getKeyboardAnimationConfigs:R,evaluatePosition:x},v.__workletHash=784372441099,v.__initData=t,v})({_worklet_784372441099_init_data:j,animatedKeyboardState:ie,KEYBOARD_STATUS:l.KEYBOARD_STATUS,animatedAnimationState:de,ANIMATION_STATUS:l.ANIMATION_STATUS,ANIMATION_SOURCE:l.ANIMATION_SOURCE,animatedLayoutState:Wt,$modal:bt,bottomInset:Et,__DEV__:!1,runOnJS:A.runOnJS,print:T.print,Platform:s.default,android_keyboardInputMode:Tt,KEYBOARD_INPUT_MODE:l.KEYBOARD_INPUT_MODE,keyboardBehavior:It,KEYBOARD_BEHAVIOR:l.KEYBOARD_BEHAVIOR,animatedContentGestureState:ee,State:u.State,animatedHandleGestureState:ne,keyboardBlurBehavior:ct,KEYBOARD_BLUR_BEHAVIOR:l.KEYBOARD_BLUR_BEHAVIOR,getKeyboardAnimationConfigs:T.getKeyboardAnimationConfigs,evaluatePosition:Pe}),[bt,Et,It,ct,Tt,ie,Wt,ge]),(0,A.useAnimatedReaction)((function({_worklet_150016498047_init_data:t,animatedPosition:e}){const n=()=>e.value;return n.__closure={animatedPosition:e},n.__workletHash=150016498047,n.__initData=t,n})({_worklet_150016498047_init_data:X,animatedPosition:$t}),(function({_worklet_14307923316202_init_data:t,_providedAnimatedPosition:e,topInset:n}){const o=function(t){e&&(e.value=t+n)};return o.__closure={_providedAnimatedPosition:e,topInset:n},o.__workletHash=0xd0352afcdea,o.__initData=t,o})({_worklet_14307923316202_init_data:z,_providedAnimatedPosition:ft,topInset:ht}),[ft,ht]),(0,A.useAnimatedReaction)((function({_worklet_1413329246429_init_data:t,animatedIndex:e}){const n=()=>e.value;return n.__closure={animatedIndex:e},n.__workletHash=1413329246429,n.__initData=t,n})({_worklet_1413329246429_init_data:$,animatedIndex:le}),(function({_worklet_11790345600748_init_data:t,_providedAnimatedIndex:e}){const n=function(t){e&&(e.value=t)};return n.__closure={_providedAnimatedIndex:e},n.__workletHash=0xab9275c7eec,n.__initData=t,n})({_worklet_11790345600748_init_data:Z,_providedAnimatedIndex:Ct}),[Ct]),(0,n.useEffect)(()=>{et&&!Zt.value||De(Q)},[et,Q,Zt,De]),(0,U.jsx)(I.BottomSheetProvider,{value:pe,children:(0,U.jsx)(I.BottomSheetInternalProvider,{value:ve,children:(0,U.jsxs)(h.default,{gestureEventsHandlersHook:lt,children:[Kt?(0,U.jsx)(Kt,{animatedIndex:le,animatedPosition:$t,style:_.default.absoluteFill}):null,(0,U.jsx)(P.BottomSheetHostingContainer,{shouldCalculateHeight:!bt,layoutState:Wt,containerLayoutState:Nt,topInset:ht,bottomInset:Et,detached:Lt,style:ut,children:(0,U.jsxs)(D.BottomSheetBody,{style:_t,children:[null===Vt?null:(0,U.jsx)(O.BottomSheetBackgroundContainer,{animatedIndex:le,animatedPosition:$t,backgroundComponent:Vt,backgroundStyle:At},"BottomSheetBackgroundContainer"),(0,U.jsxs)(f.BottomSheetContent,{pointerEvents:"box-none",accessible:Gt??void 0,accessibilityRole:Ft??void 0,accessibilityLabel:Jt??void 0,keyboardBehavior:It,detached:Lt,children:[wt,Yt?(0,U.jsx)(N.BottomSheetFooterContainer,{footerComponent:Yt}):null]}),null!==kt?(0,U.jsx)(E.BottomSheetHandleContainer,{animatedIndex:le,animatedPosition:$t,enableHandlePanningGesture:it,enableOverDrag:at,enablePanDownToClose:ot,overDragResistanceFactor:dt,keyboardBehavior:It,handleComponent:kt,handleStyle:mt,handleIndicatorStyle:St},"BottomSheetHandleContainer"):null]})},"BottomSheetContainer")]})})})}),Q=(0,n.memo)(q);Q.displayName='BottomSheet';var tt=Q},2481,[42,36,183,25,59,2482,2570,2929,2930,2936,2942,2966,2970,2974,2976,2981,2984,2986,2961,279]);
|
|
@@ -14916,7 +14916,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
14916
14916
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"create",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]);const c=e=>e;function l(e,t=c){const n=u.default.useSyncExternalStore(e.subscribe,u.default.useCallback(()=>t(e.getState()),[e,t]),u.default.useCallback(()=>t(e.getInitialState()),[e,t]));return u.default.useDebugValue(n),n}const s=e=>{const t=(0,n.createStore)(e),u=e=>l(t,e);return Object.assign(u,t),u},o=e=>e?s(e):s},3271,[36,3270]);
|
|
14917
14917
|
__d(function(g,r,i,a,m,e,d){"use strict";function t(){let t=1;const n=new Map;return{registerHandler:o=>(n.set(o.handlerId,Object.assign({},o,{registeredAt:t++})),()=>{n.get(o.handlerId)&&n.delete(o.handlerId)}),dispatch(t){const o=Array.from(n.values()).filter(n=>n.actions.includes(t.id)).filter(t=>t.enabled).filter(t=>!t.isActive||t.isActive()).sort((t,n)=>t.priority!==n.priority?n.priority-t.priority:n.registeredAt-t.registeredAt);for(const n of o)if(n.handle(t))return!0;return!1}}}Object.defineProperty(e,'__esModule',{value:!0}),e.createKeyboardActionDispatcher=t,Object.defineProperty(e,"keyboardActionDispatcher",{enumerable:!0,get:function(){return n}});const n=t()},3272,[]);
|
|
14918
14918
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.allSessionsQueryKey=n,_e.useAllSessionsList=function(o){const u=(0,e.c)(14),{serverId:c,enabled:y}=o,f=(0,t.useHostRuntimeClient)(c??""),v=c??"";let L;u[0]!==v?(L=n(v),u[0]=v,u[1]=L):L=u[1];const A=y&&null!==c&&null!==f;let _,b;u[2]!==f?(_=async e=>{const{signal:s}=e;if(!f)return[];return(await f.listAllSessions({signal:s})).map(l)},u[2]=f,u[3]=_):_=u[3];u[4]!==L||u[5]!==A||u[6]!==_?(b={queryKey:L,enabled:A,staleTime:3e4,gcTime:3e5,queryFn:_},u[4]=L,u[5]=A,u[6]=_,u[7]=b):b=u[7];const w=(0,s.useQuery)(b);let S;u[8]!==w.data?(S=w.data??[],u[8]=w.data,u[9]=S):S=u[9];const p=w.error??null;let q;u[10]!==w.isLoading||u[11]!==S||u[12]!==p?(q={sessions:S,isLoading:w.isLoading,error:p},u[10]=w.isLoading,u[11]=S,u[12]=p,u[13]=q):q=u[13];return q};var e=r(d[0]),s=r(d[1]),t=r(d[2]);function n(e){return["server",e,"all-sessions"]}function l(e){return{sid:e.sid,title:e.title,lastActivity:e.lastActivity,cwd:e.cwd,agentName:e.agentName}}},3273,[350,3030,3274]);
|
|
14919
|
-
__d(function(g,r,i,a,m,_e,d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.isHostRuntimeConnected=P,_e.isHostRuntimeDirectoryLoading=M,Object.defineProperty(_e,"HostRuntimeController",{enumerable:!0,get:function(){return Q}}),_e.readInitialDaemonConnectionHint=nt,_e.hasConfiguredLocalDaemonOverride=function(){return null!==st()},Object.defineProperty(_e,"HostRuntimeStore",{enumerable:!0,get:function(){return ct}}),_e.getHostRuntimeStore=ut,_e.useHostRuntimeSnapshot=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t),h=()=>c.getSnapshot(t),s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeClient=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.client??null,h=()=>c.getSnapshot(t)?.client??null,s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeIsConnected=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>P(c.getSnapshot(t)),h=()=>P(c.getSnapshot(t)),s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeConnectionStatus=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.connectionStatus??"connecting",h=()=>c.getSnapshot(t)?.connectionStatus??"connecting",s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeConnectionStatuses=function(t){const s=(0,e.c)(7);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]===Symbol.for("react.memo_cache_sentinel")?(l=t=>c.subscribeAll(t),u=()=>c.getVersion(),h=()=>c.getVersion(),s[1]=l,s[2]=u,s[3]=h):(l=s[1],u=s[2],h=s[3]);(0,n.useSyncExternalStore)(l,u,h);let p;if(s[4]!==t){let e;s[6]===Symbol.for("react.memo_cache_sentinel")?(e=t=>[t,c.getSnapshot(t)?.connectionStatus??"connecting"],s[6]=e):e=s[6],p=new Map(t.map(e)),s[4]=t,s[5]=p}else p=s[5];return p},_e.useHostRuntimeLastError=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.lastError??null,h=()=>c.getSnapshot(t)?.lastError??null,s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeAgentDirectoryStatus=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.agentDirectoryStatus??"idle",h=()=>c.getSnapshot(t)?.agentDirectoryStatus??"idle",s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeIsDirectoryLoading=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>M(c.getSnapshot(t)),h=()=>M(c.getSnapshot(t)),s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHosts=function(){const t=(0,e.c)(4);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=ut(),t[0]=s):s=t[0];const o=s;let c,l,u;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=t=>o.subscribeHostList(t),l=()=>o.getHosts(),u=()=>o.getHosts(),t[1]=c,t[2]=l,t[3]=u):(c=t[1],l=t[2],u=t[3]);return(0,n.useSyncExternalStore)(c,l,u)},_e.useHostRegistryStatus=function(){const t=(0,e.c)(4);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=ut(),t[0]=s):s=t[0];const o=s;let c,l,u;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=t=>o.subscribeHostList(t),l=()=>o.getHostRegistryStatus(),u=()=>o.getHostRegistryStatus(),t[1]=c,t[2]=l,t[3]=u):(c=t[1],l=t[2],u=t[3]);return(0,n.useSyncExternalStore)(c,l,u)},_e.useHostRegistryLoaded=function(){const t=(0,e.c)(4);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=ut(),t[0]=s):s=t[0];const o=s;let c,l,u;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=t=>o.subscribeHostList(t),l=()=>o.isHostRegistryLoaded(),u=()=>o.isHostRegistryLoaded(),t[1]=c,t[2]=l,t[3]=u):(c=t[1],l=t[2],u=t[3]);return(0,n.useSyncExternalStore)(c,l,u)},_e.useHostMutations=function(){const t=(0,e.c)(2);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=ut(),t[0]=n):n=t[0];const s=n;let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={upsertDirectConnection:t=>s.upsertDirectConnection(t),probeAndUpsertDirectConnection:t=>s.probeAndUpsertDirectConnection(t),upsertRelayConnection:t=>s.upsertRelayConnection(t),upsertConnectionFromOffer:(t,e)=>s.upsertConnectionFromOffer(t,e),upsertConnectionFromOfferUrl:(t,e)=>s.upsertConnectionFromOfferUrl(t,e),renameHost:(t,e)=>s.renameHost(t,e),removeHost:t=>s.removeHost(t),removeConnection:(t,e)=>s.removeConnection(t,e)},t[1]=o):o=t[1];return o};var e=r(d[0]),n=r(d[1]),s=t(r(d[2])),o=t(r(d[3])),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),y=r(d[9]),f=r(d[10]),C=r(d[11]),b=r(d[12]),S=r(d[13]),v=r(d[14]),I=r(d[15]),w=r(d[16]),H=r(d[17]),D=r(d[18]),A=r(d[19]),L=r(d[20]),R=r(d[21]),E=r(d[22]),O=r(d[23]);function _(t,e,n){t[e]=n}function P(t){return"online"===t?.connectionStatus}function M(t){return!t||("initial_loading"===t.agentDirectoryStatus||"revalidating"===t.agentDirectoryStatus||!t.hasEverLoadedAgentDirectory&&("connecting"===t.connectionStatus||"online"===t.connectionStatus))}function F(t){return t instanceof Error?t.message:String(t)}function T(t){let e=0;for(let n=0;n<t.length;n+=1)e=31*e+t.charCodeAt(n)|0;return`h_${Math.abs(e).toString(16)}`}const B=[{key:"updated_at",direction:"desc"}];function k(t){const e=t;return"boolean"==typeof e.hasMore?e.hasMore:"boolean"==typeof e.hasMoreAfter&&e.hasMoreAfter}function x(t){const e=t;return"string"==typeof e.nextCursor&&e.nextCursor.length>0?e.nextCursor:"string"==typeof e.afterCursor&&e.afterCursor.length>0?e.afterCursor:null}async function j(t){const e=t.page?.limit??200;let n=t.page?.cursor??null,s=!0,o=null;const c=[];for(;;){const l=await t.client.fetchAgents(Object.assign({scope:t.filter?void 0:"active"},t.filter?{filter:t.filter}:{},{sort:B},s&&t.subscribe?{subscribe:t.subscribe}:{},{page:n?{limit:e,cursor:n}:{limit:e}}));if(c.push(...l.entries),o=o??l.subscriptionId??null,s=!1,!k(l.pageInfo))break;const u=x(l.pageInfo);if(!u)break;n=u}return{entries:c,subscriptionId:o}}function V(t){return"directSocket"===t.type?{type:"directSocket",endpoint:t.path,display:"socket"}:"directPipe"===t.type?{type:"directPipe",endpoint:t.path,display:"pipe"}:"directTcp"===t.type?{type:"directTcp",endpoint:t.endpoint,display:t.endpoint}:{type:"relay",endpoint:t.relayEndpoint,display:"relay"}}function q(t){return"connecting"===t.tag||"online"===t.tag||"offline"===t.tag||"error"===t.tag?{id:t.activeConnectionId,connection:t.activeConnection}:{id:null,connection:null}}function U(t,e,n){const s=n.state.status;return"connected"===s?{tag:"online",activeConnectionId:t,activeConnection:e,lastOnlineAt:(new Date).toISOString()}:"connecting"===s||"idle"===s?{tag:"connecting",activeConnectionId:t,activeConnection:e}:"disposed"===s?{tag:"offline",activeConnectionId:t,activeConnection:e}:null}function N(t,e,n){const s=U(t,e,n);if(s)return s;const o=("disconnected"===n.state.status?n.state.reason??null:null)??n.lastError??null;return o&&"client_closed"!==o?{tag:"error",activeConnectionId:t,activeConnection:e,message:o}:{tag:"offline",activeConnectionId:t,activeConnection:e}}function W(t){const{state:e,event:n}=t;if("select_connection"===n.type)return{tag:"connecting",activeConnectionId:n.connectionId,activeConnection:n.connection};if("connect_failed"===n.type){const t=q(e);return{tag:"error",activeConnectionId:t.id,activeConnection:t.connection,message:n.message}}if("no_connections"===n.type||"stopped"===n.type)return{tag:"offline",activeConnectionId:null,activeConnection:null};const s=q(e);return s.id&&s.connection?N(s.id,s.connection,n):"booting"===e.tag?e:{tag:"offline",activeConnectionId:null,activeConnection:null}}function $(t){return"booting"===t.tag?{activeConnectionId:null,activeConnection:null,connectionStatus:"connecting",lastError:null,lastOnlineAt:null}:"connecting"===t.tag?{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"connecting",lastError:null,lastOnlineAt:null}:"online"===t.tag?{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"online",lastError:null,lastOnlineAt:t.lastOnlineAt}:"offline"===t.tag?{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"offline",lastError:null,lastOnlineAt:null}:{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"error",lastError:t.message,lastOnlineAt:null}}function G(t){return t.connections.map(t=>({connectionId:t.id,connection:t}))}function K(t,e){return e?t.connections.find(t=>t.id===e)??null:null}function z(t,e,n,s){if(e)return 1e4;if(n)return 12e4;const o=s-t;return o<1e4?2e3:o<3e4?5e3:o<6e4?1e4:3e4}function J(){const t="function"==typeof(0,I.getDesktopHost)()?.browser?.executeAutomationCommand?{[w.CLIENT_CAPS.browserHost]:{supportedCommands:[...H.BROWSER_AUTOMATION_COMMAND_NAMES],hostKind:"desktop app"}}:void 0;return{createClient:({host:e,connection:n,clientId:s,runtimeGeneration:o})=>{const l=(0,v.createDesktopLocalDaemonTransportFactory)(),p=Object.assign({suppressSendErrors:!0,clientId:s,clientType:"mobile",appVersion:(0,h.resolveAppVersion)()??void 0,runtimeGeneration:o,defaultSendQueueTimeoutMs:2e3},t?{capabilities:t}:{});return"directSocket"===n.type||"directPipe"===n.type?new c.DaemonClient(Object.assign({},p,l?{transportFactory:l}:{},{url:(0,v.buildLocalDaemonTransportUrl)({transportType:"directSocket"===n.type?"socket":"pipe",transportPath:n.path})})):"directTcp"===n.type?new c.DaemonClient(Object.assign({},p,{url:(0,u.buildDaemonWebSocketUrl)(n.endpoint,{useTls:n.useTls??!1})},n.password?{password:n.password}:{})):new c.DaemonClient(Object.assign({},p,{url:(0,u.buildRelayWebSocketUrl)({endpoint:n.relayEndpoint,useTls:n.useTls??(0,u.shouldUseTlsForDefaultHostedRelay)(n.relayEndpoint),serverId:e.serverId}),e2ee:{enabled:!0,daemonPublicKeyB64:n.daemonPublicKeyB64}}))},connectToDaemon:({host:e,connection:n,timeoutMs:s})=>(0,C.connectToDaemon)(n,Object.assign({},e.serverId?{serverId:e.serverId}:{},void 0!==s?{timeoutMs:s}:{},t?{capabilities:t}:{})),getClientId:()=>(0,b.getOrCreateClientId)(),mountClientHandlers:({client:e,host:n})=>t?(0,O.mountBrowserAutomationDaemonClientHandler)(e,{serverId:n.serverId}):()=>{}}}class Q{listeners=new Set;activeClient=null;unsubscribeClientStatus=null;unsubscribeClientHandlers=null;probeIntervalHandle=null;started=!1;connectionFirstSeenAt=new Map;connectionLastProbedAt=new Map;switchCandidateConnectionId=null;switchCandidateHitCount=0;clientIdPromise=null;clientIdHash=null;switchRequestVersion=0;probeRequestVersion=0;probeCycleInFlight=null;constructor(t){this.host=t.host,this.deps=t.deps??J(),this.onReconcileServerId=t.onReconcileServerId??null,this.connectionMachineState={tag:"booting"},this.snapshot=Object.assign({serverId:this.host.serverId},$(this.connectionMachineState),{client:null,agentDirectoryStatus:"idle",agentDirectoryError:null,hasEverLoadedAgentDirectory:!1,probeByConnectionId:new Map,clientGeneration:0})}getSnapshot(){return this.snapshot}getClient(){return this.snapshot.client}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}async start(t){this.started||(this.started=!0,this.trackConnectionFirstSeen(),t?.initialConnection&&await this.switchToConnection({connectionId:t.initialConnection.connectionId,existingClient:t.initialConnection.existingClient}),await this.runProbeCycleNow(),!1!==t?.autoProbe&&(this.probeIntervalHandle=setInterval(()=>{this.runProbeCycleNow()},2e3)))}async stop(){if(this.switchRequestVersion+=1,this.probeRequestVersion+=1,this.started=!1,this.probeIntervalHandle&&(clearInterval(this.probeIntervalHandle),this.probeIntervalHandle=null),this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const t=this.activeClient;this.activeClient=null,await t.close().catch(()=>{})}this.applyConnectionEvent({type:"stopped"}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState),{client:null}))}async updateHost(t){const e=this.snapshot.activeConnectionId,n=K(this.host,e);this.host=t,this.trackConnectionFirstSeen();const s=K(this.host,e);e&&n&&s&&!(0,o.default)(n,s)&&(this.connectionLastProbedAt.delete(e),await this.switchToConnection({connectionId:e})),await this.runProbeCycleNow()}ensureConnected(){this.activeClient?.ensureConnected()}markAgentDirectorySyncLoading(){const t=this.snapshot.hasEverLoadedAgentDirectory?"revalidating":"initial_loading";this.updateSnapshot({agentDirectoryStatus:t,agentDirectoryError:null})}markAgentDirectorySyncReady(){this.updateSnapshot({agentDirectoryStatus:"ready",agentDirectoryError:null,hasEverLoadedAgentDirectory:!0})}markAgentDirectorySyncError(t){const e=this.snapshot.hasEverLoadedAgentDirectory;this.updateSnapshot({agentDirectoryStatus:e?"error_after_ready":"error_before_first_success",agentDirectoryError:t,hasEverLoadedAgentDirectory:e})}markAgentDirectorySyncIdle(){this.updateSnapshot({agentDirectoryStatus:this.snapshot.hasEverLoadedAgentDirectory?"ready":"idle",agentDirectoryError:null})}markStartupError(t){this.applyConnectionEvent({type:"connect_failed",message:t}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState)))}async activateConnection(t){await this.switchToConnection(t)}async runProbeCycleNow(){if(this.probeCycleInFlight)return this.probeCycleInFlight;const t=this.runProbeCycle().finally(()=>{this.probeCycleInFlight===t&&(this.probeCycleInFlight=null)});return this.probeCycleInFlight=t,t}async runProbeCycle(){const t=++this.probeRequestVersion;if(0===this.host.connections.length){if(!this.isCurrentProbeRequest(t))return;return this.applyConnectionEvent({type:"no_connections"}),void this.updateSnapshot(Object.assign({},$(this.connectionMachineState),{probeByConnectionId:new Map}))}const e=performance.now(),n="online"===this.snapshot.connectionStatus,s=this.snapshot.activeConnectionId,o=n&&null!==s,c=this.host.connections.filter(t=>{const c=this.connectionLastProbedAt.get(t.id);if(null==c)return!0;const l=z(this.connectionFirstSeenAt.get(t.id)??e,n&&t.id===s,o,e);return e-c>=l});if(0===c.length)return;const l=new Map(this.snapshot.probeByConnectionId);for(const t of c){this.connectionLastProbedAt.set(t.id,performance.now());const e=l.get(t.id);n&&t.id===s&&"available"===e?.status||l.set(t.id,{status:"pending",latencyMs:null})}this.updateSnapshot({probeByConnectionId:new Map(l)});let u=c.length,h=null;const p=()=>{this.isCurrentProbeRequest(t)&&this.updateSnapshot({probeByConnectionId:new Map(l)})},y=async(e,n)=>{for(;!this.snapshot.activeConnectionId;){if(!h)return h=this.switchToConnection({connectionId:e,expectedProbeVersion:t,existingClient:n}).finally(()=>{h=null}),await h,this.snapshot.activeConnectionId===e;await h}return!1},f=async()=>{if(u>0||!this.isCurrentProbeRequest(t))return;const e=this.snapshot.activeConnectionId,n=e?l.get(e):null;if(!e||!K(this.host,e)){const e=(0,S.selectBestConnection)({candidates:G(this.host),probeByConnectionId:l});return void(e&&await this.switchToConnection({connectionId:e,expectedProbeVersion:t}))}if("unavailable"===n?.status){const n=(0,S.selectBestConnection)({candidates:G(this.host),probeByConnectionId:l});return n&&n!==e&&await this.switchToConnection({connectionId:n,expectedProbeVersion:t}),this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0)}if(!n||"available"!==n.status)return;const s=Array.from(l.entries()).filter(t=>"available"===t[1].status).map(([t,e])=>({connectionId:t,latencyMs:e.latencyMs})).sort((t,e)=>t.latencyMs-e.latencyMs)[0]??null;if(!s||s.connectionId===e)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);if(n.latencyMs-s.latencyMs<40)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);this.switchCandidateConnectionId===s.connectionId?this.switchCandidateHitCount+=1:(this.switchCandidateConnectionId=s.connectionId,this.switchCandidateHitCount=1),this.switchCandidateHitCount>=3&&(this.switchCandidateConnectionId=null,this.switchCandidateHitCount=0,await this.switchToConnection({connectionId:s.connectionId,expectedProbeVersion:t}))};await new Promise(e=>{for(const n of c)(async()=>{let s=null,o=!1;try{const e="online"===this.snapshot.connectionStatus&&this.snapshot.activeConnectionId===n.id?this.snapshot.client:null;if(e)s=e;else{const{client:t,serverId:e}=await this.deps.connectToDaemon({host:this.host,connection:n});if(e!==this.host.serverId){if(!ot(this.host.serverId)||!this.onReconcileServerId)throw await t.close().catch(()=>{}),new Error(`Connection resolved to ${e}, expected ${this.host.serverId}.`);this.onReconcileServerId(this.host.serverId,e)}s=t,o=!0}if(!this.isCurrentProbeRequest(t))return;const c=await y(n.id,s);if(o=o&&!c,e){const s=e.getLastLivenessRttMs();if(!this.isCurrentProbeRequest(t))return;return void(null!==s&&(l.set(n.id,{status:"available",latencyMs:s}),p()))}const u=await s.measureLatency({timeoutMs:5e3});if(!this.isCurrentProbeRequest(t))return;l.set(n.id,{status:"available",latencyMs:u}),p()}catch{this.isCurrentProbeRequest(t)&&(l.set(n.id,{status:"unavailable",latencyMs:null}),p())}finally{s&&o&&await s.close().catch(()=>{}),u-=1,f().finally(()=>{0===u&&e()})}})()})}updateSnapshot(t){const e=Object.assign({},t);let n=this.host.serverId!==this.snapshot.serverId;for(const s of Object.keys(t)){const c=t[s];(0,o.default)(this.snapshot[s],c)?_(e,s,this.snapshot[s]):n=!0}if(n){this.snapshot=Object.assign({},this.snapshot,e,{serverId:this.host.serverId});for(const t of this.listeners)t()}}applyConnectionEvent(t){const e=this.connectionMachineState,n=W({state:e,event:t});this.connectionMachineState=n,this.logConnectionTransition({from:e.tag,to:n.tag,event:t})}logConnectionTransition(t){}trackConnectionFirstSeen(){const t=performance.now(),e=new Set(this.host.connections.map(t=>t.id));for(const t of this.connectionFirstSeenAt.keys())e.has(t)||(this.connectionFirstSeenAt.delete(t),this.connectionLastProbedAt.delete(t));for(const e of this.host.connections)this.connectionFirstSeenAt.has(e.id)||this.connectionFirstSeenAt.set(e.id,t)}isCurrentSwitchRequest(t){return t===this.switchRequestVersion}isCurrentProbeRequest(t){return t===this.probeRequestVersion}canProceedForProbe(t){return void 0===t||this.isCurrentProbeRequest(t)}async abortSwitchWithClient(t){t&&await t.close().catch(()=>{})}isSwitchStillValid(t,e){return this.isCurrentSwitchRequest(t)&&this.canProceedForProbe(e)}async resolveClientIdForSwitch(t){try{return await this.resolveClientId()}catch(e){if(await this.abortSwitchWithClient(t.existingClient),!this.isCurrentSwitchRequest(t.requestVersion))return null;const n=F(e);return this.applyConnectionEvent({type:"connect_failed",message:`Failed to resolve client id: ${n}`}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState))),null}}async disposePreviousActiveClient(){if(this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const t=this.activeClient;this.activeClient=null,await t.close().catch(()=>{})}}buildAgentDirectoryStatusPatch(){if(this.snapshot.hasEverLoadedAgentDirectory)return{};const t=this.connectionMachineState.tag;return"connecting"===t||"online"===t?{agentDirectoryStatus:"initial_loading",agentDirectoryError:null}:"error"===t?{agentDirectoryStatus:"error_before_first_success",agentDirectoryError:this.connectionMachineState.message}:{agentDirectoryStatus:"idle",agentDirectoryError:null}}async switchToConnection(t){const{connectionId:e,expectedProbeVersion:n,existingClient:s}=t;if(!this.canProceedForProbe(n))return void await this.abortSwitchWithClient(s);const o=K(this.host,e);if(!o)return void await this.abortSwitchWithClient(s);const c=++this.switchRequestVersion,l=await this.resolveClientIdForSwitch({existingClient:s,requestVersion:c});if(null===l)return;if(!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);if(await this.disposePreviousActiveClient(),!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);const u=this.snapshot.clientGeneration+1;s&&s.setReconnectEnabled(!0);const h=s??this.deps.createClient({host:this.host,connection:o,clientId:l,runtimeGeneration:u});if(this.isSwitchStillValid(c,n)){this.activeClient=h,this.unsubscribeClientHandlers=this.deps.mountClientHandlers?.({client:h,host:this.host,connection:o})??null,this.applyConnectionEvent({type:"select_connection",connectionId:o.id,connection:V(o)}),this.snapshot=Object.assign({},this.snapshot,{serverId:this.host.serverId},$(this.connectionMachineState),{client:h,clientGeneration:u});for(const t of this.listeners)t();this.unsubscribeClientStatus=h.subscribeConnectionStatus(t=>{if(!this.isCurrentSwitchRequest(c)||this.activeClient!==h)return;this.applyConnectionEvent({type:"client_state",state:t,lastError:h.lastError});const e=Object.assign({},$(this.connectionMachineState),this.buildAgentDirectoryStatusPatch());this.updateSnapshot(e)});try{s||await h.connect()}catch(t){if(!this.isCurrentSwitchRequest(c)||this.activeClient!==h)return;const e=F(t);this.applyConnectionEvent({type:"connect_failed",message:e}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState)))}}else await h.close().catch(()=>{})}adoptReconciledServerId(t){this.host=Object.assign({},this.host,{serverId:t}),this.snapshot=Object.assign({},this.snapshot,{serverId:t});for(const t of this.listeners)t()}resolveClientId(){return this.clientIdPromise||(this.clientIdPromise=this.deps.getClientId().then(t=>(this.clientIdHash=T(t),t))),this.clientIdPromise}}const X="@paseo:daemon-registry",Y="localhost:6767",Z=2500,tt="__PASEO_INITIAL_DAEMON_CONNECTION__";function et(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function nt(t){if(!(t?.isWebRuntime??f.isWeb)||"undefined"==typeof globalThis)return null;const e=globalThis[tt];if(!et(e))return null;const n="string"==typeof e.listen?e.listen.trim():"";return n?{listen:n,useTls:!0===e.useTls}:null}function st(){return null}function ot(t){return t.startsWith("local:")}function it(t){return new Promise(e=>setTimeout(e,t))}function rt(t,e,n){const s=t.get(e);void 0!==s&&(t.delete(e),t.set(n,s))}class ct{controllers=new Map;serverListeners=new Map;globalListeners=new Set;hostListListeners=new Set;version=0;hostListVersion=0;hostRegistryLoaded=!1;hosts=[];hostRegistryStatus="loading";lastConnectionStatusByServer=new Map;agentDirectoryBootstrapInFlight=new Map;configuredOverrideBootstrapInFlight=null;bootStarted=!1;constructor(t){this.deps=t?.deps??J(),this.storage=t?.storage??s.default}getHosts(){return this.hosts}getHostRegistryStatus(){return this.hostRegistryStatus}subscribeHostList(t){return this.hostListListeners.add(t),()=>{this.hostListListeners.delete(t)}}getHostListVersion(){return this.hostListVersion}isHostRegistryLoaded(){return this.hostRegistryLoaded}boot(){this.bootStarted||(this.bootStarted=!0,this.runBoot())}async runBoot(){await this.loadFromStorage(),this.markHostRegistryLoaded();let t=null;try{t=await this.storage.getItem("@paseo:e2e")}catch{return}if(t)return;if((0,y.shouldUseDesktopDaemon)())return;const e=this.deps.readInitialConnectionHint?this.deps.readInitialConnectionHint():nt();if(e){if(await this.bootstrapInitialConnectionHint(e))return}await this.bootstrapDefaultLocalhost()}async loadFromStorage(){let t=!1;try{const e=await this.storage.getItem(X);if(!e)return;const n=JSON.parse(e);if(!Array.isArray(n))return;const s=n.map(t=>(0,l.normalizeStoredHostProfile)(t)).filter(t=>null!==t),o=s.filter(t=>!ot(t.serverId));this.hosts=o,this.syncHosts(o),o.length!==s.length&&(t=!0)}catch(t){console.error("[HostRuntime] Failed to load host registry from storage",t)}finally{this.hostRegistryStatus="ready",this.emitHostList(),t&&this.persistHosts()}}markHostRegistryLoaded(){this.hostRegistryLoaded||(this.hostRegistryLoaded=!0,this.emitHostList())}async bootstrapDefaultLocalhost(){const t=(0,l.connectionFromListen)(Y);if(t&&!(0,l.registryHasConnection)(this.hosts,t))try{await this.probeAndUpsertConnection({connection:t,timeoutMs:Z})}catch(t){console.warn("[HostRuntime] bootstrap probe failed",{endpoint:Y,error:t})}}bootstrapConfiguredOverride(t){const e=(0,l.connectionFromListen)(t);if(!e)return;if((0,l.registryHasConnection)(this.hosts,e))return;if(this.configuredOverrideBootstrapInFlight)return;const n=this.runConfiguredOverrideBootstrap(t,e).finally(()=>{this.configuredOverrideBootstrapInFlight===n&&(this.configuredOverrideBootstrapInFlight=null)});this.configuredOverrideBootstrapInFlight=n}async runConfiguredOverrideBootstrap(t,e){let n=0;for(;!(0,l.registryHasConnection)(this.hosts,e);){n+=1;try{return void await this.probeAndUpsertConnection({connection:e,timeoutMs:Z})}catch(e){1!==n&&n%10!=0||console.warn("[HostRuntime] configured bootstrap probe failed",{endpoint:t,attempt:n,error:e}),await it(1e3)}}}async bootstrapInitialConnectionHint(t){const e=(0,l.connectionFromListen)(t.listen);if(!e)return!1;const n="directTcp"===e.type?Object.assign({},e,{useTls:t.useTls??e.useTls??!1}):e;if((0,l.registryHasConnection)(this.hosts,n))return!0;try{return await this.probeAndUpsertConnection({connection:n,timeoutMs:Z}),!0}catch(e){return console.warn("[HostRuntime] initial connection hint probe failed",{listen:t.listen,useTls:t.useTls,error:e}),!1}}reconcileServerId(t,e){if(t===e)return;const n=this.controllers.get(t);if(!n)return;if(this.controllers.has(e))return;rt(this.controllers,t,e),n.adoptReconciledServerId(e),rt(this.lastConnectionStatusByServer,t,e),rt(this.agentDirectoryBootstrapInFlight,t,e);const s=this.serverListeners.get(t);if(s){this.serverListeners.delete(t);const n=this.serverListeners.get(e)??new Set;for(const t of s)n.add(t);this.serverListeners.set(e,n)}this.hosts=this.hosts.map(n=>n.serverId===t?Object.assign({},n,{serverId:e,updatedAt:(new Date).toISOString()}):n),this.emitHostList(),this.emit(e),this.persistHosts()}async upsertDirectConnection(t){const e=(0,u.normalizeHostPort)(t.endpoint),n=t.password?.trim();return this.upsertHostConnection({serverId:t.serverId,label:t.label,connection:Object.assign({id:`direct:${e}`,type:"directTcp",endpoint:e,useTls:t.useTls??!1},n?{password:n}:{}),existingClient:t.existingClient})}async probeAndUpsertConnection(t){if("relay"===t.connection.type)throw new Error("Cannot probe a relay connection without a server id.");const e={serverId:"",label:t.label??t.connection.id,lifecycle:{},connections:[t.connection],preferredConnectionId:t.connection.id,createdAt:new Date(0).toISOString(),updatedAt:new Date(0).toISOString()},{client:n,serverId:s,hostname:o}=await this.deps.connectToDaemon(Object.assign({host:e,connection:t.connection},void 0!==t.timeoutMs?{timeoutMs:t.timeoutMs}:{}));return{profile:await this.upsertHostConnection({serverId:s,label:t.label??o??void 0,connection:t.connection,existingClient:n}),serverId:s,hostname:o}}async probeAndUpsertDirectConnection(t){const e=(0,u.normalizeHostPort)(t.endpoint),n=t.password?.trim();return this.probeAndUpsertConnection({label:t.label,connection:Object.assign({id:`direct:${e}`,type:"directTcp",endpoint:e,useTls:t.useTls??!1},n?{password:n}:{})})}async upsertRelayConnection(t){const e=(0,u.normalizeHostPort)(t.relayEndpoint),n=t.useTls??!1,s=t.daemonPublicKeyB64.trim();if(!s)throw new Error("daemonPublicKeyB64 is required");const o=void 0!==t.useTls;return this.upsertHostConnection({serverId:t.serverId,label:t.label,connection:Object.assign({id:n?`relay:wss:${e}`:`relay:${e}`,type:"relay",relayEndpoint:e},o?{useTls:n}:{},{daemonPublicKeyB64:s})})}async upsertConnectionFromOffer(t,e){const n=t.relay.useTls??(0,u.shouldUseTlsForDefaultHostedRelay)(t.relay.endpoint);return this.upsertRelayConnection({serverId:t.serverId,relayEndpoint:t.relay.endpoint,useTls:n,daemonPublicKeyB64:t.daemonPublicKeyB64,label:e})}async upsertConnectionFromOfferUrl(t,e){const n="#offer=",s=t.indexOf(n);if(-1===s)throw new Error("Missing #offer= fragment");const o=t.slice(s+7).trim();if(!o)throw new Error("Offer payload is empty");const c=(0,u.decodeOfferFragmentPayload)(o),l=p.ConnectionOfferSchema.parse(c);return this.upsertConnectionFromOffer(l,e)}async upsertConnectionFromListen(t){const e=t.listenAddress.trim(),n=t.serverId.trim(),s=(0,l.connectionFromListen)(e);if(!s)throw new Error(`Unsupported listen address: ${t.listenAddress}`);if(!n)throw new Error("Desktop daemon did not return a server id.");return this.upsertHostConnection({serverId:n,label:t.hostname??void 0,connection:s})}async renameHost(t,e){const n=this.hosts.map(n=>n.serverId===t?Object.assign({},n,{label:e,updatedAt:(new Date).toISOString()}):n);this.setHostsAndSync(n),await this.persistHosts()}async removeHost(t){const e=this.hosts.filter(e=>e.serverId!==t);this.setHostsAndSync(e),await this.persistHosts()}async removeConnection(t,e){const n=(new Date).toISOString(),s=this.hosts.map(s=>{if(s.serverId!==t)return s;const o=s.connections.filter(t=>t.id!==e);if(0===o.length)return null;const c=s.preferredConnectionId===e?o[0]?.id??null:s.preferredConnectionId;return Object.assign({},s,{connections:o,preferredConnectionId:c,updatedAt:n})}).filter(t=>null!==t);this.setHostsAndSync(s),await this.persistHosts()}async upsertHostConnection(t){const e=(new Date).toISOString(),n=(0,l.upsertHostConnectionInProfiles)({profiles:this.hosts,serverId:t.serverId,label:t.label,connection:t.connection,now:e});return this.setHostsAndSync(n,{initialConnectionByServerId:t.existingClient?new Map([[t.serverId,{connectionId:t.connection.id,existingClient:t.existingClient}]]):void 0}),this.persistHosts(),n.find(e=>e.serverId===t.serverId)}setHostsAndSync(t,e){this.hosts=t,this.syncHosts(t,e),this.emitHostList()}async persistHosts(){try{await this.storage.setItem(X,JSON.stringify(this.hosts))}catch(t){console.error("[HostRuntime] Failed to persist host registry",t)}}emitHostList(){this.hostListVersion+=1;for(const t of this.hostListListeners)t()}syncHosts(t,e){const n=new Set(t.map(t=>t.serverId));for(const[t,e]of this.controllers)n.has(t)||(this.controllers.delete(t),this.lastConnectionStatusByServer.delete(t),this.agentDirectoryBootstrapInFlight.delete(t),e.stop(),this.emit(t));for(const n of t){const t=e?.initialConnectionByServerId?.get(n.serverId),s=this.controllers.get(n.serverId);if(s){s.updateHost(n),t&&s.activateConnection(t).catch(()=>{t.existingClient.close().catch(()=>{})});continue}const o=new Q({host:n,deps:this.deps,onReconcileServerId:(t,e)=>this.reconcileServerId(t,e)});this.controllers.set(n.serverId,o),this.lastConnectionStatusByServer.set(n.serverId,o.getSnapshot().connectionStatus),o.subscribe(()=>{this.maybeAutoBootstrapAgentDirectory(n.serverId),this.emit(n.serverId)}),o.start(t?{initialConnection:t}:{}).catch(t=>{const e=t instanceof Error?t.message:String(t);o.markStartupError(e)}),this.emit(n.serverId)}}maybeAutoBootstrapAgentDirectory(t){const e=this.controllers.get(t);if(!e)return this.lastConnectionStatusByServer.delete(t),void this.agentDirectoryBootstrapInFlight.delete(t);const n=e.getSnapshot(),s=this.lastConnectionStatusByServer.get(t);this.lastConnectionStatusByServer.set(t,n.connectionStatus);const o="online"===n.connectionStatus&&"online"!==s;if(o&&(A.useSessionStore.getState().bumpHistorySyncGeneration(t),(0,R.invalidateCheckoutGitQueriesForServer)(E.queryClient,t)),"online"!==n.connectionStatus)return;if(!o&&n.hasEverLoadedAgentDirectory)return;if(this.agentDirectoryBootstrapInFlight.has(t))return;const c=Promise.resolve().then(()=>this.refreshAgentDirectory({serverId:t,subscribe:{subscriptionId:`app:${t}`},page:{limit:200}})).then(()=>{}).catch(e=>{console.error(`[HostRuntime] agent directory bootstrap failed (server ${t}): ${F(e)}`)}).finally(()=>{this.agentDirectoryBootstrapInFlight.get(t)===c&&this.agentDirectoryBootstrapInFlight.delete(t)});this.agentDirectoryBootstrapInFlight.set(t,c)}getSnapshot(t){return this.controllers.get(t)?.getSnapshot()??null}getVersion(){return this.version}getClient(t){return this.controllers.get(t)?.getClient()??null}subscribe(t,e){const n=this.serverListeners.get(t)??new Set;return n.add(e),this.serverListeners.set(t,n),()=>{const n=this.serverListeners.get(t);n&&(n.delete(e),0===n.size&&this.serverListeners.delete(t))}}subscribeAll(t){return this.globalListeners.add(t),()=>{this.globalListeners.delete(t)}}getEarliestOnlineHostServerId(){let t=null,e=null;for(const n of this.hosts){const s=this.getSnapshot(n.serverId);P(s)&&s?.lastOnlineAt&&((!e||s.lastOnlineAt<e)&&(e=s.lastOnlineAt,t=n.serverId))}return t}ensureConnectedAll(){for(const t of this.controllers.values())t.ensureConnected()}runProbeCycleNow(t){return t?this.controllers.get(t)?.runProbeCycleNow()??Promise.resolve():Promise.all(Array.from(this.controllers.values(),t=>t.runProbeCycleNow())).then(()=>{})}async refreshAgentDirectory(t){const e=this.controllers.get(t.serverId);if(!e)throw new Error(`Unknown host runtime for serverId ${t.serverId}`);const n=e.getSnapshot(),s=e.getClient();if(!s||"online"!==n.connectionStatus)throw new Error(`Host ${t.serverId} is not connected`);e.markAgentDirectorySyncLoading();try{const n=A.useSessionStore.getState().sessions[t.serverId];if(!t.filter&&(0,L.shouldUseLegacyDaemonWorkspaceDirectory)(n?.serverInfo)){const n=await(0,L.fetchLegacyDaemonWorkspaceDirectory)({client:s,serverId:t.serverId,subscribe:t.subscribe,page:t.page});return e.markAgentDirectorySyncReady(),{agents:n.agents,subscriptionId:n.subscriptionId}}const o=await j({client:s,filter:t.filter,subscribe:t.subscribe,page:t.page}),{agents:c}=(0,D.replaceFetchedAgentDirectory)({serverId:t.serverId,entries:o.entries});return e.markAgentDirectorySyncReady(),{agents:c,subscriptionId:o.subscriptionId}}catch(t){throw e.markAgentDirectorySyncError(F(t)),t}}refreshAllAgentDirectories(t){const e=t?.serverIds?new Set(t.serverIds):null;for(const[t]of this.controllers)e&&!e.has(t)||this.refreshAgentDirectory({serverId:t}).catch(()=>{})}markAgentDirectorySyncLoading(t){this.controllers.get(t)?.markAgentDirectorySyncLoading()}markAgentDirectorySyncReady(t){this.controllers.get(t)?.markAgentDirectorySyncReady()}markAgentDirectorySyncError(t,e){this.controllers.get(t)?.markAgentDirectorySyncError(e)}markAgentDirectorySyncIdle(t){this.controllers.get(t)?.markAgentDirectorySyncIdle()}emit(t){this.version+=1;const e=this.serverListeners.get(t);if(e){for(const t of e)t();for(const t of this.globalListeners)t()}else for(const t of this.globalListeners)t()}}let at=null;const lt="__paseoHostRuntimeStore";function ut(){if(at)return at;const t=globalThis;return t[lt]&&(at=t[lt]??null,at)||(at=new ct,t[lt]=at),at}},3274,[350,36,3275,3281,3282,3410,3412,3414,3413,3416,3420,3421,3422,3425,3423,3417,3283,3386,3426,3427,3440,3443,3445,3446]);
|
|
14919
|
+
__d(function(g,r,i,a,m,_e,d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.isHostRuntimeConnected=P,_e.isHostRuntimeDirectoryLoading=M,Object.defineProperty(_e,"HostRuntimeController",{enumerable:!0,get:function(){return Q}}),_e.readInitialDaemonConnectionHint=nt,_e.hasConfiguredLocalDaemonOverride=function(){return null!==st()},Object.defineProperty(_e,"HostRuntimeStore",{enumerable:!0,get:function(){return ct}}),_e.getHostRuntimeStore=ut,_e.useHostRuntimeSnapshot=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t),h=()=>c.getSnapshot(t),s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeClient=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.client??null,h=()=>c.getSnapshot(t)?.client??null,s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeIsConnected=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>P(c.getSnapshot(t)),h=()=>P(c.getSnapshot(t)),s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeConnectionStatus=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.connectionStatus??"connecting",h=()=>c.getSnapshot(t)?.connectionStatus??"connecting",s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeConnectionStatuses=function(t){const s=(0,e.c)(7);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]===Symbol.for("react.memo_cache_sentinel")?(l=t=>c.subscribeAll(t),u=()=>c.getVersion(),h=()=>c.getVersion(),s[1]=l,s[2]=u,s[3]=h):(l=s[1],u=s[2],h=s[3]);(0,n.useSyncExternalStore)(l,u,h);let p;if(s[4]!==t){let e;s[6]===Symbol.for("react.memo_cache_sentinel")?(e=t=>[t,c.getSnapshot(t)?.connectionStatus??"connecting"],s[6]=e):e=s[6],p=new Map(t.map(e)),s[4]=t,s[5]=p}else p=s[5];return p},_e.useHostRuntimeLastError=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.lastError??null,h=()=>c.getSnapshot(t)?.lastError??null,s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeAgentDirectoryStatus=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>c.getSnapshot(t)?.agentDirectoryStatus??"idle",h=()=>c.getSnapshot(t)?.agentDirectoryStatus??"idle",s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHostRuntimeIsDirectoryLoading=function(t){const s=(0,e.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=ut(),s[0]=o):o=s[0];const c=o;let l,u,h;s[1]!==t?(l=e=>c.subscribe(t,e),u=()=>M(c.getSnapshot(t)),h=()=>M(c.getSnapshot(t)),s[1]=t,s[2]=l,s[3]=u,s[4]=h):(l=s[2],u=s[3],h=s[4]);return(0,n.useSyncExternalStore)(l,u,h)},_e.useHosts=function(){const t=(0,e.c)(4);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=ut(),t[0]=s):s=t[0];const o=s;let c,l,u;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=t=>o.subscribeHostList(t),l=()=>o.getHosts(),u=()=>o.getHosts(),t[1]=c,t[2]=l,t[3]=u):(c=t[1],l=t[2],u=t[3]);return(0,n.useSyncExternalStore)(c,l,u)},_e.useHostRegistryStatus=function(){const t=(0,e.c)(4);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=ut(),t[0]=s):s=t[0];const o=s;let c,l,u;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=t=>o.subscribeHostList(t),l=()=>o.getHostRegistryStatus(),u=()=>o.getHostRegistryStatus(),t[1]=c,t[2]=l,t[3]=u):(c=t[1],l=t[2],u=t[3]);return(0,n.useSyncExternalStore)(c,l,u)},_e.useHostRegistryLoaded=function(){const t=(0,e.c)(4);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=ut(),t[0]=s):s=t[0];const o=s;let c,l,u;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=t=>o.subscribeHostList(t),l=()=>o.isHostRegistryLoaded(),u=()=>o.isHostRegistryLoaded(),t[1]=c,t[2]=l,t[3]=u):(c=t[1],l=t[2],u=t[3]);return(0,n.useSyncExternalStore)(c,l,u)},_e.useHostMutations=function(){const t=(0,e.c)(2);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=ut(),t[0]=n):n=t[0];const s=n;let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={upsertDirectConnection:t=>s.upsertDirectConnection(t),probeAndUpsertDirectConnection:t=>s.probeAndUpsertDirectConnection(t),upsertRelayConnection:t=>s.upsertRelayConnection(t),upsertConnectionFromOffer:(t,e)=>s.upsertConnectionFromOffer(t,e),upsertConnectionFromOfferUrl:(t,e)=>s.upsertConnectionFromOfferUrl(t,e),renameHost:(t,e)=>s.renameHost(t,e),removeHost:t=>s.removeHost(t),removeConnection:(t,e)=>s.removeConnection(t,e)},t[1]=o):o=t[1];return o};var e=r(d[0]),n=r(d[1]),s=t(r(d[2])),o=t(r(d[3])),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),y=r(d[9]),f=r(d[10]),C=r(d[11]),b=r(d[12]),S=r(d[13]),v=r(d[14]),I=r(d[15]),w=r(d[16]),H=r(d[17]),D=r(d[18]),A=r(d[19]),L=r(d[20]),R=r(d[21]),E=r(d[22]),O=r(d[23]);function _(t,e,n){t[e]=n}function P(t){return"online"===t?.connectionStatus}function M(t){return!t||("initial_loading"===t.agentDirectoryStatus||"revalidating"===t.agentDirectoryStatus||!t.hasEverLoadedAgentDirectory&&("connecting"===t.connectionStatus||"online"===t.connectionStatus))}function F(t){return t instanceof Error?t.message:String(t)}function T(t){let e=0;for(let n=0;n<t.length;n+=1)e=31*e+t.charCodeAt(n)|0;return`h_${Math.abs(e).toString(16)}`}const B=[{key:"updated_at",direction:"desc"}];function k(t){const e=t;return"boolean"==typeof e.hasMore?e.hasMore:"boolean"==typeof e.hasMoreAfter&&e.hasMoreAfter}function x(t){const e=t;return"string"==typeof e.nextCursor&&e.nextCursor.length>0?e.nextCursor:"string"==typeof e.afterCursor&&e.afterCursor.length>0?e.afterCursor:null}async function j(t){const e=t.page?.limit??200;let n=t.page?.cursor??null,s=!0,o=null;const c=[];for(;;){const l=await t.client.fetchAgents(Object.assign({scope:t.filter?void 0:"active"},t.filter?{filter:t.filter}:{},{sort:B},s&&t.subscribe?{subscribe:t.subscribe}:{},{page:n?{limit:e,cursor:n}:{limit:e}}));if(c.push(...l.entries),o=o??l.subscriptionId??null,s=!1,!k(l.pageInfo))break;const u=x(l.pageInfo);if(!u)break;n=u}return{entries:c,subscriptionId:o}}function V(t){return"directSocket"===t.type?{type:"directSocket",endpoint:t.path,display:"socket"}:"directPipe"===t.type?{type:"directPipe",endpoint:t.path,display:"pipe"}:"directTcp"===t.type?{type:"directTcp",endpoint:t.endpoint,display:t.endpoint}:{type:"relay",endpoint:t.relayEndpoint,display:"relay"}}function q(t){return"connecting"===t.tag||"online"===t.tag||"offline"===t.tag||"error"===t.tag?{id:t.activeConnectionId,connection:t.activeConnection}:{id:null,connection:null}}function U(t,e,n){const s=n.state.status;return"connected"===s?{tag:"online",activeConnectionId:t,activeConnection:e,lastOnlineAt:(new Date).toISOString()}:"connecting"===s||"idle"===s?{tag:"connecting",activeConnectionId:t,activeConnection:e}:"disposed"===s?{tag:"offline",activeConnectionId:t,activeConnection:e}:null}function N(t,e,n){const s=U(t,e,n);if(s)return s;const o=("disconnected"===n.state.status?n.state.reason??null:null)??n.lastError??null;return o&&"client_closed"!==o?{tag:"error",activeConnectionId:t,activeConnection:e,message:o}:{tag:"offline",activeConnectionId:t,activeConnection:e}}function W(t){const{state:e,event:n}=t;if("select_connection"===n.type)return{tag:"connecting",activeConnectionId:n.connectionId,activeConnection:n.connection};if("connect_failed"===n.type){const t=q(e);return{tag:"error",activeConnectionId:t.id,activeConnection:t.connection,message:n.message}}if("no_connections"===n.type||"stopped"===n.type)return{tag:"offline",activeConnectionId:null,activeConnection:null};const s=q(e);return s.id&&s.connection?N(s.id,s.connection,n):"booting"===e.tag?e:{tag:"offline",activeConnectionId:null,activeConnection:null}}function $(t){return"booting"===t.tag?{activeConnectionId:null,activeConnection:null,connectionStatus:"connecting",lastError:null,lastOnlineAt:null}:"connecting"===t.tag?{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"connecting",lastError:null,lastOnlineAt:null}:"online"===t.tag?{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"online",lastError:null,lastOnlineAt:t.lastOnlineAt}:"offline"===t.tag?{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"offline",lastError:null,lastOnlineAt:null}:{activeConnectionId:t.activeConnectionId,activeConnection:t.activeConnection,connectionStatus:"error",lastError:t.message,lastOnlineAt:null}}function G(t){return t.connections.map(t=>({connectionId:t.id,connection:t}))}function K(t,e){return e?t.connections.find(t=>t.id===e)??null:null}function z(t,e,n,s){if(e)return 1e4;if(n)return 12e4;const o=s-t;return o<1e4?2e3:o<3e4?5e3:o<6e4?1e4:3e4}function J(){const t="function"==typeof(0,I.getDesktopHost)()?.browser?.executeAutomationCommand?{[w.CLIENT_CAPS.browserHost]:{supportedCommands:[...H.BROWSER_AUTOMATION_COMMAND_NAMES],hostKind:"desktop app"}}:void 0;return{createClient:({host:e,connection:n,clientId:s,runtimeGeneration:o})=>{const l=(0,v.createDesktopLocalDaemonTransportFactory)(),p=Object.assign({suppressSendErrors:!0,clientId:s,clientType:"mobile",appVersion:(0,h.resolveAppVersion)()??void 0,runtimeGeneration:o,defaultSendQueueTimeoutMs:4e3},t?{capabilities:t}:{});return"directSocket"===n.type||"directPipe"===n.type?new c.DaemonClient(Object.assign({},p,l?{transportFactory:l}:{},{url:(0,v.buildLocalDaemonTransportUrl)({transportType:"directSocket"===n.type?"socket":"pipe",transportPath:n.path})})):"directTcp"===n.type?new c.DaemonClient(Object.assign({},p,{url:(0,u.buildDaemonWebSocketUrl)(n.endpoint,{useTls:n.useTls??!1})},n.password?{password:n.password}:{})):new c.DaemonClient(Object.assign({},p,{url:(0,u.buildRelayWebSocketUrl)({endpoint:n.relayEndpoint,useTls:n.useTls??(0,u.shouldUseTlsForDefaultHostedRelay)(n.relayEndpoint),serverId:e.serverId}),e2ee:{enabled:!0,daemonPublicKeyB64:n.daemonPublicKeyB64}}))},connectToDaemon:({host:e,connection:n,timeoutMs:s})=>(0,C.connectToDaemon)(n,Object.assign({},e.serverId?{serverId:e.serverId}:{},void 0!==s?{timeoutMs:s}:{},t?{capabilities:t}:{})),getClientId:()=>(0,b.getOrCreateClientId)(),mountClientHandlers:({client:e,host:n})=>t?(0,O.mountBrowserAutomationDaemonClientHandler)(e,{serverId:n.serverId}):()=>{}}}class Q{listeners=new Set;activeClient=null;unsubscribeClientStatus=null;unsubscribeClientHandlers=null;probeIntervalHandle=null;started=!1;connectionFirstSeenAt=new Map;connectionLastProbedAt=new Map;switchCandidateConnectionId=null;switchCandidateHitCount=0;clientIdPromise=null;clientIdHash=null;switchRequestVersion=0;probeRequestVersion=0;probeCycleInFlight=null;constructor(t){this.host=t.host,this.deps=t.deps??J(),this.onReconcileServerId=t.onReconcileServerId??null,this.connectionMachineState={tag:"booting"},this.snapshot=Object.assign({serverId:this.host.serverId},$(this.connectionMachineState),{client:null,agentDirectoryStatus:"idle",agentDirectoryError:null,hasEverLoadedAgentDirectory:!1,probeByConnectionId:new Map,clientGeneration:0})}getSnapshot(){return this.snapshot}getClient(){return this.snapshot.client}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}async start(t){this.started||(this.started=!0,this.trackConnectionFirstSeen(),t?.initialConnection&&await this.switchToConnection({connectionId:t.initialConnection.connectionId,existingClient:t.initialConnection.existingClient}),await this.runProbeCycleNow(),!1!==t?.autoProbe&&(this.probeIntervalHandle=setInterval(()=>{this.runProbeCycleNow()},2e3)))}async stop(){if(this.switchRequestVersion+=1,this.probeRequestVersion+=1,this.started=!1,this.probeIntervalHandle&&(clearInterval(this.probeIntervalHandle),this.probeIntervalHandle=null),this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const t=this.activeClient;this.activeClient=null,await t.close().catch(()=>{})}this.applyConnectionEvent({type:"stopped"}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState),{client:null}))}async updateHost(t){const e=this.snapshot.activeConnectionId,n=K(this.host,e);this.host=t,this.trackConnectionFirstSeen();const s=K(this.host,e);e&&n&&s&&!(0,o.default)(n,s)&&(this.connectionLastProbedAt.delete(e),await this.switchToConnection({connectionId:e})),await this.runProbeCycleNow()}ensureConnected(){this.activeClient?.ensureConnected()}markAgentDirectorySyncLoading(){const t=this.snapshot.hasEverLoadedAgentDirectory?"revalidating":"initial_loading";this.updateSnapshot({agentDirectoryStatus:t,agentDirectoryError:null})}markAgentDirectorySyncReady(){this.updateSnapshot({agentDirectoryStatus:"ready",agentDirectoryError:null,hasEverLoadedAgentDirectory:!0})}markAgentDirectorySyncError(t){const e=this.snapshot.hasEverLoadedAgentDirectory;this.updateSnapshot({agentDirectoryStatus:e?"error_after_ready":"error_before_first_success",agentDirectoryError:t,hasEverLoadedAgentDirectory:e})}markAgentDirectorySyncIdle(){this.updateSnapshot({agentDirectoryStatus:this.snapshot.hasEverLoadedAgentDirectory?"ready":"idle",agentDirectoryError:null})}markStartupError(t){this.applyConnectionEvent({type:"connect_failed",message:t}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState)))}async activateConnection(t){await this.switchToConnection(t)}async runProbeCycleNow(){if(this.probeCycleInFlight)return this.probeCycleInFlight;const t=this.runProbeCycle().finally(()=>{this.probeCycleInFlight===t&&(this.probeCycleInFlight=null)});return this.probeCycleInFlight=t,t}async runProbeCycle(){const t=++this.probeRequestVersion;if(0===this.host.connections.length){if(!this.isCurrentProbeRequest(t))return;return this.applyConnectionEvent({type:"no_connections"}),void this.updateSnapshot(Object.assign({},$(this.connectionMachineState),{probeByConnectionId:new Map}))}const e=performance.now(),n="online"===this.snapshot.connectionStatus,s=this.snapshot.activeConnectionId,o=n&&null!==s,c=this.host.connections.filter(t=>{const c=this.connectionLastProbedAt.get(t.id);if(null==c)return!0;const l=z(this.connectionFirstSeenAt.get(t.id)??e,n&&t.id===s,o,e);return e-c>=l});if(0===c.length)return;const l=new Map(this.snapshot.probeByConnectionId);for(const t of c){this.connectionLastProbedAt.set(t.id,performance.now());const e=l.get(t.id);n&&t.id===s&&"available"===e?.status||l.set(t.id,{status:"pending",latencyMs:null})}this.updateSnapshot({probeByConnectionId:new Map(l)});let u=c.length,h=null;const p=()=>{this.isCurrentProbeRequest(t)&&this.updateSnapshot({probeByConnectionId:new Map(l)})},y=async(e,n)=>{for(;!this.snapshot.activeConnectionId;){if(!h)return h=this.switchToConnection({connectionId:e,expectedProbeVersion:t,existingClient:n}).finally(()=>{h=null}),await h,this.snapshot.activeConnectionId===e;await h}return!1},f=async()=>{if(u>0||!this.isCurrentProbeRequest(t))return;const e=this.snapshot.activeConnectionId,n=e?l.get(e):null;if(!e||!K(this.host,e)){const e=(0,S.selectBestConnection)({candidates:G(this.host),probeByConnectionId:l});return void(e&&await this.switchToConnection({connectionId:e,expectedProbeVersion:t}))}if("unavailable"===n?.status){const n=(0,S.selectBestConnection)({candidates:G(this.host),probeByConnectionId:l});return n&&n!==e&&await this.switchToConnection({connectionId:n,expectedProbeVersion:t}),this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0)}if(!n||"available"!==n.status)return;const s=Array.from(l.entries()).filter(t=>"available"===t[1].status).map(([t,e])=>({connectionId:t,latencyMs:e.latencyMs})).sort((t,e)=>t.latencyMs-e.latencyMs)[0]??null;if(!s||s.connectionId===e)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);if(n.latencyMs-s.latencyMs<40)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);this.switchCandidateConnectionId===s.connectionId?this.switchCandidateHitCount+=1:(this.switchCandidateConnectionId=s.connectionId,this.switchCandidateHitCount=1),this.switchCandidateHitCount>=3&&(this.switchCandidateConnectionId=null,this.switchCandidateHitCount=0,await this.switchToConnection({connectionId:s.connectionId,expectedProbeVersion:t}))};await new Promise(e=>{for(const n of c)(async()=>{let s=null,o=!1;try{const e="online"===this.snapshot.connectionStatus&&this.snapshot.activeConnectionId===n.id?this.snapshot.client:null;if(e)s=e;else{const{client:t,serverId:e}=await this.deps.connectToDaemon({host:this.host,connection:n});if(e!==this.host.serverId){if(!ot(this.host.serverId)||!this.onReconcileServerId)throw await t.close().catch(()=>{}),new Error(`Connection resolved to ${e}, expected ${this.host.serverId}.`);this.onReconcileServerId(this.host.serverId,e)}s=t,o=!0}if(!this.isCurrentProbeRequest(t))return;const c=await y(n.id,s);if(o=o&&!c,e){const s=e.getLastLivenessRttMs();if(!this.isCurrentProbeRequest(t))return;return void(null!==s&&(l.set(n.id,{status:"available",latencyMs:s}),p()))}const u=await s.measureLatency({timeoutMs:1e4});if(!this.isCurrentProbeRequest(t))return;l.set(n.id,{status:"available",latencyMs:u}),p()}catch{this.isCurrentProbeRequest(t)&&(l.set(n.id,{status:"unavailable",latencyMs:null}),p())}finally{s&&o&&await s.close().catch(()=>{}),u-=1,f().finally(()=>{0===u&&e()})}})()})}updateSnapshot(t){const e=Object.assign({},t);let n=this.host.serverId!==this.snapshot.serverId;for(const s of Object.keys(t)){const c=t[s];(0,o.default)(this.snapshot[s],c)?_(e,s,this.snapshot[s]):n=!0}if(n){this.snapshot=Object.assign({},this.snapshot,e,{serverId:this.host.serverId});for(const t of this.listeners)t()}}applyConnectionEvent(t){const e=this.connectionMachineState,n=W({state:e,event:t});this.connectionMachineState=n,this.logConnectionTransition({from:e.tag,to:n.tag,event:t})}logConnectionTransition(t){}trackConnectionFirstSeen(){const t=performance.now(),e=new Set(this.host.connections.map(t=>t.id));for(const t of this.connectionFirstSeenAt.keys())e.has(t)||(this.connectionFirstSeenAt.delete(t),this.connectionLastProbedAt.delete(t));for(const e of this.host.connections)this.connectionFirstSeenAt.has(e.id)||this.connectionFirstSeenAt.set(e.id,t)}isCurrentSwitchRequest(t){return t===this.switchRequestVersion}isCurrentProbeRequest(t){return t===this.probeRequestVersion}canProceedForProbe(t){return void 0===t||this.isCurrentProbeRequest(t)}async abortSwitchWithClient(t){t&&await t.close().catch(()=>{})}isSwitchStillValid(t,e){return this.isCurrentSwitchRequest(t)&&this.canProceedForProbe(e)}async resolveClientIdForSwitch(t){try{return await this.resolveClientId()}catch(e){if(await this.abortSwitchWithClient(t.existingClient),!this.isCurrentSwitchRequest(t.requestVersion))return null;const n=F(e);return this.applyConnectionEvent({type:"connect_failed",message:`Failed to resolve client id: ${n}`}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState))),null}}async disposePreviousActiveClient(){if(this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const t=this.activeClient;this.activeClient=null,await t.close().catch(()=>{})}}buildAgentDirectoryStatusPatch(){if(this.snapshot.hasEverLoadedAgentDirectory)return{};const t=this.connectionMachineState.tag;return"connecting"===t||"online"===t?{agentDirectoryStatus:"initial_loading",agentDirectoryError:null}:"error"===t?{agentDirectoryStatus:"error_before_first_success",agentDirectoryError:this.connectionMachineState.message}:{agentDirectoryStatus:"idle",agentDirectoryError:null}}async switchToConnection(t){const{connectionId:e,expectedProbeVersion:n,existingClient:s}=t;if(!this.canProceedForProbe(n))return void await this.abortSwitchWithClient(s);const o=K(this.host,e);if(!o)return void await this.abortSwitchWithClient(s);const c=++this.switchRequestVersion,l=await this.resolveClientIdForSwitch({existingClient:s,requestVersion:c});if(null===l)return;if(!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);if(await this.disposePreviousActiveClient(),!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);const u=this.snapshot.clientGeneration+1;s&&s.setReconnectEnabled(!0);const h=s??this.deps.createClient({host:this.host,connection:o,clientId:l,runtimeGeneration:u});if(this.isSwitchStillValid(c,n)){this.activeClient=h,this.unsubscribeClientHandlers=this.deps.mountClientHandlers?.({client:h,host:this.host,connection:o})??null,this.applyConnectionEvent({type:"select_connection",connectionId:o.id,connection:V(o)}),this.snapshot=Object.assign({},this.snapshot,{serverId:this.host.serverId},$(this.connectionMachineState),{client:h,clientGeneration:u});for(const t of this.listeners)t();this.unsubscribeClientStatus=h.subscribeConnectionStatus(t=>{if(!this.isCurrentSwitchRequest(c)||this.activeClient!==h)return;this.applyConnectionEvent({type:"client_state",state:t,lastError:h.lastError});const e=Object.assign({},$(this.connectionMachineState),this.buildAgentDirectoryStatusPatch());this.updateSnapshot(e)});try{s||await h.connect()}catch(t){if(!this.isCurrentSwitchRequest(c)||this.activeClient!==h)return;const e=F(t);this.applyConnectionEvent({type:"connect_failed",message:e}),this.updateSnapshot(Object.assign({},$(this.connectionMachineState)))}}else await h.close().catch(()=>{})}adoptReconciledServerId(t){this.host=Object.assign({},this.host,{serverId:t}),this.snapshot=Object.assign({},this.snapshot,{serverId:t});for(const t of this.listeners)t()}resolveClientId(){return this.clientIdPromise||(this.clientIdPromise=this.deps.getClientId().then(t=>(this.clientIdHash=T(t),t))),this.clientIdPromise}}const X="@paseo:daemon-registry",Y="localhost:6767",Z=5e3,tt="__PASEO_INITIAL_DAEMON_CONNECTION__";function et(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function nt(t){if(!(t?.isWebRuntime??f.isWeb)||"undefined"==typeof globalThis)return null;const e=globalThis[tt];if(!et(e))return null;const n="string"==typeof e.listen?e.listen.trim():"";return n?{listen:n,useTls:!0===e.useTls}:null}function st(){return null}function ot(t){return t.startsWith("local:")}function it(t){return new Promise(e=>setTimeout(e,t))}function rt(t,e,n){const s=t.get(e);void 0!==s&&(t.delete(e),t.set(n,s))}class ct{controllers=new Map;serverListeners=new Map;globalListeners=new Set;hostListListeners=new Set;version=0;hostListVersion=0;hostRegistryLoaded=!1;hosts=[];hostRegistryStatus="loading";lastConnectionStatusByServer=new Map;agentDirectoryBootstrapInFlight=new Map;configuredOverrideBootstrapInFlight=null;bootStarted=!1;constructor(t){this.deps=t?.deps??J(),this.storage=t?.storage??s.default}getHosts(){return this.hosts}getHostRegistryStatus(){return this.hostRegistryStatus}subscribeHostList(t){return this.hostListListeners.add(t),()=>{this.hostListListeners.delete(t)}}getHostListVersion(){return this.hostListVersion}isHostRegistryLoaded(){return this.hostRegistryLoaded}boot(){this.bootStarted||(this.bootStarted=!0,this.runBoot())}async runBoot(){await this.loadFromStorage(),this.markHostRegistryLoaded();let t=null;try{t=await this.storage.getItem("@paseo:e2e")}catch{return}if(t)return;if((0,y.shouldUseDesktopDaemon)())return;const e=this.deps.readInitialConnectionHint?this.deps.readInitialConnectionHint():nt();if(e){if(await this.bootstrapInitialConnectionHint(e))return}await this.bootstrapDefaultLocalhost()}async loadFromStorage(){let t=!1;try{const e=await this.storage.getItem(X);if(!e)return;const n=JSON.parse(e);if(!Array.isArray(n))return;const s=n.map(t=>(0,l.normalizeStoredHostProfile)(t)).filter(t=>null!==t),o=s.filter(t=>!ot(t.serverId));this.hosts=o,this.syncHosts(o),o.length!==s.length&&(t=!0)}catch(t){console.error("[HostRuntime] Failed to load host registry from storage",t)}finally{this.hostRegistryStatus="ready",this.emitHostList(),t&&this.persistHosts()}}markHostRegistryLoaded(){this.hostRegistryLoaded||(this.hostRegistryLoaded=!0,this.emitHostList())}async bootstrapDefaultLocalhost(){const t=(0,l.connectionFromListen)(Y);if(t&&!(0,l.registryHasConnection)(this.hosts,t))try{await this.probeAndUpsertConnection({connection:t,timeoutMs:Z})}catch(t){console.warn("[HostRuntime] bootstrap probe failed",{endpoint:Y,error:t})}}bootstrapConfiguredOverride(t){const e=(0,l.connectionFromListen)(t);if(!e)return;if((0,l.registryHasConnection)(this.hosts,e))return;if(this.configuredOverrideBootstrapInFlight)return;const n=this.runConfiguredOverrideBootstrap(t,e).finally(()=>{this.configuredOverrideBootstrapInFlight===n&&(this.configuredOverrideBootstrapInFlight=null)});this.configuredOverrideBootstrapInFlight=n}async runConfiguredOverrideBootstrap(t,e){let n=0;for(;!(0,l.registryHasConnection)(this.hosts,e);){n+=1;try{return void await this.probeAndUpsertConnection({connection:e,timeoutMs:Z})}catch(e){1!==n&&n%10!=0||console.warn("[HostRuntime] configured bootstrap probe failed",{endpoint:t,attempt:n,error:e}),await it(1e3)}}}async bootstrapInitialConnectionHint(t){const e=(0,l.connectionFromListen)(t.listen);if(!e)return!1;const n="directTcp"===e.type?Object.assign({},e,{useTls:t.useTls??e.useTls??!1}):e;if((0,l.registryHasConnection)(this.hosts,n))return!0;try{return await this.probeAndUpsertConnection({connection:n,timeoutMs:Z}),!0}catch(e){return console.warn("[HostRuntime] initial connection hint probe failed",{listen:t.listen,useTls:t.useTls,error:e}),!1}}reconcileServerId(t,e){if(t===e)return;const n=this.controllers.get(t);if(!n)return;if(this.controllers.has(e))return;rt(this.controllers,t,e),n.adoptReconciledServerId(e),rt(this.lastConnectionStatusByServer,t,e),rt(this.agentDirectoryBootstrapInFlight,t,e);const s=this.serverListeners.get(t);if(s){this.serverListeners.delete(t);const n=this.serverListeners.get(e)??new Set;for(const t of s)n.add(t);this.serverListeners.set(e,n)}this.hosts=this.hosts.map(n=>n.serverId===t?Object.assign({},n,{serverId:e,updatedAt:(new Date).toISOString()}):n),this.emitHostList(),this.emit(e),this.persistHosts()}async upsertDirectConnection(t){const e=(0,u.normalizeHostPort)(t.endpoint),n=t.password?.trim();return this.upsertHostConnection({serverId:t.serverId,label:t.label,connection:Object.assign({id:`direct:${e}`,type:"directTcp",endpoint:e,useTls:t.useTls??!1},n?{password:n}:{}),existingClient:t.existingClient})}async probeAndUpsertConnection(t){if("relay"===t.connection.type)throw new Error("Cannot probe a relay connection without a server id.");const e={serverId:"",label:t.label??t.connection.id,lifecycle:{},connections:[t.connection],preferredConnectionId:t.connection.id,createdAt:new Date(0).toISOString(),updatedAt:new Date(0).toISOString()},{client:n,serverId:s,hostname:o}=await this.deps.connectToDaemon(Object.assign({host:e,connection:t.connection},void 0!==t.timeoutMs?{timeoutMs:t.timeoutMs}:{}));return{profile:await this.upsertHostConnection({serverId:s,label:t.label??o??void 0,connection:t.connection,existingClient:n}),serverId:s,hostname:o}}async probeAndUpsertDirectConnection(t){const e=(0,u.normalizeHostPort)(t.endpoint),n=t.password?.trim();return this.probeAndUpsertConnection({label:t.label,connection:Object.assign({id:`direct:${e}`,type:"directTcp",endpoint:e,useTls:t.useTls??!1},n?{password:n}:{})})}async upsertRelayConnection(t){const e=(0,u.normalizeHostPort)(t.relayEndpoint),n=t.useTls??!1,s=t.daemonPublicKeyB64.trim();if(!s)throw new Error("daemonPublicKeyB64 is required");const o=void 0!==t.useTls;return this.upsertHostConnection({serverId:t.serverId,label:t.label,connection:Object.assign({id:n?`relay:wss:${e}`:`relay:${e}`,type:"relay",relayEndpoint:e},o?{useTls:n}:{},{daemonPublicKeyB64:s})})}async upsertConnectionFromOffer(t,e){const n=t.relay.useTls??(0,u.shouldUseTlsForDefaultHostedRelay)(t.relay.endpoint);return this.upsertRelayConnection({serverId:t.serverId,relayEndpoint:t.relay.endpoint,useTls:n,daemonPublicKeyB64:t.daemonPublicKeyB64,label:e})}async upsertConnectionFromOfferUrl(t,e){const n="#offer=",s=t.indexOf(n);if(-1===s)throw new Error("Missing #offer= fragment");const o=t.slice(s+7).trim();if(!o)throw new Error("Offer payload is empty");const c=(0,u.decodeOfferFragmentPayload)(o),l=p.ConnectionOfferSchema.parse(c);return this.upsertConnectionFromOffer(l,e)}async upsertConnectionFromListen(t){const e=t.listenAddress.trim(),n=t.serverId.trim(),s=(0,l.connectionFromListen)(e);if(!s)throw new Error(`Unsupported listen address: ${t.listenAddress}`);if(!n)throw new Error("Desktop daemon did not return a server id.");return this.upsertHostConnection({serverId:n,label:t.hostname??void 0,connection:s})}async renameHost(t,e){const n=this.hosts.map(n=>n.serverId===t?Object.assign({},n,{label:e,updatedAt:(new Date).toISOString()}):n);this.setHostsAndSync(n),await this.persistHosts()}async removeHost(t){const e=this.hosts.filter(e=>e.serverId!==t);this.setHostsAndSync(e),await this.persistHosts()}async removeConnection(t,e){const n=(new Date).toISOString(),s=this.hosts.map(s=>{if(s.serverId!==t)return s;const o=s.connections.filter(t=>t.id!==e);if(0===o.length)return null;const c=s.preferredConnectionId===e?o[0]?.id??null:s.preferredConnectionId;return Object.assign({},s,{connections:o,preferredConnectionId:c,updatedAt:n})}).filter(t=>null!==t);this.setHostsAndSync(s),await this.persistHosts()}async upsertHostConnection(t){const e=(new Date).toISOString(),n=(0,l.upsertHostConnectionInProfiles)({profiles:this.hosts,serverId:t.serverId,label:t.label,connection:t.connection,now:e});return this.setHostsAndSync(n,{initialConnectionByServerId:t.existingClient?new Map([[t.serverId,{connectionId:t.connection.id,existingClient:t.existingClient}]]):void 0}),this.persistHosts(),n.find(e=>e.serverId===t.serverId)}setHostsAndSync(t,e){this.hosts=t,this.syncHosts(t,e),this.emitHostList()}async persistHosts(){try{await this.storage.setItem(X,JSON.stringify(this.hosts))}catch(t){console.error("[HostRuntime] Failed to persist host registry",t)}}emitHostList(){this.hostListVersion+=1;for(const t of this.hostListListeners)t()}syncHosts(t,e){const n=new Set(t.map(t=>t.serverId));for(const[t,e]of this.controllers)n.has(t)||(this.controllers.delete(t),this.lastConnectionStatusByServer.delete(t),this.agentDirectoryBootstrapInFlight.delete(t),e.stop(),this.emit(t));for(const n of t){const t=e?.initialConnectionByServerId?.get(n.serverId),s=this.controllers.get(n.serverId);if(s){s.updateHost(n),t&&s.activateConnection(t).catch(()=>{t.existingClient.close().catch(()=>{})});continue}const o=new Q({host:n,deps:this.deps,onReconcileServerId:(t,e)=>this.reconcileServerId(t,e)});this.controllers.set(n.serverId,o),this.lastConnectionStatusByServer.set(n.serverId,o.getSnapshot().connectionStatus),o.subscribe(()=>{this.maybeAutoBootstrapAgentDirectory(n.serverId),this.emit(n.serverId)}),o.start(t?{initialConnection:t}:{}).catch(t=>{const e=t instanceof Error?t.message:String(t);o.markStartupError(e)}),this.emit(n.serverId)}}maybeAutoBootstrapAgentDirectory(t){const e=this.controllers.get(t);if(!e)return this.lastConnectionStatusByServer.delete(t),void this.agentDirectoryBootstrapInFlight.delete(t);const n=e.getSnapshot(),s=this.lastConnectionStatusByServer.get(t);this.lastConnectionStatusByServer.set(t,n.connectionStatus);const o="online"===n.connectionStatus&&"online"!==s;if(o&&(A.useSessionStore.getState().bumpHistorySyncGeneration(t),(0,R.invalidateCheckoutGitQueriesForServer)(E.queryClient,t)),"online"!==n.connectionStatus)return;if(!o&&n.hasEverLoadedAgentDirectory)return;if(this.agentDirectoryBootstrapInFlight.has(t))return;const c=Promise.resolve().then(()=>this.refreshAgentDirectory({serverId:t,subscribe:{subscriptionId:`app:${t}`},page:{limit:200}})).then(()=>{}).catch(e=>{console.error(`[HostRuntime] agent directory bootstrap failed (server ${t}): ${F(e)}`)}).finally(()=>{this.agentDirectoryBootstrapInFlight.get(t)===c&&this.agentDirectoryBootstrapInFlight.delete(t)});this.agentDirectoryBootstrapInFlight.set(t,c)}getSnapshot(t){return this.controllers.get(t)?.getSnapshot()??null}getVersion(){return this.version}getClient(t){return this.controllers.get(t)?.getClient()??null}subscribe(t,e){const n=this.serverListeners.get(t)??new Set;return n.add(e),this.serverListeners.set(t,n),()=>{const n=this.serverListeners.get(t);n&&(n.delete(e),0===n.size&&this.serverListeners.delete(t))}}subscribeAll(t){return this.globalListeners.add(t),()=>{this.globalListeners.delete(t)}}getEarliestOnlineHostServerId(){let t=null,e=null;for(const n of this.hosts){const s=this.getSnapshot(n.serverId);P(s)&&s?.lastOnlineAt&&((!e||s.lastOnlineAt<e)&&(e=s.lastOnlineAt,t=n.serverId))}return t}ensureConnectedAll(){for(const t of this.controllers.values())t.ensureConnected()}runProbeCycleNow(t){return t?this.controllers.get(t)?.runProbeCycleNow()??Promise.resolve():Promise.all(Array.from(this.controllers.values(),t=>t.runProbeCycleNow())).then(()=>{})}async refreshAgentDirectory(t){const e=this.controllers.get(t.serverId);if(!e)throw new Error(`Unknown host runtime for serverId ${t.serverId}`);const n=e.getSnapshot(),s=e.getClient();if(!s||"online"!==n.connectionStatus)throw new Error(`Host ${t.serverId} is not connected`);e.markAgentDirectorySyncLoading();try{const n=A.useSessionStore.getState().sessions[t.serverId];if(!t.filter&&(0,L.shouldUseLegacyDaemonWorkspaceDirectory)(n?.serverInfo)){const n=await(0,L.fetchLegacyDaemonWorkspaceDirectory)({client:s,serverId:t.serverId,subscribe:t.subscribe,page:t.page});return e.markAgentDirectorySyncReady(),{agents:n.agents,subscriptionId:n.subscriptionId}}const o=await j({client:s,filter:t.filter,subscribe:t.subscribe,page:t.page}),{agents:c}=(0,D.replaceFetchedAgentDirectory)({serverId:t.serverId,entries:o.entries});return e.markAgentDirectorySyncReady(),{agents:c,subscriptionId:o.subscriptionId}}catch(t){throw e.markAgentDirectorySyncError(F(t)),t}}refreshAllAgentDirectories(t){const e=t?.serverIds?new Set(t.serverIds):null;for(const[t]of this.controllers)e&&!e.has(t)||this.refreshAgentDirectory({serverId:t}).catch(()=>{})}markAgentDirectorySyncLoading(t){this.controllers.get(t)?.markAgentDirectorySyncLoading()}markAgentDirectorySyncReady(t){this.controllers.get(t)?.markAgentDirectorySyncReady()}markAgentDirectorySyncError(t,e){this.controllers.get(t)?.markAgentDirectorySyncError(e)}markAgentDirectorySyncIdle(t){this.controllers.get(t)?.markAgentDirectorySyncIdle()}emit(t){this.version+=1;const e=this.serverListeners.get(t);if(e){for(const t of e)t();for(const t of this.globalListeners)t()}else for(const t of this.globalListeners)t()}}let at=null;const lt="__paseoHostRuntimeStore";function ut(){if(at)return at;const t=globalThis;return t[lt]&&(at=t[lt]??null,at)||(at=new ct,t[lt]=at),at}},3274,[350,36,3275,3281,3282,3410,3412,3414,3413,3416,3420,3421,3422,3425,3423,3417,3283,3386,3426,3427,3440,3443,3445,3446]);
|
|
14920
14920
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAsyncStorage",{enumerable:!0,get:function(){return n.useAsyncStorage}}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return o}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=u.default},3275,[3276,3280]);
|
|
14921
14921
|
__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return i}});var e,t=r(d[0]);const o=((e=t)&&e.__esModule?e:{default:e}).default.bind({concatArrays:!0,ignoreUndefined:!0});function n(e,t){const n=window.localStorage.getItem(e);if(n){const l=JSON.parse(n),c=JSON.parse(t),s=JSON.stringify(o(l,c));window.localStorage.setItem(e,s)}else window.localStorage.setItem(e,t)}function l(e,t){return new Promise((o,n)=>{try{const n=e();t?.(null,n),o(n)}catch(e){t?.(e),n(e)}})}function c(e,t,o){return Promise.all(e).then(e=>{const n=o?.(e)??null;return t?.(null,n),Promise.resolve(n)},e=>(t?.(e),Promise.reject(e)))}const s={getItem:(e,t)=>l(()=>window.localStorage.getItem(e),t),setItem:(e,t,o)=>l(()=>window.localStorage.setItem(e,t),o),removeItem:(e,t)=>l(()=>window.localStorage.removeItem(e),t),mergeItem:(e,t,o)=>l(()=>n(e,t),o),clear:e=>l(()=>window.localStorage.clear(),e),getAllKeys:e=>l(()=>{const e=window.localStorage.length,t=[];for(let o=0;o<e;o+=1){const e=window.localStorage.key(o)||"";t.push(e)}return t},e),flushGetRequests:()=>{},multiGet:(e,t)=>c(e.map(e=>s.getItem(e)),t,t=>t.map((t,o)=>[e[o],t])),multiSet:(e,t)=>c(e.map(e=>s.setItem(e[0],e[1])),t),multiRemove:(e,t)=>c(e.map(e=>s.removeItem(e)),t),multiMerge:(e,t)=>c(e.map(e=>s.mergeItem(e[0],e[1])),t)};var i=s},3276,[3277]);
|
|
14922
14922
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),u=((e=t)&&e.__esModule?e:{default:e}).default},3277,[3278]);
|
|
@@ -14924,7 +14924,7 @@ __d(function(g,r,i,a,m,e,d){'use strict';const t=r(d[0]),{hasOwnProperty:n}=Obje
|
|
|
14924
14924
|
__d(function(g,r,i,a,m,e,d){'use strict';m.exports=t=>{if('[object Object]'!==Object.prototype.toString.call(t))return!1;const o=Object.getPrototypeOf(t);return null===o||o===Object.prototype}},3279,[]);
|
|
14925
14925
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useAsyncStorage=function(e){return{getItem:(...t)=>u.default.getItem(e,...t),setItem:(...t)=>u.default.setItem(e,...t),mergeItem:(...t)=>u.default.mergeItem(e,...t),removeItem:(...t)=>u.default.removeItem(e,...t)}};var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},3280,[3276]);
|
|
14926
14926
|
__d(function(g,r,_i,_a,m,e,d){'use strict';m.exports=function t(n,f){if(n===f)return!0;if(n&&f&&'object'==typeof n&&'object'==typeof f){if(n.constructor!==f.constructor)return!1;var i,o,u;if(Array.isArray(n)){if((i=n.length)!=f.length)return!1;for(o=i;0!==o--;)if(!t(n[o],f[o]))return!1;return!0}if(n instanceof Map&&f instanceof Map){if(n.size!==f.size)return!1;for(o of n.entries())if(!f.has(o[0]))return!1;for(o of n.entries())if(!t(o[1],f.get(o[0])))return!1;return!0}if(n instanceof Set&&f instanceof Set){if(n.size!==f.size)return!1;for(o of n.entries())if(!f.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(n)&&ArrayBuffer.isView(f)){if((i=n.length)!=f.length)return!1;for(o=i;0!==o--;)if(n[o]!==f[o])return!1;return!0}if(n.constructor===RegExp)return n.source===f.source&&n.flags===f.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===f.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===f.toString();if((i=(u=Object.keys(n)).length)!==Object.keys(f).length)return!1;for(o=i;0!==o--;)if(!Object.prototype.hasOwnProperty.call(f,u[o]))return!1;for(o=i;0!==o--;){var s=u[o];if(!t(n[s],f[s]))return!1}return!0}return n!=n&&f!=f}},3281,[]);
|
|
14927
|
-
__d(function(e,s,t,r,n,o,a){"use strict";const i=["requestId"],c=["config","provider","cwd","env","workspaceId","initialPrompt","images","git","worktreeName","requestId","labels","routine"];Object.defineProperty(o,'__esModule',{value:!0}),Object.defineProperty(o,"UploadCancelledError",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"UploadCapExceededError",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"UploadFailedError",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"DaemonClient",{enumerable:!0,get:function(){return B}});var d,u=s(a[0]),p=(d=u)&&d.__esModule?d:{default:d},l=s(a[1]),h=s(a[2]),m=s(a[3]),g=s(a[4]),y=s(a[5]),I=s(a[6]),q=s(a[7]),f=s(a[8]),w=s(a[9]),_=s(a[10]),S=s(a[11]);const b={debug:()=>{},info:(e,s)=>console.log(s,e),warn:(e,s)=>console.warn(s,e),error:(e,s)=>console.error(s,e)},R="undefined"!=typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>Date.now();function k(e){return"string"!=typeof e?null:e.length>0?e:null}function v(e,s){return"string"!=typeof e?e:"string"==typeof s?{agentId:e,requestId:s}:Object.assign({agentId:e},s)}function T(e,s){return"string"!=typeof e?e:"string"==typeof s?{agentId:e,requestId:s}:Object.assign({agentId:e},s)}class C extends Error{constructor(e){const s=[e.error];e.requestType&&s.push(`requestType=${e.requestType}`),e.code&&s.push(`code=${e.code}`),super(s.join(" ")),this.name="DaemonRpcError",this.requestId=e.requestId,this.requestType=e.requestType,this.code=e.code}}class M extends Error{constructor(e){super("Upload cancelled"),this.name="UploadCancelledError",this.uploadId=e}}class E extends Error{constructor(e,s){super(s??"Upload exceeds the size cap"),this.name="UploadCapExceededError",this.uploadId=e,this.code="too_large"}}class P extends Error{constructor(e,s,t){super(s),this.name="UploadFailedError",this.uploadId=e,t&&(this.code=t)}}function A(e,s,t){return"too_large"===s?new E(e,t):new P(e,t??`Upload failed: ${s}`,s)}class j extends Error{constructor(e){super(`Ping timed out (${e}ms)`),this.timeoutMs=e,this.name="PingTimeoutError"}}function O(e,s,t){return e instanceof j?new Error(`${s} timed out (${t}ms)`):e instanceof Error?e:new Error(String(e))}const F=6e4;function L(e){return e instanceof Error&&e.message.startsWith("Timeout waiting for message")}function x(e){if("string"!=typeof e)return null;const s=e.trim();return s.length>0?s:null}function D(e){const s=globalThis.atob(e),t=new Uint8Array(s.length);for(let e=0;e<s.length;e+=1)t[e]=s.charCodeAt(e);return t}function Q(e){let s="";for(let t=0;t<e.length;t+=32768)s+=String.fromCharCode.apply(null,e.subarray(t,t+32768));return globalThis.btoa(s)}function N(e){let s;return s="base64"===e.encoding&&e.content?D(e.content):"utf-8"===e.encoding&&e.content?(new TextEncoder).encode(e.content):new Uint8Array,{bytes:s,mime:e.mimeType??"application/octet-stream",size:e.size,path:e.path,kind:e.kind,modifiedAt:e.modifiedAt}}function H(e,s){const t=new Uint8Array(s);let r=0;for(const s of e)t.set(s,r),r+=s.byteLength;return t}function U(e){let s=0;for(let t=0;t<e.length;t+=1)s=31*s+e.charCodeAt(t)|0;return`h_${Math.abs(s).toString(16)}`}function W(e){if(!e)return null;const s=e.toLowerCase();return s.includes("timed out")?"connect_timeout":s.includes("disposed")?"disposed":s.includes("client closed")?"client_closed":s.includes("transport")?"transport_error":s.includes("failed to connect")?"connect_failed":"unknown"}class B{constructor(e){this.config=e,this.transport=null,this.transportCleanup=[],this.rawMessageListeners=new Set,this.messageHandlers=new Map,this.eventListeners=new Set,this.waiters=new Set,this.checkoutStatusInFlight=new Map,this.connectionListeners=new Set,this.reconnectTimeout=null,this.connectTimeout=null,this.pendingGenericTransportErrorTimeout=null,this.reconnectAttempt=0,this.shouldReconnect=!0,this.connectPromise=null,this.connectResolve=null,this.connectReject=null,this.lastErrorValue=null,this.connectionState={status:"idle"},this.checkoutDiffSubscriptions=new Map,this.terminalDirectorySubscriptions=new Map,this.terminalStreams=new S.TerminalStreamRouter,this.pendingBinaryFileReads=new Map,this.activeBinaryFileTransfers=new Map,this.completedBinaryFileReads=new Map,this.pendingSendQueue=[],this.lastServerInfoMessage=null,this.runtimeMetricsInterval=null,this.runtimeMetrics=null,this.pingProbe=null,this.livenessHeartbeatTimer=null,this.lastLivenessRttMs=null,this.consecutiveLivenessFailures=0,this.logger=e.logger??b,this.logConnectionPath=(0,g.isRelayClientWebSocketUrl)(this.config.url)?"relay":"direct";let s=null;try{s=new URL(this.config.url)}catch{s=null}const t=x(s?.searchParams.get("serverId"));this.logServerId=t??s?.host??null;const r=x(this.config.clientId);if(!r)throw new Error("Daemon client requires a non-empty clientId");this.config.clientId=r,this.logClientIdHash=U(r),this.logGeneration="number"==typeof this.config.runtimeGeneration&&Number.isFinite(this.config.runtimeGeneration)?this.config.runtimeGeneration:null;const n="number"==typeof e.runtimeMetricsIntervalMs&&e.runtimeMetricsIntervalMs>0?e.runtimeMetricsIntervalMs:0;if(n>0){const s="number"==typeof e.runtimeMetricsWindowMs&&e.runtimeMetricsWindowMs>0?Math.max(e.runtimeMetricsWindowMs,n):void 0;this.runtimeMetrics=new w.DaemonClientRuntimeMetrics(this.logger,{connectionPath:this.logConnectionPath,serverId:this.logServerId,getConnectionStatus:()=>this.connectionState.status},s?{windowMs:s}:void 0),this.runtimeMetricsInterval=setInterval(()=>{this.runtimeMetrics?.flush()},n)}}async connect(){if("disposed"===this.connectionState.status)throw new Error("Daemon client is disposed");if("connected"!==this.connectionState.status)return this.connectPromise||(this.shouldReconnect=!0,this.connectPromise=new Promise((e,s)=>{this.connectResolve=e,this.connectReject=s,this.attemptConnect()})),this.connectPromise}attemptConnect(){if("disposed"===this.connectionState.status)return void this.rejectConnect(new Error("Daemon client is disposed"));if(!this.shouldReconnect)return void this.rejectConnect(new Error("Daemon client is closed"));if("connecting"===this.connectionState.status)return;const e={},s=k(this.config.password);s?e.Authorization=`Bearer ${s}`:this.config.authHeader&&(e.Authorization=this.config.authHeader);const t=s?[`paseo.bearer.${s}`]:void 0;try{this.disposeTransport();const s=this.config.transportFactory??(0,f.createWebSocketTransportFactory)(this.config.webSocketFactory??f.defaultWebSocketFactory),r=!0===this.config.e2ee?.enabled&&(0,g.isRelayClientWebSocketUrl)(this.config.url);let n=s;if(r){const e=this.config.e2ee?.daemonPublicKeyB64;if(!e)throw new Error("daemonPublicKeyB64 is required for relay E2EE");n=(0,f.createRelayE2eeTransportFactory)({baseFactory:s,daemonPublicKeyB64:e,logger:this.logger})}const o=this.resolveTransportUrlForAttempt(),a=n(Object.assign({url:o,headers:e},t?{protocols:t}:{}));this.transport=a,this.lastServerInfoMessage=null,this.updateConnectionState({status:"connecting",attempt:this.reconnectAttempt},{event:"CONNECT_REQUEST"}),this.resetConnectTimeout();const i=Math.max(1,this.config.connectTimeoutMs??15e3);this.connectTimeout=setTimeout(()=>{"connecting"===this.connectionState.status&&(this.lastErrorValue="Connection timed out",this.disposeTransport(1001,"Connection timed out"),this.scheduleReconnect({reason:"Connection timed out",event:"CONNECT_TIMEOUT",reasonCode:"connect_timeout"}))},i),this.transportCleanup=[a.onOpen(()=>{this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null),this.lastErrorValue=null,this.sendHelloMessage()}),a.onClose(e=>{this.resetConnectTimeout(),this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null);const s=(0,f.describeTransportClose)(e);s&&(this.lastErrorValue=s),this.scheduleReconnect({reason:s,event:"TRANSPORT_CLOSE",reasonCode:"transport_closed"})}),a.onError(e=>{this.resetConnectTimeout();const s=(0,f.describeTransportError)(e);if("Transport error"===s)return this.lastErrorValue??(this.lastErrorValue=s),void(this.pendingGenericTransportErrorTimeout||(this.pendingGenericTransportErrorTimeout=setTimeout(()=>{this.pendingGenericTransportErrorTimeout=null,"connected"!==this.connectionState.status&&"connecting"!==this.connectionState.status||(this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"TRANSPORT_ERROR",reasonCode:"transport_error"}))},250)));this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null),this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"TRANSPORT_ERROR",reasonCode:"transport_error"})}),a.onMessage(e=>this.handleTransportMessage(e))]}catch(e){this.resetConnectTimeout();const s=e instanceof Error?e.message:"Failed to connect";this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"CONNECT_FAILED",reasonCode:"connect_failed"}),this.rejectConnect(e instanceof Error?e:new Error(s))}}resolveConnect(){this.connectResolve&&this.connectResolve(),this.connectPromise=null,this.connectResolve=null,this.connectReject=null}rejectConnect(e){this.connectReject&&this.connectReject(e),this.connectPromise=null,this.connectResolve=null,this.connectReject=null}async close(){"disposed"!==this.connectionState.status&&(this.shouldReconnect=!1,this.connectPromise=null,this.connectResolve=null,this.connectReject=null,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.resetConnectTimeout(),this.disposeTransport(1e3,"Client closed"),this.clearWaiters(new Error("Daemon client closed")),this.rejectPendingSendQueue(new Error("Daemon client closed")),this.rejectPingProbe(new Error("Daemon client closed")),this.terminalStreams.clearSlots(),this.lastServerInfoMessage=null,this.runtimeMetricsInterval&&(clearInterval(this.runtimeMetricsInterval),this.runtimeMetricsInterval=null,this.runtimeMetrics?.flush({final:!0}),this.runtimeMetrics=null),this.updateConnectionState({status:"disposed"},{event:"DISPOSE",reason:"Client closed",reasonCode:"disposed"}))}ensureConnected(){"disposed"!==this.connectionState.status&&(this.shouldReconnect||(this.shouldReconnect=!0),"connected"!==this.connectionState.status&&"connecting"!==this.connectionState.status&&this.connect())}getConnectionState(){return this.connectionState}subscribeConnectionStatus(e){return this.connectionListeners.add(e),e(this.connectionState),()=>{this.connectionListeners.delete(e)}}get isConnected(){return"connected"===this.connectionState.status}get isConnecting(){return"connecting"===this.connectionState.status}get lastError(){return this.lastErrorValue}getLastLivenessRttMs(){return this.lastLivenessRttMs}subscribe(e){return this.eventListeners.add(e),()=>this.eventListeners.delete(e)}subscribeRawMessages(e){return this.rawMessageListeners.add(e),()=>{this.rawMessageListeners.delete(e)}}on(e,s){if("function"==typeof e)return this.subscribe(e);const t=e,r=s;return this.messageHandlers.has(t)||this.messageHandlers.set(t,new Set),this.messageHandlers.get(t).add(r),()=>{const e=this.messageHandlers.get(t);e&&(e.delete(r),0===e.size&&this.messageHandlers.delete(t))}}sendSessionMessage(e){if(!this.transport||"connected"!==this.connectionState.status){if(this.config.suppressSendErrors)return;throw new Error(`Transport not connected (status: ${this.connectionState.status})`)}const s=h.SessionInboundMessageSchema.parse(e);try{this.transport.send(JSON.stringify({type:"session",message:s}))}catch(e){if(this.config.suppressSendErrors)return;throw e instanceof Error?e:new Error(String(e))}}sendBinaryFrame(e){if(!this.transport||"connected"!==this.connectionState.status){if(this.config.suppressSendErrors)return;throw new Error(`Transport not connected (status: ${this.connectionState.status})`)}try{this.transport.send(e)}catch(e){if(this.config.suppressSendErrors)return;throw e instanceof Error?e:new Error(String(e))}}sendSessionMessageOrThrow(e){const s=this.connectionState.status;if(this.transport&&"connected"===s){const s=h.SessionInboundMessageSchema.parse(e);return this.transport.send(JSON.stringify({type:"session",message:s})),Promise.resolve()}return"connecting"===s?new Promise((s,t)=>{const r=setTimeout(()=>{const e=this.pendingSendQueue.findIndex(e=>e.resolve===s);-1!==e&&this.pendingSendQueue.splice(e,1),t(new Error("Timed out waiting for connection to send message"))},this.config.defaultSendQueueTimeoutMs??6e4);this.pendingSendQueue.push({message:e,resolve:s,reject:t,timeoutHandle:r})}):Promise.reject(new Error(`Transport not connected (status: ${s})`))}flushPendingSendQueue(){const e=this.pendingSendQueue;this.pendingSendQueue=[];for(const s of e){clearTimeout(s.timeoutHandle);try{if(this.transport&&"connected"===this.connectionState.status){const e=h.SessionInboundMessageSchema.parse(s.message);this.transport.send(JSON.stringify({type:"session",message:e})),s.resolve()}else s.reject(new Error("Connection lost before message could be sent"))}catch(e){s.reject(e instanceof Error?e:new Error(String(e)))}}}rejectPendingSendQueue(e){const s=this.pendingSendQueue;this.pendingSendQueue=[];for(const t of s)clearTimeout(t.timeoutHandle),t.reject(e)}async sendRequest(e){const s=e.timeout??F,{promise:t,cancel:r}=this.waitForWithCancel(s=>{if("rpc_error"===s.type&&s.payload.requestId===e.requestId)return{kind:"error",error:new C({requestId:s.payload.requestId,error:s.payload.error,requestType:s.payload.requestType,code:s.payload.code})};const t=e.select(s);return null===t?null:{kind:"ok",value:t}},s,e.options);try{await this.sendSessionMessageOrThrow(e.message)}catch(e){const s=e instanceof Error?e:new Error(String(e));throw r(s),t.catch(()=>{}),s}const n=await t;if("error"===n.kind)throw n.error;return n.value}async sendCorrelatedRequest(e){return this.sendRequest({requestId:e.requestId,message:e.message,timeout:e.timeout,options:e.options,select:s=>{const t=s;if(t.type!==e.responseType)return null;const r=t.payload;return r.requestId!==e.requestId?null:e.selectPayload?e.selectPayload(r):r}})}sendCorrelatedSessionRequest(e){const s=this.createRequestId(e.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({},e.message,{requestId:s}));return this.sendCorrelatedRequest(Object.assign({requestId:s,message:t,responseType:e.responseType,timeout:e.timeout,options:{skipQueue:!0}},e.selectPayload?{selectPayload:e.selectPayload}:{}))}sendNamespacedCorrelatedSessionRequest(e){const s=e.message.type.replace(/\.request$/,".response");return this.sendCorrelatedSessionRequest(Object.assign({},e,{responseType:s}))}sendSessionMessageStrict(e){if(!this.transport||"connected"!==this.connectionState.status)throw new Error("Transport not connected");const s=h.SessionInboundMessageSchema.parse(e);try{this.transport.send(JSON.stringify({type:"session",message:s}))}catch(e){throw e instanceof Error?e:new Error(String(e))}}async clearAgentAttention(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"clear_agent_attention",agentId:e,requestId:s});await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"clear_agent_attention_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async clearWorkspaceAttention(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"workspace.clear_attention.request",workspaceId:e,requestId:s}),r=await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"workspace.clear_attention.response"!==e.type||e.payload.requestId!==s?null:e.payload});if(!r.success)throw new Error(r.error??"Failed to clear workspace attention")}sendHeartbeat(e){this.sendSessionMessage({type:"client_heartbeat",deviceType:e.deviceType,focusedAgentId:e.focusedAgentId,focusedTerminalId:e.focusedTerminalId??null,lastActivityAt:e.lastActivityAt,appVisible:e.appVisible,appVisibilityChangedAt:e.appVisibilityChangedAt})}registerPushToken(e){this.sendSessionMessage({type:"register_push_token",token:e})}sendWatchAction(e){this.sendSessionMessage(e)}async ping(e){const s=e?.requestId??`ping-${Date.now()}-${Math.random().toString(36).slice(2)}`,t=Date.now(),r=await this.sendRequest({requestId:s,message:{type:"ping",requestId:s,clientSentAt:t},timeout:e?.timeoutMs??5e3,select:e=>"pong"!==e.type||e.payload.requestId!==s||"number"!=typeof e.payload.serverReceivedAt||"number"!=typeof e.payload.serverSentAt?null:e.payload});return{requestId:s,clientSentAt:t,serverReceivedAt:r.serverReceivedAt,serverSentAt:r.serverSentAt,rttMs:Date.now()-t}}measureLatency(e){const s=Math.max(1,e?.timeoutMs??5e3);return this.sendPingAwaitRtt({timeoutMs:s,drivesLivenessFailure:!1}).catch(e=>{throw O(e,"Latency measurement",s)})}async livenessPing(e){const s=Math.max(1,e?.timeoutMs??5e3);try{const e=await this.sendPingAwaitRtt({timeoutMs:s,drivesLivenessFailure:!0});return this.lastLivenessRttMs=e,e}catch(e){throw O(e,"Liveness check",s)}}sendPingAwaitRtt(e){if("connected"!==this.connectionState.status||!this.transport)return Promise.reject(new Error(`Transport not connected (status: ${this.connectionState.status})`));if(this.pingProbe)return this.pingProbe.promise;const s=R(),t=e.timeoutMs;let r=null,n=null;const o=new Promise((e,s)=>{r=e,n=s}),a={promise:o,resolve:e=>r?.(e),reject:e=>n?.(e),timeoutHandle:setTimeout(()=>{if(this.pingProbe!==a)return;this.pingProbe=null;const e=new j(t);a.reject(e),a.drivesLivenessFailure&&this.recordLivenessFailure(O(e,"Liveness check",t))},t),startedAt:s,drivesLivenessFailure:e.drivesLivenessFailure};this.pingProbe=a;try{this.transport.send(JSON.stringify({type:"ping"}))}catch(e){this.clearPingProbe();const s=e instanceof Error?e:new Error(String(e));return a.drivesLivenessFailure&&this.recordLivenessFailure(s),Promise.reject(s)}return o}startLivenessHeartbeat(){this.stopLivenessHeartbeat(),this.lastLivenessRttMs=null,this.scheduleNextLivenessHeartbeat()}stopLivenessHeartbeat(){this.livenessHeartbeatTimer&&(clearTimeout(this.livenessHeartbeatTimer),this.livenessHeartbeatTimer=null)}scheduleNextLivenessHeartbeat(){"connected"!==this.connectionState.status||this.livenessHeartbeatTimer||(this.livenessHeartbeatTimer=setTimeout(()=>{this.livenessHeartbeatTimer=null,this.livenessPing({timeoutMs:15e3}).catch(()=>{}).finally(()=>{this.scheduleNextLivenessHeartbeat()})},1e4))}async fetchAgents(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_agents_request",requestId:s},e?.scope?{scope:e.scope}:{},e?.filter?{filter:e.filter}:{},e?.sort?{sort:e.sort}:{},e?.page?{page:e.page}:{},e?.subscribe?{subscribe:e.subscribe}:{}));return this.sendRequest({requestId:s,message:t,timeout:e?.timeout,options:{skipQueue:!0},select:e=>"fetch_agents_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async fetchAgentHistory(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_agent_history_request",requestId:s},e?.filter?{filter:e.filter}:{},e?.sort?{sort:e.sort}:{},e?.page?{page:e.page}:{}));return this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"fetch_agent_history_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async fetchRecentProviderSessions(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_recent_provider_sessions_request",requestId:s},e?.cwd?{cwd:e.cwd}:{},e?.providers?{providers:e.providers}:{},e?.since?{since:e.since}:{},e?.limit?{limit:e.limit}:{}));return this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"fetch_recent_provider_sessions_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async fetchWorkspaces(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_workspaces_request",requestId:s},e?.filter?{filter:e.filter}:{},e?.sort?{sort:e.sort}:{},e?.page?{page:e.page}:{},e?.subscribe?{subscribe:e.subscribe}:{}));return this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"fetch_workspaces_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async openProject(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"open_project_request",cwd:e},responseType:"open_project_response"})}async addProject(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"project.add.request",cwd:e},responseType:"project.add.response"})}async startWorkspaceScript(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"start_workspace_script_request",workspaceId:e,scriptName:s},responseType:"start_workspace_script_response"})}async archiveWorkspace(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"archive_workspace_request",workspaceId:e},responseType:"archive_workspace_response"})}async renameProject(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"project.rename.request",projectId:e,customName:s},responseType:"project.rename.response",timeout:1e4})}async fetchWorkspaceSetupStatus(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"workspace_setup_status_request",workspaceId:e},responseType:"workspace_setup_status_response"})}async fetchAgent(e,s){const t=v(e,s),r=this.createRequestId(t.requestId),n=h.SessionInboundMessageSchema.parse({type:"fetch_agent_request",requestId:r,agentId:t.agentId}),o=await this.sendRequest({requestId:r,message:n,timeout:t.timeout,options:{skipQueue:!0},select:e=>"fetch_agent_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(o.error)throw new Error(o.error);return o.agent?{agent:o.agent,project:o.project??null}:null}resubscribeCheckoutDiffSubscriptions(){if(0!==this.checkoutDiffSubscriptions.size)for(const[e,s]of this.checkoutDiffSubscriptions){const t=h.SessionInboundMessageSchema.parse({type:"subscribe_checkout_diff_request",subscriptionId:e,cwd:s.cwd,compare:s.compare,requestId:this.createRequestId()});this.sendSessionMessage(t)}}resubscribeTerminalDirectorySubscriptions(){if(0!==this.terminalDirectorySubscriptions.size)for(const e of this.terminalDirectorySubscriptions.values())this.sendSessionMessage(Object.assign({type:"subscribe_terminals_request",cwd:e.cwd},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{}))}async createAgent(e){return(await this.createAgentRequest(e)).agent}async createAgentWithRoutine(e){const s=await this.createAgentRequest(e);if(!s.scheduleId)throw new Error(`Agent ${s.agent.id} was created but the daemon reported no routine. Check its schedules before relying on it.`);return{agent:s.agent,routine:{scheduleId:s.scheduleId,nextRunAt:s.scheduleNextRunAt??null}}}async createAgentRequest(e){const s=this.createRequestId(e.requestId),t=h.SessionInboundMessageSchema.parse($(e,s)),r=await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const t=h.AgentCreatedStatusPayloadSchema.safeParse(e.payload);if(t.success&&t.data.requestId===s)return t.data;const r=h.AgentCreateFailedStatusPayloadSchema.safeParse(e.payload);return r.success&&r.data.requestId===s?r.data:null}});if("agent_create_failed"===r.status)throw new Error(r.error);return Object.assign({agent:r.agent},r.scheduleId?{scheduleId:r.scheduleId}:{},void 0!==r.scheduleNextRunAt?{scheduleNextRunAt:r.scheduleNextRunAt}:{})}async deleteAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"delete_agent_request",agentId:e,requestId:s});await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"agent_deleted"!==e.type||e.payload.requestId!==s?null:e.payload})}async archiveAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"archive_agent_request",agentId:e,requestId:s});return{archivedAt:(await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"agent_archived"!==e.type||e.payload.requestId!==s?null:e.payload})).archivedAt}}async listBackgroundTasks(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"list_background_tasks_request"},void 0===e?{}:{agentId:e},{requestId:s}));return(await this.sendCorrelatedRequest({requestId:s,message:t,responseType:"list_background_tasks_response",options:{skipQueue:!0}})).tasks}async setAgentContext(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"set_agent_context_request",agentId:e.agentId},void 0===e.links?{}:{links:e.links},void 0===e.secrets?{}:{secrets:e.secrets},{requestId:s})),r=await this.sendCorrelatedRequest({requestId:s,message:t,responseType:"set_agent_context_response",options:{skipQueue:!0}});return Object.assign({digest:r.digest,maskedCount:r.maskedCount},void 0===r.error?{}:{error:r.error})}async enrichReferences(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"enrich_references_request",urls:e,requestId:s});return(await this.sendCorrelatedRequest({requestId:s,message:t,responseType:"enrich_references_response",options:{skipQueue:!0}})).enrichments}async readBackgroundTaskOutput(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"background_task_output_request",agentId:e,taskId:s},void 0===t?.maxBytes?{}:{maxBytes:t.maxBytes},{requestId:r})),o=await this.sendCorrelatedRequest({requestId:r,message:n,responseType:"background_task_output_response",options:{skipQueue:!0}});return{text:o.text,truncated:o.truncated,byteSize:o.byteSize}}async dismissBackgroundTask(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"dismiss_background_task_request",agentId:e,taskId:s,requestId:t});return{dismissed:(await this.sendRequest({requestId:t,message:r,timeout:1e4,options:{skipQueue:!0},select:e=>"background_task_dismissed"!==e.type||e.payload.requestId!==t?null:e.payload})).dismissed}}async detachAgent(e){const s=await this.sendNamespacedCorrelatedSessionRequest({message:{type:"agent.detach.request",agentId:e}});if(!s.accepted)throw new Error(s.error??"detachAgent rejected")}async updateAgent(e,s){const t=this.createRequestId(),r={},n=[];for(const[e,t]of Object.entries(s.labels??{}))null===t?n.push(e):r[e]=t;const o=h.SessionInboundMessageSchema.parse(Object.assign({type:"update_agent_request",agentId:e},void 0!==s.name?{name:s.name}:{},Object.keys(r).length>0?{labels:r}:{},n.length>0?{labelsRemove:n}:{},{requestId:t})),a=await this.sendRequest({requestId:t,message:o,options:{skipQueue:!0},select:e=>"update_agent_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!a.accepted)throw new Error(a.error??"updateAgent rejected")}async rewindSession(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"rewind_session_request",requestId:t,agentId:e,turnId:s}),n=await this.sendRequest({requestId:t,message:r,timeout:3e4,options:{skipQueue:!0},select:e=>"rewind_session_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error||!n.newSessionId)throw new Error(n.error??"rewind: daemon response missing newSessionId");return{newSessionId:n.newSessionId}}async editMessage(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"edit_message_request",requestId:r,agentId:e,turnId:s},"string"==typeof t?{newContent:t}:{})),o=await this.sendRequest({requestId:r,message:n,timeout:3e4,options:{skipQueue:!0},select:e=>"edit_message_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(o.error||!o.newSessionId)throw new Error(o.error??"editMessage: daemon response missing newSessionId");return{newSessionId:o.newSessionId,adopted:!0===o.adopted}}async listWorkspaceSessions(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"list_workspace_sessions_request",requestId:t,workspaceId:e}),n=await this.sendRequest({requestId:t,message:r,timeout:3e4,options:{skipQueue:!0},select:e=>"list_workspace_sessions_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error)throw new Error(n.error);return Array.isArray(n.sessions)?n.sessions:[]}async subscribePush(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"subscribe_push_request",requestId:s,subscription:e}),r=await this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"subscribe_push_response"!==e.type||e.payload.requestId!==s?null:e.payload});if(!r.ok||r.error)throw new Error(r.error??"subscribePush rejected");return Object.assign({ok:r.ok},r.vapidPublicKey?{vapidPublicKey:r.vapidPublicKey}:{})}async getVapidPublicKey(){const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"get_vapid_public_key_request",requestId:e});return(await this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"get_vapid_public_key_response"!==s.type||s.payload.requestId!==e?null:s.payload})).publicKey}async listAllSessions(e){if(this.lastServerInfoMessage?.features?.sessionsListRpc||(0,g.isRelayClientWebSocketUrl)(this.config.url)){const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"list_all_sessions_request",requestId:e}),t=await this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"list_all_sessions_response"!==s.type||s.payload.requestId!==e?null:s.payload});if(t.error)throw new Error(`list_all_sessions failed: ${t.error}`);return Array.isArray(t.sessions)?t.sessions:[]}const s=await this.daemonHttpJson({method:"GET",path:"/sessions",signal:e?.signal});return Array.isArray(s.sessions)?s.sessions:[]}async listWorkflows(){if(!0!==this.lastServerInfoMessage?.features?.workflows)return[];const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"workflow.list.request",requestId:e});return this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"workflow.list.response"!==s.type||s.payload.requestId!==e?null:s.payload.workflows})}async getWorkflow(e){if(!0!==this.lastServerInfoMessage?.features?.workflows)return null;const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"workflow.get.request",requestId:s,workflowId:e});return this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"workflow.get.response"!==e.type||e.payload.requestId!==s?null:e.payload.workflow})}async cancelWorkflow(e){if(!0!==this.lastServerInfoMessage?.features?.workflows)throw new Error("This host does not support workflows. Update the host to use this.");const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"workflow.cancel.request",requestId:s,workflowId:e});return this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"workflow.cancel.response"!==e.type||e.payload.requestId!==s?null:e.payload.workflow})}async startWorkflow(e){if(!0!==this.lastServerInfoMessage?.features?.workflows)throw new Error("This host does not support workflows. Update the host to use this.");const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"workflow.start.request",requestId:s,graph:e.graph,provider:e.provider,cwd:e.cwd},e.model?{model:e.model}:{},e.title?{title:e.title}:{},e.labels?{labels:e.labels}:{},e.agentPresets&&Object.keys(e.agentPresets).length>0?{agentPresets:e.agentPresets}:{}));return this.sendRequest({requestId:s,message:t,timeout:3e4,options:{skipQueue:!0},select:e=>"workflow.start.response"!==e.type||e.payload.requestId!==s?null:{workflowId:e.payload.workflowId,childAgentIds:e.payload.childAgentIds,status:e.payload.status}})}async listExtensions(){if(!this.lastServerInfoMessage?.features?.extensions)return[];const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"extensions.list.request",requestId:e}),t=await this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"extensions.list.response"!==s.type||s.payload.requestId!==e?null:s.payload});if(t.error)throw new Error(`extensions.list failed: ${t.error}`);return t.extensions}async executeExtensionCommand(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"extensions.command.execute.request",requestId:t,commandId:e,args:s}),n=await this.sendRequest({requestId:t,message:r,timeout:3e4,options:{skipQueue:!0},select:e=>"extensions.command.execute.response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.ok)throw new Error(n.error??"extension command failed");return n.result}async searchSessions(e){if(this.lastServerInfoMessage?.features?.sessionsListRpc||(0,g.isRelayClientWebSocketUrl)(this.config.url)){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"search_sessions_request",requestId:s,query:e.query},"number"==typeof e.limit?{limit:e.limit}:{},e.sources&&e.sources.length>0?{sources:[...e.sources]}:{})),r=await this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"search_sessions_response"!==e.type||e.payload.requestId!==s?null:e.payload});if(r.error)throw new Error(`search_sessions failed: ${r.error}`);return Array.isArray(r.results)?r.results:[]}const s=new URLSearchParams;s.set("q",e.query),"number"==typeof e.limit&&s.set("limit",String(e.limit)),e.sources&&e.sources.length>0&&s.set("source",e.sources.join(","));const t=await this.daemonHttpJson({method:"GET",path:`/sessions/search?${s.toString()}`,signal:e.signal});return Array.isArray(t.results)?t.results:[]}getHttpBaseUrl(){const e=this.config.url;if((0,g.isRelayClientWebSocketUrl)(e))throw new Error("HTTP routes are not available over relay transport");let s;try{s=new URL(e)}catch{throw new Error(`Cannot derive HTTP base from WS url: ${e}`)}return"ws:"===s.protocol?s.protocol="http:":"wss:"===s.protocol&&(s.protocol="https:"),s.username="",s.password="",s.pathname=s.pathname.replace(/\/ws\/?$/,"/"),s.search="",s.hash="",s.origin}buildAuthHeader(){const e=k(this.config.password);return e?`Bearer ${e}`:this.config.authHeader?this.config.authHeader:null}async daemonHttpJson(e){const s=this.getHttpBaseUrl(),t=new URL(e.path,s).toString(),r={},n=this.buildAuthHeader();let o;n&&(r.Authorization=n),void 0!==e.body&&(r["Content-Type"]="application/json");try{o=await fetch(t,Object.assign({method:e.method,headers:r},void 0!==e.body?{body:JSON.stringify(e.body)}:{},e.signal?{signal:e.signal}:{}))}catch(s){const t=s instanceof Error?s.message:String(s);throw new Error(`daemon HTTP ${e.method} ${e.path} failed: ${t}`,{cause:s})}if(!o.ok){let s=null;try{s=await o.json()}catch{s=null}const t=s&&"object"==typeof s&&"error"in s?String(s.error):`http_${o.status}`;throw new Error(`daemon HTTP ${e.method} ${e.path} ${o.status}: ${t}`)}return await o.json()}async removeProject(e,s){const t=await this.sendNamespacedCorrelatedSessionRequest({requestId:s,message:{type:"project.remove.request",projectId:e}});if(!t.accepted)throw new Error(t.error??"removeProject rejected");return{removedWorkspaceIds:t.removedWorkspaceIds}}async setWorkspaceTitle(e,s,t){const r=await this.sendCorrelatedSessionRequest({requestId:t,message:{type:"workspace.title.set.request",workspaceId:e,title:s},responseType:"workspace.title.set.response"});if(!r.accepted)throw new Error(r.error??"setWorkspaceTitle rejected");return{title:r.title}}async answerAgentDecision(e,s,t,r,n){const o=await this.sendCorrelatedSessionRequest({requestId:n,message:{type:"agent.decision.answer.request",agentId:e,decisionId:s,optionId:t,note:r},responseType:"agent.decision.answer.response"});if(!o.accepted)throw new Error(o.error??"answerAgentDecision rejected");return{decision:o.decision}}async consolidateAgents(e,s,t){const r=await this.sendCorrelatedSessionRequest({requestId:t,message:{type:"agent.consolidate.request",winnerId:e,sourceIds:s},responseType:"agent.consolidate.response"});if(!r.accepted)throw new Error(r.error??"consolidateAgents rejected");return{archivedIds:r.archivedIds}}async snoozeAgent(e,s,t=null,r=null,n){const o=await this.sendCorrelatedSessionRequest({requestId:n,message:{type:"agent.snooze.request",agentId:e,until:s,untilWhat:t,why:r},responseType:"agent.snooze.response"});if(!o.accepted)throw new Error(o.error??"snoozeAgent rejected");return{snooze:o.snooze}}async resumeAgent(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"resume_agent_request",requestId:t,handle:e},s?{overrides:s}:{}));return(await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const s=h.AgentResumedStatusPayloadSchema.safeParse(e.payload);return s.success&&s.data.requestId===t?s.data:null}})).agent}async importAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"import_agent_request",requestId:s},"providerId"in e?{providerId:e.providerId,providerHandleId:e.providerHandleId}:{provider:e.provider,sessionId:e.sessionId},e.cwd?{cwd:e.cwd}:{},e.labels&&Object.keys(e.labels).length>0?{labels:e.labels}:{})),r=await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const t=h.AgentResumedStatusPayloadSchema.safeParse(e.payload);if(t.success&&t.data.requestId===s)return t.data;const r=h.AgentCreateFailedStatusPayloadSchema.safeParse(e.payload);return r.success&&r.data.requestId===s?r.data:null}});if("agent_create_failed"===r.status)throw new Error(r.error);return r.agent}async refreshAgent(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse({type:"refresh_agent_request",agentId:e,requestId:t});return this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const s=h.AgentRefreshedStatusPayloadSchema.safeParse(e.payload);return s.success&&s.data.requestId===t?s.data:null}})}async fetchAgentTimeline(e,s={}){const t=this.createRequestId(s.requestId),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_agent_timeline_request",agentId:e,requestId:t},s.direction?{direction:s.direction}:{},s.cursor?{cursor:s.cursor}:{},"number"==typeof s.limit?{limit:s.limit}:{},s.projection?{projection:s.projection}:{})),n=await this.sendRequest({requestId:t,message:r,timeout:s.timeout,options:{skipQueue:!0},select:e=>"fetch_agent_timeline_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error)throw new Error(n.error);return n}async buildAgentForkContext(e,s={}){const t=this.createRequestId(s.requestId),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"agent.fork_context.request",agentId:e,requestId:t},s.boundaryMessageId?{boundaryMessageId:s.boundaryMessageId}:{})),n=await this.sendRequest({requestId:t,message:r,timeout:15e3,options:{skipQueue:!0},select:e=>"agent.fork_context.response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error)throw new Error(n.error);return n}async sendAgentMessage(e,s,t){const r=this.createRequestId(),n=t?.messageId??crypto.randomUUID(),o=h.SessionInboundMessageSchema.parse(Object.assign({type:"send_agent_message_request",requestId:r,agentId:e,text:s},n?{messageId:n}:{},t?.images?{images:t.images}:{},t?.attachments?{attachments:t.attachments}:{})),a=await this.sendRequest({requestId:r,message:o,options:{skipQueue:!0},select:e=>"send_agent_message_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!a.accepted)throw new Error(a.error??"sendAgentMessage rejected")}async sendMessage(e,s,t){await this.sendAgentMessage(e,s,t)}async rewindAgent(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse({type:"agent.rewind.request",requestId:r,agentId:e,messageId:s,mode:t}),o=await this.sendRequest({requestId:r,message:n,options:{skipQueue:!0},select:e=>"agent.rewind.response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.ok)throw new Error(o.error??"Agent rewind failed");return o}async cancelAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"cancel_agent_request",agentId:e,requestId:s});await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"cancel_agent_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async setAgentMode(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"set_agent_mode_request",agentId:e,modeId:s,requestId:t}),n=await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>"set_agent_mode_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.accepted)throw new Error(n.error??"setAgentMode rejected");return n.notice??null}async setAgentModel(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"set_agent_model_request",agentId:e,modelId:s,requestId:t}),n=await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>"set_agent_model_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.accepted)throw new Error(n.error??"setAgentModel rejected")}async swapAgentProvider(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"swap_agent_provider_request",agentId:e,newProviderId:s,requestId:r},t?{overrides:t}:{})),o=await this.sendRequest({requestId:r,message:n,timeout:3e4,options:{skipQueue:!0},select:e=>"swap_agent_provider_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.accepted)throw new Error(o.error??"swapAgentProvider rejected")}async setAgentFeature(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse({type:"set_agent_feature_request",agentId:e,featureId:s,value:t,requestId:r}),o=await this.sendRequest({requestId:r,message:n,options:{skipQueue:!0},select:e=>"set_agent_feature_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.accepted)throw new Error(o.error??"setAgentFeature rejected")}async setAgentThinkingOption(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"set_agent_thinking_request",agentId:e,thinkingOptionId:s,requestId:t}),n=await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>"set_agent_thinking_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.accepted)throw new Error(n.error??"setAgentThinkingOption rejected");return n.notice??null}async restartServer(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"restart_server_request"},e&&e.trim().length>0?{reason:e}:{},{requestId:t}));return this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const s=h.RestartRequestedStatusPayloadSchema.safeParse(e.payload);return s.success?s.data.requestId!==t?null:s.data:null}})}async shutdownServer(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse({type:"shutdown_server_request",requestId:s});return this.sendRequest({requestId:s,message:t,timeout:e?.timeout,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const t=h.ShutdownRequestedStatusPayloadSchema.safeParse(e.payload);return t.success?t.data.requestId!==s?null:t.data:null}})}async updateDaemon(e){const s=this.createRequestId(e),t=h.SessionInboundMessageSchema.parse({type:"daemon.update.request",requestId:s});return this.sendRequest({requestId:s,message:t,timeout:3e5,options:{skipQueue:!0},select:e=>{const t=h.DaemonUpdateResponseSchema.safeParse(e);return t.success?t.data.payload.requestId!==s?null:t.data.payload:null}})}async setVoiceMode(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"set_voice_mode",enabled:e},s?{agentId:s}:{},t?{language:t}:{},{requestId:r})),o=await this.sendRequest({requestId:r,message:n,select:e=>"set_voice_mode_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.accepted){const e="string"==typeof o.reasonCode&&o.reasonCode.trim().length>0?` (${o.reasonCode})`:"";throw new Error((o.error??"Failed to set voice mode")+e)}return o}async sendVoiceAudioChunk(e,s,t=!1){this.sendSessionMessage({type:"voice_audio_chunk",audio:e,format:s,isLast:t})}async startDictationStream(e,s,t){const r=this.waitForWithCancel(s=>"dictation_stream_ack"!==s.type||s.payload.dictationId!==e||-1!==s.payload.ackSeq?null:s.payload,3e4,{skipQueue:!0}),n=r.promise.then(()=>{}),o=this.waitForWithCancel(s=>"dictation_stream_error"!==s.type||s.payload.dictationId!==e?null:s.payload,3e4,{skipQueue:!0}),a=o.promise.then(e=>{throw new Error(e.error)}),i=new Error("Cancelled dictation start waiter");try{this.sendSessionMessageStrict(Object.assign({type:"dictation_stream_start",dictationId:e,format:s},t?{language:t}:{})),await Promise.race([n,a])}finally{r.cancel(i),o.cancel(i),n.catch(()=>{}),a.catch(()=>{})}}sendDictationStreamChunk(e,s,t,r){this.sendSessionMessageStrict({type:"dictation_stream_chunk",dictationId:e,seq:s,audio:t,format:r})}async finishDictationStream(e,s){const t=this.waitForWithCancel(s=>"dictation_stream_final"!==s.type||s.payload.dictationId!==e?null:s.payload,0,{skipQueue:!0}),r=this.waitForWithCancel(s=>"dictation_stream_error"!==s.type||s.payload.dictationId!==e?null:s.payload,0,{skipQueue:!0}),n=this.waitForWithCancel(s=>"dictation_stream_finish_accepted"!==s.type||s.payload.dictationId!==e?null:s.payload,6e4,{skipQueue:!0}),o=t.promise,a=r.promise.then(e=>{throw new Error(e.error)}),i=n.promise,c=o.then(e=>({kind:"final",payload:e})),d=a.then(()=>({kind:"error",error:new Error("Unexpected dictation stream error state")}),e=>({kind:"error",error:e instanceof Error?e:new Error(String(e))})),u=i.then(e=>({kind:"accepted",payload:e}),e=>L(e)?{kind:"accepted_timeout"}:{kind:"accepted_error",error:e instanceof Error?e:new Error(String(e))}),p=async e=>{if(!Number.isFinite(e)||e<=0){const e=await Promise.race([c,d]);if("error"===e.kind)throw e.error;return e.payload}let s=null;const t=new Promise(t=>{s=setTimeout(()=>t({kind:"timeout"}),e)}),r=await Promise.race([c,d,t]);if(s&&clearTimeout(s),"timeout"===r.kind)throw new Error(`Timeout waiting for dictation finalization (${e}ms)`);if("error"===r.kind)throw r.error;return r.payload},l=new Error("Cancelled dictation finish waiter");try{this.sendSessionMessageStrict({type:"dictation_stream_finish",dictationId:e,finalSeq:s});const t=await Promise.race([c,d,u]);if("final"===t.kind)return t.payload;if("error"===t.kind)throw t.error;return"accepted"===t.kind?await p(t.payload.timeoutMs+5e3):await p(3e5)}finally{t.cancel(l),r.cancel(l),n.cancel(l),o.catch(()=>{}),a.catch(()=>{}),i.catch(()=>{})}}cancelDictationStream(e){this.sendSessionMessageStrict({type:"dictation_stream_cancel",dictationId:e})}async abortRequest(){this.sendSessionMessage({type:"abort_request"})}async audioPlayed(e){this.sendSessionMessage({type:"audio_played",id:e})}async getCheckoutStatus(e,s){const t=s?.requestId;if(!t){const s=this.checkoutStatusInFlight.get(e);if(s)return s}const r=this.createRequestId(t),n=h.SessionInboundMessageSchema.parse({type:"checkout_status_request",cwd:e,requestId:r}),o=this.sendRequest({requestId:r,message:n,options:{skipQueue:!0},select:e=>"checkout_status_response"!==e.type||e.payload.requestId!==r?null:e.payload});return t||(this.checkoutStatusInFlight.set(e,o),o.finally(()=>{this.checkoutStatusInFlight.get(e)===o&&this.checkoutStatusInFlight.delete(e)}).catch(()=>{})),o}normalizeCheckoutDiffCompare(e){if("uncommitted"===e.mode)return!0===e.ignoreWhitespace?{mode:"uncommitted",ignoreWhitespace:!0}:{mode:"uncommitted"};const s=e.baseRef?.trim();return s?!0===e.ignoreWhitespace?{mode:"base",baseRef:s,ignoreWhitespace:!0}:{mode:"base",baseRef:s}:!0===e.ignoreWhitespace?{mode:"base",ignoreWhitespace:!0}:{mode:"base"}}async getCheckoutDiff(e,s,t){const r=`oneshot-checkout-diff:${crypto.randomUUID()}`;try{const n=await this.subscribeCheckoutDiff(e,s,{subscriptionId:r,requestId:t});return{cwd:n.cwd,files:n.files,error:n.error,requestId:n.requestId}}finally{try{this.unsubscribeCheckoutDiff(r)}catch{}}}async subscribeCheckoutDiff(e,s,t){const r=t?.subscriptionId??crypto.randomUUID(),n=this.normalizeCheckoutDiffCompare(s),o=this.checkoutDiffSubscriptions.get(r)??null;this.checkoutDiffSubscriptions.set(r,{cwd:e,compare:n});const a=this.createRequestId(t?.requestId),i=h.SessionInboundMessageSchema.parse({type:"subscribe_checkout_diff_request",subscriptionId:r,cwd:e,compare:n,requestId:a});try{return await this.sendCorrelatedRequest({requestId:a,message:i,responseType:"subscribe_checkout_diff_response",options:{skipQueue:!0},selectPayload:e=>e.subscriptionId!==r?null:e})}catch(e){throw o?this.checkoutDiffSubscriptions.set(r,o):this.checkoutDiffSubscriptions.delete(r),e}}unsubscribeCheckoutDiff(e){this.checkoutDiffSubscriptions.delete(e),this.sendSessionMessage({type:"unsubscribe_checkout_diff_request",subscriptionId:e})}async checkoutCommit(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_commit_request",cwd:e,message:s.message,addAll:s.addAll},responseType:"checkout_commit_response"})}async checkoutMerge(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_merge_request",cwd:e,baseRef:s.baseRef,strategy:s.strategy,requireCleanTarget:s.requireCleanTarget},responseType:"checkout_merge_response"})}async checkoutMergeFromBase(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_merge_from_base_request",cwd:e,baseRef:s.baseRef,requireCleanTarget:s.requireCleanTarget},responseType:"checkout_merge_from_base_response"})}async checkoutPull(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout_pull_request",cwd:e},responseType:"checkout_pull_response"})}async checkoutPush(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout_push_request",cwd:e},responseType:"checkout_push_response"})}async checkoutRefresh(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout.refresh.request",cwd:e},responseType:"checkout.refresh.response"})}async checkoutPrCreate(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_pr_create_request",cwd:e,title:s.title,body:s.body,baseRef:s.baseRef},responseType:"checkout_pr_create_response"})}async checkoutPrMerge(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_pr_merge_request",cwd:e,mergeMethod:s.method},responseType:"checkout_pr_merge_response"})}async checkoutGithubSetAutoMerge(e,s,t){return this.sendNamespacedCorrelatedSessionRequest({requestId:t,message:Object.assign({type:"checkout.github.set_auto_merge.request",cwd:e,enabled:s.enabled},s.enabled?{mergeMethod:s.method}:{})})}async checkoutGithubGetCheckDetails(e,s){return this.sendNamespacedCorrelatedSessionRequest({requestId:s,message:{type:"checkout.github.get_check_details.request",cwd:e.cwd,repoOwner:e.repoOwner,repoName:e.repoName,checkRunId:e.checkRunId,workflowRunId:e.workflowRunId}})}async checkoutPrStatus(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout_pr_status_request",cwd:e},responseType:"checkout_pr_status_response"})}async pullRequestTimeline(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"pull_request_timeline_request",cwd:e.cwd,prNumber:e.prNumber,repoOwner:e.repoOwner,repoName:e.repoName},responseType:"pull_request_timeline_response"})}async checkoutSwitchBranch(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_switch_branch_request",cwd:e,branch:s},responseType:"checkout_switch_branch_response"})}async renameBranch(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"checkout.rename_branch.request",cwd:e.cwd,branch:e.branch},responseType:"checkout.rename_branch.response"})}async stashSave(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"stash_save_request",cwd:e,branch:s?.branch},responseType:"stash_save_response"})}async stashPop(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"stash_pop_request",cwd:e,stashIndex:s},responseType:"stash_pop_response"})}async stashList(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"stash_list_request",cwd:e,paseoOnly:s?.paseoOnly},responseType:"stash_list_response"})}async getPaseoWorktreeList(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"paseo_worktree_list_request",cwd:e.cwd,repoRoot:e.repoRoot},responseType:"paseo_worktree_list_response"})}async archivePaseoWorktree(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"paseo_worktree_archive_request",worktreePath:e.worktreePath,repoRoot:e.repoRoot,branchName:e.branchName},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{},void 0!==e.scope?{scope:e.scope}:{}),responseType:"paseo_worktree_archive_response"})}async createPaseoWorktree(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"create_paseo_worktree_request",cwd:e.cwd},void 0!==e.projectId?{projectId:e.projectId}:{},{worktreeSlug:e.worktreeSlug},void 0!==e.firstAgentContext?{firstAgentContext:e.firstAgentContext}:{},void 0!==e.refName?{refName:e.refName}:{},void 0!==e.action?{action:e.action}:{},void 0!==e.githubPrNumber?{githubPrNumber:e.githubPrNumber}:{}),responseType:"create_paseo_worktree_response"})}async createWorkspace(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"workspace.create.request",source:e.source},void 0!==e.title?{title:e.title}:{},void 0!==e.firstAgentContext?{firstAgentContext:e.firstAgentContext}:{}),responseType:"workspace.create.response"})}async validateBranch(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"validate_branch_request",cwd:e.cwd,branchName:e.branchName},responseType:"validate_branch_response"})}async getBranchSuggestions(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"branch_suggestions_request",cwd:e.cwd,query:e.query,limit:e.limit},responseType:"branch_suggestions_response"})}async searchGitHub(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"github_search_request",cwd:e.cwd,query:e.query,limit:e.limit,kinds:e.kinds},responseType:"github_search_response"})}async getDirectorySuggestions(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"directory_suggestions_request",query:e.query,cwd:e.cwd,includeFiles:e.includeFiles,includeDirectories:e.includeDirectories,matchMode:e.matchMode,limit:e.limit},responseType:"directory_suggestions_response"})}async requestFileExplorer(e,s,t,r,n=!1){return this.sendCorrelatedSessionRequest({requestId:r,message:Object.assign({type:"file_explorer_request",cwd:e,path:s,mode:t},n?{acceptBinary:!0}:{}),responseType:"file_explorer_response"})}async listDirectory(e,s,t){const r=await this.requestFileExplorer(e,s,"list",t);if(r.error)throw new Error(r.error);if(!r.directory)throw new Error("Directory listing unavailable.");return r.directory}async readFile(e,s,t){const r=this.createRequestId(t);this.pendingBinaryFileReads.set(r,{cwd:e,path:s});try{const t=await this.requestFileExplorer(e,s,"file",r,!0);if(t.error)throw new Error(t.error);const n=this.completedBinaryFileReads.get(r);if(n)return this.completedBinaryFileReads.delete(r),n;if(!t.file)throw new Error("File unavailable.");return N(t.file)}finally{this.pendingBinaryFileReads.delete(r),this.activeBinaryFileTransfers.delete(r)}}async requestDownloadToken(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"file_download_token_request",cwd:e,path:s},responseType:"file_download_token_response"})}async requestProjectIcon(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"project_icon_request",cwd:e},responseType:"project_icon_response"})}async listProviderModels(e,s){const t=await this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"list_provider_models_request",provider:e,cwd:s?.cwd},responseType:"list_provider_models_response",timeout:9e4});return(0,_.normalizeListProviderModelsPayload)(t)}async listProviderModes(e,s){return this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"list_provider_modes_request",provider:e,cwd:s?.cwd},responseType:"list_provider_modes_response",timeout:9e4})}async listProviderFeatures(e,s){return this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"list_provider_features_request",draftConfig:e},responseType:"list_provider_features_response",timeout:9e4})}async listAvailableProviders(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"list_available_providers_request"},responseType:"list_available_providers_response"})}async getProvidersSnapshot(e){const s=await this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"get_providers_snapshot_request",cwd:e?.cwd},responseType:"get_providers_snapshot_response"});return(0,_.normalizeProvidersSnapshotPayload)(s)}async reloadProviderConfig(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"providers.reload_config.request"},responseType:"providers.reload_config.response",timeout:15e3})}async getDaemonConfig(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"get_daemon_config_request"},responseType:"get_daemon_config_response"})}async getDaemonStatus(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"daemon.get_status.request"},responseType:"daemon.get_status.response",timeout:e?.timeout})}async getDaemonPairingOffer(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"daemon.get_pairing_offer.request"},responseType:"daemon.get_pairing_offer.response",timeout:e?.timeout})}async collectDiagnostics(e){return this.sendNamespacedCorrelatedSessionRequest({requestId:e,message:{type:"diagnostics.request"}})}async patchDaemonConfig(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"set_daemon_config_request",config:e},responseType:"set_daemon_config_response"})}sendBrowserAutomationExecuteResponse(e){this.sendSessionMessageStrict(e)}async readProjectConfig(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"read_project_config_request",repoRoot:e},responseType:"read_project_config_response"})}async writeProjectConfig(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"write_project_config_request",repoRoot:e.repoRoot,config:e.config,expectedRevision:e.expectedRevision},responseType:"write_project_config_response"})}async refreshProvidersSnapshot(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"refresh_providers_snapshot_request",cwd:e?.cwd,providers:e?.providers},responseType:"refresh_providers_snapshot_response",timeout:12e4})}async getProviderDiagnostic(e,s){return this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"provider_diagnostic_request",provider:e},responseType:"provider_diagnostic_response",timeout:18e4})}async listProviderUsage(e){return this.sendNamespacedCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"provider.usage.list.request"}})}async listCommands(e,s){const t=T(e,s);return this.sendCorrelatedSessionRequest({requestId:t.requestId,message:Object.assign({type:"list_commands_request",agentId:t.agentId},t.draftConfig?{draftConfig:t.draftConfig}:{}),responseType:"list_commands_response"})}async respondToPermission(e,s,t){this.sendSessionMessage({type:"agent_permission_response",agentId:e,requestId:s,response:t})}async respondToPermissionAndWait(e,s,t,r=15e3){const n=h.SessionInboundMessageSchema.parse({type:"agent_permission_response",agentId:e,requestId:s,response:t});return this.sendRequest({requestId:s,message:n,timeout:r,options:{skipQueue:!0},select:t=>"agent_permission_resolved"!==t.type||t.payload.requestId!==s||t.payload.agentId!==e?null:t.payload})}async waitForAgentUpsert(e,s,t=6e4){const r=Date.now()+t,n=()=>new Error(`Timed out waiting for agent ${e}`),o=()=>this.fetchAgent({agentId:e,timeout:Math.max(1,r-Date.now())}).catch(()=>null),a=await o();if(a&&s(a.agent))return a.agent;if(Date.now()>=r)throw n();return await new Promise((t,a)=>{let i=!1,c=!1,d=null,u=null,p=null;const l=e=>{i||(i=!0,u&&(clearTimeout(u),u=null),d&&(clearInterval(d),d=null),p&&(p(),p=null),"ok"!==e.kind?a(e.error):t(e.snapshot))},h=e=>!!e&&(!!s(e)&&(l({kind:"ok",snapshot:e}),!0)),m=async()=>{if(!i&&!c){c=!0;try{const e=await o();h(e?.agent??null)}finally{c=!1}}};p=this.on("agent_update",s=>{if(i)return;if("upsert"!==s.payload.kind)return;const t=s.payload.agent;t.id===e&&h(t)});const g=Math.max(1,r-Date.now());u=setTimeout(()=>{l({kind:"error",error:n()})},g),d=setInterval(()=>{m()},250),m()})}async waitForFinish(e,s=6e4){const t=this.createRequestId(),r=Number.isFinite(s)&&s>0,n=h.SessionInboundMessageSchema.parse(Object.assign({type:"wait_for_finish_request",requestId:t,agentId:e},r?{timeoutMs:s}:{})),o=await this.sendCorrelatedRequest({requestId:t,message:n,responseType:"wait_for_finish_response",timeout:r?s+5e3:0,options:{skipQueue:!0}});return{status:o.status,final:o.final,error:o.error,lastMessage:o.lastMessage}}subscribeTerminals(e){this.terminalDirectorySubscriptions.set((0,y.terminalSubscriptionKey)(e.cwd,e.workspaceId),{cwd:e.cwd,workspaceId:e.workspaceId}),this.transport&&"connected"===this.connectionState.status&&this.sendSessionMessage(Object.assign({type:"subscribe_terminals_request",cwd:e.cwd},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{}))}unsubscribeTerminals(e){this.terminalDirectorySubscriptions.delete((0,y.terminalSubscriptionKey)(e.cwd,e.workspaceId)),this.transport&&"connected"===this.connectionState.status&&this.sendSessionMessage(Object.assign({type:"unsubscribe_terminals_request",cwd:e.cwd},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{}))}async listTerminals(e,s,t){const r=this.createRequestId(s),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"list_terminals_request"},void 0===e?{}:{cwd:e},void 0!==t?.workspaceId?{workspaceId:t.workspaceId}:{},{requestId:r}));return this.sendCorrelatedRequest({requestId:r,message:n,responseType:"list_terminals_response",options:{skipQueue:!0}})}async createTerminal(e,s,t,r){const n=this.createRequestId(t),o=h.SessionInboundMessageSchema.parse(Object.assign({type:"create_terminal_request",cwd:e,name:s,agentId:r?.agentId,command:r?.command,args:r?.args},void 0!==r?.workspaceId?{workspaceId:r.workspaceId}:{},{requestId:n}));return this.sendCorrelatedRequest({requestId:n,message:o,responseType:"create_terminal_response",options:{skipQueue:!0}})}async renameTerminal(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"terminal.rename.request",terminalId:e.terminalId,title:e.title},responseType:"terminal.rename.response"})}async subscribeTerminal(e,s){const t="object"==typeof s?s.restore:void 0,r="object"==typeof s?s.requestId:s,n=this.createRequestId(r),o=h.SessionInboundMessageSchema.parse(Object.assign({type:"subscribe_terminal_request",terminalId:e,requestId:n},t?{restore:t}:{})),a=await this.sendCorrelatedRequest({requestId:n,message:o,responseType:"subscribe_terminal_response",options:{skipQueue:!0}});return null===a.error&&this.terminalStreams.setSlot(e,a.slot),a}unsubscribeTerminal(e){this.terminalStreams.removeTerminal(e),this.sendSessionMessage({type:"unsubscribe_terminal_request",terminalId:e})}sendTerminalInput(e,s){const t=this.terminalStreams.encodeInput(e,s);t?this.sendBinaryFrame(t):this.sendSessionMessage({type:"terminal_input",terminalId:e,message:s})}async killTerminal(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse({type:"kill_terminal_request",terminalId:e,requestId:t});return this.sendCorrelatedRequest({requestId:t,message:r,responseType:"kill_terminal_response",options:{skipQueue:!0}})}async closeItems(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse({type:"close_items_request",agentIds:e.agentIds??[],terminalIds:e.terminalIds??[],requestId:t});return this.sendCorrelatedRequest({requestId:t,message:r,responseType:"close_items_response",options:{skipQueue:!0}})}async captureTerminal(e,s,t){const r=this.createRequestId(t),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"capture_terminal_request",terminalId:e},void 0===s?.start?{}:{start:s.start},void 0===s?.end?{}:{end:s.end},void 0===s?.stripAnsi?{}:{stripAnsi:s.stripAnsi},{requestId:r}));return this.sendCorrelatedRequest({requestId:r,message:n,responseType:"capture_terminal_response",options:{skipQueue:!0}})}async captureAgentPane(e,s,t){const r=this.createRequestId(t),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"capture_agent_pane_request",agentId:e},void 0===s?.ansi?{}:{ansi:s.ansi},void 0===s?.scrollbackLines?{}:{scrollbackLines:s.scrollbackLines},{requestId:r}));return this.sendCorrelatedRequest({requestId:r,message:n,responseType:"capture_agent_pane_response",options:{skipQueue:!0}})}async createChatRoom(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/create",name:e.name},e.purpose?{purpose:e.purpose}:{}),responseType:"chat/create/response"})}async listChatRooms(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"chat/list"},responseType:"chat/list/response"})}async inspectChatRoom(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"chat/inspect",room:e.room},responseType:"chat/inspect/response"})}async deleteChatRoom(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"chat/delete",room:e.room},responseType:"chat/delete/response"})}async postChatMessage(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/post",room:e.room,body:e.body},e.authorAgentId?{authorAgentId:e.authorAgentId}:{},e.replyToMessageId?{replyToMessageId:e.replyToMessageId}:{}),responseType:"chat/post/response"})}async readChatMessages(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/read",room:e.room},"number"==typeof e.limit?{limit:e.limit}:{},e.since?{since:e.since}:{},e.authorAgentId?{authorAgentId:e.authorAgentId}:{}),responseType:"chat/read/response",timeout:e.timeout})}async waitForChatMessages(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/wait",room:e.room},e.afterMessageId?{afterMessageId:e.afterMessageId}:{},"number"==typeof e.timeoutMs?{timeoutMs:e.timeoutMs}:{}),responseType:"chat/wait/response",timeout:(e.timeoutMs??0)+1e4})}async scheduleCreate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"schedule/create",prompt:e.prompt,cadence:e.cadence,target:e.target},e.name?{name:e.name}:{},"number"==typeof e.maxRuns?{maxRuns:e.maxRuns}:{},e.expiresAt?{expiresAt:e.expiresAt}:{},"boolean"==typeof e.runOnCreate?{runOnCreate:e.runOnCreate}:{}),responseType:"schedule/create/response"})}async scheduleList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"schedule/list"},responseType:"schedule/list/response"})}async ingestionBackfill(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/backfill",filterId:e.filterId,windowDays:e.windowDays},responseType:"ingestion/backfill/response"})}async ingestionApply(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"ingestion/apply",filterId:e.filterId,itemKeys:e.itemKeys,mode:e.mode},"number"==typeof e.confirmedGroups?{confirmedGroups:e.confirmedGroups}:{}),responseType:"ingestion/apply/response"})}async ingestionCohortInspect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/cohort/inspect",cohortId:e.cohortId},responseType:"ingestion/cohort/inspect/response"})}async ingestionCohortCancel(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/cohort/cancel",cohortId:e.cohortId},responseType:"ingestion/cohort/cancel/response"})}async ingestionRuns(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/runs",filterId:e.filterId,includeClosed:e.includeClosed},responseType:"ingestion/runs/response"})}async fleetList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"fleet/list"},responseType:"fleet/list/response"})}async fleetInspect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/inspect",name:e.name},responseType:"fleet/inspect/response"})}async fleetRunNow(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/run-now",name:e.name},responseType:"fleet/run-now/response"})}async fleetPause(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/pause",name:e.name},responseType:"fleet/pause/response"})}async fleetAsk(e){const{requestId:s}=e,t=(0,p.default)(e,i);return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"fleet/ask"},t),responseType:"fleet/ask/response"})}async fleetDecisions(e={}){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/decisions",name:e.name,includeResolved:e.includeResolved},responseType:"fleet/decisions/response"})}async fleetResolveDecision(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/resolve-decision",decisionId:e.decisionId,optionId:e.optionId},responseType:"fleet/resolve-decision/response"})}async fleetSetParams(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/set-params",name:e.name,values:e.values},responseType:"fleet/set-params/response"})}async fleetSetMode(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/set-mode",name:e.name,mode:e.mode},responseType:"fleet/set-mode/response"})}async fleetResume(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/resume",name:e.name},responseType:"fleet/resume/response"})}async fleetCreate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"fleet/create",name:e.name,description:e.description,cron:e.cron,action:e.action},void 0!==e.mode?{mode:e.mode}:{},void 0!==e.rails?{rails:e.rails}:{},void 0!==e.allowed?{allowed:e.allowed}:{}),responseType:"fleet/create/response"})}async fleetExecutions(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/executions",name:e.name},responseType:"fleet/executions/response"})}async scheduleInspect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/inspect",scheduleId:e.id},responseType:"schedule/inspect/response"})}async scheduleLogs(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/logs",scheduleId:e.id},responseType:"schedule/logs/response"})}async schedulePause(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/pause",scheduleId:e.id},responseType:"schedule/pause/response"})}async scheduleResume(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/resume",scheduleId:e.id},responseType:"schedule/resume/response"})}async scheduleDelete(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/delete",scheduleId:e.id},responseType:"schedule/delete/response"})}async scheduleRunOnce(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/run-once",scheduleId:e.id},responseType:"schedule/run-once/response"})}async scheduleUpdate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"schedule/update",scheduleId:e.id},void 0!==e.name?{name:e.name}:{},void 0!==e.prompt?{prompt:e.prompt}:{},void 0!==e.cadence?{cadence:e.cadence}:{},void 0!==e.newAgentConfig?{newAgentConfig:e.newAgentConfig}:{},void 0!==e.maxRuns?{maxRuns:e.maxRuns}:{},void 0!==e.expiresAt?{expiresAt:e.expiresAt}:{}),responseType:"schedule/update/response"})}async sourceCatalogue(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"source/catalogue",kind:e.kind,query:e.query},e.cursor?{cursor:e.cursor}:{}),responseType:"source/catalogue/response"})}async sourceConnect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/connect",kind:e.kind,appSlug:e.appSlug},responseType:"source/connect/response"})}async sourceList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"source/list"},responseType:"source/list/response"})}async sourceCheck(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/check",sourceId:e.sourceId},responseType:"source/check/response"})}async ingestionFilterList(e={}){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"ingestion/filter/list"},void 0===e.sourceId?{}:{sourceId:e.sourceId}),responseType:"ingestion/filter/list/response"})}async ingestionFilterCreate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/filter/create",draft:e.draft},responseType:"ingestion/filter/create/response"})}async ingestionFilterUpdate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/filter/update",filterId:e.filterId,patch:e.patch},responseType:"ingestion/filter/update/response"})}async ingestionFilterDelete(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/filter/delete",filterId:e.filterId},responseType:"ingestion/filter/delete/response"})}async sourceTriggers(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/triggers",sourceId:e.sourceId},responseType:"source/triggers/response"})}async sourceSubscribe(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"source/subscribe",sourceId:e.sourceId},void 0===e.componentId?{}:{componentId:e.componentId}),responseType:"source/subscribe/response"})}async sourceDisconnect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/disconnect",sourceId:e.sourceId},responseType:"source/disconnect/response"})}async loopRun(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"loop/run",prompt:e.prompt,cwd:e.cwd},e.provider?{provider:e.provider}:{},e.model?{model:e.model}:{},e.modeId?{modeId:e.modeId}:{},e.verifierProvider?{verifierProvider:e.verifierProvider}:{},e.verifierModel?{verifierModel:e.verifierModel}:{},e.verifierModeId?{verifierModeId:e.verifierModeId}:{},e.verifyPrompt?{verifyPrompt:e.verifyPrompt}:{},e.verifyChecks&&e.verifyChecks.length>0?{verifyChecks:e.verifyChecks}:{},e.name?{name:e.name}:{},"number"==typeof e.sleepMs?{sleepMs:e.sleepMs}:{},"number"==typeof e.maxIterations?{maxIterations:e.maxIterations}:{},"number"==typeof e.maxTimeMs?{maxTimeMs:e.maxTimeMs}:{}),responseType:"loop/run/response"})}async loopList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"loop/list"},responseType:"loop/list/response"})}async loopInspect(e){const s="string"==typeof e?{id:e}:e;return this.sendCorrelatedSessionRequest({requestId:s.requestId,message:{type:"loop/inspect",id:s.id},responseType:"loop/inspect/response"})}async loopLogs(e,s){const t="string"==typeof e?{id:e,afterSeq:s}:e;return this.sendCorrelatedSessionRequest({requestId:t.requestId,message:Object.assign({type:"loop/logs",id:t.id},"number"==typeof t.afterSeq?{afterSeq:t.afterSeq}:{}),responseType:"loop/logs/response"})}async loopStop(e){const s="string"==typeof e?{id:e}:e;return this.sendCorrelatedSessionRequest({requestId:s.requestId,message:{type:"loop/stop",id:s.id},responseType:"loop/stop/response"})}onTerminalStreamEvent(e){return this.terminalStreams.onEvent(e)}async waitForTerminalStreamEvent(e,s=5e3){return new Promise((t,r)=>{const n=setTimeout(()=>{o(),r(new Error(`Timeout waiting for terminal stream event (${s}ms)`))},s),o=this.onTerminalStreamEvent(s=>{e(s)&&(clearTimeout(n),o(),t(s))})})}async uploadFile(e,s){const t=this.createRequestId(),r=crypto.randomUUID(),n=e.bytes.byteLength,o=s.signal;if(o?.aborted)throw new M(r);const a=[];for(let s=0;s<n;s+=q.UPLOAD_CHUNK_SIZE_BYTES)a.push(e.bytes.subarray(s,Math.min(s+q.UPLOAD_CHUNK_SIZE_BYTES,n)));const i=a.length;let c;try{c=await this.sendCorrelatedRequest({requestId:t,message:h.SessionInboundMessageSchema.parse({type:"files.upload.begin.request",requestId:t,agentId:s.agentId,uploadId:r,metadata:{mime:e.mime,size:n,encoding:"binary",modifiedAt:e.modifiedAt,fileName:e.path.split(/[\\/]/).at(-1)||e.path}}),responseType:"files.upload.begin.response",timeout:3e4,options:{skipQueue:!0}})}catch(e){throw new P(r,e instanceof Error?e.message:String(e))}if(!c.accepted||c.error)throw A(r,c.error??"write_failed");const d=new Map;let u=0,p=0,l=0,m=!1,g=!1;const y=[],I=()=>{for(const e of y.splice(0))try{e()}catch{}d.clear()};let f;await new Promise((e,c)=>{const h=()=>{g||(g=!0,I(),e())},q=e=>{g||(g=!0,I(),c(e))},f=()=>{for(;d.size<8&&u<i;){if(m||g)return;const e=u,s=a[e];if(u+=1,d.set(e,s.byteLength),d.size>8)return void q(new P(r,`upload window invariant violated: ${d.size} chunks in flight`));try{this.sendSessionMessage({type:"files.upload.chunk",payload:{requestId:t,uploadId:r,chunkIndex:e,data:Q(s)}})}catch(e){return void q(new P(r,e instanceof Error?e.message:String(e)))}}};y.push(this.on("files.upload.chunk.ack",e=>{if(e.payload.requestId!==t)return;const r=e.payload.chunkIndex,o=d.get(r);void 0!==o&&(d.delete(r),l+=1,p+=o,s.onProgress?.(p,n),l>=i?h():f())})),y.push(this.on("files.upload.error",e=>{e.payload.requestId!==t&&e.payload.uploadId!==r||q(A(r,e.payload.code,e.payload.message))}));const w=()=>{m=!0;try{this.sendSessionMessage({type:"files.upload.error",payload:{requestId:t,uploadId:r,code:"aborted"}})}catch{}q(new M(r))};o&&(o.addEventListener("abort",w,{once:!0}),y.push(()=>o.removeEventListener("abort",w))),0!==i?o?.aborted?w():f():h()});try{f=await this.sendCorrelatedRequest({requestId:t,message:h.SessionInboundMessageSchema.parse({type:"files.upload.complete.request",requestId:t,uploadId:r,totalChunks:i}),responseType:"files.upload.complete.response",timeout:3e4,options:{skipQueue:!0}})}catch(e){throw new P(r,e instanceof Error?e.message:String(e))}if(f.error)throw A(r,f.error);return{fileId:f.fileId,path:f.path,size:f.size,mimeType:f.mimeType}}createRequestId(e){return e??crypto.randomUUID()}getLastServerInfoMessage(){return this.lastServerInfoMessage}getFileUploadsCapability(){return this.lastServerInfoMessage?.features?.fileUploads??!1}resolveTransportUrlForAttempt(){return this.config.url}sendHelloMessage(){if(this.transport)try{this.transport.send(JSON.stringify(Object.assign({type:"hello",clientId:this.config.clientId,clientType:this.config.clientType??"cli",protocolVersion:1,capabilities:Object.assign({[l.CLIENT_CAPS.customModeIcons]:!0,[l.CLIENT_CAPS.reasoningMergeEnum]:!0,[l.CLIENT_CAPS.terminalReflowableSnapshot]:!0},this.config.capabilities)},this.config.appVersion?{appVersion:this.config.appVersion}:{})))}catch(e){const s=e instanceof Error?e.message:"Failed to send hello message";this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"HELLO_SEND_FAILED",reasonCode:"transport_error"})}else this.scheduleReconnect({reason:"Transport unavailable before hello",event:"HELLO_TRANSPORT_MISSING",reasonCode:"transport_error"})}disposeTransport(e=1001,s="Reconnecting"){if(this.stopLivenessHeartbeat(),this.cleanupTransport(),this.transport){try{this.transport.close(e,s)}catch{}this.transport=null}}cleanupTransport(){this.resetConnectTimeout(),this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null);for(const e of this.transportCleanup)try{e()}catch{}this.transportCleanup=[]}resetConnectTimeout(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null)}handleTransportMessage(e){const s=e&&"object"==typeof e&&"data"in e?e.data:e;if("undefined"!=typeof Blob&&s instanceof Blob&&"function"==typeof s.arrayBuffer)return void s.arrayBuffer().then(e=>{this.handleTransportMessage(e)}).catch(()=>{});const t=(0,I.asUint8Array)(s);if(t&&this.tryHandleBinaryFrame(t))return;const r=(0,f.decodeMessageData)(s);r&&this.handleJsonPayload(r,t?.byteLength)}handleJsonPayload(e,s){const t=s??e.length,r=R();let n;try{n=JSON.parse(e)}catch{return}const o=(0,m.validateWSOutboundMessage)(n);if(!o.success){const e=null!=n&&"object"==typeof n&&"type"in n&&"string"==typeof n.type?n.type:"unknown";return void this.logger.warn({msgType:e,error:o.error.message},"Message validation failed")}if(this.consecutiveLivenessFailures=0,"pong"===o.data.type)return this.resolvePingProbe(),void this.runtimeMetrics?.recordMessage("pong",t,R()-r);this.handleSessionMessage(o.data.message);const a=o.data.message.type;this.runtimeMetrics?.recordMessage(a,t,R()-r),"agent_stream"===o.data.message.type&&this.runtimeMetrics?.recordAgentStream(o.data.message.payload)}tryHandleBinaryFrame(e){const s=(0,I.decodeFileTransferFrame)(e);if(s)return this.consecutiveLivenessFailures=0,this.handleFileTransferFrame(s),this.runtimeMetrics?.recordBinaryFrame("other",e.byteLength,0),!0;const t=(0,I.decodeTerminalStreamFrame)(e);if(!t)return!1;this.consecutiveLivenessFailures=0;const r=R();this.terminalStreams.handleFrame(t);let n="other";return t.opcode===I.TerminalStreamOpcode.Output?n="output":t.opcode===I.TerminalStreamOpcode.Snapshot?n="snapshot":t.opcode===I.TerminalStreamOpcode.Restore&&(n="output"),this.runtimeMetrics?.recordBinaryFrame(n,e.byteLength,R()-r),!0}handleFileTransferFrame(e){if(e.opcode===I.FileTransferOpcode.FileBegin){const s=this.pendingBinaryFileReads.get(e.requestId);if(!s)return;return void this.activeBinaryFileTransfers.set(e.requestId,Object.assign({},s,{mime:e.metadata.mime,size:e.metadata.size,encoding:e.metadata.encoding,modifiedAt:e.metadata.modifiedAt,chunks:[]}))}const s=this.activeBinaryFileTransfers.get(e.requestId);if(!s)return;if(e.opcode===I.FileTransferOpcode.FileChunk)return void s.chunks.push(e.payload);const t=H(s.chunks,s.size);var r,n;this.activeBinaryFileTransfers.delete(e.requestId),this.completedBinaryFileReads.set(e.requestId,{bytes:t,mime:s.mime,size:s.size,path:s.path,kind:(r=s.mime,n=s.encoding,r.startsWith("image/")?"image":"utf-8"===n||r.startsWith("text/")||"application/json"===r?"text":"binary"),modifiedAt:s.modifiedAt}),this.handleSessionMessage({type:"file_explorer_response",payload:{cwd:s.cwd,path:s.path,mode:"file",directory:null,file:null,error:null,requestId:e.requestId}})}updateConnectionState(e,s){const t=this.connectionState;this.connectionState=e;const r="disconnected"===e.status&&"string"==typeof e.reason?e.reason:null,n=s?.reason??r,o=s?.reasonCode??W(n);this.logger.debug({serverId:this.logServerId,clientIdHash:this.logClientIdHash,from:t.status,to:e.status,event:s?.event??"STATE_UPDATE",connectionPath:this.logConnectionPath,generation:this.logGeneration,reasonCode:o,reason:n},"DaemonClientTransition");for(const s of this.connectionListeners)try{s(e)}catch{}}setReconnectEnabled(e){this.config=Object.assign({},this.config,{reconnect:Object.assign({},this.config.reconnect,{enabled:e})})}scheduleReconnect(e){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null);const s="disposed"===this.connectionState.status,t=e?.reason;"string"==typeof t&&t.trim().length>0&&(this.lastErrorValue=t.trim()),this.clearWaiters(new Error(t??"Connection lost")),this.rejectPendingSendQueue(new Error(t??"Connection lost")),this.rejectPingProbe(new Error(t??"Connection lost")),this.terminalStreams.clearSlots(),this.lastServerInfoMessage=null,s?this.rejectConnect(new Error(t??"Daemon client is disposed")):(this.emitDisconnectedStateForReconnect(t,e),this.shouldReconnect&&!1!==this.config.reconnect?.enabled?this.armReconnectTimer():this.rejectConnect(new Error(t??"Transport disconnected before connect")))}emitDisconnectedStateForReconnect(e,s){this.updateConnectionState(Object.assign({status:"disconnected"},e?{reason:e}:{}),Object.assign({event:s?.event??"TRANSPORT_CLOSE"},e?{reason:e}:{},s?.reasonCode?{reasonCode:s.reasonCode}:{}))}armReconnectTimer(){const e=this.reconnectAttempt,s=this.config.reconnect?.baseDelayMs??1500,t=this.config.reconnect?.maxDelayMs??3e4,r=Math.min(s*2**e,t);this.reconnectAttempt=e+1,this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.shouldReconnect&&this.attemptConnect()},r)}resolvePingProbe(){const e=this.pingProbe;e&&(this.pingProbe=null,clearTimeout(e.timeoutHandle),e.resolve(R()-e.startedAt))}clearPingProbe(){const e=this.pingProbe;e&&(this.pingProbe=null,clearTimeout(e.timeoutHandle))}rejectPingProbe(e){const s=this.pingProbe;s&&(this.pingProbe=null,clearTimeout(s.timeoutHandle),s.reject(e))}recordLivenessFailure(e){this.consecutiveLivenessFailures+=1,this.consecutiveLivenessFailures<2||(this.consecutiveLivenessFailures=0,this.lastErrorValue=e.message,this.disposeTransport(1001,"Liveness check timed out"),this.scheduleReconnect({reason:e.message,event:"LIVENESS_TIMEOUT",reasonCode:"liveness_timeout"}))}handleSessionMessage(e){const s=(0,_.normalizeProviderSnapshotUpdateMessage)(e);if("status"===s.type){const e=(0,h.parseServerInfoStatusPayload)(s.payload);e&&(this.lastServerInfoMessage=e,"connecting"===this.connectionState.status&&(this.resetConnectTimeout(),this.reconnectAttempt=0,this.updateConnectionState({status:"connected"},{event:"HELLO_SERVER_INFO"}),this.startLivenessHeartbeat(),this.resubscribeCheckoutDiffSubscriptions(),this.resubscribeTerminalDirectorySubscriptions(),this.flushPendingSendQueue(),this.resolveConnect()))}if("terminal_stream_exit"===s.type&&this.terminalStreams.removeTerminal(s.payload.terminalId),this.rawMessageListeners.size>0)for(const e of this.rawMessageListeners)try{e(s)}catch{}const t=this.messageHandlers.get(s.type);if(t)for(const e of t)try{e(s)}catch{}const r=this.toEvent(s);if(r)for(const e of this.eventListeners)e(r);this.resolveWaiters(s)}resolveWaiters(e){for(const s of Array.from(this.waiters)){const t=s.predicate(e);null!==t&&(this.waiters.delete(s),s.timeoutHandle&&clearTimeout(s.timeoutHandle),s.resolve(t))}}clearWaiters(e){for(const s of Array.from(this.waiters))s.timeoutHandle&&clearTimeout(s.timeoutHandle),s.reject(e);this.waiters.clear()}toEvent(e){switch(e.type){case"agent_update":return{type:"agent_update",agentId:"upsert"===e.payload.kind?e.payload.agent.id:e.payload.agentId,payload:e.payload};case"workspace_update":return{type:"workspace_update",workspaceId:"upsert"===e.payload.kind?e.payload.workspace.id:e.payload.id,payload:e.payload};case"workspace_setup_progress":return{type:"workspace_setup_progress",workspaceId:e.payload.workspaceId,payload:e.payload};case"agent_stream":return Object.assign({type:"agent_stream",agentId:e.payload.agentId,event:e.payload.event,timestamp:e.payload.timestamp},"number"==typeof e.payload.seq?{seq:e.payload.seq}:{},"string"==typeof e.payload.epoch?{epoch:e.payload.epoch}:{});case"status":return{type:"status",payload:e.payload};case"agent_deleted":return{type:"agent_deleted",agentId:e.payload.agentId};case"agent_permission_request":return{type:"agent_permission_request",agentId:e.payload.agentId,request:e.payload.request};case"agent_permission_resolved":return{type:"agent_permission_resolved",agentId:e.payload.agentId,requestId:e.payload.requestId,resolution:e.payload.resolution};case"providers_snapshot_update":return{type:"providers_snapshot_update",payload:e.payload};default:return null}}waitForWithCancel(e,s=3e4,t){const r=new Error(`Timeout waiting for message (${s}ms)`);let n=null,o=!1,a=null;return{promise:new Promise((t,i)=>{const c=e=>{o||(o=!0,i(e))};a=c;const d=s>0?setTimeout(()=>{n&&this.waiters.delete(n),c(r)},s):null;n={predicate:e,resolve:e=>{o||(o=!0,t(e))},reject:c,timeoutHandle:d},this.waiters.add(n)}),cancel:e=>{o||(n&&(this.waiters.delete(n),n.timeoutHandle&&clearTimeout(n.timeoutHandle)),a?a(e):queueMicrotask(()=>{!o&&a&&a(e)}))}}}}function $(e,s){return Object.assign({type:"create_agent_request",requestId:s,config:z(e)},e.env?{env:e.env}:{},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{},e.initialPrompt?{initialPrompt:e.initialPrompt}:{},e.clientMessageId?{clientMessageId:e.clientMessageId}:{},e.outputSchema?{outputSchema:e.outputSchema}:{},e.images&&e.images.length>0?{images:e.images}:{},e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{},e.git?{git:e.git}:{},e.worktree?{worktree:e.worktree}:{},void 0!==e.autoArchive?{autoArchive:e.autoArchive}:{},e.worktreeName?{worktreeName:e.worktreeName}:{},e.labels&&Object.keys(e.labels).length>0?{labels:e.labels}:{},e.resumeSessionId?{resumeSessionId:e.resumeSessionId}:{},e.routine?{routine:e.routine}:{})}function z(e){const{config:s,provider:t,cwd:r}=e,n=(0,p.default)(e,c),o=Object.assign({},t?{provider:t}:{},r?{cwd:r}:{},n),a=s?Object.assign({},o,s):o;if(!a.provider||!a.cwd)throw new Error("createAgent requires provider and cwd");return Object.assign({},a,{provider:a.provider,cwd:a.cwd})}},3282,[35,3283,3284,3389,3392,3393,3394,3396,3397,3407,3408,3409]);
|
|
14927
|
+
__d(function(e,s,t,r,n,o,a){"use strict";const i=["requestId"],c=["config","provider","cwd","env","workspaceId","initialPrompt","images","git","worktreeName","requestId","labels","routine"];Object.defineProperty(o,'__esModule',{value:!0}),Object.defineProperty(o,"UploadCancelledError",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"UploadCapExceededError",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"UploadFailedError",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"DaemonClient",{enumerable:!0,get:function(){return z}});var d,u=s(a[0]),p=(d=u)&&d.__esModule?d:{default:d},l=s(a[1]),h=s(a[2]),m=s(a[3]),g=s(a[4]),y=s(a[5]),I=s(a[6]),q=s(a[7]),f=s(a[8]),w=s(a[9]),_=s(a[10]),S=s(a[11]);const b={debug:()=>{},info:(e,s)=>console.log(s,e),warn:(e,s)=>console.warn(s,e),error:(e,s)=>console.error(s,e)},R="undefined"!=typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>Date.now();function k(e){return"string"!=typeof e?null:e.length>0?e:null}function v(e,s){return"string"!=typeof e?e:"string"==typeof s?{agentId:e,requestId:s}:Object.assign({agentId:e},s)}function T(e,s){return"string"!=typeof e?e:"string"==typeof s?{agentId:e,requestId:s}:Object.assign({agentId:e},s)}class C extends Error{constructor(e){const s=[e.error];e.requestType&&s.push(`requestType=${e.requestType}`),e.code&&s.push(`code=${e.code}`),super(s.join(" ")),this.name="DaemonRpcError",this.requestId=e.requestId,this.requestType=e.requestType,this.code=e.code}}class M extends Error{constructor(e){super("Upload cancelled"),this.name="UploadCancelledError",this.uploadId=e}}class E extends Error{constructor(e,s){super(s??"Upload exceeds the size cap"),this.name="UploadCapExceededError",this.uploadId=e,this.code="too_large"}}class P extends Error{constructor(e,s,t){super(s),this.name="UploadFailedError",this.uploadId=e,t&&(this.code=t)}}function A(e,s,t){return"too_large"===s?new E(e,t):new P(e,t??`Upload failed: ${s}`,s)}class j extends Error{constructor(e){super(`Ping timed out (${e}ms)`),this.timeoutMs=e,this.name="PingTimeoutError"}}function O(e,s,t){return e instanceof j?new Error(`${s} timed out (${t}ms)`):e instanceof Error?e:new Error(String(e))}const F=12e4,L=F,x=F;function D(e){return e instanceof Error&&e.message.startsWith("Timeout waiting for message")}function Q(e){if("string"!=typeof e)return null;const s=e.trim();return s.length>0?s:null}function N(e){const s=globalThis.atob(e),t=new Uint8Array(s.length);for(let e=0;e<s.length;e+=1)t[e]=s.charCodeAt(e);return t}function H(e){let s="";for(let t=0;t<e.length;t+=32768)s+=String.fromCharCode.apply(null,e.subarray(t,t+32768));return globalThis.btoa(s)}function U(e){let s;return s="base64"===e.encoding&&e.content?N(e.content):"utf-8"===e.encoding&&e.content?(new TextEncoder).encode(e.content):new Uint8Array,{bytes:s,mime:e.mimeType??"application/octet-stream",size:e.size,path:e.path,kind:e.kind,modifiedAt:e.modifiedAt}}function W(e,s){const t=new Uint8Array(s);let r=0;for(const s of e)t.set(s,r),r+=s.byteLength;return t}function B(e){let s=0;for(let t=0;t<e.length;t+=1)s=31*s+e.charCodeAt(t)|0;return`h_${Math.abs(s).toString(16)}`}function $(e){if(!e)return null;const s=e.toLowerCase();return s.includes("timed out")?"connect_timeout":s.includes("disposed")?"disposed":s.includes("client closed")?"client_closed":s.includes("transport")?"transport_error":s.includes("failed to connect")?"connect_failed":"unknown"}class z{constructor(e){this.config=e,this.transport=null,this.transportCleanup=[],this.rawMessageListeners=new Set,this.messageHandlers=new Map,this.eventListeners=new Set,this.waiters=new Set,this.checkoutStatusInFlight=new Map,this.connectionListeners=new Set,this.reconnectTimeout=null,this.connectTimeout=null,this.pendingGenericTransportErrorTimeout=null,this.reconnectAttempt=0,this.shouldReconnect=!0,this.connectPromise=null,this.connectResolve=null,this.connectReject=null,this.lastErrorValue=null,this.connectionState={status:"idle"},this.checkoutDiffSubscriptions=new Map,this.terminalDirectorySubscriptions=new Map,this.terminalStreams=new S.TerminalStreamRouter,this.pendingBinaryFileReads=new Map,this.activeBinaryFileTransfers=new Map,this.completedBinaryFileReads=new Map,this.pendingSendQueue=[],this.lastServerInfoMessage=null,this.runtimeMetricsInterval=null,this.runtimeMetrics=null,this.pingProbe=null,this.livenessHeartbeatTimer=null,this.lastLivenessRttMs=null,this.consecutiveLivenessFailures=0,this.logger=e.logger??b,this.logConnectionPath=(0,g.isRelayClientWebSocketUrl)(this.config.url)?"relay":"direct";let s=null;try{s=new URL(this.config.url)}catch{s=null}const t=Q(s?.searchParams.get("serverId"));this.logServerId=t??s?.host??null;const r=Q(this.config.clientId);if(!r)throw new Error("Daemon client requires a non-empty clientId");this.config.clientId=r,this.logClientIdHash=B(r),this.logGeneration="number"==typeof this.config.runtimeGeneration&&Number.isFinite(this.config.runtimeGeneration)?this.config.runtimeGeneration:null;const n="number"==typeof e.runtimeMetricsIntervalMs&&e.runtimeMetricsIntervalMs>0?e.runtimeMetricsIntervalMs:0;if(n>0){const s="number"==typeof e.runtimeMetricsWindowMs&&e.runtimeMetricsWindowMs>0?Math.max(e.runtimeMetricsWindowMs,n):void 0;this.runtimeMetrics=new w.DaemonClientRuntimeMetrics(this.logger,{connectionPath:this.logConnectionPath,serverId:this.logServerId,getConnectionStatus:()=>this.connectionState.status},s?{windowMs:s}:void 0),this.runtimeMetricsInterval=setInterval(()=>{this.runtimeMetrics?.flush()},n)}}async connect(){if("disposed"===this.connectionState.status)throw new Error("Daemon client is disposed");if("connected"!==this.connectionState.status)return this.connectPromise||(this.shouldReconnect=!0,this.connectPromise=new Promise((e,s)=>{this.connectResolve=e,this.connectReject=s,this.attemptConnect()})),this.connectPromise}attemptConnect(){if("disposed"===this.connectionState.status)return void this.rejectConnect(new Error("Daemon client is disposed"));if(!this.shouldReconnect)return void this.rejectConnect(new Error("Daemon client is closed"));if("connecting"===this.connectionState.status)return;const e={},s=k(this.config.password);s?e.Authorization=`Bearer ${s}`:this.config.authHeader&&(e.Authorization=this.config.authHeader);const t=s?[`paseo.bearer.${s}`]:void 0;try{this.disposeTransport();const s=this.config.transportFactory??(0,f.createWebSocketTransportFactory)(this.config.webSocketFactory??f.defaultWebSocketFactory),r=!0===this.config.e2ee?.enabled&&(0,g.isRelayClientWebSocketUrl)(this.config.url);let n=s;if(r){const e=this.config.e2ee?.daemonPublicKeyB64;if(!e)throw new Error("daemonPublicKeyB64 is required for relay E2EE");n=(0,f.createRelayE2eeTransportFactory)({baseFactory:s,daemonPublicKeyB64:e,logger:this.logger})}const o=this.resolveTransportUrlForAttempt(),a=n(Object.assign({url:o,headers:e},t?{protocols:t}:{}));this.transport=a,this.lastServerInfoMessage=null,this.updateConnectionState({status:"connecting",attempt:this.reconnectAttempt},{event:"CONNECT_REQUEST"}),this.resetConnectTimeout();const i=Math.max(1,this.config.connectTimeoutMs??3e4);this.connectTimeout=setTimeout(()=>{"connecting"===this.connectionState.status&&(this.lastErrorValue="Connection timed out",this.disposeTransport(1001,"Connection timed out"),this.scheduleReconnect({reason:"Connection timed out",event:"CONNECT_TIMEOUT",reasonCode:"connect_timeout"}))},i),this.transportCleanup=[a.onOpen(()=>{this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null),this.lastErrorValue=null,this.sendHelloMessage()}),a.onClose(e=>{this.resetConnectTimeout(),this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null);const s=(0,f.describeTransportClose)(e);s&&(this.lastErrorValue=s),this.scheduleReconnect({reason:s,event:"TRANSPORT_CLOSE",reasonCode:"transport_closed"})}),a.onError(e=>{this.resetConnectTimeout();const s=(0,f.describeTransportError)(e);if("Transport error"===s)return this.lastErrorValue??(this.lastErrorValue=s),void(this.pendingGenericTransportErrorTimeout||(this.pendingGenericTransportErrorTimeout=setTimeout(()=>{this.pendingGenericTransportErrorTimeout=null,"connected"!==this.connectionState.status&&"connecting"!==this.connectionState.status||(this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"TRANSPORT_ERROR",reasonCode:"transport_error"}))},250)));this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null),this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"TRANSPORT_ERROR",reasonCode:"transport_error"})}),a.onMessage(e=>this.handleTransportMessage(e))]}catch(e){this.resetConnectTimeout();const s=e instanceof Error?e.message:"Failed to connect";this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"CONNECT_FAILED",reasonCode:"connect_failed"}),this.rejectConnect(e instanceof Error?e:new Error(s))}}resolveConnect(){this.connectResolve&&this.connectResolve(),this.connectPromise=null,this.connectResolve=null,this.connectReject=null}rejectConnect(e){this.connectReject&&this.connectReject(e),this.connectPromise=null,this.connectResolve=null,this.connectReject=null}async close(){"disposed"!==this.connectionState.status&&(this.shouldReconnect=!1,this.connectPromise=null,this.connectResolve=null,this.connectReject=null,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.resetConnectTimeout(),this.disposeTransport(1e3,"Client closed"),this.clearWaiters(new Error("Daemon client closed")),this.rejectPendingSendQueue(new Error("Daemon client closed")),this.rejectPingProbe(new Error("Daemon client closed")),this.terminalStreams.clearSlots(),this.lastServerInfoMessage=null,this.runtimeMetricsInterval&&(clearInterval(this.runtimeMetricsInterval),this.runtimeMetricsInterval=null,this.runtimeMetrics?.flush({final:!0}),this.runtimeMetrics=null),this.updateConnectionState({status:"disposed"},{event:"DISPOSE",reason:"Client closed",reasonCode:"disposed"}))}ensureConnected(){"disposed"!==this.connectionState.status&&(this.shouldReconnect||(this.shouldReconnect=!0),"connected"!==this.connectionState.status&&"connecting"!==this.connectionState.status&&this.connect())}getConnectionState(){return this.connectionState}subscribeConnectionStatus(e){return this.connectionListeners.add(e),e(this.connectionState),()=>{this.connectionListeners.delete(e)}}get isConnected(){return"connected"===this.connectionState.status}get isConnecting(){return"connecting"===this.connectionState.status}get lastError(){return this.lastErrorValue}getLastLivenessRttMs(){return this.lastLivenessRttMs}subscribe(e){return this.eventListeners.add(e),()=>this.eventListeners.delete(e)}subscribeRawMessages(e){return this.rawMessageListeners.add(e),()=>{this.rawMessageListeners.delete(e)}}on(e,s){if("function"==typeof e)return this.subscribe(e);const t=e,r=s;return this.messageHandlers.has(t)||this.messageHandlers.set(t,new Set),this.messageHandlers.get(t).add(r),()=>{const e=this.messageHandlers.get(t);e&&(e.delete(r),0===e.size&&this.messageHandlers.delete(t))}}sendSessionMessage(e){if(!this.transport||"connected"!==this.connectionState.status){if(this.config.suppressSendErrors)return;throw new Error(`Transport not connected (status: ${this.connectionState.status})`)}const s=h.SessionInboundMessageSchema.parse(e);try{this.transport.send(JSON.stringify({type:"session",message:s}))}catch(e){if(this.config.suppressSendErrors)return;throw e instanceof Error?e:new Error(String(e))}}sendBinaryFrame(e){if(!this.transport||"connected"!==this.connectionState.status){if(this.config.suppressSendErrors)return;throw new Error(`Transport not connected (status: ${this.connectionState.status})`)}try{this.transport.send(e)}catch(e){if(this.config.suppressSendErrors)return;throw e instanceof Error?e:new Error(String(e))}}sendSessionMessageOrThrow(e){const s=this.connectionState.status;if(this.transport&&"connected"===s){const s=h.SessionInboundMessageSchema.parse(e);return this.transport.send(JSON.stringify({type:"session",message:s})),Promise.resolve()}return"connecting"===s?new Promise((s,t)=>{const r=setTimeout(()=>{const e=this.pendingSendQueue.findIndex(e=>e.resolve===s);-1!==e&&this.pendingSendQueue.splice(e,1),t(new Error("Timed out waiting for connection to send message"))},this.config.defaultSendQueueTimeoutMs??L);this.pendingSendQueue.push({message:e,resolve:s,reject:t,timeoutHandle:r})}):Promise.reject(new Error(`Transport not connected (status: ${s})`))}flushPendingSendQueue(){const e=this.pendingSendQueue;this.pendingSendQueue=[];for(const s of e){clearTimeout(s.timeoutHandle);try{if(this.transport&&"connected"===this.connectionState.status){const e=h.SessionInboundMessageSchema.parse(s.message);this.transport.send(JSON.stringify({type:"session",message:e})),s.resolve()}else s.reject(new Error("Connection lost before message could be sent"))}catch(e){s.reject(e instanceof Error?e:new Error(String(e)))}}}rejectPendingSendQueue(e){const s=this.pendingSendQueue;this.pendingSendQueue=[];for(const t of s)clearTimeout(t.timeoutHandle),t.reject(e)}async sendRequest(e){const s=e.timeout??F,{promise:t,cancel:r}=this.waitForWithCancel(s=>{if("rpc_error"===s.type&&s.payload.requestId===e.requestId)return{kind:"error",error:new C({requestId:s.payload.requestId,error:s.payload.error,requestType:s.payload.requestType,code:s.payload.code})};const t=e.select(s);return null===t?null:{kind:"ok",value:t}},s,e.options);try{await this.sendSessionMessageOrThrow(e.message)}catch(e){const s=e instanceof Error?e:new Error(String(e));throw r(s),t.catch(()=>{}),s}const n=await t;if("error"===n.kind)throw n.error;return n.value}async sendCorrelatedRequest(e){return this.sendRequest({requestId:e.requestId,message:e.message,timeout:e.timeout,options:e.options,select:s=>{const t=s;if(t.type!==e.responseType)return null;const r=t.payload;return r.requestId!==e.requestId?null:e.selectPayload?e.selectPayload(r):r}})}sendCorrelatedSessionRequest(e){const s=this.createRequestId(e.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({},e.message,{requestId:s}));return this.sendCorrelatedRequest(Object.assign({requestId:s,message:t,responseType:e.responseType,timeout:e.timeout,options:{skipQueue:!0}},e.selectPayload?{selectPayload:e.selectPayload}:{}))}sendNamespacedCorrelatedSessionRequest(e){const s=e.message.type.replace(/\.request$/,".response");return this.sendCorrelatedSessionRequest(Object.assign({},e,{responseType:s}))}sendSessionMessageStrict(e){if(!this.transport||"connected"!==this.connectionState.status)throw new Error("Transport not connected");const s=h.SessionInboundMessageSchema.parse(e);try{this.transport.send(JSON.stringify({type:"session",message:s}))}catch(e){throw e instanceof Error?e:new Error(String(e))}}async clearAgentAttention(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"clear_agent_attention",agentId:e,requestId:s});await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"clear_agent_attention_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async clearWorkspaceAttention(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"workspace.clear_attention.request",workspaceId:e,requestId:s}),r=await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"workspace.clear_attention.response"!==e.type||e.payload.requestId!==s?null:e.payload});if(!r.success)throw new Error(r.error??"Failed to clear workspace attention")}sendHeartbeat(e){this.sendSessionMessage({type:"client_heartbeat",deviceType:e.deviceType,focusedAgentId:e.focusedAgentId,focusedTerminalId:e.focusedTerminalId??null,lastActivityAt:e.lastActivityAt,appVisible:e.appVisible,appVisibilityChangedAt:e.appVisibilityChangedAt})}registerPushToken(e){this.sendSessionMessage({type:"register_push_token",token:e})}sendWatchAction(e){this.sendSessionMessage(e)}async ping(e){const s=e?.requestId??`ping-${Date.now()}-${Math.random().toString(36).slice(2)}`,t=Date.now(),r=await this.sendRequest({requestId:s,message:{type:"ping",requestId:s,clientSentAt:t},timeout:e?.timeoutMs??5e3,select:e=>"pong"!==e.type||e.payload.requestId!==s||"number"!=typeof e.payload.serverReceivedAt||"number"!=typeof e.payload.serverSentAt?null:e.payload});return{requestId:s,clientSentAt:t,serverReceivedAt:r.serverReceivedAt,serverSentAt:r.serverSentAt,rttMs:Date.now()-t}}measureLatency(e){const s=Math.max(1,e?.timeoutMs??1e4);return this.sendPingAwaitRtt({timeoutMs:s,drivesLivenessFailure:!1}).catch(e=>{throw O(e,"Latency measurement",s)})}async livenessPing(e){const s=Math.max(1,e?.timeoutMs??1e4);try{const e=await this.sendPingAwaitRtt({timeoutMs:s,drivesLivenessFailure:!0});return this.lastLivenessRttMs=e,e}catch(e){throw O(e,"Liveness check",s)}}sendPingAwaitRtt(e){if("connected"!==this.connectionState.status||!this.transport)return Promise.reject(new Error(`Transport not connected (status: ${this.connectionState.status})`));if(this.pingProbe)return this.pingProbe.promise;const s=R(),t=e.timeoutMs;let r=null,n=null;const o=new Promise((e,s)=>{r=e,n=s}),a={promise:o,resolve:e=>r?.(e),reject:e=>n?.(e),timeoutHandle:setTimeout(()=>{if(this.pingProbe!==a)return;this.pingProbe=null;const e=new j(t);a.reject(e),a.drivesLivenessFailure&&this.recordLivenessFailure(O(e,"Liveness check",t))},t),startedAt:s,drivesLivenessFailure:e.drivesLivenessFailure};this.pingProbe=a;try{this.transport.send(JSON.stringify({type:"ping"}))}catch(e){this.clearPingProbe();const s=e instanceof Error?e:new Error(String(e));return a.drivesLivenessFailure&&this.recordLivenessFailure(s),Promise.reject(s)}return o}startLivenessHeartbeat(){this.stopLivenessHeartbeat(),this.lastLivenessRttMs=null,this.scheduleNextLivenessHeartbeat()}stopLivenessHeartbeat(){this.livenessHeartbeatTimer&&(clearTimeout(this.livenessHeartbeatTimer),this.livenessHeartbeatTimer=null)}scheduleNextLivenessHeartbeat(){"connected"!==this.connectionState.status||this.livenessHeartbeatTimer||(this.livenessHeartbeatTimer=setTimeout(()=>{this.livenessHeartbeatTimer=null,this.livenessPing({timeoutMs:3e4}).catch(()=>{}).finally(()=>{this.scheduleNextLivenessHeartbeat()})},1e4))}async fetchAgents(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_agents_request",requestId:s},e?.scope?{scope:e.scope}:{},e?.filter?{filter:e.filter}:{},e?.sort?{sort:e.sort}:{},e?.page?{page:e.page}:{},e?.subscribe?{subscribe:e.subscribe}:{}));return this.sendRequest({requestId:s,message:t,timeout:e?.timeout,options:{skipQueue:!0},select:e=>"fetch_agents_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async fetchAgentHistory(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_agent_history_request",requestId:s},e?.filter?{filter:e.filter}:{},e?.sort?{sort:e.sort}:{},e?.page?{page:e.page}:{}));return this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"fetch_agent_history_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async fetchRecentProviderSessions(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_recent_provider_sessions_request",requestId:s},e?.cwd?{cwd:e.cwd}:{},e?.providers?{providers:e.providers}:{},e?.since?{since:e.since}:{},e?.limit?{limit:e.limit}:{}));return this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"fetch_recent_provider_sessions_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async fetchWorkspaces(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_workspaces_request",requestId:s},e?.filter?{filter:e.filter}:{},e?.sort?{sort:e.sort}:{},e?.page?{page:e.page}:{},e?.subscribe?{subscribe:e.subscribe}:{}));return this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"fetch_workspaces_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async openProject(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"open_project_request",cwd:e},responseType:"open_project_response"})}async addProject(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"project.add.request",cwd:e},responseType:"project.add.response"})}async startWorkspaceScript(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"start_workspace_script_request",workspaceId:e,scriptName:s},responseType:"start_workspace_script_response"})}async archiveWorkspace(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"archive_workspace_request",workspaceId:e},responseType:"archive_workspace_response"})}async renameProject(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"project.rename.request",projectId:e,customName:s},responseType:"project.rename.response",timeout:1e4})}async fetchWorkspaceSetupStatus(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"workspace_setup_status_request",workspaceId:e},responseType:"workspace_setup_status_response"})}async fetchAgent(e,s){const t=v(e,s),r=this.createRequestId(t.requestId),n=h.SessionInboundMessageSchema.parse({type:"fetch_agent_request",requestId:r,agentId:t.agentId}),o=await this.sendRequest({requestId:r,message:n,timeout:t.timeout,options:{skipQueue:!0},select:e=>"fetch_agent_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(o.error)throw new Error(o.error);return o.agent?{agent:o.agent,project:o.project??null}:null}resubscribeCheckoutDiffSubscriptions(){if(0!==this.checkoutDiffSubscriptions.size)for(const[e,s]of this.checkoutDiffSubscriptions){const t=h.SessionInboundMessageSchema.parse({type:"subscribe_checkout_diff_request",subscriptionId:e,cwd:s.cwd,compare:s.compare,requestId:this.createRequestId()});this.sendSessionMessage(t)}}resubscribeTerminalDirectorySubscriptions(){if(0!==this.terminalDirectorySubscriptions.size)for(const e of this.terminalDirectorySubscriptions.values())this.sendSessionMessage(Object.assign({type:"subscribe_terminals_request",cwd:e.cwd},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{}))}async createAgent(e){return(await this.createAgentRequest(e)).agent}async createAgentWithRoutine(e){const s=await this.createAgentRequest(e);if(!s.scheduleId)throw new Error(`Agent ${s.agent.id} was created but the daemon reported no routine. Check its schedules before relying on it.`);return{agent:s.agent,routine:{scheduleId:s.scheduleId,nextRunAt:s.scheduleNextRunAt??null}}}async createAgentRequest(e){const s=this.createRequestId(e.requestId),t=h.SessionInboundMessageSchema.parse(G(e,s)),r=await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const t=h.AgentCreatedStatusPayloadSchema.safeParse(e.payload);if(t.success&&t.data.requestId===s)return t.data;const r=h.AgentCreateFailedStatusPayloadSchema.safeParse(e.payload);return r.success&&r.data.requestId===s?r.data:null}});if("agent_create_failed"===r.status)throw new Error(r.error);return Object.assign({agent:r.agent},r.scheduleId?{scheduleId:r.scheduleId}:{},void 0!==r.scheduleNextRunAt?{scheduleNextRunAt:r.scheduleNextRunAt}:{})}async deleteAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"delete_agent_request",agentId:e,requestId:s});await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"agent_deleted"!==e.type||e.payload.requestId!==s?null:e.payload})}async archiveAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"archive_agent_request",agentId:e,requestId:s});return{archivedAt:(await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"agent_archived"!==e.type||e.payload.requestId!==s?null:e.payload})).archivedAt}}async listBackgroundTasks(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"list_background_tasks_request"},void 0===e?{}:{agentId:e},{requestId:s}));return(await this.sendCorrelatedRequest({requestId:s,message:t,responseType:"list_background_tasks_response",options:{skipQueue:!0}})).tasks}async setAgentContext(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"set_agent_context_request",agentId:e.agentId},void 0===e.links?{}:{links:e.links},void 0===e.secrets?{}:{secrets:e.secrets},{requestId:s})),r=await this.sendCorrelatedRequest({requestId:s,message:t,responseType:"set_agent_context_response",options:{skipQueue:!0}});return Object.assign({digest:r.digest,maskedCount:r.maskedCount},void 0===r.error?{}:{error:r.error})}async enrichReferences(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"enrich_references_request",urls:e,requestId:s});return(await this.sendCorrelatedRequest({requestId:s,message:t,responseType:"enrich_references_response",options:{skipQueue:!0}})).enrichments}async readBackgroundTaskOutput(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"background_task_output_request",agentId:e,taskId:s},void 0===t?.maxBytes?{}:{maxBytes:t.maxBytes},{requestId:r})),o=await this.sendCorrelatedRequest({requestId:r,message:n,responseType:"background_task_output_response",options:{skipQueue:!0}});return{text:o.text,truncated:o.truncated,byteSize:o.byteSize}}async dismissBackgroundTask(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"dismiss_background_task_request",agentId:e,taskId:s,requestId:t});return{dismissed:(await this.sendRequest({requestId:t,message:r,timeout:1e4,options:{skipQueue:!0},select:e=>"background_task_dismissed"!==e.type||e.payload.requestId!==t?null:e.payload})).dismissed}}async detachAgent(e){const s=await this.sendNamespacedCorrelatedSessionRequest({message:{type:"agent.detach.request",agentId:e}});if(!s.accepted)throw new Error(s.error??"detachAgent rejected")}async updateAgent(e,s){const t=this.createRequestId(),r={},n=[];for(const[e,t]of Object.entries(s.labels??{}))null===t?n.push(e):r[e]=t;const o=h.SessionInboundMessageSchema.parse(Object.assign({type:"update_agent_request",agentId:e},void 0!==s.name?{name:s.name}:{},Object.keys(r).length>0?{labels:r}:{},n.length>0?{labelsRemove:n}:{},{requestId:t})),a=await this.sendRequest({requestId:t,message:o,options:{skipQueue:!0},select:e=>"update_agent_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!a.accepted)throw new Error(a.error??"updateAgent rejected")}async rewindSession(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"rewind_session_request",requestId:t,agentId:e,turnId:s}),n=await this.sendRequest({requestId:t,message:r,timeout:3e4,options:{skipQueue:!0},select:e=>"rewind_session_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error||!n.newSessionId)throw new Error(n.error??"rewind: daemon response missing newSessionId");return{newSessionId:n.newSessionId}}async editMessage(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"edit_message_request",requestId:r,agentId:e,turnId:s},"string"==typeof t?{newContent:t}:{})),o=await this.sendRequest({requestId:r,message:n,timeout:3e4,options:{skipQueue:!0},select:e=>"edit_message_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(o.error||!o.newSessionId)throw new Error(o.error??"editMessage: daemon response missing newSessionId");return{newSessionId:o.newSessionId,adopted:!0===o.adopted}}async listWorkspaceSessions(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"list_workspace_sessions_request",requestId:t,workspaceId:e}),n=await this.sendRequest({requestId:t,message:r,timeout:3e4,options:{skipQueue:!0},select:e=>"list_workspace_sessions_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error)throw new Error(n.error);return Array.isArray(n.sessions)?n.sessions:[]}async subscribePush(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"subscribe_push_request",requestId:s,subscription:e}),r=await this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"subscribe_push_response"!==e.type||e.payload.requestId!==s?null:e.payload});if(!r.ok||r.error)throw new Error(r.error??"subscribePush rejected");return Object.assign({ok:r.ok},r.vapidPublicKey?{vapidPublicKey:r.vapidPublicKey}:{})}async getVapidPublicKey(){const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"get_vapid_public_key_request",requestId:e});return(await this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"get_vapid_public_key_response"!==s.type||s.payload.requestId!==e?null:s.payload})).publicKey}async listAllSessions(e){if(this.lastServerInfoMessage?.features?.sessionsListRpc||(0,g.isRelayClientWebSocketUrl)(this.config.url)){const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"list_all_sessions_request",requestId:e}),t=await this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"list_all_sessions_response"!==s.type||s.payload.requestId!==e?null:s.payload});if(t.error)throw new Error(`list_all_sessions failed: ${t.error}`);return Array.isArray(t.sessions)?t.sessions:[]}const s=await this.daemonHttpJson({method:"GET",path:"/sessions",signal:e?.signal});return Array.isArray(s.sessions)?s.sessions:[]}async listWorkflows(){if(!0!==this.lastServerInfoMessage?.features?.workflows)return[];const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"workflow.list.request",requestId:e});return this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"workflow.list.response"!==s.type||s.payload.requestId!==e?null:s.payload.workflows})}async getWorkflow(e){if(!0!==this.lastServerInfoMessage?.features?.workflows)return null;const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"workflow.get.request",requestId:s,workflowId:e});return this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"workflow.get.response"!==e.type||e.payload.requestId!==s?null:e.payload.workflow})}async cancelWorkflow(e){if(!0!==this.lastServerInfoMessage?.features?.workflows)throw new Error("This host does not support workflows. Update the host to use this.");const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"workflow.cancel.request",requestId:s,workflowId:e});return this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"workflow.cancel.response"!==e.type||e.payload.requestId!==s?null:e.payload.workflow})}async startWorkflow(e){if(!0!==this.lastServerInfoMessage?.features?.workflows)throw new Error("This host does not support workflows. Update the host to use this.");const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"workflow.start.request",requestId:s,graph:e.graph,provider:e.provider,cwd:e.cwd},e.model?{model:e.model}:{},e.title?{title:e.title}:{},e.labels?{labels:e.labels}:{},e.agentPresets&&Object.keys(e.agentPresets).length>0?{agentPresets:e.agentPresets}:{}));return this.sendRequest({requestId:s,message:t,timeout:3e4,options:{skipQueue:!0},select:e=>"workflow.start.response"!==e.type||e.payload.requestId!==s?null:{workflowId:e.payload.workflowId,childAgentIds:e.payload.childAgentIds,status:e.payload.status}})}async listExtensions(){if(!this.lastServerInfoMessage?.features?.extensions)return[];const e=this.createRequestId(),s=h.SessionInboundMessageSchema.parse({type:"extensions.list.request",requestId:e}),t=await this.sendRequest({requestId:e,message:s,timeout:15e3,options:{skipQueue:!0},select:s=>"extensions.list.response"!==s.type||s.payload.requestId!==e?null:s.payload});if(t.error)throw new Error(`extensions.list failed: ${t.error}`);return t.extensions}async executeExtensionCommand(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"extensions.command.execute.request",requestId:t,commandId:e,args:s}),n=await this.sendRequest({requestId:t,message:r,timeout:3e4,options:{skipQueue:!0},select:e=>"extensions.command.execute.response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.ok)throw new Error(n.error??"extension command failed");return n.result}async searchSessions(e){if(this.lastServerInfoMessage?.features?.sessionsListRpc||(0,g.isRelayClientWebSocketUrl)(this.config.url)){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"search_sessions_request",requestId:s,query:e.query},"number"==typeof e.limit?{limit:e.limit}:{},e.sources&&e.sources.length>0?{sources:[...e.sources]}:{})),r=await this.sendRequest({requestId:s,message:t,timeout:15e3,options:{skipQueue:!0},select:e=>"search_sessions_response"!==e.type||e.payload.requestId!==s?null:e.payload});if(r.error)throw new Error(`search_sessions failed: ${r.error}`);return Array.isArray(r.results)?r.results:[]}const s=new URLSearchParams;s.set("q",e.query),"number"==typeof e.limit&&s.set("limit",String(e.limit)),e.sources&&e.sources.length>0&&s.set("source",e.sources.join(","));const t=await this.daemonHttpJson({method:"GET",path:`/sessions/search?${s.toString()}`,signal:e.signal});return Array.isArray(t.results)?t.results:[]}getHttpBaseUrl(){const e=this.config.url;if((0,g.isRelayClientWebSocketUrl)(e))throw new Error("HTTP routes are not available over relay transport");let s;try{s=new URL(e)}catch{throw new Error(`Cannot derive HTTP base from WS url: ${e}`)}return"ws:"===s.protocol?s.protocol="http:":"wss:"===s.protocol&&(s.protocol="https:"),s.username="",s.password="",s.pathname=s.pathname.replace(/\/ws\/?$/,"/"),s.search="",s.hash="",s.origin}buildAuthHeader(){const e=k(this.config.password);return e?`Bearer ${e}`:this.config.authHeader?this.config.authHeader:null}async daemonHttpJson(e){const s=this.getHttpBaseUrl(),t=new URL(e.path,s).toString(),r={},n=this.buildAuthHeader();let o;n&&(r.Authorization=n),void 0!==e.body&&(r["Content-Type"]="application/json");try{o=await fetch(t,Object.assign({method:e.method,headers:r},void 0!==e.body?{body:JSON.stringify(e.body)}:{},e.signal?{signal:e.signal}:{}))}catch(s){const t=s instanceof Error?s.message:String(s);throw new Error(`daemon HTTP ${e.method} ${e.path} failed: ${t}`,{cause:s})}if(!o.ok){let s=null;try{s=await o.json()}catch{s=null}const t=s&&"object"==typeof s&&"error"in s?String(s.error):`http_${o.status}`;throw new Error(`daemon HTTP ${e.method} ${e.path} ${o.status}: ${t}`)}return await o.json()}async removeProject(e,s){const t=await this.sendNamespacedCorrelatedSessionRequest({requestId:s,message:{type:"project.remove.request",projectId:e}});if(!t.accepted)throw new Error(t.error??"removeProject rejected");return{removedWorkspaceIds:t.removedWorkspaceIds}}async setWorkspaceTitle(e,s,t){const r=await this.sendCorrelatedSessionRequest({requestId:t,message:{type:"workspace.title.set.request",workspaceId:e,title:s},responseType:"workspace.title.set.response"});if(!r.accepted)throw new Error(r.error??"setWorkspaceTitle rejected");return{title:r.title}}async answerAgentDecision(e,s,t,r,n){const o=await this.sendCorrelatedSessionRequest({requestId:n,message:{type:"agent.decision.answer.request",agentId:e,decisionId:s,optionId:t,note:r},responseType:"agent.decision.answer.response"});if(!o.accepted)throw new Error(o.error??"answerAgentDecision rejected");return{decision:o.decision}}async consolidateAgents(e,s,t){const r=await this.sendCorrelatedSessionRequest({requestId:t,message:{type:"agent.consolidate.request",winnerId:e,sourceIds:s},responseType:"agent.consolidate.response"});if(!r.accepted)throw new Error(r.error??"consolidateAgents rejected");return{archivedIds:r.archivedIds}}async snoozeAgent(e,s,t=null,r=null,n){const o=await this.sendCorrelatedSessionRequest({requestId:n,message:{type:"agent.snooze.request",agentId:e,until:s,untilWhat:t,why:r},responseType:"agent.snooze.response"});if(!o.accepted)throw new Error(o.error??"snoozeAgent rejected");return{snooze:o.snooze}}async resumeAgent(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"resume_agent_request",requestId:t,handle:e},s?{overrides:s}:{}));return(await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const s=h.AgentResumedStatusPayloadSchema.safeParse(e.payload);return s.success&&s.data.requestId===t?s.data:null}})).agent}async importAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse(Object.assign({type:"import_agent_request",requestId:s},"providerId"in e?{providerId:e.providerId,providerHandleId:e.providerHandleId}:{provider:e.provider,sessionId:e.sessionId},e.cwd?{cwd:e.cwd}:{},e.labels&&Object.keys(e.labels).length>0?{labels:e.labels}:{})),r=await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const t=h.AgentResumedStatusPayloadSchema.safeParse(e.payload);if(t.success&&t.data.requestId===s)return t.data;const r=h.AgentCreateFailedStatusPayloadSchema.safeParse(e.payload);return r.success&&r.data.requestId===s?r.data:null}});if("agent_create_failed"===r.status)throw new Error(r.error);return r.agent}async refreshAgent(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse({type:"refresh_agent_request",agentId:e,requestId:t});return this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const s=h.AgentRefreshedStatusPayloadSchema.safeParse(e.payload);return s.success&&s.data.requestId===t?s.data:null}})}async fetchAgentTimeline(e,s={}){const t=this.createRequestId(s.requestId),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"fetch_agent_timeline_request",agentId:e,requestId:t},s.direction?{direction:s.direction}:{},s.cursor?{cursor:s.cursor}:{},"number"==typeof s.limit?{limit:s.limit}:{},s.projection?{projection:s.projection}:{})),n=await this.sendRequest({requestId:t,message:r,timeout:s.timeout,options:{skipQueue:!0},select:e=>"fetch_agent_timeline_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error)throw new Error(n.error);return n}async buildAgentForkContext(e,s={}){const t=this.createRequestId(s.requestId),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"agent.fork_context.request",agentId:e,requestId:t},s.boundaryMessageId?{boundaryMessageId:s.boundaryMessageId}:{})),n=await this.sendRequest({requestId:t,message:r,timeout:15e3,options:{skipQueue:!0},select:e=>"agent.fork_context.response"!==e.type||e.payload.requestId!==t?null:e.payload});if(n.error)throw new Error(n.error);return n}async sendAgentMessage(e,s,t){const r=this.createRequestId(),n=t?.messageId??crypto.randomUUID(),o=h.SessionInboundMessageSchema.parse(Object.assign({type:"send_agent_message_request",requestId:r,agentId:e,text:s},n?{messageId:n}:{},t?.images?{images:t.images}:{},t?.attachments?{attachments:t.attachments}:{})),a=await this.sendRequest({requestId:r,message:o,options:{skipQueue:!0},select:e=>"send_agent_message_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!a.accepted)throw new Error(a.error??"sendAgentMessage rejected")}async sendMessage(e,s,t){await this.sendAgentMessage(e,s,t)}async rewindAgent(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse({type:"agent.rewind.request",requestId:r,agentId:e,messageId:s,mode:t}),o=await this.sendRequest({requestId:r,message:n,options:{skipQueue:!0},select:e=>"agent.rewind.response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.ok)throw new Error(o.error??"Agent rewind failed");return o}async cancelAgent(e){const s=this.createRequestId(),t=h.SessionInboundMessageSchema.parse({type:"cancel_agent_request",agentId:e,requestId:s});await this.sendRequest({requestId:s,message:t,options:{skipQueue:!0},select:e=>"cancel_agent_response"!==e.type||e.payload.requestId!==s?null:e.payload})}async setAgentMode(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"set_agent_mode_request",agentId:e,modeId:s,requestId:t}),n=await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>"set_agent_mode_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.accepted)throw new Error(n.error??"setAgentMode rejected");return n.notice??null}async setAgentModel(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"set_agent_model_request",agentId:e,modelId:s,requestId:t}),n=await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>"set_agent_model_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.accepted)throw new Error(n.error??"setAgentModel rejected")}async swapAgentProvider(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"swap_agent_provider_request",agentId:e,newProviderId:s,requestId:r},t?{overrides:t}:{})),o=await this.sendRequest({requestId:r,message:n,timeout:3e4,options:{skipQueue:!0},select:e=>"swap_agent_provider_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.accepted)throw new Error(o.error??"swapAgentProvider rejected")}async setAgentFeature(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse({type:"set_agent_feature_request",agentId:e,featureId:s,value:t,requestId:r}),o=await this.sendRequest({requestId:r,message:n,options:{skipQueue:!0},select:e=>"set_agent_feature_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.accepted)throw new Error(o.error??"setAgentFeature rejected")}async setAgentThinkingOption(e,s){const t=this.createRequestId(),r=h.SessionInboundMessageSchema.parse({type:"set_agent_thinking_request",agentId:e,thinkingOptionId:s,requestId:t}),n=await this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>"set_agent_thinking_response"!==e.type||e.payload.requestId!==t?null:e.payload});if(!n.accepted)throw new Error(n.error??"setAgentThinkingOption rejected");return n.notice??null}async restartServer(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse(Object.assign({type:"restart_server_request"},e&&e.trim().length>0?{reason:e}:{},{requestId:t}));return this.sendRequest({requestId:t,message:r,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const s=h.RestartRequestedStatusPayloadSchema.safeParse(e.payload);return s.success?s.data.requestId!==t?null:s.data:null}})}async shutdownServer(e){const s=this.createRequestId(e?.requestId),t=h.SessionInboundMessageSchema.parse({type:"shutdown_server_request",requestId:s});return this.sendRequest({requestId:s,message:t,timeout:e?.timeout,options:{skipQueue:!0},select:e=>{if("status"!==e.type)return null;const t=h.ShutdownRequestedStatusPayloadSchema.safeParse(e.payload);return t.success?t.data.requestId!==s?null:t.data:null}})}async updateDaemon(e){const s=this.createRequestId(e),t=h.SessionInboundMessageSchema.parse({type:"daemon.update.request",requestId:s});return this.sendRequest({requestId:s,message:t,timeout:3e5,options:{skipQueue:!0},select:e=>{const t=h.DaemonUpdateResponseSchema.safeParse(e);return t.success?t.data.payload.requestId!==s?null:t.data.payload:null}})}async setVoiceMode(e,s,t){const r=this.createRequestId(),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"set_voice_mode",enabled:e},s?{agentId:s}:{},t?{language:t}:{},{requestId:r})),o=await this.sendRequest({requestId:r,message:n,select:e=>"set_voice_mode_response"!==e.type||e.payload.requestId!==r?null:e.payload});if(!o.accepted){const e="string"==typeof o.reasonCode&&o.reasonCode.trim().length>0?` (${o.reasonCode})`:"";throw new Error((o.error??"Failed to set voice mode")+e)}return o}async sendVoiceAudioChunk(e,s,t=!1){this.sendSessionMessage({type:"voice_audio_chunk",audio:e,format:s,isLast:t})}async startDictationStream(e,s,t){const r=this.waitForWithCancel(s=>"dictation_stream_ack"!==s.type||s.payload.dictationId!==e||-1!==s.payload.ackSeq?null:s.payload,3e4,{skipQueue:!0}),n=r.promise.then(()=>{}),o=this.waitForWithCancel(s=>"dictation_stream_error"!==s.type||s.payload.dictationId!==e?null:s.payload,3e4,{skipQueue:!0}),a=o.promise.then(e=>{throw new Error(e.error)}),i=new Error("Cancelled dictation start waiter");try{this.sendSessionMessageStrict(Object.assign({type:"dictation_stream_start",dictationId:e,format:s},t?{language:t}:{})),await Promise.race([n,a])}finally{r.cancel(i),o.cancel(i),n.catch(()=>{}),a.catch(()=>{})}}sendDictationStreamChunk(e,s,t,r){this.sendSessionMessageStrict({type:"dictation_stream_chunk",dictationId:e,seq:s,audio:t,format:r})}async finishDictationStream(e,s){const t=this.waitForWithCancel(s=>"dictation_stream_final"!==s.type||s.payload.dictationId!==e?null:s.payload,0,{skipQueue:!0}),r=this.waitForWithCancel(s=>"dictation_stream_error"!==s.type||s.payload.dictationId!==e?null:s.payload,0,{skipQueue:!0}),n=this.waitForWithCancel(s=>"dictation_stream_finish_accepted"!==s.type||s.payload.dictationId!==e?null:s.payload,x,{skipQueue:!0}),o=t.promise,a=r.promise.then(e=>{throw new Error(e.error)}),i=n.promise,c=o.then(e=>({kind:"final",payload:e})),d=a.then(()=>({kind:"error",error:new Error("Unexpected dictation stream error state")}),e=>({kind:"error",error:e instanceof Error?e:new Error(String(e))})),u=i.then(e=>({kind:"accepted",payload:e}),e=>D(e)?{kind:"accepted_timeout"}:{kind:"accepted_error",error:e instanceof Error?e:new Error(String(e))}),p=async e=>{if(!Number.isFinite(e)||e<=0){const e=await Promise.race([c,d]);if("error"===e.kind)throw e.error;return e.payload}let s=null;const t=new Promise(t=>{s=setTimeout(()=>t({kind:"timeout"}),e)}),r=await Promise.race([c,d,t]);if(s&&clearTimeout(s),"timeout"===r.kind)throw new Error(`Timeout waiting for dictation finalization (${e}ms)`);if("error"===r.kind)throw r.error;return r.payload},l=new Error("Cancelled dictation finish waiter");try{this.sendSessionMessageStrict({type:"dictation_stream_finish",dictationId:e,finalSeq:s});const t=await Promise.race([c,d,u]);if("final"===t.kind)return t.payload;if("error"===t.kind)throw t.error;return"accepted"===t.kind?await p(t.payload.timeoutMs+1e4):await p(6e5)}finally{t.cancel(l),r.cancel(l),n.cancel(l),o.catch(()=>{}),a.catch(()=>{}),i.catch(()=>{})}}cancelDictationStream(e){this.sendSessionMessageStrict({type:"dictation_stream_cancel",dictationId:e})}async abortRequest(){this.sendSessionMessage({type:"abort_request"})}async audioPlayed(e){this.sendSessionMessage({type:"audio_played",id:e})}async getCheckoutStatus(e,s){const t=s?.requestId;if(!t){const s=this.checkoutStatusInFlight.get(e);if(s)return s}const r=this.createRequestId(t),n=h.SessionInboundMessageSchema.parse({type:"checkout_status_request",cwd:e,requestId:r}),o=this.sendRequest({requestId:r,message:n,options:{skipQueue:!0},select:e=>"checkout_status_response"!==e.type||e.payload.requestId!==r?null:e.payload});return t||(this.checkoutStatusInFlight.set(e,o),o.finally(()=>{this.checkoutStatusInFlight.get(e)===o&&this.checkoutStatusInFlight.delete(e)}).catch(()=>{})),o}normalizeCheckoutDiffCompare(e){if("uncommitted"===e.mode)return!0===e.ignoreWhitespace?{mode:"uncommitted",ignoreWhitespace:!0}:{mode:"uncommitted"};const s=e.baseRef?.trim();return s?!0===e.ignoreWhitespace?{mode:"base",baseRef:s,ignoreWhitespace:!0}:{mode:"base",baseRef:s}:!0===e.ignoreWhitespace?{mode:"base",ignoreWhitespace:!0}:{mode:"base"}}async getCheckoutDiff(e,s,t){const r=`oneshot-checkout-diff:${crypto.randomUUID()}`;try{const n=await this.subscribeCheckoutDiff(e,s,{subscriptionId:r,requestId:t});return{cwd:n.cwd,files:n.files,error:n.error,requestId:n.requestId}}finally{try{this.unsubscribeCheckoutDiff(r)}catch{}}}async subscribeCheckoutDiff(e,s,t){const r=t?.subscriptionId??crypto.randomUUID(),n=this.normalizeCheckoutDiffCompare(s),o=this.checkoutDiffSubscriptions.get(r)??null;this.checkoutDiffSubscriptions.set(r,{cwd:e,compare:n});const a=this.createRequestId(t?.requestId),i=h.SessionInboundMessageSchema.parse({type:"subscribe_checkout_diff_request",subscriptionId:r,cwd:e,compare:n,requestId:a});try{return await this.sendCorrelatedRequest({requestId:a,message:i,responseType:"subscribe_checkout_diff_response",options:{skipQueue:!0},selectPayload:e=>e.subscriptionId!==r?null:e})}catch(e){throw o?this.checkoutDiffSubscriptions.set(r,o):this.checkoutDiffSubscriptions.delete(r),e}}unsubscribeCheckoutDiff(e){this.checkoutDiffSubscriptions.delete(e),this.sendSessionMessage({type:"unsubscribe_checkout_diff_request",subscriptionId:e})}async checkoutCommit(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_commit_request",cwd:e,message:s.message,addAll:s.addAll},responseType:"checkout_commit_response"})}async checkoutMerge(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_merge_request",cwd:e,baseRef:s.baseRef,strategy:s.strategy,requireCleanTarget:s.requireCleanTarget},responseType:"checkout_merge_response"})}async checkoutMergeFromBase(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_merge_from_base_request",cwd:e,baseRef:s.baseRef,requireCleanTarget:s.requireCleanTarget},responseType:"checkout_merge_from_base_response"})}async checkoutPull(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout_pull_request",cwd:e},responseType:"checkout_pull_response"})}async checkoutPush(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout_push_request",cwd:e},responseType:"checkout_push_response"})}async checkoutRefresh(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout.refresh.request",cwd:e},responseType:"checkout.refresh.response"})}async checkoutPrCreate(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_pr_create_request",cwd:e,title:s.title,body:s.body,baseRef:s.baseRef},responseType:"checkout_pr_create_response"})}async checkoutPrMerge(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_pr_merge_request",cwd:e,mergeMethod:s.method},responseType:"checkout_pr_merge_response"})}async checkoutGithubSetAutoMerge(e,s,t){return this.sendNamespacedCorrelatedSessionRequest({requestId:t,message:Object.assign({type:"checkout.github.set_auto_merge.request",cwd:e,enabled:s.enabled},s.enabled?{mergeMethod:s.method}:{})})}async checkoutGithubGetCheckDetails(e,s){return this.sendNamespacedCorrelatedSessionRequest({requestId:s,message:{type:"checkout.github.get_check_details.request",cwd:e.cwd,repoOwner:e.repoOwner,repoName:e.repoName,checkRunId:e.checkRunId,workflowRunId:e.workflowRunId}})}async checkoutPrStatus(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"checkout_pr_status_request",cwd:e},responseType:"checkout_pr_status_response"})}async pullRequestTimeline(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"pull_request_timeline_request",cwd:e.cwd,prNumber:e.prNumber,repoOwner:e.repoOwner,repoName:e.repoName},responseType:"pull_request_timeline_response"})}async checkoutSwitchBranch(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"checkout_switch_branch_request",cwd:e,branch:s},responseType:"checkout_switch_branch_response"})}async renameBranch(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"checkout.rename_branch.request",cwd:e.cwd,branch:e.branch},responseType:"checkout.rename_branch.response"})}async stashSave(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"stash_save_request",cwd:e,branch:s?.branch},responseType:"stash_save_response"})}async stashPop(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"stash_pop_request",cwd:e,stashIndex:s},responseType:"stash_pop_response"})}async stashList(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"stash_list_request",cwd:e,paseoOnly:s?.paseoOnly},responseType:"stash_list_response"})}async getPaseoWorktreeList(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"paseo_worktree_list_request",cwd:e.cwd,repoRoot:e.repoRoot},responseType:"paseo_worktree_list_response"})}async archivePaseoWorktree(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"paseo_worktree_archive_request",worktreePath:e.worktreePath,repoRoot:e.repoRoot,branchName:e.branchName},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{},void 0!==e.scope?{scope:e.scope}:{}),responseType:"paseo_worktree_archive_response"})}async createPaseoWorktree(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"create_paseo_worktree_request",cwd:e.cwd},void 0!==e.projectId?{projectId:e.projectId}:{},{worktreeSlug:e.worktreeSlug},void 0!==e.firstAgentContext?{firstAgentContext:e.firstAgentContext}:{},void 0!==e.refName?{refName:e.refName}:{},void 0!==e.action?{action:e.action}:{},void 0!==e.githubPrNumber?{githubPrNumber:e.githubPrNumber}:{}),responseType:"create_paseo_worktree_response"})}async createWorkspace(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"workspace.create.request",source:e.source},void 0!==e.title?{title:e.title}:{},void 0!==e.firstAgentContext?{firstAgentContext:e.firstAgentContext}:{}),responseType:"workspace.create.response"})}async validateBranch(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"validate_branch_request",cwd:e.cwd,branchName:e.branchName},responseType:"validate_branch_response"})}async getBranchSuggestions(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"branch_suggestions_request",cwd:e.cwd,query:e.query,limit:e.limit},responseType:"branch_suggestions_response"})}async searchGitHub(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"github_search_request",cwd:e.cwd,query:e.query,limit:e.limit,kinds:e.kinds},responseType:"github_search_response"})}async getDirectorySuggestions(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"directory_suggestions_request",query:e.query,cwd:e.cwd,includeFiles:e.includeFiles,includeDirectories:e.includeDirectories,matchMode:e.matchMode,limit:e.limit},responseType:"directory_suggestions_response"})}async requestFileExplorer(e,s,t,r,n=!1){return this.sendCorrelatedSessionRequest({requestId:r,message:Object.assign({type:"file_explorer_request",cwd:e,path:s,mode:t},n?{acceptBinary:!0}:{}),responseType:"file_explorer_response"})}async listDirectory(e,s,t){const r=await this.requestFileExplorer(e,s,"list",t);if(r.error)throw new Error(r.error);if(!r.directory)throw new Error("Directory listing unavailable.");return r.directory}async readFile(e,s,t){const r=this.createRequestId(t);this.pendingBinaryFileReads.set(r,{cwd:e,path:s});try{const t=await this.requestFileExplorer(e,s,"file",r,!0);if(t.error)throw new Error(t.error);const n=this.completedBinaryFileReads.get(r);if(n)return this.completedBinaryFileReads.delete(r),n;if(!t.file)throw new Error("File unavailable.");return U(t.file)}finally{this.pendingBinaryFileReads.delete(r),this.activeBinaryFileTransfers.delete(r)}}async requestDownloadToken(e,s,t){return this.sendCorrelatedSessionRequest({requestId:t,message:{type:"file_download_token_request",cwd:e,path:s},responseType:"file_download_token_response"})}async requestProjectIcon(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"project_icon_request",cwd:e},responseType:"project_icon_response"})}async listProviderModels(e,s){const t=await this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"list_provider_models_request",provider:e,cwd:s?.cwd},responseType:"list_provider_models_response",timeout:9e4});return(0,_.normalizeListProviderModelsPayload)(t)}async listProviderModes(e,s){return this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"list_provider_modes_request",provider:e,cwd:s?.cwd},responseType:"list_provider_modes_response",timeout:9e4})}async listProviderFeatures(e,s){return this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"list_provider_features_request",draftConfig:e},responseType:"list_provider_features_response",timeout:9e4})}async listAvailableProviders(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"list_available_providers_request"},responseType:"list_available_providers_response"})}async getProvidersSnapshot(e){const s=await this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"get_providers_snapshot_request",cwd:e?.cwd},responseType:"get_providers_snapshot_response"});return(0,_.normalizeProvidersSnapshotPayload)(s)}async reloadProviderConfig(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"providers.reload_config.request"},responseType:"providers.reload_config.response",timeout:15e3})}async getDaemonConfig(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"get_daemon_config_request"},responseType:"get_daemon_config_response"})}async getDaemonStatus(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"daemon.get_status.request"},responseType:"daemon.get_status.response",timeout:e?.timeout})}async getDaemonPairingOffer(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"daemon.get_pairing_offer.request"},responseType:"daemon.get_pairing_offer.response",timeout:e?.timeout})}async collectDiagnostics(e){return this.sendNamespacedCorrelatedSessionRequest({requestId:e,message:{type:"diagnostics.request"}})}async patchDaemonConfig(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"set_daemon_config_request",config:e},responseType:"set_daemon_config_response"})}sendBrowserAutomationExecuteResponse(e){this.sendSessionMessageStrict(e)}async readProjectConfig(e,s){return this.sendCorrelatedSessionRequest({requestId:s,message:{type:"read_project_config_request",repoRoot:e},responseType:"read_project_config_response"})}async writeProjectConfig(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"write_project_config_request",repoRoot:e.repoRoot,config:e.config,expectedRevision:e.expectedRevision},responseType:"write_project_config_response"})}async refreshProvidersSnapshot(e){return this.sendCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"refresh_providers_snapshot_request",cwd:e?.cwd,providers:e?.providers},responseType:"refresh_providers_snapshot_response",timeout:12e4})}async getProviderDiagnostic(e,s){return this.sendCorrelatedSessionRequest({requestId:s?.requestId,message:{type:"provider_diagnostic_request",provider:e},responseType:"provider_diagnostic_response",timeout:18e4})}async listProviderUsage(e){return this.sendNamespacedCorrelatedSessionRequest({requestId:e?.requestId,message:{type:"provider.usage.list.request"}})}async listCommands(e,s){const t=T(e,s);return this.sendCorrelatedSessionRequest({requestId:t.requestId,message:Object.assign({type:"list_commands_request",agentId:t.agentId},t.draftConfig?{draftConfig:t.draftConfig}:{}),responseType:"list_commands_response"})}async respondToPermission(e,s,t){this.sendSessionMessage({type:"agent_permission_response",agentId:e,requestId:s,response:t})}async respondToPermissionAndWait(e,s,t,r=15e3){const n=h.SessionInboundMessageSchema.parse({type:"agent_permission_response",agentId:e,requestId:s,response:t});return this.sendRequest({requestId:s,message:n,timeout:r,options:{skipQueue:!0},select:t=>"agent_permission_resolved"!==t.type||t.payload.requestId!==s||t.payload.agentId!==e?null:t.payload})}async waitForAgentUpsert(e,s,t=6e4){const r=Date.now()+t,n=()=>new Error(`Timed out waiting for agent ${e}`),o=()=>this.fetchAgent({agentId:e,timeout:Math.max(1,r-Date.now())}).catch(()=>null),a=await o();if(a&&s(a.agent))return a.agent;if(Date.now()>=r)throw n();return await new Promise((t,a)=>{let i=!1,c=!1,d=null,u=null,p=null;const l=e=>{i||(i=!0,u&&(clearTimeout(u),u=null),d&&(clearInterval(d),d=null),p&&(p(),p=null),"ok"!==e.kind?a(e.error):t(e.snapshot))},h=e=>!!e&&(!!s(e)&&(l({kind:"ok",snapshot:e}),!0)),m=async()=>{if(!i&&!c){c=!0;try{const e=await o();h(e?.agent??null)}finally{c=!1}}};p=this.on("agent_update",s=>{if(i)return;if("upsert"!==s.payload.kind)return;const t=s.payload.agent;t.id===e&&h(t)});const g=Math.max(1,r-Date.now());u=setTimeout(()=>{l({kind:"error",error:n()})},g),d=setInterval(()=>{m()},250),m()})}async waitForFinish(e,s=6e4){const t=this.createRequestId(),r=Number.isFinite(s)&&s>0,n=h.SessionInboundMessageSchema.parse(Object.assign({type:"wait_for_finish_request",requestId:t,agentId:e},r?{timeoutMs:s}:{})),o=await this.sendCorrelatedRequest({requestId:t,message:n,responseType:"wait_for_finish_response",timeout:r?s+5e3:0,options:{skipQueue:!0}});return{status:o.status,final:o.final,error:o.error,lastMessage:o.lastMessage}}subscribeTerminals(e){this.terminalDirectorySubscriptions.set((0,y.terminalSubscriptionKey)(e.cwd,e.workspaceId),{cwd:e.cwd,workspaceId:e.workspaceId}),this.transport&&"connected"===this.connectionState.status&&this.sendSessionMessage(Object.assign({type:"subscribe_terminals_request",cwd:e.cwd},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{}))}unsubscribeTerminals(e){this.terminalDirectorySubscriptions.delete((0,y.terminalSubscriptionKey)(e.cwd,e.workspaceId)),this.transport&&"connected"===this.connectionState.status&&this.sendSessionMessage(Object.assign({type:"unsubscribe_terminals_request",cwd:e.cwd},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{}))}async listTerminals(e,s,t){const r=this.createRequestId(s),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"list_terminals_request"},void 0===e?{}:{cwd:e},void 0!==t?.workspaceId?{workspaceId:t.workspaceId}:{},{requestId:r}));return this.sendCorrelatedRequest({requestId:r,message:n,responseType:"list_terminals_response",options:{skipQueue:!0}})}async createTerminal(e,s,t,r){const n=this.createRequestId(t),o=h.SessionInboundMessageSchema.parse(Object.assign({type:"create_terminal_request",cwd:e,name:s,agentId:r?.agentId,command:r?.command,args:r?.args},void 0!==r?.workspaceId?{workspaceId:r.workspaceId}:{},{requestId:n}));return this.sendCorrelatedRequest({requestId:n,message:o,responseType:"create_terminal_response",options:{skipQueue:!0}})}async renameTerminal(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"terminal.rename.request",terminalId:e.terminalId,title:e.title},responseType:"terminal.rename.response"})}async subscribeTerminal(e,s){const t="object"==typeof s?s.restore:void 0,r="object"==typeof s?s.requestId:s,n=this.createRequestId(r),o=h.SessionInboundMessageSchema.parse(Object.assign({type:"subscribe_terminal_request",terminalId:e,requestId:n},t?{restore:t}:{})),a=await this.sendCorrelatedRequest({requestId:n,message:o,responseType:"subscribe_terminal_response",options:{skipQueue:!0}});return null===a.error&&this.terminalStreams.setSlot(e,a.slot),a}unsubscribeTerminal(e){this.terminalStreams.removeTerminal(e),this.sendSessionMessage({type:"unsubscribe_terminal_request",terminalId:e})}sendTerminalInput(e,s){const t=this.terminalStreams.encodeInput(e,s);t?this.sendBinaryFrame(t):this.sendSessionMessage({type:"terminal_input",terminalId:e,message:s})}async killTerminal(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse({type:"kill_terminal_request",terminalId:e,requestId:t});return this.sendCorrelatedRequest({requestId:t,message:r,responseType:"kill_terminal_response",options:{skipQueue:!0}})}async closeItems(e,s){const t=this.createRequestId(s),r=h.SessionInboundMessageSchema.parse({type:"close_items_request",agentIds:e.agentIds??[],terminalIds:e.terminalIds??[],requestId:t});return this.sendCorrelatedRequest({requestId:t,message:r,responseType:"close_items_response",options:{skipQueue:!0}})}async captureTerminal(e,s,t){const r=this.createRequestId(t),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"capture_terminal_request",terminalId:e},void 0===s?.start?{}:{start:s.start},void 0===s?.end?{}:{end:s.end},void 0===s?.stripAnsi?{}:{stripAnsi:s.stripAnsi},{requestId:r}));return this.sendCorrelatedRequest({requestId:r,message:n,responseType:"capture_terminal_response",options:{skipQueue:!0}})}async captureAgentPane(e,s,t){const r=this.createRequestId(t),n=h.SessionInboundMessageSchema.parse(Object.assign({type:"capture_agent_pane_request",agentId:e},void 0===s?.ansi?{}:{ansi:s.ansi},void 0===s?.scrollbackLines?{}:{scrollbackLines:s.scrollbackLines},{requestId:r}));return this.sendCorrelatedRequest({requestId:r,message:n,responseType:"capture_agent_pane_response",options:{skipQueue:!0}})}async createChatRoom(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/create",name:e.name},e.purpose?{purpose:e.purpose}:{}),responseType:"chat/create/response"})}async listChatRooms(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"chat/list"},responseType:"chat/list/response"})}async inspectChatRoom(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"chat/inspect",room:e.room},responseType:"chat/inspect/response"})}async deleteChatRoom(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"chat/delete",room:e.room},responseType:"chat/delete/response"})}async postChatMessage(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/post",room:e.room,body:e.body},e.authorAgentId?{authorAgentId:e.authorAgentId}:{},e.replyToMessageId?{replyToMessageId:e.replyToMessageId}:{}),responseType:"chat/post/response"})}async readChatMessages(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/read",room:e.room},"number"==typeof e.limit?{limit:e.limit}:{},e.since?{since:e.since}:{},e.authorAgentId?{authorAgentId:e.authorAgentId}:{}),responseType:"chat/read/response",timeout:e.timeout})}async waitForChatMessages(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"chat/wait",room:e.room},e.afterMessageId?{afterMessageId:e.afterMessageId}:{},"number"==typeof e.timeoutMs?{timeoutMs:e.timeoutMs}:{}),responseType:"chat/wait/response",timeout:(e.timeoutMs??0)+1e4})}async scheduleCreate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"schedule/create",prompt:e.prompt,cadence:e.cadence,target:e.target},e.name?{name:e.name}:{},"number"==typeof e.maxRuns?{maxRuns:e.maxRuns}:{},e.expiresAt?{expiresAt:e.expiresAt}:{},"boolean"==typeof e.runOnCreate?{runOnCreate:e.runOnCreate}:{}),responseType:"schedule/create/response"})}async scheduleList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"schedule/list"},responseType:"schedule/list/response"})}async ingestionBackfill(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/backfill",filterId:e.filterId,windowDays:e.windowDays},responseType:"ingestion/backfill/response"})}async ingestionApply(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"ingestion/apply",filterId:e.filterId,itemKeys:e.itemKeys,mode:e.mode},"number"==typeof e.confirmedGroups?{confirmedGroups:e.confirmedGroups}:{}),responseType:"ingestion/apply/response"})}async ingestionCohortInspect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/cohort/inspect",cohortId:e.cohortId},responseType:"ingestion/cohort/inspect/response"})}async ingestionCohortCancel(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/cohort/cancel",cohortId:e.cohortId},responseType:"ingestion/cohort/cancel/response"})}async ingestionRuns(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/runs",filterId:e.filterId,includeClosed:e.includeClosed},responseType:"ingestion/runs/response"})}async fleetList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"fleet/list"},responseType:"fleet/list/response"})}async fleetInspect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/inspect",name:e.name},responseType:"fleet/inspect/response"})}async fleetRunNow(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/run-now",name:e.name},responseType:"fleet/run-now/response"})}async fleetPause(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/pause",name:e.name},responseType:"fleet/pause/response"})}async fleetAsk(e){const{requestId:s}=e,t=(0,p.default)(e,i);return this.sendCorrelatedSessionRequest({requestId:s,message:Object.assign({type:"fleet/ask"},t),responseType:"fleet/ask/response"})}async fleetDecisions(e={}){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/decisions",name:e.name,includeResolved:e.includeResolved},responseType:"fleet/decisions/response"})}async fleetResolveDecision(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/resolve-decision",decisionId:e.decisionId,optionId:e.optionId},responseType:"fleet/resolve-decision/response"})}async fleetSetParams(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/set-params",name:e.name,values:e.values},responseType:"fleet/set-params/response"})}async fleetSetMode(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/set-mode",name:e.name,mode:e.mode},responseType:"fleet/set-mode/response"})}async fleetResume(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/resume",name:e.name},responseType:"fleet/resume/response"})}async fleetCreate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"fleet/create",name:e.name,description:e.description,cron:e.cron,action:e.action},void 0!==e.mode?{mode:e.mode}:{},void 0!==e.rails?{rails:e.rails}:{},void 0!==e.allowed?{allowed:e.allowed}:{}),responseType:"fleet/create/response"})}async fleetExecutions(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"fleet/executions",name:e.name},responseType:"fleet/executions/response"})}async scheduleInspect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/inspect",scheduleId:e.id},responseType:"schedule/inspect/response"})}async scheduleLogs(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/logs",scheduleId:e.id},responseType:"schedule/logs/response"})}async schedulePause(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/pause",scheduleId:e.id},responseType:"schedule/pause/response"})}async scheduleResume(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/resume",scheduleId:e.id},responseType:"schedule/resume/response"})}async scheduleDelete(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/delete",scheduleId:e.id},responseType:"schedule/delete/response"})}async scheduleRunOnce(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"schedule/run-once",scheduleId:e.id},responseType:"schedule/run-once/response"})}async scheduleUpdate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"schedule/update",scheduleId:e.id},void 0!==e.name?{name:e.name}:{},void 0!==e.prompt?{prompt:e.prompt}:{},void 0!==e.cadence?{cadence:e.cadence}:{},void 0!==e.newAgentConfig?{newAgentConfig:e.newAgentConfig}:{},void 0!==e.maxRuns?{maxRuns:e.maxRuns}:{},void 0!==e.expiresAt?{expiresAt:e.expiresAt}:{}),responseType:"schedule/update/response"})}async sourceCatalogue(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"source/catalogue",kind:e.kind,query:e.query},e.cursor?{cursor:e.cursor}:{}),responseType:"source/catalogue/response"})}async sourceConnect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/connect",kind:e.kind,appSlug:e.appSlug},responseType:"source/connect/response"})}async sourceList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"source/list"},responseType:"source/list/response"})}async sourceCheck(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/check",sourceId:e.sourceId},responseType:"source/check/response"})}async ingestionFilterList(e={}){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"ingestion/filter/list"},void 0===e.sourceId?{}:{sourceId:e.sourceId}),responseType:"ingestion/filter/list/response"})}async ingestionFilterCreate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/filter/create",draft:e.draft},responseType:"ingestion/filter/create/response"})}async ingestionFilterUpdate(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/filter/update",filterId:e.filterId,patch:e.patch},responseType:"ingestion/filter/update/response"})}async ingestionFilterDelete(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"ingestion/filter/delete",filterId:e.filterId},responseType:"ingestion/filter/delete/response"})}async sourceTriggers(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/triggers",sourceId:e.sourceId},responseType:"source/triggers/response"})}async sourceSubscribe(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"source/subscribe",sourceId:e.sourceId},void 0===e.componentId?{}:{componentId:e.componentId}),responseType:"source/subscribe/response"})}async sourceDisconnect(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:{type:"source/disconnect",sourceId:e.sourceId},responseType:"source/disconnect/response"})}async loopRun(e){return this.sendCorrelatedSessionRequest({requestId:e.requestId,message:Object.assign({type:"loop/run",prompt:e.prompt,cwd:e.cwd},e.provider?{provider:e.provider}:{},e.model?{model:e.model}:{},e.modeId?{modeId:e.modeId}:{},e.verifierProvider?{verifierProvider:e.verifierProvider}:{},e.verifierModel?{verifierModel:e.verifierModel}:{},e.verifierModeId?{verifierModeId:e.verifierModeId}:{},e.verifyPrompt?{verifyPrompt:e.verifyPrompt}:{},e.verifyChecks&&e.verifyChecks.length>0?{verifyChecks:e.verifyChecks}:{},e.name?{name:e.name}:{},"number"==typeof e.sleepMs?{sleepMs:e.sleepMs}:{},"number"==typeof e.maxIterations?{maxIterations:e.maxIterations}:{},"number"==typeof e.maxTimeMs?{maxTimeMs:e.maxTimeMs}:{}),responseType:"loop/run/response"})}async loopList(e){return this.sendCorrelatedSessionRequest({requestId:e,message:{type:"loop/list"},responseType:"loop/list/response"})}async loopInspect(e){const s="string"==typeof e?{id:e}:e;return this.sendCorrelatedSessionRequest({requestId:s.requestId,message:{type:"loop/inspect",id:s.id},responseType:"loop/inspect/response"})}async loopLogs(e,s){const t="string"==typeof e?{id:e,afterSeq:s}:e;return this.sendCorrelatedSessionRequest({requestId:t.requestId,message:Object.assign({type:"loop/logs",id:t.id},"number"==typeof t.afterSeq?{afterSeq:t.afterSeq}:{}),responseType:"loop/logs/response"})}async loopStop(e){const s="string"==typeof e?{id:e}:e;return this.sendCorrelatedSessionRequest({requestId:s.requestId,message:{type:"loop/stop",id:s.id},responseType:"loop/stop/response"})}onTerminalStreamEvent(e){return this.terminalStreams.onEvent(e)}async waitForTerminalStreamEvent(e,s=5e3){return new Promise((t,r)=>{const n=setTimeout(()=>{o(),r(new Error(`Timeout waiting for terminal stream event (${s}ms)`))},s),o=this.onTerminalStreamEvent(s=>{e(s)&&(clearTimeout(n),o(),t(s))})})}async uploadFile(e,s){const t=this.createRequestId(),r=crypto.randomUUID(),n=e.bytes.byteLength,o=s.signal;if(o?.aborted)throw new M(r);const a=[];for(let s=0;s<n;s+=q.UPLOAD_CHUNK_SIZE_BYTES)a.push(e.bytes.subarray(s,Math.min(s+q.UPLOAD_CHUNK_SIZE_BYTES,n)));const i=a.length;let c;try{c=await this.sendCorrelatedRequest({requestId:t,message:h.SessionInboundMessageSchema.parse({type:"files.upload.begin.request",requestId:t,agentId:s.agentId,uploadId:r,metadata:{mime:e.mime,size:n,encoding:"binary",modifiedAt:e.modifiedAt,fileName:e.path.split(/[\\/]/).at(-1)||e.path}}),responseType:"files.upload.begin.response",timeout:3e4,options:{skipQueue:!0}})}catch(e){throw new P(r,e instanceof Error?e.message:String(e))}if(!c.accepted||c.error)throw A(r,c.error??"write_failed");const d=new Map;let u=0,p=0,l=0,m=!1,g=!1;const y=[],I=()=>{for(const e of y.splice(0))try{e()}catch{}d.clear()};let f;await new Promise((e,c)=>{const h=()=>{g||(g=!0,I(),e())},q=e=>{g||(g=!0,I(),c(e))},f=()=>{for(;d.size<8&&u<i;){if(m||g)return;const e=u,s=a[e];if(u+=1,d.set(e,s.byteLength),d.size>8)return void q(new P(r,`upload window invariant violated: ${d.size} chunks in flight`));try{this.sendSessionMessage({type:"files.upload.chunk",payload:{requestId:t,uploadId:r,chunkIndex:e,data:H(s)}})}catch(e){return void q(new P(r,e instanceof Error?e.message:String(e)))}}};y.push(this.on("files.upload.chunk.ack",e=>{if(e.payload.requestId!==t)return;const r=e.payload.chunkIndex,o=d.get(r);void 0!==o&&(d.delete(r),l+=1,p+=o,s.onProgress?.(p,n),l>=i?h():f())})),y.push(this.on("files.upload.error",e=>{e.payload.requestId!==t&&e.payload.uploadId!==r||q(A(r,e.payload.code,e.payload.message))}));const w=()=>{m=!0;try{this.sendSessionMessage({type:"files.upload.error",payload:{requestId:t,uploadId:r,code:"aborted"}})}catch{}q(new M(r))};o&&(o.addEventListener("abort",w,{once:!0}),y.push(()=>o.removeEventListener("abort",w))),0!==i?o?.aborted?w():f():h()});try{f=await this.sendCorrelatedRequest({requestId:t,message:h.SessionInboundMessageSchema.parse({type:"files.upload.complete.request",requestId:t,uploadId:r,totalChunks:i}),responseType:"files.upload.complete.response",timeout:3e4,options:{skipQueue:!0}})}catch(e){throw new P(r,e instanceof Error?e.message:String(e))}if(f.error)throw A(r,f.error);return{fileId:f.fileId,path:f.path,size:f.size,mimeType:f.mimeType}}createRequestId(e){return e??crypto.randomUUID()}getLastServerInfoMessage(){return this.lastServerInfoMessage}getFileUploadsCapability(){return this.lastServerInfoMessage?.features?.fileUploads??!1}resolveTransportUrlForAttempt(){return this.config.url}sendHelloMessage(){if(this.transport)try{this.transport.send(JSON.stringify(Object.assign({type:"hello",clientId:this.config.clientId,clientType:this.config.clientType??"cli",protocolVersion:1,capabilities:Object.assign({[l.CLIENT_CAPS.customModeIcons]:!0,[l.CLIENT_CAPS.reasoningMergeEnum]:!0,[l.CLIENT_CAPS.terminalReflowableSnapshot]:!0},this.config.capabilities)},this.config.appVersion?{appVersion:this.config.appVersion}:{})))}catch(e){const s=e instanceof Error?e.message:"Failed to send hello message";this.lastErrorValue=s,this.scheduleReconnect({reason:s,event:"HELLO_SEND_FAILED",reasonCode:"transport_error"})}else this.scheduleReconnect({reason:"Transport unavailable before hello",event:"HELLO_TRANSPORT_MISSING",reasonCode:"transport_error"})}disposeTransport(e=1001,s="Reconnecting"){if(this.stopLivenessHeartbeat(),this.cleanupTransport(),this.transport){try{this.transport.close(e,s)}catch{}this.transport=null}}cleanupTransport(){this.resetConnectTimeout(),this.pendingGenericTransportErrorTimeout&&(clearTimeout(this.pendingGenericTransportErrorTimeout),this.pendingGenericTransportErrorTimeout=null);for(const e of this.transportCleanup)try{e()}catch{}this.transportCleanup=[]}resetConnectTimeout(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null)}handleTransportMessage(e){const s=e&&"object"==typeof e&&"data"in e?e.data:e;if("undefined"!=typeof Blob&&s instanceof Blob&&"function"==typeof s.arrayBuffer)return void s.arrayBuffer().then(e=>{this.handleTransportMessage(e)}).catch(()=>{});const t=(0,I.asUint8Array)(s);if(t&&this.tryHandleBinaryFrame(t))return;const r=(0,f.decodeMessageData)(s);r&&this.handleJsonPayload(r,t?.byteLength)}handleJsonPayload(e,s){const t=s??e.length,r=R();let n;try{n=JSON.parse(e)}catch{return}const o=(0,m.validateWSOutboundMessage)(n);if(!o.success){const e=null!=n&&"object"==typeof n&&"type"in n&&"string"==typeof n.type?n.type:"unknown";return void this.logger.warn({msgType:e,error:o.error.message},"Message validation failed")}if(this.consecutiveLivenessFailures=0,"pong"===o.data.type)return this.resolvePingProbe(),void this.runtimeMetrics?.recordMessage("pong",t,R()-r);this.handleSessionMessage(o.data.message);const a=o.data.message.type;this.runtimeMetrics?.recordMessage(a,t,R()-r),"agent_stream"===o.data.message.type&&this.runtimeMetrics?.recordAgentStream(o.data.message.payload)}tryHandleBinaryFrame(e){const s=(0,I.decodeFileTransferFrame)(e);if(s)return this.consecutiveLivenessFailures=0,this.handleFileTransferFrame(s),this.runtimeMetrics?.recordBinaryFrame("other",e.byteLength,0),!0;const t=(0,I.decodeTerminalStreamFrame)(e);if(!t)return!1;this.consecutiveLivenessFailures=0;const r=R();this.terminalStreams.handleFrame(t);let n="other";return t.opcode===I.TerminalStreamOpcode.Output?n="output":t.opcode===I.TerminalStreamOpcode.Snapshot?n="snapshot":t.opcode===I.TerminalStreamOpcode.Restore&&(n="output"),this.runtimeMetrics?.recordBinaryFrame(n,e.byteLength,R()-r),!0}handleFileTransferFrame(e){if(e.opcode===I.FileTransferOpcode.FileBegin){const s=this.pendingBinaryFileReads.get(e.requestId);if(!s)return;return void this.activeBinaryFileTransfers.set(e.requestId,Object.assign({},s,{mime:e.metadata.mime,size:e.metadata.size,encoding:e.metadata.encoding,modifiedAt:e.metadata.modifiedAt,chunks:[]}))}const s=this.activeBinaryFileTransfers.get(e.requestId);if(!s)return;if(e.opcode===I.FileTransferOpcode.FileChunk)return void s.chunks.push(e.payload);const t=W(s.chunks,s.size);var r,n;this.activeBinaryFileTransfers.delete(e.requestId),this.completedBinaryFileReads.set(e.requestId,{bytes:t,mime:s.mime,size:s.size,path:s.path,kind:(r=s.mime,n=s.encoding,r.startsWith("image/")?"image":"utf-8"===n||r.startsWith("text/")||"application/json"===r?"text":"binary"),modifiedAt:s.modifiedAt}),this.handleSessionMessage({type:"file_explorer_response",payload:{cwd:s.cwd,path:s.path,mode:"file",directory:null,file:null,error:null,requestId:e.requestId}})}updateConnectionState(e,s){const t=this.connectionState;this.connectionState=e;const r="disconnected"===e.status&&"string"==typeof e.reason?e.reason:null,n=s?.reason??r,o=s?.reasonCode??$(n);this.logger.debug({serverId:this.logServerId,clientIdHash:this.logClientIdHash,from:t.status,to:e.status,event:s?.event??"STATE_UPDATE",connectionPath:this.logConnectionPath,generation:this.logGeneration,reasonCode:o,reason:n},"DaemonClientTransition");for(const s of this.connectionListeners)try{s(e)}catch{}}setReconnectEnabled(e){this.config=Object.assign({},this.config,{reconnect:Object.assign({},this.config.reconnect,{enabled:e})})}scheduleReconnect(e){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null);const s="disposed"===this.connectionState.status,t=e?.reason;"string"==typeof t&&t.trim().length>0&&(this.lastErrorValue=t.trim()),this.clearWaiters(new Error(t??"Connection lost")),this.rejectPendingSendQueue(new Error(t??"Connection lost")),this.rejectPingProbe(new Error(t??"Connection lost")),this.terminalStreams.clearSlots(),this.lastServerInfoMessage=null,s?this.rejectConnect(new Error(t??"Daemon client is disposed")):(this.emitDisconnectedStateForReconnect(t,e),this.shouldReconnect&&!1!==this.config.reconnect?.enabled?this.armReconnectTimer():this.rejectConnect(new Error(t??"Transport disconnected before connect")))}emitDisconnectedStateForReconnect(e,s){this.updateConnectionState(Object.assign({status:"disconnected"},e?{reason:e}:{}),Object.assign({event:s?.event??"TRANSPORT_CLOSE"},e?{reason:e}:{},s?.reasonCode?{reasonCode:s.reasonCode}:{}))}armReconnectTimer(){const e=this.reconnectAttempt,s=this.config.reconnect?.baseDelayMs??1500,t=this.config.reconnect?.maxDelayMs??3e4,r=Math.min(s*2**e,t);this.reconnectAttempt=e+1,this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.shouldReconnect&&this.attemptConnect()},r)}resolvePingProbe(){const e=this.pingProbe;e&&(this.pingProbe=null,clearTimeout(e.timeoutHandle),e.resolve(R()-e.startedAt))}clearPingProbe(){const e=this.pingProbe;e&&(this.pingProbe=null,clearTimeout(e.timeoutHandle))}rejectPingProbe(e){const s=this.pingProbe;s&&(this.pingProbe=null,clearTimeout(s.timeoutHandle),s.reject(e))}recordLivenessFailure(e){this.consecutiveLivenessFailures+=1,this.consecutiveLivenessFailures<2||(this.consecutiveLivenessFailures=0,this.lastErrorValue=e.message,this.disposeTransport(1001,"Liveness check timed out"),this.scheduleReconnect({reason:e.message,event:"LIVENESS_TIMEOUT",reasonCode:"liveness_timeout"}))}handleSessionMessage(e){const s=(0,_.normalizeProviderSnapshotUpdateMessage)(e);if("status"===s.type){const e=(0,h.parseServerInfoStatusPayload)(s.payload);e&&(this.lastServerInfoMessage=e,"connecting"===this.connectionState.status&&(this.resetConnectTimeout(),this.reconnectAttempt=0,this.updateConnectionState({status:"connected"},{event:"HELLO_SERVER_INFO"}),this.startLivenessHeartbeat(),this.resubscribeCheckoutDiffSubscriptions(),this.resubscribeTerminalDirectorySubscriptions(),this.flushPendingSendQueue(),this.resolveConnect()))}if("terminal_stream_exit"===s.type&&this.terminalStreams.removeTerminal(s.payload.terminalId),this.rawMessageListeners.size>0)for(const e of this.rawMessageListeners)try{e(s)}catch{}const t=this.messageHandlers.get(s.type);if(t)for(const e of t)try{e(s)}catch{}const r=this.toEvent(s);if(r)for(const e of this.eventListeners)e(r);this.resolveWaiters(s)}resolveWaiters(e){for(const s of Array.from(this.waiters)){const t=s.predicate(e);null!==t&&(this.waiters.delete(s),s.timeoutHandle&&clearTimeout(s.timeoutHandle),s.resolve(t))}}clearWaiters(e){for(const s of Array.from(this.waiters))s.timeoutHandle&&clearTimeout(s.timeoutHandle),s.reject(e);this.waiters.clear()}toEvent(e){switch(e.type){case"agent_update":return{type:"agent_update",agentId:"upsert"===e.payload.kind?e.payload.agent.id:e.payload.agentId,payload:e.payload};case"workspace_update":return{type:"workspace_update",workspaceId:"upsert"===e.payload.kind?e.payload.workspace.id:e.payload.id,payload:e.payload};case"workspace_setup_progress":return{type:"workspace_setup_progress",workspaceId:e.payload.workspaceId,payload:e.payload};case"agent_stream":return Object.assign({type:"agent_stream",agentId:e.payload.agentId,event:e.payload.event,timestamp:e.payload.timestamp},"number"==typeof e.payload.seq?{seq:e.payload.seq}:{},"string"==typeof e.payload.epoch?{epoch:e.payload.epoch}:{});case"status":return{type:"status",payload:e.payload};case"agent_deleted":return{type:"agent_deleted",agentId:e.payload.agentId};case"agent_permission_request":return{type:"agent_permission_request",agentId:e.payload.agentId,request:e.payload.request};case"agent_permission_resolved":return{type:"agent_permission_resolved",agentId:e.payload.agentId,requestId:e.payload.requestId,resolution:e.payload.resolution};case"providers_snapshot_update":return{type:"providers_snapshot_update",payload:e.payload};default:return null}}waitForWithCancel(e,s=3e4,t){const r=new Error(`Timeout waiting for message (${s}ms)`);let n=null,o=!1,a=null;return{promise:new Promise((t,i)=>{const c=e=>{o||(o=!0,i(e))};a=c;const d=s>0?setTimeout(()=>{n&&this.waiters.delete(n),c(r)},s):null;n={predicate:e,resolve:e=>{o||(o=!0,t(e))},reject:c,timeoutHandle:d},this.waiters.add(n)}),cancel:e=>{o||(n&&(this.waiters.delete(n),n.timeoutHandle&&clearTimeout(n.timeoutHandle)),a?a(e):queueMicrotask(()=>{!o&&a&&a(e)}))}}}}function G(e,s){return Object.assign({type:"create_agent_request",requestId:s,config:V(e)},e.env?{env:e.env}:{},void 0!==e.workspaceId?{workspaceId:e.workspaceId}:{},e.initialPrompt?{initialPrompt:e.initialPrompt}:{},e.clientMessageId?{clientMessageId:e.clientMessageId}:{},e.outputSchema?{outputSchema:e.outputSchema}:{},e.images&&e.images.length>0?{images:e.images}:{},e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{},e.git?{git:e.git}:{},e.worktree?{worktree:e.worktree}:{},void 0!==e.autoArchive?{autoArchive:e.autoArchive}:{},e.worktreeName?{worktreeName:e.worktreeName}:{},e.labels&&Object.keys(e.labels).length>0?{labels:e.labels}:{},e.resumeSessionId?{resumeSessionId:e.resumeSessionId}:{},e.routine?{routine:e.routine}:{})}function V(e){const{config:s,provider:t,cwd:r}=e,n=(0,p.default)(e,c),o=Object.assign({},t?{provider:t}:{},r?{cwd:r}:{},n),a=s?Object.assign({},o,s):o;if(!a.provider||!a.cwd)throw new Error("createAgent requires provider and cwd");return Object.assign({},a,{provider:a.provider,cwd:a.cwd})}},3282,[35,3283,3284,3389,3392,3393,3394,3396,3397,3407,3408,3409]);
|
|
14928
14928
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CLIENT_CAPS",{enumerable:!0,get:function(){return o}});const o={reasoningMergeEnum:"reasoning_merge_enum",customModeIcons:"custom_mode_icons",terminalReflowableSnapshot:"terminal_reflowable_snapshot",browserHost:"browser_host"}},3283,[]);
|
|
14929
14929
|
__d(function(e,t,n,r,o,a,i){"use strict";const s=["contextKind"];Object.defineProperty(a,'__esModule',{value:!0}),Object.defineProperty(a,"PaseoConfigRawSchema",{enumerable:!0,get:function(){return k.PaseoConfigRawSchema}}),Object.defineProperty(a,"PaseoLifecycleCommandRawSchema",{enumerable:!0,get:function(){return k.PaseoLifecycleCommandRawSchema}}),Object.defineProperty(a,"PaseoMetadataGenerationEntrySchema",{enumerable:!0,get:function(){return k.PaseoMetadataGenerationEntrySchema}}),Object.defineProperty(a,"PaseoMetadataGenerationSchema",{enumerable:!0,get:function(){return k.PaseoMetadataGenerationSchema}}),Object.defineProperty(a,"PaseoScriptEntryRawSchema",{enumerable:!0,get:function(){return k.PaseoScriptEntryRawSchema}}),Object.defineProperty(a,"PaseoWorktreeConfigRawSchema",{enumerable:!0,get:function(){return k.PaseoWorktreeConfigRawSchema}}),Object.defineProperty(a,"TerminalProfileSchema",{enumerable:!0,get:function(){return C}}),Object.defineProperty(a,"KanbanBucketDefSchema",{enumerable:!0,get:function(){return T}}),Object.defineProperty(a,"KanbanBoardConfigSchema",{enumerable:!0,get:function(){return x}}),Object.defineProperty(a,"TagColorOverrideSchema",{enumerable:!0,get:function(){return D}}),Object.defineProperty(a,"MutableDaemonConfigSchema",{enumerable:!0,get:function(){return E}}),Object.defineProperty(a,"MutableDaemonConfigPatchSchema",{enumerable:!0,get:function(){return W}}),Object.defineProperty(a,"AgentStatusSchema",{enumerable:!0,get:function(){return N}}),Object.defineProperty(a,"WORKFLOW_STATUSES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(a,"WorkflowStatusSchema",{enumerable:!0,get:function(){return U}}),Object.defineProperty(a,"WorkflowPhaseSchema",{enumerable:!0,get:function(){return B}}),Object.defineProperty(a,"WorkflowAgentPresetSchema",{enumerable:!0,get:function(){return G}}),Object.defineProperty(a,"WorkflowSnapshotSchema",{enumerable:!0,get:function(){return H}}),Object.defineProperty(a,"STORED_WORKFLOW_SCHEMA",{enumerable:!0,get:function(){return K}}),Object.defineProperty(a,"WORKFLOW_EVENT_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(a,"WorkflowEventTypeSchema",{enumerable:!0,get:function(){return X}}),Object.defineProperty(a,"WorkflowLifecycleEventSchema",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(a,"WorkflowListRequestSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(a,"WorkflowListResponseSchema",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(a,"WorkflowGetRequestSchema",{enumerable:!0,get:function(){return $}}),Object.defineProperty(a,"WorkflowGetResponseSchema",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(a,"WorkflowCancelRequestSchema",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(a,"WorkflowCancelResponseSchema",{enumerable:!0,get:function(){return te}}),Object.defineProperty(a,"WorkflowEventsRequestSchema",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(a,"WorkflowEventsResponseSchema",{enumerable:!0,get:function(){return re}}),Object.defineProperty(a,"WorkflowTaskNodeSchema",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(a,"WorkflowTaskGraphSchema",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(a,"WorkflowStartRequestSchema",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(a,"WorkflowStartResponseSchema",{enumerable:!0,get:function(){return se}}),Object.defineProperty(a,"AgentFeatureToggleSchema",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(a,"AgentFeatureSelectSchema",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(a,"AgentFeatureSchema",{enumerable:!0,get:function(){return be}}),Object.defineProperty(a,"ProviderSnapshotEntrySchema",{enumerable:!0,get:function(){return me}}),Object.defineProperty(a,"AgentPermissionResponseSchema",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(a,"AgentPermissionRequestPayloadSchema",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(a,"AgentTimelineItemPayloadSchema",{enumerable:!0,get:function(){return We}}),Object.defineProperty(a,"AgentStreamEventPayloadSchema",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(a,"SessionDigestLinkSchema",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(a,"SessionSecretSchema",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(a,"PendingDecisionOptionSchema",{enumerable:!0,get:function(){return He}}),Object.defineProperty(a,"PendingDecisionSchema",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(a,"SessionDigestSchema",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(a,"AgentSnoozeStateSchema",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(a,"AgentSnapshotPayloadSchema",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(a,"AgentListItemPayloadSchema",{enumerable:!0,get:function(){return Je}}),Object.defineProperty(a,"RecentProviderSessionDescriptorPayloadSchema",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(a,"VoiceAudioChunkMessageSchema",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(a,"AbortRequestMessageSchema",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(a,"AudioPlayedMessageSchema",{enumerable:!0,get:function(){return et}}),Object.defineProperty(a,"DeleteAgentRequestMessageSchema",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(a,"ArchiveAgentRequestMessageSchema",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(a,"BackgroundTaskStatusSchema",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(a,"BackgroundTaskPayloadSchema",{enumerable:!0,get:function(){return at}}),Object.defineProperty(a,"ListBackgroundTasksRequestMessageSchema",{enumerable:!0,get:function(){return it}}),Object.defineProperty(a,"ListBackgroundTasksResponseSchema",{enumerable:!0,get:function(){return st}}),Object.defineProperty(a,"BackgroundTaskOutputRequestMessageSchema",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(a,"BackgroundTaskOutputResponseSchema",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(a,"ReferenceEnrichmentSchema",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(a,"MAX_ENRICHMENT_PREVIEW_LINES",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(a,"SetAgentContextRequestMessageSchema",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(a,"SetAgentContextResponseSchema",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(a,"EnrichReferencesRequestMessageSchema",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(a,"EnrichReferencesResponseSchema",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(a,"DismissBackgroundTaskRequestMessageSchema",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(a,"BackgroundTaskDismissedMessageSchema",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(a,"CloseItemsRequestMessageSchema",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(a,"UpdateAgentRequestMessageSchema",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(a,"ProjectRenameRequestSchema",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(a,"ProjectRemoveRequestSchema",{enumerable:!0,get:function(){return St}}),Object.defineProperty(a,"WorkspaceTitleSetRequestSchema",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(a,"AgentConsolidateRequestSchema",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(a,"AgentConsolidateResponsePayloadSchema",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(a,"AgentConsolidateResponseSchema",{enumerable:!0,get:function(){return It}}),Object.defineProperty(a,"AgentSnoozeRequestSchema",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(a,"AgentSnoozeResponsePayloadSchema",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(a,"AgentSnoozeResponseSchema",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(a,"AgentDecisionAnswerRequestSchema",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(a,"SetVoiceModeMessageSchema",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(a,"GitHubPrAttachmentSchema",{enumerable:!0,get:function(){return At}}),Object.defineProperty(a,"GitHubIssueAttachmentSchema",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(a,"TextAttachmentSchema",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(a,"ReviewAttachmentContextLineSchema",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(a,"ReviewAttachmentCommentSchema",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(a,"ReviewAttachmentSchema",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(a,"FileAttachmentSchema",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(a,"UploadedFileAttachmentSchema",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(a,"AgentAttachmentSchema",{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(a,"SendAgentMessageSchema",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(a,"FetchAgentsRequestMessageSchema",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(a,"WorkspaceStateBucketSchema",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(a,"FetchWorkspacesRequestMessageSchema",{enumerable:!0,get:function(){return Kt}}),Object.defineProperty(a,"FetchAgentHistoryRequestMessageSchema",{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(a,"FetchRecentProviderSessionsRequestMessageSchema",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(a,"FetchAgentRequestMessageSchema",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(a,"SendAgentMessageRequestSchema",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(a,"WaitForFinishRequestSchema",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(a,"DaemonGetStatusRequestSchema",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(a,"DaemonGetPairingOfferRequestSchema",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(a,"DiagnosticsRequestSchema",{enumerable:!0,get:function(){return en}}),Object.defineProperty(a,"GetDaemonConfigRequestMessageSchema",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(a,"SetDaemonConfigRequestMessageSchema",{enumerable:!0,get:function(){return nn}}),Object.defineProperty(a,"ReadProjectConfigRequestMessageSchema",{enumerable:!0,get:function(){return rn}}),Object.defineProperty(a,"WriteProjectConfigRequestMessageSchema",{enumerable:!0,get:function(){return on}}),Object.defineProperty(a,"DictationStreamStartMessageSchema",{enumerable:!0,get:function(){return an}}),Object.defineProperty(a,"DictationStreamChunkMessageSchema",{enumerable:!0,get:function(){return sn}}),Object.defineProperty(a,"DictationStreamFinishMessageSchema",{enumerable:!0,get:function(){return ln}}),Object.defineProperty(a,"DictationStreamCancelMessageSchema",{enumerable:!0,get:function(){return cn}}),Object.defineProperty(a,"CreateAgentWorktreeTargetSchema",{enumerable:!0,get:function(){return zn}}),Object.defineProperty(a,"CreateAgentRequestMessageSchema",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(a,"ListProviderModelsRequestMessageSchema",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(a,"ListProviderModesRequestMessageSchema",{enumerable:!0,get:function(){return bn}}),Object.defineProperty(a,"ListAvailableProvidersRequestMessageSchema",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(a,"GetProvidersSnapshotRequestMessageSchema",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(a,"ProvidersReloadConfigRequestMessageSchema",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(a,"RefreshProvidersSnapshotRequestMessageSchema",{enumerable:!0,get:function(){return yn}}),Object.defineProperty(a,"ProviderDiagnosticRequestMessageSchema",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(a,"ProviderUsageListRequestMessageSchema",{enumerable:!0,get:function(){return jn}}),Object.defineProperty(a,"ResumeAgentRequestMessageSchema",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(a,"ImportAgentRequestMessageSchema",{enumerable:!0,get:function(){return Pn}}),Object.defineProperty(a,"RefreshAgentRequestMessageSchema",{enumerable:!0,get:function(){return _n}}),Object.defineProperty(a,"CancelAgentRequestMessageSchema",{enumerable:!0,get:function(){return qn}}),Object.defineProperty(a,"RestartServerRequestMessageSchema",{enumerable:!0,get:function(){return In}}),Object.defineProperty(a,"ShutdownServerRequestMessageSchema",{enumerable:!0,get:function(){return Rn}}),Object.defineProperty(a,"DaemonUpdateRequestMessageSchema",{enumerable:!0,get:function(){return On}}),Object.defineProperty(a,"AgentTimelineCursorSchema",{enumerable:!0,get:function(){return kn}}),Object.defineProperty(a,"FetchAgentTimelineRequestMessageSchema",{enumerable:!0,get:function(){return wn}}),Object.defineProperty(a,"AgentForkContextRequestMessageSchema",{enumerable:!0,get:function(){return vn}}),Object.defineProperty(a,"SetAgentModeRequestMessageSchema",{enumerable:!0,get:function(){return An}}),Object.defineProperty(a,"SetAgentModeResponseMessageSchema",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(a,"SetAgentModelRequestMessageSchema",{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(a,"SetAgentModelResponseMessageSchema",{enumerable:!0,get:function(){return xn}}),Object.defineProperty(a,"SwapAgentProviderRequestMessageSchema",{enumerable:!0,get:function(){return Ln}}),Object.defineProperty(a,"SwapAgentProviderResponseMessageSchema",{enumerable:!0,get:function(){return Dn}}),Object.defineProperty(a,"AgentProviderSwappedEventSchema",{enumerable:!0,get:function(){return En}}),Object.defineProperty(a,"SetAgentThinkingRequestMessageSchema",{enumerable:!0,get:function(){return Wn}}),Object.defineProperty(a,"SetAgentThinkingResponseMessageSchema",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(a,"SetAgentFeatureRequestMessageSchema",{enumerable:!0,get:function(){return Fn}}),Object.defineProperty(a,"SetAgentFeatureResponseMessageSchema",{enumerable:!0,get:function(){return Un}}),Object.defineProperty(a,"AgentDetachRequestMessageSchema",{enumerable:!0,get:function(){return Bn}}),Object.defineProperty(a,"AgentDetachResponseMessageSchema",{enumerable:!0,get:function(){return Gn}}),Object.defineProperty(a,"AgentRewindModeSchema",{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(a,"AgentRewindRequestMessageSchema",{enumerable:!0,get:function(){return Kn}}),Object.defineProperty(a,"AgentRewindResponseMessageSchema",{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(a,"UpdateAgentResponseMessageSchema",{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(a,"ProjectRenameResponsePayloadSchema",{enumerable:!0,get:function(){return Yn}}),Object.defineProperty(a,"ProjectRenameResponseSchema",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(a,"ProjectRemoveResponsePayloadSchema",{enumerable:!0,get:function(){return Qn}}),Object.defineProperty(a,"ProjectRemoveResponseSchema",{enumerable:!0,get:function(){return $n}}),Object.defineProperty(a,"WorkspaceTitleSetResponsePayloadSchema",{enumerable:!0,get:function(){return Zn}}),Object.defineProperty(a,"WorkspaceTitleSetResponseSchema",{enumerable:!0,get:function(){return er}}),Object.defineProperty(a,"AgentDecisionAnswerResponsePayloadSchema",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(a,"AgentDecisionAnswerResponseSchema",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(a,"SetVoiceModeResponseMessageSchema",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(a,"AgentPermissionResponseMessageSchema",{enumerable:!0,get:function(){return or}}),Object.defineProperty(a,"WatchNotificationActionMessageSchema",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(a,"WatchSessionSearchMessageSchema",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(a,"WatchComposerDictateMessageSchema",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(a,"CheckoutStatusRequestSchema",{enumerable:!0,get:function(){return zr}}),Object.defineProperty(a,"SubscribeCheckoutDiffRequestSchema",{enumerable:!0,get:function(){return pr}}),Object.defineProperty(a,"UnsubscribeCheckoutDiffRequestSchema",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(a,"CheckoutCommitRequestSchema",{enumerable:!0,get:function(){return br}}),Object.defineProperty(a,"CheckoutMergeRequestSchema",{enumerable:!0,get:function(){return dr}}),Object.defineProperty(a,"CheckoutMergeFromBaseRequestSchema",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(a,"CheckoutPullRequestSchema",{enumerable:!0,get:function(){return fr}}),Object.defineProperty(a,"CheckoutPushRequestSchema",{enumerable:!0,get:function(){return yr}}),Object.defineProperty(a,"CheckoutRefreshRequestSchema",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(a,"CheckoutPrCreateRequestSchema",{enumerable:!0,get:function(){return jr}}),Object.defineProperty(a,"CheckoutPrMergeRequestSchema",{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(a,"CheckoutGithubSetAutoMergeRequestSchema",{enumerable:!0,get:function(){return Pr}}),Object.defineProperty(a,"FileUploadErrorCodeSchema",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(a,"FilesUploadBeginRequestSchema",{enumerable:!0,get:function(){return qr}}),Object.defineProperty(a,"FilesUploadCompleteRequestSchema",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(a,"FilesUploadChunkSchema",{enumerable:!0,get:function(){return Rr}}),Object.defineProperty(a,"FilesUploadErrorSchema",{enumerable:!0,get:function(){return Or}}),Object.defineProperty(a,"CheckoutGithubGetCheckDetailsRequestSchema",{enumerable:!0,get:function(){return wr}}),Object.defineProperty(a,"CheckoutPrStatusRequestSchema",{enumerable:!0,get:function(){return vr}}),Object.defineProperty(a,"PullRequestTimelineRequestSchema",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(a,"ValidateBranchRequestSchema",{enumerable:!0,get:function(){return Mr}}),Object.defineProperty(a,"CheckoutSwitchBranchRequestSchema",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(a,"CheckoutRenameBranchRequestSchema",{enumerable:!0,get:function(){return Tr}}),Object.defineProperty(a,"StashSaveRequestSchema",{enumerable:!0,get:function(){return xr}}),Object.defineProperty(a,"StashPopRequestSchema",{enumerable:!0,get:function(){return Lr}}),Object.defineProperty(a,"StashListRequestSchema",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(a,"BranchSuggestionsRequestSchema",{enumerable:!0,get:function(){return Er}}),Object.defineProperty(a,"GitHubSearchItemSchema",{enumerable:!0,get:function(){return Wr}}),Object.defineProperty(a,"GitHubSearchKindSchema",{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(a,"GitHubSearchRequestSchema",{enumerable:!0,get:function(){return Fr}}),Object.defineProperty(a,"DirectorySuggestionsRequestSchema",{enumerable:!0,get:function(){return Ur}}),Object.defineProperty(a,"PaseoWorktreeListRequestSchema",{enumerable:!0,get:function(){return Br}}),Object.defineProperty(a,"PaseoWorktreeArchiveRequestSchema",{enumerable:!0,get:function(){return Gr}}),Object.defineProperty(a,"FirstAgentContextSchema",{enumerable:!0,get:function(){return Hr}}),Object.defineProperty(a,"CreatePaseoWorktreeRequestSchema",{enumerable:!0,get:function(){return Kr}}),Object.defineProperty(a,"WorkspaceSetupStatusRequestSchema",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(a,"LEGACY_EDITOR_TARGET_IDS",{enumerable:!0,get:function(){return Xr}}),Object.defineProperty(a,"KNOWN_EDITOR_TARGET_IDS",{enumerable:!0,get:function(){return Yr}}),Object.defineProperty(a,"KnownEditorTargetIdSchema",{enumerable:!0,get:function(){return Jr}}),Object.defineProperty(a,"LegacyEditorTargetIdSchema",{enumerable:!0,get:function(){return Qr}}),Object.defineProperty(a,"EditorTargetIdSchema",{enumerable:!0,get:function(){return $r}}),a.isKnownEditorTargetId=function(e){return Zr.has(e)},a.isLegacyEditorTargetId=function(e){return eo.has(e)},Object.defineProperty(a,"EditorTargetDescriptorPayloadSchema",{enumerable:!0,get:function(){return to}}),Object.defineProperty(a,"LegacyListAvailableEditorsRequestSchema",{enumerable:!0,get:function(){return no}}),Object.defineProperty(a,"LegacyOpenInEditorRequestSchema",{enumerable:!0,get:function(){return ro}}),Object.defineProperty(a,"OpenProjectRequestSchema",{enumerable:!0,get:function(){return oo}}),Object.defineProperty(a,"ProjectAddRequestSchema",{enumerable:!0,get:function(){return ao}}),Object.defineProperty(a,"ArchiveWorkspaceRequestSchema",{enumerable:!0,get:function(){return io}}),Object.defineProperty(a,"WorkspaceCreateRequestSchema",{enumerable:!0,get:function(){return so}}),Object.defineProperty(a,"WorkspaceClearAttentionRequestSchema",{enumerable:!0,get:function(){return lo}}),Object.defineProperty(a,"FileExplorerRequestSchema",{enumerable:!0,get:function(){return fo}}),Object.defineProperty(a,"ProjectIconRequestSchema",{enumerable:!0,get:function(){return yo}}),Object.defineProperty(a,"FileDownloadTokenRequestSchema",{enumerable:!0,get:function(){return ho}}),Object.defineProperty(a,"FileUploadRequestSchema",{enumerable:!0,get:function(){return jo}}),Object.defineProperty(a,"ClearAgentAttentionMessageSchema",{enumerable:!0,get:function(){return So}}),Object.defineProperty(a,"ClientHeartbeatMessageSchema",{enumerable:!0,get:function(){return Po}}),Object.defineProperty(a,"PingMessageSchema",{enumerable:!0,get:function(){return _o}}),Object.defineProperty(a,"ListProviderFeaturesRequestMessageSchema",{enumerable:!0,get:function(){return Io}}),Object.defineProperty(a,"ListCommandsRequestSchema",{enumerable:!0,get:function(){return Ro}}),Object.defineProperty(a,"RegisterPushTokenMessageSchema",{enumerable:!0,get:function(){return Oo}}),Object.defineProperty(a,"RewindSessionRequestMessageSchema",{enumerable:!0,get:function(){return ko}}),Object.defineProperty(a,"RewindSessionResponseMessageSchema",{enumerable:!0,get:function(){return wo}}),Object.defineProperty(a,"EditMessageRequestMessageSchema",{enumerable:!0,get:function(){return vo}}),Object.defineProperty(a,"EditMessageResponseMessageSchema",{enumerable:!0,get:function(){return Ao}}),Object.defineProperty(a,"ListWorkspaceSessionsRequestMessageSchema",{enumerable:!0,get:function(){return Mo}}),Object.defineProperty(a,"ListWorkspaceSessionsResponseMessageSchema",{enumerable:!0,get:function(){return To}}),Object.defineProperty(a,"ListAllSessionsRequestMessageSchema",{enumerable:!0,get:function(){return xo}}),Object.defineProperty(a,"ListAllSessionsResponseMessageSchema",{enumerable:!0,get:function(){return Do}}),Object.defineProperty(a,"ListExtensionsRequestMessageSchema",{enumerable:!0,get:function(){return Uo}}),Object.defineProperty(a,"ListExtensionsResponseMessageSchema",{enumerable:!0,get:function(){return Bo}}),Object.defineProperty(a,"ExecuteExtensionCommandRequestMessageSchema",{enumerable:!0,get:function(){return Go}}),Object.defineProperty(a,"ExecuteExtensionCommandResponseMessageSchema",{enumerable:!0,get:function(){return Ho}}),Object.defineProperty(a,"SearchSessionsRequestMessageSchema",{enumerable:!0,get:function(){return Ko}}),Object.defineProperty(a,"SearchSessionsResponseMessageSchema",{enumerable:!0,get:function(){return Xo}}),Object.defineProperty(a,"SubscribePushRequestMessageSchema",{enumerable:!0,get:function(){return Qo}}),Object.defineProperty(a,"SubscribePushResponseMessageSchema",{enumerable:!0,get:function(){return $o}}),Object.defineProperty(a,"GetVapidPublicKeyRequestMessageSchema",{enumerable:!0,get:function(){return Zo}}),Object.defineProperty(a,"GetVapidPublicKeyResponseMessageSchema",{enumerable:!0,get:function(){return ea}}),Object.defineProperty(a,"ListTerminalsRequestSchema",{enumerable:!0,get:function(){return ta}}),Object.defineProperty(a,"SubscribeTerminalsRequestSchema",{enumerable:!0,get:function(){return na}}),Object.defineProperty(a,"UnsubscribeTerminalsRequestSchema",{enumerable:!0,get:function(){return ra}}),Object.defineProperty(a,"CreateTerminalRequestSchema",{enumerable:!0,get:function(){return oa}}),Object.defineProperty(a,"RenameTerminalRequestSchema",{enumerable:!0,get:function(){return aa}}),Object.defineProperty(a,"StartWorkspaceScriptRequestSchema",{enumerable:!0,get:function(){return ia}}),Object.defineProperty(a,"SubscribeTerminalRequestSchema",{enumerable:!0,get:function(){return sa}}),Object.defineProperty(a,"UnsubscribeTerminalRequestSchema",{enumerable:!0,get:function(){return la}}),Object.defineProperty(a,"TerminalInputSchema",{enumerable:!0,get:function(){return ua}}),Object.defineProperty(a,"KillTerminalRequestSchema",{enumerable:!0,get:function(){return za}}),Object.defineProperty(a,"CaptureTerminalRequestSchema",{enumerable:!0,get:function(){return pa}}),Object.defineProperty(a,"CaptureAgentPaneRequestSchema",{enumerable:!0,get:function(){return ga}}),Object.defineProperty(a,"SessionInboundMessageSchema",{enumerable:!0,get:function(){return ba}}),Object.defineProperty(a,"ActivityLogPayloadSchema",{enumerable:!0,get:function(){return da}}),Object.defineProperty(a,"ActivityLogMessageSchema",{enumerable:!0,get:function(){return ma}}),Object.defineProperty(a,"AssistantChunkMessageSchema",{enumerable:!0,get:function(){return fa}}),Object.defineProperty(a,"AudioOutputMessageSchema",{enumerable:!0,get:function(){return ya}}),Object.defineProperty(a,"TranscriptionResultMessageSchema",{enumerable:!0,get:function(){return ha}}),Object.defineProperty(a,"VoiceInputStateMessageSchema",{enumerable:!0,get:function(){return ja}}),Object.defineProperty(a,"DictationStreamAckMessageSchema",{enumerable:!0,get:function(){return Sa}}),Object.defineProperty(a,"DictationStreamFinishAcceptedMessageSchema",{enumerable:!0,get:function(){return Pa}}),Object.defineProperty(a,"DictationStreamPartialMessageSchema",{enumerable:!0,get:function(){return _a}}),Object.defineProperty(a,"DictationStreamFinalMessageSchema",{enumerable:!0,get:function(){return qa}}),Object.defineProperty(a,"DictationStreamErrorMessageSchema",{enumerable:!0,get:function(){return Ia}}),Object.defineProperty(a,"ServerCapabilityStateSchema",{enumerable:!0,get:function(){return Ra}}),Object.defineProperty(a,"ServerVoiceCapabilitiesSchema",{enumerable:!0,get:function(){return Oa}}),Object.defineProperty(a,"ServerCapabilitiesSchema",{enumerable:!0,get:function(){return ka}}),Object.defineProperty(a,"JarvisServerInfoSchema",{enumerable:!0,get:function(){return Ma}}),Object.defineProperty(a,"ServerInfoStatusPayloadSchema",{enumerable:!0,get:function(){return Ca}}),Object.defineProperty(a,"StatusMessageSchema",{enumerable:!0,get:function(){return Ta}}),Object.defineProperty(a,"PongMessageSchema",{enumerable:!0,get:function(){return xa}}),Object.defineProperty(a,"RpcErrorMessageSchema",{enumerable:!0,get:function(){return La}}),Object.defineProperty(a,"AgentCreatedStatusPayloadSchema",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(a,"AgentCreateFailedStatusPayloadSchema",{enumerable:!0,get:function(){return Na}}),Object.defineProperty(a,"AgentResumedStatusPayloadSchema",{enumerable:!0,get:function(){return Fa}}),Object.defineProperty(a,"AgentRefreshedStatusPayloadSchema",{enumerable:!0,get:function(){return Ua}}),Object.defineProperty(a,"RestartRequestedStatusPayloadSchema",{enumerable:!0,get:function(){return Ba}}),Object.defineProperty(a,"ShutdownRequestedStatusPayloadSchema",{enumerable:!0,get:function(){return Ga}}),Object.defineProperty(a,"DaemonConfigChangedStatusPayloadSchema",{enumerable:!0,get:function(){return Ha}}),Object.defineProperty(a,"KnownStatusPayloadSchema",{enumerable:!0,get:function(){return Ka}}),Object.defineProperty(a,"ArtifactMessageSchema",{enumerable:!0,get:function(){return Va}}),Object.defineProperty(a,"ProjectCheckoutLiteNotGitPayloadSchema",{enumerable:!0,get:function(){return Xa}}),Object.defineProperty(a,"ProjectCheckoutLiteGitNonPaseoPayloadSchema",{enumerable:!0,get:function(){return Ya}}),Object.defineProperty(a,"ProjectCheckoutLiteGitPaseoPayloadSchema",{enumerable:!0,get:function(){return Ja}}),Object.defineProperty(a,"ProjectCheckoutLitePayloadSchema",{enumerable:!0,get:function(){return Qa}}),Object.defineProperty(a,"ProjectPlacementPayloadSchema",{enumerable:!0,get:function(){return $a}}),Object.defineProperty(a,"WorkspaceScriptLifecycleSchema",{enumerable:!0,get:function(){return Za}}),Object.defineProperty(a,"WorkspaceScriptHealthSchema",{enumerable:!0,get:function(){return ei}}),Object.defineProperty(a,"WorkspaceScriptPayloadSchema",{enumerable:!0,get:function(){return ti}}),Object.defineProperty(a,"WorkspaceDescriptorPayloadSchema",{enumerable:!0,get:function(){return oi}}),Object.defineProperty(a,"AgentUpdateMessageSchema",{enumerable:!0,get:function(){return ai}}),Object.defineProperty(a,"OpenUrlMessageSchema",{enumerable:!0,get:function(){return ii}}),Object.defineProperty(a,"AgentStreamMessageSchema",{enumerable:!0,get:function(){return si}}),Object.defineProperty(a,"AgentStatusMessageSchema",{enumerable:!0,get:function(){return li}}),Object.defineProperty(a,"AgentListMessageSchema",{enumerable:!0,get:function(){return ci}}),Object.defineProperty(a,"FetchAgentsResponseMessageSchema",{enumerable:!0,get:function(){return pi}}),Object.defineProperty(a,"FetchAgentHistoryResponseMessageSchema",{enumerable:!0,get:function(){return gi}}),Object.defineProperty(a,"FetchRecentProviderSessionsResponseMessageSchema",{enumerable:!0,get:function(){return bi}}),Object.defineProperty(a,"WorkspaceProjectDescriptorPayloadSchema",{enumerable:!0,get:function(){return di}}),Object.defineProperty(a,"FetchWorkspacesResponseMessageSchema",{enumerable:!0,get:function(){return mi}}),Object.defineProperty(a,"WorkspaceUpdateMessageSchema",{enumerable:!0,get:function(){return fi}}),Object.defineProperty(a,"ScriptStatusUpdateMessageSchema",{enumerable:!0,get:function(){return yi}}),Object.defineProperty(a,"WorkspaceSetupProgressMessageSchema",{enumerable:!0,get:function(){return hi}}),Object.defineProperty(a,"WorkspaceSetupSnapshotSchema",{enumerable:!0,get:function(){return ji}}),Object.defineProperty(a,"WorkspaceSetupStatusResponseMessageSchema",{enumerable:!0,get:function(){return Si}}),Object.defineProperty(a,"OpenProjectResponseMessageSchema",{enumerable:!0,get:function(){return Pi}}),Object.defineProperty(a,"ProjectAddResponseSchema",{enumerable:!0,get:function(){return _i}}),Object.defineProperty(a,"StartWorkspaceScriptResponseMessageSchema",{enumerable:!0,get:function(){return qi}}),Object.defineProperty(a,"LegacyListAvailableEditorsResponseMessageSchema",{enumerable:!0,get:function(){return Ii}}),Object.defineProperty(a,"LegacyOpenInEditorResponseMessageSchema",{enumerable:!0,get:function(){return Ri}}),Object.defineProperty(a,"ArchiveWorkspaceResponseMessageSchema",{enumerable:!0,get:function(){return Oi}}),Object.defineProperty(a,"FetchAgentResponseMessageSchema",{enumerable:!0,get:function(){return ki}}),Object.defineProperty(a,"AgentTimelineEntryPayloadSchema",{enumerable:!0,get:function(){return vi}}),Object.defineProperty(a,"FetchAgentTimelineResponseMessageSchema",{enumerable:!0,get:function(){return Ai}}),Object.defineProperty(a,"AgentForkContextResponseMessageSchema",{enumerable:!0,get:function(){return Mi}}),Object.defineProperty(a,"CancelAgentResponseMessageSchema",{enumerable:!0,get:function(){return Ci}}),Object.defineProperty(a,"ClearAgentAttentionResponseMessageSchema",{enumerable:!0,get:function(){return Ti}}),Object.defineProperty(a,"WorkspaceCreateResponseSchema",{enumerable:!0,get:function(){return xi}}),Object.defineProperty(a,"WorkspaceClearAttentionResponseSchema",{enumerable:!0,get:function(){return Li}}),Object.defineProperty(a,"SendAgentMessageResponseMessageSchema",{enumerable:!0,get:function(){return Di}}),Object.defineProperty(a,"WaitForFinishResponseMessageSchema",{enumerable:!0,get:function(){return Ei}}),Object.defineProperty(a,"GetDaemonConfigResponseMessageSchema",{enumerable:!0,get:function(){return Wi}}),Object.defineProperty(a,"DaemonGetStatusResponseSchema",{enumerable:!0,get:function(){return Ni}}),Object.defineProperty(a,"DaemonGetPairingOfferResponseSchema",{enumerable:!0,get:function(){return Fi}}),Object.defineProperty(a,"DiagnosticsResponseSchema",{enumerable:!0,get:function(){return Ui}}),Object.defineProperty(a,"SetDaemonConfigResponseMessageSchema",{enumerable:!0,get:function(){return Bi}}),Object.defineProperty(a,"ReadProjectConfigResponseMessageSchema",{enumerable:!0,get:function(){return Gi}}),Object.defineProperty(a,"WriteProjectConfigResponseMessageSchema",{enumerable:!0,get:function(){return Hi}}),Object.defineProperty(a,"AgentPermissionRequestMessageSchema",{enumerable:!0,get:function(){return Ki}}),Object.defineProperty(a,"WatchActionSchema",{enumerable:!0,get:function(){return Vi}}),Object.defineProperty(a,"WatchActionablePushMessageSchema",{enumerable:!0,get:function(){return Xi}}),Object.defineProperty(a,"WatchActionableResolvedMessageSchema",{enumerable:!0,get:function(){return Yi}}),Object.defineProperty(a,"WatchSessionMatchSchema",{enumerable:!0,get:function(){return Ji}}),Object.defineProperty(a,"WatchSessionSearchResultMessageSchema",{enumerable:!0,get:function(){return Qi}}),Object.defineProperty(a,"AgentPermissionResolvedMessageSchema",{enumerable:!0,get:function(){return $i}}),Object.defineProperty(a,"AgentDeletedMessageSchema",{enumerable:!0,get:function(){return Zi}}),Object.defineProperty(a,"AgentArchivedMessageSchema",{enumerable:!0,get:function(){return es}}),Object.defineProperty(a,"CloseItemsResponseSchema",{enumerable:!0,get:function(){return rs}}),Object.defineProperty(a,"CheckoutStatusResponseSchema",{enumerable:!0,get:function(){return cs}}),Object.defineProperty(a,"CheckoutPrStatusSchema",{enumerable:!0,get:function(){return gs}}),Object.defineProperty(a,"CheckoutStatusUpdateSchema",{enumerable:!0,get:function(){return ms}}),Object.defineProperty(a,"SubscribeCheckoutDiffResponseSchema",{enumerable:!0,get:function(){return ys}}),Object.defineProperty(a,"CheckoutDiffUpdateSchema",{enumerable:!0,get:function(){return hs}}),Object.defineProperty(a,"CheckoutCommitResponseSchema",{enumerable:!0,get:function(){return js}}),Object.defineProperty(a,"CheckoutMergeResponseSchema",{enumerable:!0,get:function(){return Ss}}),Object.defineProperty(a,"CheckoutMergeFromBaseResponseSchema",{enumerable:!0,get:function(){return Ps}}),Object.defineProperty(a,"CheckoutPullResponseSchema",{enumerable:!0,get:function(){return _s}}),Object.defineProperty(a,"CheckoutPushResponseSchema",{enumerable:!0,get:function(){return qs}}),Object.defineProperty(a,"CheckoutRefreshResponseSchema",{enumerable:!0,get:function(){return Is}}),Object.defineProperty(a,"CheckoutPrCreateResponseSchema",{enumerable:!0,get:function(){return Rs}}),Object.defineProperty(a,"CheckoutPrMergeResponseSchema",{enumerable:!0,get:function(){return Os}}),Object.defineProperty(a,"CheckoutGithubSetAutoMergeResponseSchema",{enumerable:!0,get:function(){return ks}}),Object.defineProperty(a,"FilesUploadBeginResponseSchema",{enumerable:!0,get:function(){return ws}}),Object.defineProperty(a,"FilesUploadChunkAckSchema",{enumerable:!0,get:function(){return vs}}),Object.defineProperty(a,"FilesUploadCompleteResponseSchema",{enumerable:!0,get:function(){return As}}),Object.defineProperty(a,"CheckoutGithubCheckDetailsSchema",{enumerable:!0,get:function(){return Ts}}),Object.defineProperty(a,"CheckoutGithubGetCheckDetailsResponseSchema",{enumerable:!0,get:function(){return xs}}),Object.defineProperty(a,"CheckoutPrStatusResponseSchema",{enumerable:!0,get:function(){return Ls}}),Object.defineProperty(a,"PullRequestTimelineItemSchema",{enumerable:!0,get:function(){return Fs}}),Object.defineProperty(a,"PullRequestTimelineResponseSchema",{enumerable:!0,get:function(){return Us}}),Object.defineProperty(a,"CheckoutSwitchBranchResponseSchema",{enumerable:!0,get:function(){return Bs}}),Object.defineProperty(a,"CheckoutRenameBranchResponseSchema",{enumerable:!0,get:function(){return Gs}}),Object.defineProperty(a,"StashSaveResponseSchema",{enumerable:!0,get:function(){return Ks}}),Object.defineProperty(a,"StashPopResponseSchema",{enumerable:!0,get:function(){return Vs}}),Object.defineProperty(a,"StashListResponseSchema",{enumerable:!0,get:function(){return Xs}}),Object.defineProperty(a,"ValidateBranchResponseSchema",{enumerable:!0,get:function(){return Ys}}),Object.defineProperty(a,"BranchSuggestionsResponseSchema",{enumerable:!0,get:function(){return Js}}),Object.defineProperty(a,"GitHubSearchResponseSchema",{enumerable:!0,get:function(){return Qs}}),Object.defineProperty(a,"DirectorySuggestionsResponseSchema",{enumerable:!0,get:function(){return $s}}),Object.defineProperty(a,"PaseoWorktreeListResponseSchema",{enumerable:!0,get:function(){return el}}),Object.defineProperty(a,"PaseoWorktreeArchiveResponseSchema",{enumerable:!0,get:function(){return tl}}),Object.defineProperty(a,"CreatePaseoWorktreeResponseSchema",{enumerable:!0,get:function(){return nl}}),Object.defineProperty(a,"FileExplorerResponseSchema",{enumerable:!0,get:function(){return rl}}),Object.defineProperty(a,"ProjectIconResponseSchema",{enumerable:!0,get:function(){return al}}),Object.defineProperty(a,"FileDownloadTokenResponseSchema",{enumerable:!0,get:function(){return il}}),Object.defineProperty(a,"FileUploadResponseSchema",{enumerable:!0,get:function(){return sl}}),Object.defineProperty(a,"ListProviderModelsResponseMessageSchema",{enumerable:!0,get:function(){return ll}}),Object.defineProperty(a,"ListProviderModesResponseMessageSchema",{enumerable:!0,get:function(){return cl}}),Object.defineProperty(a,"ListProviderFeaturesResponseMessageSchema",{enumerable:!0,get:function(){return ul}}),Object.defineProperty(a,"ListAvailableProvidersResponseSchema",{enumerable:!0,get:function(){return pl}}),Object.defineProperty(a,"GetProvidersSnapshotResponseMessageSchema",{enumerable:!0,get:function(){return gl}}),Object.defineProperty(a,"ProvidersReloadConfigResponseMessageSchema",{enumerable:!0,get:function(){return bl}}),Object.defineProperty(a,"ProvidersSnapshotUpdateMessageSchema",{enumerable:!0,get:function(){return dl}}),Object.defineProperty(a,"RefreshProvidersSnapshotResponseMessageSchema",{enumerable:!0,get:function(){return ml}}),Object.defineProperty(a,"ProviderDiagnosticResponseMessageSchema",{enumerable:!0,get:function(){return fl}}),Object.defineProperty(a,"ProviderUsageToneSchema",{enumerable:!0,get:function(){return yl}}),Object.defineProperty(a,"ProviderUsageStatusSchema",{enumerable:!0,get:function(){return hl}}),Object.defineProperty(a,"ProviderUsageWindowSchema",{enumerable:!0,get:function(){return jl}}),Object.defineProperty(a,"ProviderUsageBalanceSchema",{enumerable:!0,get:function(){return Sl}}),Object.defineProperty(a,"ProviderUsageDetailSchema",{enumerable:!0,get:function(){return Pl}}),Object.defineProperty(a,"ProviderUsageSchema",{enumerable:!0,get:function(){return _l}}),Object.defineProperty(a,"ProviderUsageListResponseMessageSchema",{enumerable:!0,get:function(){return ql}}),Object.defineProperty(a,"ListCommandsResponseSchema",{enumerable:!0,get:function(){return Rl}}),Object.defineProperty(a,"TerminalCellSchema",{enumerable:!0,get:function(){return kl}}),Object.defineProperty(a,"TerminalCursorStyleSchema",{enumerable:!0,get:function(){return wl}}),Object.defineProperty(a,"TerminalCursorSchema",{enumerable:!0,get:function(){return vl}}),Object.defineProperty(a,"TerminalStateSchema",{enumerable:!0,get:function(){return Al}}),Object.defineProperty(a,"ListTerminalsResponseSchema",{enumerable:!0,get:function(){return Ml}}),Object.defineProperty(a,"TerminalsChangedSchema",{enumerable:!0,get:function(){return Cl}}),Object.defineProperty(a,"CreateTerminalResponseSchema",{enumerable:!0,get:function(){return Tl}}),Object.defineProperty(a,"RenameTerminalResponseSchema",{enumerable:!0,get:function(){return xl}}),Object.defineProperty(a,"SubscribeTerminalResponseSchema",{enumerable:!0,get:function(){return Ll}}),Object.defineProperty(a,"KillTerminalResponseSchema",{enumerable:!0,get:function(){return Dl}}),Object.defineProperty(a,"CaptureTerminalResponseSchema",{enumerable:!0,get:function(){return El}}),Object.defineProperty(a,"CaptureAgentPaneResponseSchema",{enumerable:!0,get:function(){return Wl}}),Object.defineProperty(a,"TerminalStreamExitSchema",{enumerable:!0,get:function(){return Nl}}),Object.defineProperty(a,"TerminalAttentionRequiredSchema",{enumerable:!0,get:function(){return Fl}}),Object.defineProperty(a,"DaemonUpdateResponseSchema",{enumerable:!0,get:function(){return Ul}}),Object.defineProperty(a,"DaemonUpdateProgressMessageSchema",{enumerable:!0,get:function(){return Bl}}),Object.defineProperty(a,"SessionOutboundMessageSchema",{enumerable:!0,get:function(){return Gl}}),Object.defineProperty(a,"WSPingMessageSchema",{enumerable:!0,get:function(){return Hl}}),Object.defineProperty(a,"WSPongMessageSchema",{enumerable:!0,get:function(){return Kl}}),Object.defineProperty(a,"WSHelloMessageSchema",{enumerable:!0,get:function(){return Vl}}),Object.defineProperty(a,"WSRecordingStateMessageSchema",{enumerable:!0,get:function(){return Xl}}),Object.defineProperty(a,"WSSessionInboundSchema",{enumerable:!0,get:function(){return Yl}}),Object.defineProperty(a,"WSSessionOutboundSchema",{enumerable:!0,get:function(){return Jl}}),Object.defineProperty(a,"WSInboundMessageSchema",{enumerable:!0,get:function(){return Ql}}),Object.defineProperty(a,"WSOutboundMessageSchema",{enumerable:!0,get:function(){return $l}}),a.extractSessionMessage=function(e){if("session"===e.type)return e.message;return null},a.wrapSessionMessage=function(e){return{type:"session",message:e}},a.parseServerInfoStatusPayload=function(e){const t=Ca.safeParse(e);if(!t.success)return null;return t.data},Object.defineProperty(a,"PermissionHookEventSchema",{enumerable:!0,get:function(){return Zl}}),Object.defineProperty(a,"PreToolHookEventSchema",{enumerable:!0,get:function(){return ec}}),Object.defineProperty(a,"PostToolHookEventSchema",{enumerable:!0,get:function(){return tc}}),Object.defineProperty(a,"StatusLineHookEventSchema",{enumerable:!0,get:function(){return nc}}),Object.defineProperty(a,"SessionStartHookEventSchema",{enumerable:!0,get:function(){return rc}}),Object.defineProperty(a,"SessionEndHookEventSchema",{enumerable:!0,get:function(){return oc}}),Object.defineProperty(a,"AssistantMessageDeltaHookEventSchema",{enumerable:!0,get:function(){return ac}}),Object.defineProperty(a,"UsageUpdateHookEventSchema",{enumerable:!0,get:function(){return ic}}),Object.defineProperty(a,"HookEventSchema",{enumerable:!0,get:function(){return sc}});var l,c=t(i[0]),u=(l=c)&&l.__esModule?l:{default:l},z=t(i[1]),p=t(i[2]),g=t(i[3]),b=t(i[4]),d=t(i[5]),m=t(i[6]),f=t(i[7]),y=t(i[8]),h=t(i[9]),j=t(i[10]),S=t(i[11]),P=t(i[12]),_=t(i[13]),q=t(i[14]),I=t(i[15]),R=t(i[16]),O=t(i[17]),k=t(i[18]);const w=z.z.object({id:z.z.string().min(1),label:z.z.string().min(1),description:z.z.string().optional(),isDefault:z.z.boolean().optional()}).passthrough(),v=z.z.object({enabled:z.z.boolean().optional(),additionalModels:z.z.array(w).optional()}).passthrough(),A=z.z.object({provider:z.z.string().min(1),model:z.z.string().min(1).optional(),thinkingOptionId:z.z.string().min(1).optional()}).passthrough(),M=z.z.object({providers:z.z.array(A).default([])}).passthrough(),C=z.z.object({id:z.z.string(),name:z.z.string(),command:z.z.string(),args:z.z.array(z.z.string()).optional(),icon:z.z.string().optional()}).passthrough(),T=z.z.object({id:z.z.string().min(1),label:z.z.string().min(1),limit:z.z.number().int().positive().optional()}).passthrough(),x=z.z.object({buckets:z.z.array(T).default([]),defaultBucketId:z.z.string().nullable().default(null)}).passthrough(),L=z.z.object({enabled:z.z.boolean().default(!1)}).passthrough(),D=z.z.object({tag:z.z.string().min(1),color:z.z.enum(h.TAG_COLOR_NAMES)}),E=z.z.object({mcp:z.z.object({injectIntoAgents:z.z.boolean()}).passthrough(),browserTools:L.default({enabled:!1}),providers:z.z.record(z.z.string(),v).default({}),metadataGeneration:M.default({providers:[]}),autoArchiveAfterMerge:z.z.boolean().default(!1),ingestionReconcileEnabled:z.z.boolean().default(!0),ingestionReconcileStaleMs:z.z.number().int().positive().default(6e4),enableTerminalAgentHooks:z.z.boolean().default(!1),appendSystemPrompt:z.z.string().default(""),terminalProfiles:z.z.array(C).optional(),kanbanBoard:x.optional(),tagColors:z.z.array(D).optional()}).passthrough(),W=z.z.object({mcp:E.shape.mcp.partial().optional(),browserTools:L.partial().optional(),providers:z.z.record(z.z.string(),v.partial().passthrough()).optional(),metadataGeneration:M.partial().optional(),autoArchiveAfterMerge:z.z.boolean().optional(),ingestionReconcileEnabled:z.z.boolean().optional(),ingestionReconcileStaleMs:z.z.number().int().positive().optional(),enableTerminalAgentHooks:z.z.boolean().optional(),appendSystemPrompt:z.z.string().optional(),terminalProfiles:z.z.array(C).optional(),kanbanBoard:x.optional(),tagColors:z.z.array(D).optional()}).partial().passthrough(),N=z.z.enum(b.AGENT_LIFECYCLE_STATUSES),F=["pending","running","completed","failed","cancelled"],U=z.z.enum(F),B=z.z.object({id:z.z.string(),title:z.z.string(),status:U,storyCount:z.z.number().int().nonnegative().optional(),completedStoryCount:z.z.number().int().nonnegative().optional()}),G=z.z.object({provider:z.z.string().optional(),model:z.z.string().optional(),modeId:z.z.string().optional(),systemPrompt:z.z.string().optional(),thinkingOptionId:z.z.string().optional(),approvalPolicy:z.z.string().optional(),sandboxMode:z.z.string().optional(),networkAccess:z.z.boolean().optional(),webSearch:z.z.boolean().optional()}).strict(),H=z.z.object({id:z.z.string(),cwd:z.z.string(),status:U,title:z.z.string().nullable().optional(),labels:z.z.record(z.z.string(),z.z.string()).default({}),agentPresets:z.z.record(z.z.string(),G).optional(),phases:z.z.array(B).default([]),childAgentIds:z.z.array(z.z.string()).default([]),totalStoryCount:z.z.number().int().nonnegative().optional(),completedStoryCount:z.z.number().int().nonnegative().default(0),createdAt:z.z.string(),updatedAt:z.z.string(),startedAt:z.z.string().nullable().optional(),completedAt:z.z.string().nullable().optional(),archivedAt:z.z.string().nullable().optional()}),K=H,V=["created","started","completed","failed","cancelled","archived"],X=z.z.enum(V),Y=z.z.object({workflowId:z.z.string(),type:X,status:U,at:z.z.string()}),J=z.z.object({type:z.z.literal("workflow.list.request"),requestId:z.z.string()}),Q=z.z.object({type:z.z.literal("workflow.list.response"),payload:z.z.object({requestId:z.z.string(),workflows:z.z.array(H)})}),$=z.z.object({type:z.z.literal("workflow.get.request"),requestId:z.z.string(),workflowId:z.z.string()}),Z=z.z.object({type:z.z.literal("workflow.get.response"),payload:z.z.object({requestId:z.z.string(),workflow:H.nullable()})}),ee=z.z.object({type:z.z.literal("workflow.cancel.request"),requestId:z.z.string(),workflowId:z.z.string()}),te=z.z.object({type:z.z.literal("workflow.cancel.response"),payload:z.z.object({requestId:z.z.string(),workflow:H})}),ne=z.z.object({type:z.z.literal("workflow.events.request"),requestId:z.z.string(),workflowId:z.z.string()}),re=z.z.object({type:z.z.literal("workflow.events.response"),payload:z.z.object({requestId:z.z.string(),workflowId:z.z.string(),events:z.z.array(Y)})}),oe=z.z.object({id:z.z.string(),dependencies:z.z.array(z.z.string()),description:z.z.string(),prompt:z.z.string(),title:z.z.string(),outputFile:z.z.string(),parallelizable:z.z.boolean(),estimatedMinutes:z.z.number(),agentType:z.z.string().optional(),agentConfig:G.optional(),targetFiles:z.z.array(z.z.string()).optional()}),ae=z.z.object({goal:z.z.string(),masterPrompt:z.z.string(),metadata:z.z.object({executionLayers:z.z.array(z.z.array(z.z.string())),maxParallelism:z.z.number(),totalTasks:z.z.number(),estimatedDuration:z.z.number(),perFileMode:z.z.boolean(),storyFormat:z.z.boolean().optional(),totalFiles:z.z.number().optional()}),session:z.z.object({id:z.z.string(),createdAt:z.z.string(),outputDirectory:z.z.string()}),tasks:z.z.array(oe)}),ie=z.z.object({type:z.z.literal("workflow.start.request"),requestId:z.z.string(),graph:ae,provider:z.z.string(),cwd:z.z.string(),model:z.z.string().optional(),title:z.z.string().optional(),labels:z.z.record(z.z.string(),z.z.string()).optional(),agentPresets:z.z.record(z.z.string(),G).optional()}),se=z.z.object({type:z.z.literal("workflow.start.response"),payload:z.z.object({requestId:z.z.string(),workflowId:z.z.string(),childAgentIds:z.z.array(z.z.string()),status:U})}),le=z.z.object({id:z.z.string(),label:z.z.string(),description:z.z.string().optional(),icon:z.z.string().optional(),colorTier:z.z.string().optional()}),ce=z.z.enum(["ready","loading","error","unavailable"]),ue=z.z.object({id:z.z.string(),label:z.z.string(),description:z.z.string().optional(),isDefault:z.z.boolean().optional(),metadata:z.z.record(z.z.string(),z.z.unknown()).optional()}),ze=z.z.discriminatedUnion("type",[z.z.object({type:z.z.literal("info"),message:z.z.string()}),z.z.object({type:z.z.literal("warning"),message:z.z.string()}),z.z.object({type:z.z.literal("error"),message:z.z.string()})]),pe=z.z.object({type:z.z.literal("toggle"),id:z.z.string(),label:z.z.string(),description:z.z.string().optional(),tooltip:z.z.string().optional(),icon:z.z.string().optional(),value:z.z.boolean()}),ge=z.z.object({type:z.z.literal("select"),id:z.z.string(),label:z.z.string(),description:z.z.string().optional(),tooltip:z.z.string().optional(),icon:z.z.string().optional(),value:z.z.string().nullable(),options:z.z.array(ue)}),be=z.z.discriminatedUnion("type",[pe,ge]),de=z.z.object({provider:m.AgentProviderSchema,id:z.z.string(),label:z.z.string(),description:z.z.string().optional(),isDefault:z.z.boolean().optional(),metadata:z.z.record(z.z.string(),z.z.unknown()).optional(),contextWindowMaxTokens:z.z.number().optional(),thinkingOptions:z.z.array(ue).optional(),defaultThinkingOptionId:z.z.string().optional()}),me=z.z.object({provider:m.AgentProviderSchema,status:ce,enabled:z.z.boolean().optional().default(!0),error:z.z.string().optional(),models:z.z.array(de).optional(),modes:z.z.array(le).optional(),fetchedAt:z.z.string().optional(),label:z.z.string().optional(),description:z.z.string().optional(),defaultModeId:z.z.string().nullable().optional(),wireFamily:z.z.enum(["anthropic-messages","openai-compatible","generic-acp"]).optional(),compatibleProviders:z.z.array(z.z.string()).optional()}),fe=z.z.object({supportsStreaming:z.z.boolean(),supportsSessionPersistence:z.z.boolean(),supportsSessionListing:z.z.boolean().optional(),supportsDynamicModes:z.z.boolean(),supportsMcpServers:z.z.boolean(),supportsReasoningStream:z.z.boolean(),supportsToolInvocations:z.z.boolean(),supportsRewindConversation:z.z.boolean().optional().default(!1),supportsRewindFiles:z.z.boolean().optional().default(!1),supportsRewindBoth:z.z.boolean().optional().default(!1)}).catchall(z.z.boolean()),ye=z.z.object({inputTokens:z.z.number().optional(),cachedInputTokens:z.z.number().optional(),outputTokens:z.z.number().optional(),totalCostUsd:z.z.number().optional(),contextWindowMaxTokens:z.z.number().optional(),contextWindowUsedTokens:z.z.number().optional()}),he=z.z.object({type:z.z.literal("stdio"),command:z.z.string(),args:z.z.array(z.z.string()).optional(),env:z.z.record(z.z.string(),z.z.string()).optional(),alwaysLoad:z.z.boolean().optional()}),je=z.z.object({type:z.z.literal("http"),url:z.z.string(),headers:z.z.record(z.z.string(),z.z.string()).optional(),alwaysLoad:z.z.boolean().optional()}),Se=z.z.object({type:z.z.literal("sse"),url:z.z.string(),headers:z.z.record(z.z.string(),z.z.string()).optional(),alwaysLoad:z.z.boolean().optional()}),Pe=z.z.discriminatedUnion("type",[he,je,Se]),_e=z.z.object({provider:m.AgentProviderSchema,cwd:z.z.string(),modeId:z.z.string().optional(),model:z.z.string().optional(),thinkingOptionId:z.z.string().optional(),featureValues:z.z.record(z.z.string(),z.z.unknown()).optional(),title:z.z.string().trim().min(1).max(d.MAX_EXPLICIT_AGENT_TITLE_CHARS).optional().nullable(),approvalPolicy:z.z.string().optional(),sandboxMode:z.z.string().optional(),networkAccess:z.z.boolean().optional(),webSearch:z.z.boolean().optional(),extra:z.z.object({codex:z.z.record(z.z.string(),z.z.unknown()).optional(),claude:z.z.record(z.z.string(),z.z.unknown()).optional()}).partial().optional(),systemPrompt:z.z.string().optional(),outputLanguage:z.z.string().optional(),goal:z.z.string().optional(),jobToBeDone:z.z.string().optional(),mcpServers:z.z.record(z.z.string(),Pe).optional(),allowedTools:z.z.array(z.z.string()).optional()}),qe=z.z.record(z.z.string(),z.z.unknown()),Ie=z.z.object({id:z.z.string(),label:z.z.string(),behavior:z.z.enum(["allow","deny"]),variant:z.z.enum(["primary","secondary","danger"]).optional(),intent:z.z.enum(["implement","implement_resume","dismiss"]).optional()}),Re=z.z.discriminatedUnion("behavior",[z.z.object({behavior:z.z.literal("allow"),selectedActionId:z.z.string().optional(),updatedInput:z.z.record(z.z.string(),z.z.unknown()).optional(),updatedPermissions:z.z.array(qe).optional()}),z.z.object({behavior:z.z.literal("deny"),selectedActionId:z.z.string().optional(),message:z.z.string().optional(),interrupt:z.z.boolean().optional()})]),Oe=z.z.object({id:z.z.string(),provider:m.AgentProviderSchema,name:z.z.string(),kind:z.z.enum(["tool","plan","question","mode","other"]),title:z.z.string().optional(),description:z.z.string().optional(),input:z.z.record(z.z.string(),z.z.unknown()).optional(),detail:z.z.lazy(()=>Me).optional(),suggestions:z.z.array(qe).optional(),actions:z.z.array(Ie).optional(),metadata:z.z.record(z.z.string(),z.z.unknown()).optional()}),ke=z.z.union([z.z.null(),z.z.boolean(),z.z.number(),z.z.string(),z.z.array(z.z.unknown()),z.z.object({}).passthrough()]),we=z.z.union([z.z.boolean(),z.z.number(),z.z.string(),z.z.array(z.z.unknown()),z.z.object({}).passthrough()]),ve=z.z.object({index:z.z.number().int().positive(),command:z.z.string(),cwd:z.z.string(),log:z.z.string().optional().default(""),status:z.z.enum(["running","completed","failed"]),exitCode:z.z.number().nullable(),durationMs:z.z.number().nonnegative().optional()}),Ae=z.z.object({type:z.z.literal("worktree_setup"),worktreePath:z.z.string(),branchName:z.z.string(),log:z.z.string(),commands:z.z.array(ve),truncated:z.z.boolean().optional()}),Me=z.z.discriminatedUnion("type",[Ae,z.z.object({type:z.z.literal("shell"),command:z.z.string(),cwd:z.z.string().optional(),output:z.z.string().optional(),exitCode:z.z.number().nullable().optional()}),z.z.object({type:z.z.literal("read"),filePath:z.z.string(),content:z.z.string().optional(),offset:z.z.number().optional(),limit:z.z.number().optional()}),z.z.object({type:z.z.literal("edit"),filePath:z.z.string(),oldString:z.z.string().optional(),newString:z.z.string().optional(),unifiedDiff:z.z.string().optional()}),z.z.object({type:z.z.literal("write"),filePath:z.z.string(),content:z.z.string().optional()}),z.z.object({type:z.z.literal("search"),query:z.z.string(),toolName:z.z.enum(["search","grep","glob","web_search"]).optional(),content:z.z.string().optional(),filePaths:z.z.array(z.z.string()).optional(),webResults:z.z.array(z.z.object({title:z.z.string(),url:z.z.string()})).optional(),annotations:z.z.array(z.z.string()).optional(),numFiles:z.z.number().optional(),numMatches:z.z.number().optional(),durationMs:z.z.number().optional(),durationSeconds:z.z.number().optional(),truncated:z.z.boolean().optional(),mode:z.z.enum(["content","files_with_matches","count"]).optional()}),z.z.object({type:z.z.literal("fetch"),url:z.z.string(),prompt:z.z.string().optional(),result:z.z.string().optional(),code:z.z.number().optional(),codeText:z.z.string().optional(),bytes:z.z.number().optional(),durationMs:z.z.number().optional()}),z.z.object({type:z.z.literal("sub_agent"),subAgentType:z.z.string().optional(),description:z.z.string().optional(),childSessionId:z.z.string().optional(),log:z.z.string(),actions:z.z.array(z.z.object({index:z.z.number().int().positive(),toolName:z.z.string(),summary:z.z.string().optional()})).optional()}),z.z.object({type:z.z.literal("plain_text"),label:z.z.string().optional(),text:z.z.string().optional(),icon:z.z.enum(y.TOOL_CALL_ICON_NAMES).optional()}),z.z.object({type:z.z.literal("plan"),text:z.z.string()}),z.z.object({type:z.z.literal("unknown"),input:ke,output:ke})]),Ce=z.z.object({type:z.z.literal("tool_call"),callId:z.z.string(),name:z.z.string(),detail:Me,metadata:z.z.record(z.z.string(),z.z.unknown()).optional()}),Te=Ce.extend({status:z.z.literal("running"),error:z.z.null()}),xe=Ce.extend({status:z.z.literal("completed"),error:z.z.null()}),Le=Ce.extend({status:z.z.literal("failed"),error:we}),De=Ce.extend({status:z.z.literal("canceled"),error:z.z.null()}),Ee=z.z.discriminatedUnion("status",[Te,xe,Le,De]),We=z.z.union([z.z.object({type:z.z.literal("user_message"),text:z.z.string(),messageId:z.z.string().optional()}),z.z.object({type:z.z.literal("assistant_message"),text:z.z.string(),messageId:z.z.string().optional()}),z.z.object({type:z.z.literal("reasoning"),text:z.z.string()}),Ee,z.z.object({type:z.z.literal("todo"),items:z.z.array(z.z.object({text:z.z.string(),completed:z.z.boolean()}))}),z.z.object({type:z.z.literal("error"),message:z.z.string()}),z.z.object({type:z.z.literal("compaction"),status:z.z.enum(["loading","completed"]),trigger:z.z.enum(["auto","manual"]).optional(),preTokens:z.z.number().optional()})]),Ne=z.z.discriminatedUnion("type",[z.z.object({type:z.z.literal("thread_started"),sessionId:z.z.string(),provider:m.AgentProviderSchema}),z.z.object({type:z.z.literal("turn_started"),provider:m.AgentProviderSchema}),z.z.object({type:z.z.literal("turn_completed"),provider:m.AgentProviderSchema,usage:ye.optional()}),z.z.object({type:z.z.literal("turn_failed"),provider:m.AgentProviderSchema,error:z.z.string(),code:z.z.string().optional(),diagnostic:z.z.string().optional()}),z.z.object({type:z.z.literal("turn_canceled"),provider:m.AgentProviderSchema,reason:z.z.string()}),z.z.object({type:z.z.literal("timeline"),provider:m.AgentProviderSchema,item:We}),z.z.object({type:z.z.literal("permission_requested"),provider:m.AgentProviderSchema,request:Oe}),z.z.object({type:z.z.literal("permission_resolved"),provider:m.AgentProviderSchema,requestId:z.z.string(),resolution:Re}),z.z.object({type:z.z.literal("attention_required"),provider:m.AgentProviderSchema,reason:z.z.enum(["finished","error","permission"]),timestamp:z.z.string(),shouldNotify:z.z.boolean(),notification:z.z.object({title:z.z.string(),body:z.z.string(),data:z.z.object({serverId:z.z.string(),agentId:z.z.string(),reason:z.z.enum(["finished","error","permission"])})}).optional()})]),Fe=z.z.object({provider:m.AgentProviderSchema,sessionId:z.z.string(),nativeHandle:z.z.string().optional(),metadata:z.z.record(z.z.string(),z.z.unknown()).optional()}).nullable(),Ue=z.z.object({provider:m.AgentProviderSchema,sessionId:z.z.string().nullable(),model:z.z.string().nullable().optional(),thinkingOptionId:z.z.string().nullable().optional(),modeId:z.z.string().nullable().optional(),extra:z.z.record(z.z.string(),z.z.unknown()).optional()}),Be=z.z.object({kind:z.z.enum(["pr","mr","issue","deploy","preview","doc","session","other"]),url:z.z.string(),label:z.z.string().optional()}),Ge=z.z.object({label:z.z.string().min(1).max(80),value:z.z.string().max(200),masked:z.z.boolean(),source:z.z.string().max(200).optional(),discoveredAt:z.z.string().optional()}),He=z.z.object({id:z.z.string(),label:z.z.string(),detail:z.z.string().optional(),pros:z.z.array(z.z.string()).optional(),cons:z.z.array(z.z.string()).optional(),impact:z.z.string().optional(),recommended:z.z.boolean().optional(),emoji:z.z.string().max(8).optional()}),Ke=z.z.object({id:z.z.string(),question:z.z.string(),context:z.z.string().optional(),options:z.z.array(He),blocking:z.z.boolean().optional(),urgency:z.z.enum(["low","normal","high"]).optional(),deadline:z.z.string().optional(),askedAt:z.z.string(),answeredAt:z.z.string().optional(),chosenOptionId:z.z.string().optional(),answerNote:z.z.string().optional(),answeredBy:z.z.enum(["user","agent","timeout"]).optional()}),Ve=z.z.object({goal:z.z.string().optional(),nextStep:z.z.string().optional(),blockers:z.z.array(z.z.string()).optional(),links:z.z.array(Be).optional(),secrets:z.z.array(Ge).optional(),keyFiles:z.z.array(z.z.string()).optional(),summary:z.z.string().optional(),accomplishments:z.z.array(z.z.string()).optional(),pendingDecisions:z.z.array(Ke).optional(),selfReportedAt:z.z.string().optional(),generatedAt:z.z.string().optional(),derivedNextStep:z.z.string().optional(),derivedBlockers:z.z.array(z.z.string()).optional(),urgency:z.z.enum(["low","normal","high"]).optional(),deadline:z.z.string().optional(),derivedDeadline:z.z.string().optional()}),Xe=z.z.object({until:z.z.string(),untilWhat:z.z.string().nullable(),why:z.z.string().nullable(),count:z.z.number().int().nonnegative(),at:z.z.string()}),Ye=z.z.object({id:z.z.string(),provider:m.AgentProviderSchema,cwd:z.z.string(),workspaceId:z.z.string().optional(),model:z.z.string().nullable(),features:z.z.array(be).optional(),thinkingOptionId:z.z.string().nullable().optional(),effectiveThinkingOptionId:z.z.string().nullable().optional(),createdAt:z.z.string(),updatedAt:z.z.string(),lastUserMessageAt:z.z.string().nullable(),status:N,capabilities:fe,currentModeId:z.z.string().nullable(),availableModes:z.z.array(le),pendingPermissions:z.z.array(Oe),persistence:Fe.nullable(),runtimeInfo:Ue.optional(),lastUsage:ye.optional(),lastError:z.z.string().optional(),title:z.z.string().nullable(),labels:z.z.record(z.z.string(),z.z.string()).default({}),digest:Ve.optional(),requiresAttention:z.z.boolean().optional(),attentionReason:z.z.enum(["finished","error","permission"]).nullable().optional(),attentionTimestamp:z.z.string().nullable().optional(),archivedAt:z.z.string().nullable().optional(),snooze:Xe.nullable().optional(),activeBackgroundTaskCount:z.z.number().int().nonnegative().optional(),providerUnavailable:z.z.boolean().optional(),hasSystemPrompt:z.z.boolean().optional(),goal:z.z.string().optional(),jobToBeDone:z.z.string().optional(),allowedTools:z.z.array(z.z.string()).nullable().optional(),mcpServerNames:z.z.array(z.z.string()).optional(),nextFireAt:z.z.string().nullable().optional(),hasRoutine:z.z.boolean().optional()}),Je=z.z.object({id:z.z.string(),shortId:z.z.string(),title:z.z.string().nullable(),provider:m.AgentProviderSchema,model:z.z.string().nullable(),thinkingOptionId:z.z.string().nullable().optional(),effectiveThinkingOptionId:z.z.string().nullable().optional(),status:N,cwd:z.z.string(),createdAt:z.z.string(),updatedAt:z.z.string(),lastUserMessageAt:z.z.string().nullable(),archivedAt:z.z.string().nullable().optional(),snooze:Xe.nullable().optional(),requiresAttention:z.z.boolean().optional(),attentionReason:z.z.enum(["finished","error","permission"]).nullable().optional(),attentionTimestamp:z.z.string().nullable().optional(),labels:z.z.record(z.z.string(),z.z.string()).default({}),digest:Ve.optional(),activeBackgroundTaskCount:z.z.number().int().nonnegative().optional(),pendingPermissionCount:z.z.number().int().nonnegative().optional(),activeChildCount:z.z.number().int().nonnegative().optional(),providerUnavailable:z.z.boolean().optional(),modeId:z.z.string().nullable().optional(),hasSystemPrompt:z.z.boolean().optional(),goal:z.z.string().optional(),jobToBeDone:z.z.string().optional(),allowedTools:z.z.array(z.z.string()).nullable().optional(),mcpServerNames:z.z.array(z.z.string()).optional(),nextFireAt:z.z.string().nullable().optional(),hasRoutine:z.z.boolean().optional()}),Qe=z.z.object({providerId:z.z.string(),providerLabel:z.z.string(),providerHandleId:z.z.string(),cwd:z.z.string(),title:z.z.string().nullable(),firstPromptPreview:z.z.string().nullable(),lastPromptPreview:z.z.string().nullable(),lastActivityAt:z.z.string()}),$e=z.z.object({type:z.z.literal("voice_audio_chunk"),audio:z.z.string(),format:z.z.string(),isLast:z.z.boolean()}),Ze=z.z.object({type:z.z.literal("abort_request")}),et=z.z.object({type:z.z.literal("audio_played"),id:z.z.string()}),tt=z.z.object({labels:z.z.record(z.z.string(),z.z.string()).optional(),projectKeys:z.z.array(z.z.string()).optional(),statuses:z.z.array(N).optional(),includeArchived:z.z.boolean().optional(),requiresAttention:z.z.boolean().optional(),thinkingOptionId:z.z.string().nullable().optional()}),nt=z.z.object({type:z.z.literal("delete_agent_request"),agentId:z.z.string(),requestId:z.z.string()}),rt=z.z.object({type:z.z.literal("archive_agent_request"),agentId:z.z.string(),requestId:z.z.string()}),ot=z.z.enum(["running","completed","failed","canceled"]),at=z.z.object({agentId:z.z.string(),agentTitle:z.z.string().nullable().optional(),taskId:z.z.string(),command:z.z.string().nullable(),description:z.z.string().nullable(),status:ot,startedAt:z.z.string(),endedAt:z.z.string().nullable(),summary:z.z.string().nullable(),hasOutput:z.z.boolean()}),it=z.z.object({type:z.z.literal("list_background_tasks_request"),agentId:z.z.string().optional(),requestId:z.z.string()}),st=z.z.object({type:z.z.literal("list_background_tasks_response"),payload:z.z.object({tasks:z.z.array(at),requestId:z.z.string()})}),lt=z.z.object({type:z.z.literal("background_task_output_request"),agentId:z.z.string(),taskId:z.z.string(),maxBytes:z.z.number().int().positive().optional(),requestId:z.z.string()}),ct=z.z.object({type:z.z.literal("background_task_output_response"),payload:z.z.object({agentId:z.z.string(),taskId:z.z.string(),text:z.z.string().nullable(),truncated:z.z.boolean(),byteSize:z.z.number().int().nonnegative(),requestId:z.z.string()})}),ut=z.z.object({url:z.z.string(),kind:z.z.string(),status:z.z.string().nullable(),state:z.z.enum(["running","success","failed","blocked","neutral"]),title:z.z.string().nullable(),detail:z.z.string().nullable(),progress:z.z.string().nullable(),updatedAt:z.z.string().nullable(),unavailableReason:z.z.string().nullable(),live:z.z.boolean(),sensitivePreview:z.z.array(z.z.string().max(400)).max(20).nullable().optional()}),zt=20,pt=z.z.object({type:z.z.literal("set_agent_context_request"),agentId:z.z.string(),links:z.z.array(z.z.object({kind:z.z.enum(["pr","mr","issue","deploy","preview","doc","session","other"]),url:z.z.string().min(1).max(500),label:z.z.string().max(80).optional()})).max(20).optional(),secrets:z.z.array(z.z.object({label:z.z.string().min(1).max(80),value:z.z.string().max(200),source:z.z.string().max(200).optional()})).max(20).optional(),requestId:z.z.string()}),gt=z.z.object({type:z.z.literal("set_agent_context_response"),payload:z.z.object({agentId:z.z.string(),digest:Ve.nullable(),maskedCount:z.z.number().int().nonnegative(),error:z.z.string().optional(),requestId:z.z.string()})}),bt=z.z.object({type:z.z.literal("enrich_references_request"),urls:z.z.array(z.z.string().min(1).max(500)).max(20),requestId:z.z.string()}),dt=z.z.object({type:z.z.literal("enrich_references_response"),payload:z.z.object({enrichments:z.z.array(ut),requestId:z.z.string()})}),mt=z.z.object({type:z.z.literal("dismiss_background_task_request"),agentId:z.z.string(),taskId:z.z.string(),requestId:z.z.string()}),ft=z.z.object({type:z.z.literal("background_task_dismissed"),payload:z.z.object({agentId:z.z.string(),taskId:z.z.string(),dismissed:z.z.boolean(),requestId:z.z.string()})}),yt=z.z.object({type:z.z.literal("close_items_request"),agentIds:z.z.array(z.z.string()).default([]),terminalIds:z.z.array(z.z.string()).default([]),requestId:z.z.string()}),ht=z.z.object({type:z.z.literal("update_agent_request"),agentId:z.z.string(),name:z.z.string().optional(),labels:z.z.record(z.z.string(),z.z.string()).optional(),labelsRemove:z.z.array(z.z.string()).optional(),requestId:z.z.string()}),jt=z.z.object({type:z.z.literal("project.rename.request"),projectId:z.z.string(),customName:z.z.string().nullable(),requestId:z.z.string()}),St=z.z.object({type:z.z.literal("project.remove.request"),projectId:z.z.string(),requestId:z.z.string()}),Pt=z.z.object({type:z.z.literal("workspace.title.set.request"),workspaceId:z.z.string(),title:z.z.string().nullable(),requestId:z.z.string()}),_t=z.z.object({type:z.z.literal("agent.consolidate.request"),winnerId:z.z.string(),sourceIds:z.z.array(z.z.string()).min(1).max(20),requestId:z.z.string()}),qt=z.z.object({requestId:z.z.string(),winnerId:z.z.string(),accepted:z.z.boolean(),archivedIds:z.z.array(z.z.string()),error:z.z.string().nullable()}),It=z.z.object({type:z.z.literal("agent.consolidate.response"),payload:qt}),Rt=z.z.object({type:z.z.literal("agent.snooze.request"),agentId:z.z.string(),until:z.z.string().nullable(),untilWhat:z.z.string().max(200).nullable(),why:z.z.string().max(500).nullable(),requestId:z.z.string()}),Ot=z.z.object({requestId:z.z.string(),agentId:z.z.string(),accepted:z.z.boolean(),snooze:Xe.nullable(),error:z.z.string().nullable()}),kt=z.z.object({type:z.z.literal("agent.snooze.response"),payload:Ot}),wt=z.z.object({type:z.z.literal("agent.decision.answer.request"),agentId:z.z.string(),decisionId:z.z.string(),optionId:z.z.string().nullable(),note:z.z.string().nullable(),requestId:z.z.string()}),vt=z.z.object({type:z.z.literal("set_voice_mode"),enabled:z.z.boolean(),agentId:z.z.string().optional(),requestId:z.z.string().optional(),language:z.z.string().optional()}),At=z.z.object({type:z.z.literal("github_pr"),mimeType:z.z.literal("application/github-pr"),number:z.z.number().int().positive(),title:z.z.string(),url:z.z.string(),body:z.z.string().nullable().optional(),baseRefName:z.z.string().nullable().optional(),headRefName:z.z.string().nullable().optional()}),Mt=z.z.object({type:z.z.literal("github_issue"),mimeType:z.z.literal("application/github-issue"),number:z.z.number().int().positive(),title:z.z.string(),url:z.z.string(),body:z.z.string().nullable().optional()}),Ct=z.z.object({type:z.z.literal("text"),mimeType:z.z.literal("text/plain"),contextKind:z.z.string().optional(),title:z.z.string().nullable().optional(),text:z.z.string()}).transform(e=>{let{contextKind:t}=e,n=(0,u.default)(e,s);return Object.assign({},n,"chat_history"===t?{contextKind:t}:{})}),Tt=z.z.object({oldLineNumber:z.z.number().int().positive().nullable(),newLineNumber:z.z.number().int().positive().nullable(),type:z.z.enum(["add","remove","context"]),content:z.z.string()}),xt=z.z.object({filePath:z.z.string(),side:z.z.enum(["old","new"]),lineNumber:z.z.number().int().positive(),body:z.z.string(),context:z.z.object({hunkHeader:z.z.string(),targetLine:Tt,lines:z.z.array(Tt)})}),Lt=z.z.object({type:z.z.literal("review"),mimeType:z.z.literal("application/paseo-review"),cwd:z.z.string(),mode:z.z.enum(["uncommitted","base"]),baseRef:z.z.string().nullable().optional(),comments:z.z.array(xt)}),Dt=z.z.object({type:z.z.literal("file"),name:z.z.string(),mimeType:z.z.string(),size:z.z.number().int().nonnegative(),fileId:z.z.string(),path:z.z.string()}),Et=z.z.object({type:z.z.literal("uploaded_file"),id:z.z.string(),fileName:z.z.string(),mimeType:z.z.string(),size:z.z.number().int().nonnegative(),path:z.z.string()}),Wt=z.z.discriminatedUnion("type",[At,Mt,Ct,Lt,Dt,Et]);const Nt=z.z.unknown().transform(function(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const e=Wt.safeParse(n);if(e.success){t.push(e.data);continue}const r="object"==typeof n&&null!==n&&"type"in n?String(n.type):"<missing>";console.warn(`[protocol] dropping unparseable agent attachment (type: ${r}):`,e.error.issues)}return t}).optional(),Ft=z.z.object({data:z.z.string(),mimeType:z.z.string()}),Ut=z.z.object({type:z.z.literal("send_agent_message"),agentId:z.z.string(),text:z.z.string(),messageId:z.z.string().optional(),images:z.z.array(Ft).optional(),attachments:Nt}),Bt=z.z.object({type:z.z.literal("fetch_agents_request"),requestId:z.z.string(),scope:z.z.enum(["active"]).optional(),filter:tt.optional(),sort:z.z.array(z.z.object({key:z.z.enum(["status_priority","created_at","updated_at","title"]),direction:z.z.enum(["asc","desc"])})).optional(),page:z.z.object({limit:z.z.number().int().positive().max(200),cursor:z.z.string().min(1).optional()}).optional(),subscribe:z.z.object({subscriptionId:z.z.string().optional()}).optional()}),Gt=z.z.enum(["needs_input","failed","running","attention","pending","done"]),Ht=Gt.catch("running"),Kt=z.z.object({type:z.z.literal("fetch_workspaces_request"),requestId:z.z.string(),filter:z.z.object({query:z.z.string().optional(),projectId:z.z.string().optional(),idPrefix:z.z.string().optional()}).optional(),sort:z.z.array(z.z.object({key:z.z.enum(["status_priority","activity_at","name","project_id"]),direction:z.z.enum(["asc","desc"])})).optional(),page:z.z.object({limit:z.z.number().int().positive().max(200),cursor:z.z.string().min(1).optional()}).optional(),subscribe:z.z.object({subscriptionId:z.z.string().optional()}).optional()}),Vt=z.z.object({type:z.z.literal("fetch_agent_history_request"),requestId:z.z.string(),filter:tt.optional(),sort:z.z.array(z.z.object({key:z.z.enum(["status_priority","created_at","updated_at","title"]),direction:z.z.enum(["asc","desc"])})).optional(),page:z.z.object({limit:z.z.number().int().positive().max(200),cursor:z.z.string().min(1).optional()}).optional()}),Xt=z.z.object({type:z.z.literal("fetch_recent_provider_sessions_request"),requestId:z.z.string(),cwd:z.z.string().optional(),providers:z.z.array(z.z.string()).optional(),since:z.z.string().optional(),limit:z.z.number().int().positive().max(200).optional()}),Yt=z.z.object({type:z.z.literal("fetch_agent_request"),requestId:z.z.string(),agentId:z.z.string()}),Jt=z.z.object({type:z.z.literal("send_agent_message_request"),requestId:z.z.string(),agentId:z.z.string(),text:z.z.string(),messageId:z.z.string().optional(),images:z.z.array(Ft).optional(),attachments:Nt}),Qt=z.z.object({type:z.z.literal("wait_for_finish_request"),requestId:z.z.string(),agentId:z.z.string(),timeoutMs:z.z.number().int().positive().optional()}),$t=z.z.object({type:z.z.literal("daemon.get_status.request"),requestId:z.z.string()}),Zt=z.z.object({type:z.z.literal("daemon.get_pairing_offer.request"),requestId:z.z.string()}),en=z.z.object({type:z.z.literal("diagnostics.request"),requestId:z.z.string()}),tn=z.z.object({type:z.z.literal("get_daemon_config_request"),requestId:z.z.string()}),nn=z.z.object({type:z.z.literal("set_daemon_config_request"),requestId:z.z.string(),config:W}),rn=z.z.object({type:z.z.literal("read_project_config_request"),requestId:z.z.string(),repoRoot:z.z.string()}),on=z.z.object({type:z.z.literal("write_project_config_request"),requestId:z.z.string(),repoRoot:z.z.string(),config:k.PaseoConfigRawSchema,expectedRevision:k.PaseoConfigRevisionSchema.nullable()}),an=z.z.object({type:z.z.literal("dictation_stream_start"),dictationId:z.z.string(),format:z.z.string(),language:z.z.string().optional()}),sn=z.z.object({type:z.z.literal("dictation_stream_chunk"),dictationId:z.z.string(),seq:z.z.number().int().nonnegative(),audio:z.z.string(),format:z.z.string()}),ln=z.z.object({type:z.z.literal("dictation_stream_finish"),dictationId:z.z.string(),finalSeq:z.z.number().int().nonnegative()}),cn=z.z.object({type:z.z.literal("dictation_stream_cancel"),dictationId:z.z.string()}),un=z.z.object({baseBranch:z.z.string().optional(),createNewBranch:z.z.boolean().optional(),newBranchName:z.z.string().optional(),createWorktree:z.z.boolean().optional(),worktreeSlug:z.z.string().optional(),refName:z.z.string().min(1).optional(),action:z.z.enum(["branch-off","checkout"]).optional(),githubPrNumber:z.z.number().int().positive().optional()}),zn=z.z.discriminatedUnion("mode",[z.z.object({mode:z.z.literal("branch-off"),newBranch:z.z.string().min(1),base:z.z.string().min(1).optional()}),z.z.object({mode:z.z.literal("checkout-branch"),branch:z.z.string().min(1)}),z.z.object({mode:z.z.literal("checkout-pr"),prNumber:z.z.number().int().positive()})]),pn=z.z.object({type:z.z.literal("create_agent_request"),config:_e,routine:f.AgentRoutineSchema.optional(),env:z.z.record(z.z.string(),z.z.string()).optional(),workspaceId:z.z.string().optional(),worktreeName:z.z.string().optional(),initialPrompt:z.z.string().optional(),clientMessageId:z.z.string().optional(),outputSchema:z.z.record(z.z.string(),z.z.unknown()).optional(),images:z.z.array(Ft).optional(),attachments:Nt,git:un.optional(),worktree:zn.optional(),autoArchive:z.z.boolean().optional(),labels:z.z.record(z.z.string(),z.z.string()).default({}),resumeSessionId:z.z.string().min(1).optional(),requestId:z.z.string()}),gn=z.z.object({type:z.z.literal("list_provider_models_request"),provider:m.AgentProviderSchema,cwd:z.z.string().optional(),requestId:z.z.string()}),bn=z.z.object({type:z.z.literal("list_provider_modes_request"),provider:m.AgentProviderSchema,cwd:z.z.string().optional(),requestId:z.z.string()}),dn=z.z.object({type:z.z.literal("list_available_providers_request"),requestId:z.z.string()}),mn=z.z.object({type:z.z.literal("get_providers_snapshot_request"),cwd:z.z.string().optional(),requestId:z.z.string()}),fn=z.z.object({type:z.z.literal("providers.reload_config.request"),requestId:z.z.string()}),yn=z.z.object({type:z.z.literal("refresh_providers_snapshot_request"),cwd:z.z.string().optional(),providers:z.z.array(m.AgentProviderSchema).optional(),requestId:z.z.string()}),hn=z.z.object({type:z.z.literal("provider_diagnostic_request"),provider:m.AgentProviderSchema,requestId:z.z.string()}),jn=z.z.object({type:z.z.literal("provider.usage.list.request"),requestId:z.z.string()}),Sn=z.z.object({type:z.z.literal("resume_agent_request"),handle:Fe,overrides:_e.partial().optional(),requestId:z.z.string()}),Pn=z.z.object({type:z.z.literal("import_agent_request"),provider:m.AgentProviderSchema.optional(),providerId:z.z.string().optional(),sessionId:z.z.string().optional(),providerHandleId:z.z.string().optional(),cwd:z.z.string().optional(),labels:z.z.record(z.z.string(),z.z.string()).optional(),requestId:z.z.string()}),_n=z.z.object({type:z.z.literal("refresh_agent_request"),agentId:z.z.string(),requestId:z.z.string()}),qn=z.z.object({type:z.z.literal("cancel_agent_request"),agentId:z.z.string(),requestId:z.z.string().optional()}),In=z.z.object({type:z.z.literal("restart_server_request"),reason:z.z.string().optional(),requestId:z.z.string()}),Rn=z.z.object({type:z.z.literal("shutdown_server_request"),requestId:z.z.string()}),On=z.z.object({type:z.z.literal("daemon.update.request"),requestId:z.z.string()}),kn=z.z.object({epoch:z.z.string(),seq:z.z.number().int().nonnegative()}),wn=z.z.object({type:z.z.literal("fetch_agent_timeline_request"),agentId:z.z.string(),requestId:z.z.string(),direction:z.z.enum(["tail","before","after"]).optional(),cursor:kn.optional(),limit:z.z.number().int().nonnegative().optional(),projection:z.z.enum(["projected","canonical"]).optional()}),vn=z.z.object({type:z.z.literal("agent.fork_context.request"),agentId:z.z.string(),boundaryMessageId:z.z.string().optional(),requestId:z.z.string()}),An=z.z.object({type:z.z.literal("set_agent_mode_request"),agentId:z.z.string(),modeId:z.z.string(),requestId:z.z.string()}),Mn=z.z.object({requestId:z.z.string(),agentId:z.z.string(),accepted:z.z.boolean(),error:z.z.string().nullable(),notice:ze.nullable().optional()}),Cn=z.z.object({type:z.z.literal("set_agent_mode_response"),payload:Mn}),Tn=z.z.object({type:z.z.literal("set_agent_model_request"),agentId:z.z.string(),modelId:z.z.string().nullable(),requestId:z.z.string()}),xn=z.z.object({type:z.z.literal("set_agent_model_response"),payload:Mn}),Ln=z.z.object({type:z.z.literal("swap_agent_provider_request"),requestId:z.z.string(),agentId:z.z.string(),newProviderId:z.z.string(),overrides:z.z.object({model:z.z.string().nullable().optional(),modeId:z.z.string().optional()}).optional()}),Dn=z.z.object({type:z.z.literal("swap_agent_provider_response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),accepted:z.z.boolean(),error:z.z.string().nullable(),oldProvider:z.z.string().optional(),newProvider:z.z.string().optional()})}),En=z.z.object({type:z.z.literal("agent_provider_swapped"),payload:z.z.object({agentId:z.z.string(),oldProvider:z.z.string(),newProvider:z.z.string(),timestamp:z.z.string()})}),Wn=z.z.object({type:z.z.literal("set_agent_thinking_request"),agentId:z.z.string(),thinkingOptionId:z.z.string().nullable(),requestId:z.z.string()}),Nn=z.z.object({type:z.z.literal("set_agent_thinking_response"),payload:Mn}),Fn=z.z.object({type:z.z.literal("set_agent_feature_request"),agentId:z.z.string(),featureId:z.z.string(),value:z.z.unknown(),requestId:z.z.string()}),Un=z.z.object({type:z.z.literal("set_agent_feature_response"),payload:Mn}),Bn=z.z.object({type:z.z.literal("agent.detach.request"),agentId:z.z.string(),requestId:z.z.string()}),Gn=z.z.object({type:z.z.literal("agent.detach.response"),payload:Mn}),Hn=z.z.enum(["conversation","files","both"]),Kn=z.z.object({type:z.z.literal("agent.rewind.request"),agentId:z.z.string(),messageId:z.z.string(),mode:Hn,requestId:z.z.string()}),Vn=z.z.object({type:z.z.literal("agent.rewind.response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),ok:z.z.boolean(),error:z.z.string().nullable()})}),Xn=z.z.object({type:z.z.literal("update_agent_response"),payload:Mn}),Yn=z.z.object({requestId:z.z.string(),projectId:z.z.string(),accepted:z.z.boolean(),customName:z.z.string().nullable(),error:z.z.string().nullable()}),Jn=z.z.object({type:z.z.literal("project.rename.response"),payload:Yn}),Qn=z.z.object({requestId:z.z.string(),projectId:z.z.string(),accepted:z.z.boolean(),removedWorkspaceIds:z.z.array(z.z.string()).default([]),error:z.z.string().nullable()}),$n=z.z.object({type:z.z.literal("project.remove.response"),payload:Qn}),Zn=z.z.object({requestId:z.z.string(),workspaceId:z.z.string(),accepted:z.z.boolean(),title:z.z.string().nullable(),error:z.z.string().nullable()}),er=z.z.object({type:z.z.literal("workspace.title.set.response"),payload:Zn}),tr=z.z.object({requestId:z.z.string(),agentId:z.z.string(),decisionId:z.z.string(),accepted:z.z.boolean(),decision:Ke.nullable(),error:z.z.string().nullable()}),nr=z.z.object({type:z.z.literal("agent.decision.answer.response"),payload:tr}),rr=z.z.object({type:z.z.literal("set_voice_mode_response"),payload:z.z.object({requestId:z.z.string(),enabled:z.z.boolean(),agentId:z.z.string().nullable(),accepted:z.z.boolean(),error:z.z.string().nullable(),reasonCode:z.z.string().optional(),retryable:z.z.boolean().optional(),missingModelIds:z.z.array(z.z.string()).optional()})}),or=z.z.object({type:z.z.literal("agent_permission_response"),agentId:z.z.string(),requestId:z.z.string(),response:Re}),ar=z.z.object({type:z.z.literal("watch.notificationAction"),notificationId:z.z.string(),action:z.z.enum(["approve","deny","reply"]),replyText:z.z.string().optional()}),ir=z.z.object({type:z.z.literal("watch.sessionSearch"),requestId:z.z.string(),query:z.z.string()}),sr=z.z.object({type:z.z.literal("watch.composerDictate"),sessionId:z.z.string(),text:z.z.string()}),lr=z.z.enum(["NOT_GIT_REPO","NOT_ALLOWED","MERGE_CONFLICT","UNKNOWN"]),cr=z.z.object({code:lr,message:z.z.string()}),ur=z.z.object({mode:z.z.enum(["uncommitted","base"]),baseRef:z.z.string().optional(),ignoreWhitespace:z.z.boolean().optional()}),zr=z.z.object({type:z.z.literal("checkout_status_request"),cwd:z.z.string(),requestId:z.z.string()}),pr=z.z.object({type:z.z.literal("subscribe_checkout_diff_request"),subscriptionId:z.z.string(),cwd:z.z.string(),compare:ur,requestId:z.z.string()}),gr=z.z.object({type:z.z.literal("unsubscribe_checkout_diff_request"),subscriptionId:z.z.string()}),br=z.z.object({type:z.z.literal("checkout_commit_request"),cwd:z.z.string(),message:z.z.string().optional(),addAll:z.z.boolean().optional(),requestId:z.z.string()}),dr=z.z.object({type:z.z.literal("checkout_merge_request"),cwd:z.z.string(),baseRef:z.z.string().optional(),strategy:z.z.enum(["merge","squash"]).optional(),requireCleanTarget:z.z.boolean().optional(),requestId:z.z.string()}),mr=z.z.object({type:z.z.literal("checkout_merge_from_base_request"),cwd:z.z.string(),baseRef:z.z.string().optional(),requireCleanTarget:z.z.boolean().optional(),requestId:z.z.string()}),fr=z.z.object({type:z.z.literal("checkout_pull_request"),cwd:z.z.string(),requestId:z.z.string()}),yr=z.z.object({type:z.z.literal("checkout_push_request"),cwd:z.z.string(),requestId:z.z.string()}),hr=z.z.object({type:z.z.literal("checkout.refresh.request"),cwd:z.z.string(),requestId:z.z.string()}),jr=z.z.object({type:z.z.literal("checkout_pr_create_request"),cwd:z.z.string(),title:z.z.string().optional(),body:z.z.string().optional(),baseRef:z.z.string().optional(),requestId:z.z.string()}),Sr=z.z.object({type:z.z.literal("checkout_pr_merge_request"),cwd:z.z.string(),mergeMethod:z.z.enum(["merge","squash","rebase"]),requestId:z.z.string()}),Pr=z.z.object({type:z.z.literal("checkout.github.set_auto_merge.request"),cwd:z.z.string(),enabled:z.z.boolean(),mergeMethod:z.z.enum(["merge","squash","rebase"]).optional(),requestId:z.z.string()}),_r=z.z.enum(["too_large","checksum_mismatch","aborted","write_failed","unsupported"]),qr=z.z.object({type:z.z.literal("files.upload.begin.request"),requestId:z.z.string(),agentId:z.z.string(),uploadId:z.z.string(),metadata:z.z.lazy(()=>j.FileBeginMetadataSchema)}),Ir=z.z.object({type:z.z.literal("files.upload.complete.request"),requestId:z.z.string(),uploadId:z.z.string(),totalChunks:z.z.number().int().nonnegative()}),Rr=z.z.object({type:z.z.literal("files.upload.chunk"),payload:z.z.object({requestId:z.z.string(),uploadId:z.z.string(),chunkIndex:z.z.number().int().nonnegative(),data:z.z.string()})}),Or=z.z.object({type:z.z.literal("files.upload.error"),payload:z.z.object({requestId:z.z.string(),uploadId:z.z.string(),code:_r,message:z.z.string().optional()})}),kr=z.z.string().regex(/^[A-Za-z0-9._-]+$/),wr=z.z.object({type:z.z.literal("checkout.github.get_check_details.request"),cwd:z.z.string(),repoOwner:kr,repoName:kr,checkRunId:z.z.number().int().positive(),workflowRunId:z.z.number().int().positive().optional(),requestId:z.z.string()}),vr=z.z.object({type:z.z.literal("checkout_pr_status_request"),cwd:z.z.string(),requestId:z.z.string()}),Ar=z.z.object({type:z.z.literal("pull_request_timeline_request"),cwd:z.z.string(),prNumber:z.z.number(),repoOwner:z.z.string(),repoName:z.z.string(),requestId:z.z.string()}),Mr=z.z.object({type:z.z.literal("validate_branch_request"),cwd:z.z.string(),branchName:z.z.string(),requestId:z.z.string()}),Cr=z.z.object({type:z.z.literal("checkout_switch_branch_request"),cwd:z.z.string(),branch:z.z.string(),requestId:z.z.string()}),Tr=z.z.object({type:z.z.literal("checkout.rename_branch.request"),cwd:z.z.string(),branch:z.z.string(),requestId:z.z.string()}),xr=z.z.object({type:z.z.literal("stash_save_request"),cwd:z.z.string(),branch:z.z.string().optional(),requestId:z.z.string()}),Lr=z.z.object({type:z.z.literal("stash_pop_request"),cwd:z.z.string(),stashIndex:z.z.number().int().min(0),requestId:z.z.string()}),Dr=z.z.object({type:z.z.literal("stash_list_request"),cwd:z.z.string(),paseoOnly:z.z.boolean().optional(),requestId:z.z.string()}),Er=z.z.object({type:z.z.literal("branch_suggestions_request"),cwd:z.z.string(),query:z.z.string().optional(),limit:z.z.number().int().min(1).max(200).optional(),requestId:z.z.string()}),Wr=z.z.object({kind:z.z.enum(["issue","pr"]),number:z.z.number(),title:z.z.string(),url:z.z.string(),state:z.z.string(),body:z.z.string().nullable(),labels:z.z.array(z.z.string()),baseRefName:z.z.string().nullable().optional(),headRefName:z.z.string().nullable().optional(),updatedAt:z.z.string().optional()}),Nr=z.z.enum(["github-issue","github-pr"]),Fr=z.z.object({type:z.z.literal("github_search_request"),cwd:z.z.string(),query:z.z.string(),limit:z.z.number().int().min(1).max(50).optional(),kinds:z.z.array(Nr).optional(),requestId:z.z.string()}),Ur=z.z.object({type:z.z.literal("directory_suggestions_request"),query:z.z.string(),cwd:z.z.string().optional(),includeFiles:z.z.boolean().optional(),includeDirectories:z.z.boolean().optional(),matchMode:z.z.enum(["fuzzy","suffix"]).optional(),limit:z.z.number().int().min(1).max(100).optional(),requestId:z.z.string()}),Br=z.z.object({type:z.z.literal("paseo_worktree_list_request"),cwd:z.z.string().optional(),repoRoot:z.z.string().optional(),requestId:z.z.string()}),Gr=z.z.object({type:z.z.literal("paseo_worktree_archive_request"),worktreePath:z.z.string().optional(),repoRoot:z.z.string().optional(),branchName:z.z.string().optional(),workspaceId:z.z.string().optional(),scope:z.z.enum(["workspace","worktree"]).optional().default("workspace"),deleteWorktreeFromDisk:z.z.boolean().optional().default(!1),requestId:z.z.string()}),Hr=z.z.object({prompt:z.z.string().optional(),attachments:Nt}),Kr=z.z.object({type:z.z.literal("create_paseo_worktree_request"),cwd:z.z.string(),projectId:z.z.string().optional(),worktreeSlug:z.z.string().optional(),nameContext:z.z.string().optional(),attachments:Nt.optional(),firstAgentContext:Hr.optional(),refName:z.z.string().min(1).optional(),action:z.z.enum(["branch-off","checkout"]).optional(),githubPrNumber:z.z.number().int().positive().optional(),requestId:z.z.string()}),Vr=z.z.object({type:z.z.literal("workspace_setup_status_request"),workspaceId:z.z.string(),requestId:z.z.string()}),Xr=["cursor","vscode","zed","finder","explorer","file-manager"],Yr=[...Xr,"webstorm"],Jr=z.z.enum(Yr),Qr=z.z.enum(Xr),$r=z.z.string().trim().min(1),Zr=new Set(Yr),eo=new Set(Xr);const to=z.z.object({id:$r,label:z.z.string()}),no=z.z.object({type:z.z.literal("list_available_editors_request"),requestId:z.z.string()}),ro=z.z.object({type:z.z.literal("open_in_editor_request"),path:z.z.string(),editorId:z.z.string().trim().min(1),mode:z.z.enum(["open","reveal"]).optional(),cwd:z.z.string().optional(),requestId:z.z.string()}),oo=z.z.object({type:z.z.literal("open_project_request"),cwd:z.z.string(),requestId:z.z.string()}),ao=z.z.object({type:z.z.literal("project.add.request"),cwd:z.z.string(),requestId:z.z.string()}),io=z.z.object({type:z.z.literal("archive_workspace_request"),workspaceId:z.z.string(),requestId:z.z.string()}),so=z.z.object({type:z.z.literal("workspace.create.request"),requestId:z.z.string(),title:z.z.string().optional(),firstAgentContext:Hr.optional(),source:z.z.discriminatedUnion("kind",[z.z.object({kind:z.z.literal("directory"),path:z.z.string(),projectId:z.z.string().optional()}),z.z.object({kind:z.z.literal("worktree"),cwd:z.z.string().optional(),projectId:z.z.string().optional(),action:z.z.enum(["branch-off","checkout"]).optional(),refName:z.z.string().min(1).optional(),baseBranch:z.z.string().optional(),githubPrNumber:z.z.number().int().positive().optional(),worktreeSlug:z.z.string().optional()})])}),lo=z.z.object({type:z.z.literal("workspace.clear_attention.request"),workspaceId:z.z.union([z.z.string(),z.z.array(z.z.string())]),requestId:z.z.string()}),co=z.z.object({text:z.z.string(),style:z.z.string().nullable()}),uo=z.z.object({type:z.z.enum(["add","remove","context","header"]),content:z.z.string(),tokens:z.z.array(co).optional()}),zo=z.z.object({oldStart:z.z.number(),oldCount:z.z.number(),newStart:z.z.number(),newCount:z.z.number(),lines:z.z.array(uo)}),po=z.z.object({path:z.z.string(),isNew:z.z.boolean(),isDeleted:z.z.boolean(),additions:z.z.number(),deletions:z.z.number(),hunks:z.z.array(zo),status:z.z.enum(["ok","too_large","binary"]).optional()}),go=z.z.object({name:z.z.string(),path:z.z.string(),kind:z.z.enum(["file","directory"]),size:z.z.number(),modifiedAt:z.z.string()}),bo=z.z.object({path:z.z.string(),kind:z.z.enum(["text","image","binary"]),encoding:z.z.enum(["utf-8","base64","none"]),content:z.z.string().optional(),mimeType:z.z.string().optional(),size:z.z.number(),modifiedAt:z.z.string()}),mo=z.z.object({path:z.z.string(),entries:z.z.array(go)}),fo=z.z.object({type:z.z.literal("file_explorer_request"),cwd:z.z.string(),path:z.z.string().optional(),mode:z.z.enum(["list","file"]),requestId:z.z.string(),acceptBinary:z.z.boolean().optional()}),yo=z.z.object({type:z.z.literal("project_icon_request"),cwd:z.z.string(),requestId:z.z.string()}),ho=z.z.object({type:z.z.literal("file_download_token_request"),cwd:z.z.string(),path:z.z.string(),requestId:z.z.string()}),jo=z.z.object({type:z.z.literal("file.upload.request"),fileName:z.z.string().min(1),mimeType:z.z.string().min(1),size:z.z.number().int().nonnegative(),modifiedAt:z.z.string(),requestId:z.z.string()}),So=z.z.object({type:z.z.literal("clear_agent_attention"),agentId:z.z.union([z.z.string(),z.z.array(z.z.string())]),requestId:z.z.string().optional()}),Po=z.z.object({type:z.z.literal("client_heartbeat"),deviceType:z.z.enum(["web","mobile"]),focusedAgentId:z.z.string().nullable(),focusedTerminalId:z.z.string().nullable().optional().default(null),lastActivityAt:z.z.string(),appVisible:z.z.boolean(),appVisibilityChangedAt:z.z.string().optional()}),_o=z.z.object({type:z.z.literal("ping"),requestId:z.z.string(),clientSentAt:z.z.number().int().optional()}),qo=z.z.object({provider:m.AgentProviderSchema,cwd:z.z.string(),modeId:z.z.string().optional(),model:z.z.string().optional(),thinkingOptionId:z.z.string().optional(),featureValues:z.z.record(z.z.string(),z.z.unknown()).optional()}),Io=z.z.object({type:z.z.literal("list_provider_features_request"),draftConfig:qo,requestId:z.z.string()}),Ro=z.z.object({type:z.z.literal("list_commands_request"),agentId:z.z.string(),draftConfig:qo.optional(),requestId:z.z.string()}),Oo=z.z.object({type:z.z.literal("register_push_token"),token:z.z.string()}),ko=z.z.object({type:z.z.literal("rewind_session_request"),requestId:z.z.string(),agentId:z.z.string(),turnId:z.z.string()}),wo=z.z.object({type:z.z.literal("rewind_session_response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),newSessionId:z.z.string().optional(),linesCopied:z.z.number().int().nonnegative().optional(),error:z.z.string().optional(),errorCode:z.z.string().optional()})}),vo=z.z.object({type:z.z.literal("edit_message_request"),requestId:z.z.string(),agentId:z.z.string(),turnId:z.z.string(),newContent:z.z.string().optional()}),Ao=z.z.object({type:z.z.literal("edit_message_response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),newSessionId:z.z.string().optional(),linesCopied:z.z.number().int().nonnegative().optional(),adopted:z.z.boolean().optional(),error:z.z.string().optional(),errorCode:z.z.string().optional()})}),Mo=z.z.object({type:z.z.literal("list_workspace_sessions_request"),requestId:z.z.string(),workspaceId:z.z.string()}),Co=z.z.object({sid:z.z.string(),title:z.z.string().nullable(),lastActivity:z.z.string(),cwd:z.z.string(),agentName:z.z.string().nullable()}),To=z.z.object({type:z.z.literal("list_workspace_sessions_response"),payload:z.z.object({requestId:z.z.string(),workspaceId:z.z.string(),sessions:z.z.array(Co),error:z.z.string().optional(),errorCode:z.z.string().optional()})}),xo=z.z.object({type:z.z.literal("list_all_sessions_request"),requestId:z.z.string()}),Lo=z.z.object({sid:z.z.string(),title:z.z.string().nullable(),lastActivity:z.z.string(),cwd:z.z.string(),agentName:z.z.string().nullable()}),Do=z.z.object({type:z.z.literal("list_all_sessions_response"),payload:z.z.object({requestId:z.z.string(),sessions:z.z.array(Lo),error:z.z.string().optional(),errorCode:z.z.string().optional()})}),Eo=z.z.object({id:z.z.string(),title:z.z.string(),icon:z.z.string().optional()}),Wo=z.z.object({id:z.z.string(),title:z.z.string(),icon:z.z.string().optional(),command:z.z.string().optional(),view:z.z.string().optional(),order:z.z.number().optional()}),No=z.z.object({id:z.z.string(),title:z.z.string(),location:z.z.enum(["sidebar","panel"]).optional(),ui:z.z.string(),uiUrl:z.z.string().optional()}),Fo=z.z.object({id:z.z.string(),name:z.z.string(),version:z.z.string(),commands:z.z.array(Eo),sidebarItems:z.z.array(Wo),views:z.z.array(No)}),Uo=z.z.object({type:z.z.literal("extensions.list.request"),requestId:z.z.string()}),Bo=z.z.object({type:z.z.literal("extensions.list.response"),payload:z.z.object({requestId:z.z.string(),extensions:z.z.array(Fo),error:z.z.string().optional(),errorCode:z.z.string().optional()})}),Go=z.z.object({type:z.z.literal("extensions.command.execute.request"),requestId:z.z.string(),commandId:z.z.string(),args:z.z.array(z.z.unknown()).optional()}),Ho=z.z.object({type:z.z.literal("extensions.command.execute.response"),payload:z.z.object({requestId:z.z.string(),ok:z.z.boolean(),result:z.z.unknown().optional(),error:z.z.string().optional()})}),Ko=z.z.object({type:z.z.literal("search_sessions_request"),requestId:z.z.string(),query:z.z.string(),limit:z.z.number().int().positive().optional(),sources:z.z.array(z.z.string()).optional()}),Vo=z.z.object({sid:z.z.string(),source:z.z.string(),cwd:z.z.string(),timestamp:z.z.string(),snippet:z.z.string(),resumeCommand:z.z.string()}),Xo=z.z.object({type:z.z.literal("search_sessions_response"),payload:z.z.object({requestId:z.z.string(),query:z.z.string(),results:z.z.array(Vo),error:z.z.string().optional(),errorCode:z.z.string().optional()})}),Yo=z.z.object({endpoint:z.z.string(),keys:z.z.object({p256dh:z.z.string(),auth:z.z.string()}),expirationTime:z.z.union([z.z.number(),z.z.null()]).optional()}),Jo=z.z.discriminatedUnion("type",[z.z.object({type:z.z.literal("expo"),token:z.z.string().min(1)}),z.z.object({type:z.z.literal("web"),subscription:Yo})]),Qo=z.z.object({type:z.z.literal("subscribe_push_request"),requestId:z.z.string(),subscription:Jo}),$o=z.z.object({type:z.z.literal("subscribe_push_response"),payload:z.z.object({requestId:z.z.string(),ok:z.z.boolean(),error:z.z.string().optional(),errorCode:z.z.string().optional(),vapidPublicKey:z.z.string().optional()})}),Zo=z.z.object({type:z.z.literal("get_vapid_public_key_request"),requestId:z.z.string()}),ea=z.z.object({type:z.z.literal("get_vapid_public_key_response"),payload:z.z.object({requestId:z.z.string(),publicKey:z.z.string().nullable(),error:z.z.string().optional()})}),ta=z.z.object({type:z.z.literal("list_terminals_request"),cwd:z.z.string().optional(),workspaceId:z.z.string().optional(),requestId:z.z.string()}),na=z.z.object({type:z.z.literal("subscribe_terminals_request"),cwd:z.z.string(),workspaceId:z.z.string().optional()}),ra=z.z.object({type:z.z.literal("unsubscribe_terminals_request"),cwd:z.z.string(),workspaceId:z.z.string().optional()}),oa=z.z.object({type:z.z.literal("create_terminal_request"),cwd:z.z.string(),workspaceId:z.z.string().optional(),name:z.z.string().optional(),agentId:z.z.string().optional(),command:z.z.string().optional(),args:z.z.array(z.z.string()).optional(),requestId:z.z.string()}),aa=z.z.object({type:z.z.literal("terminal.rename.request"),terminalId:z.z.string(),title:z.z.string(),requestId:z.z.string()}),ia=z.z.object({type:z.z.literal("start_workspace_script_request"),workspaceId:z.z.string(),scriptName:z.z.string(),requestId:z.z.string()}),sa=z.z.object({type:z.z.literal("subscribe_terminal_request"),terminalId:z.z.string(),requestId:z.z.string(),restore:z.z.object({mode:z.z.enum(["live","visible-snapshot","full-snapshot"]),scrollbackLines:z.z.number().int().nonnegative().optional(),size:z.z.object({rows:z.z.number().int().positive(),cols:z.z.number().int().positive()}).optional()}).optional()}),la=z.z.object({type:z.z.literal("unsubscribe_terminal_request"),terminalId:z.z.string()}),ca=z.z.discriminatedUnion("type",[z.z.object({type:z.z.literal("input"),data:z.z.string()}),z.z.object({type:z.z.literal("resize"),rows:z.z.number(),cols:z.z.number()}),z.z.object({type:z.z.literal("mouse"),row:z.z.number(),col:z.z.number(),button:z.z.number(),action:z.z.enum(["down","up","move"])})]),ua=z.z.object({type:z.z.literal("terminal_input"),terminalId:z.z.string(),message:ca}),za=z.z.object({type:z.z.literal("kill_terminal_request"),terminalId:z.z.string(),requestId:z.z.string()}),pa=z.z.object({type:z.z.literal("capture_terminal_request"),terminalId:z.z.string(),start:z.z.number().int().optional(),end:z.z.number().int().optional(),stripAnsi:z.z.boolean().default(!0),requestId:z.z.string()}),ga=z.z.object({type:z.z.literal("capture_agent_pane_request"),agentId:z.z.string(),ansi:z.z.boolean().default(!0),scrollbackLines:z.z.number().int().nonnegative().max(1e4).default(0),requestId:z.z.string()}),ba=z.z.discriminatedUnion("type",[R.BrowserAutomationExecuteResponseSchema,$e,Ze,et,Bt,Vt,Xt,Kt,Yt,nt,rt,mt,it,lt,bt,pt,yt,ht,jt,St,Pt,wt,Rt,_t,vt,Jt,Qt,$t,Zt,J,$,ee,ne,ie,en,tn,nn,rn,on,an,sn,ln,cn,pn,gn,bn,Io,dn,mn,fn,yn,hn,jn,Sn,Pn,_n,qn,Rn,In,On,wn,vn,An,Tn,Ln,Wn,Fn,Bn,Kn,or,zr,pr,gr,br,dr,mr,fr,yr,hr,jr,Sr,Pr,qr,Ir,Rr,Or,wr,vr,Ar,Cr,Tr,xr,Lr,Dr,Mr,Er,Fr,Ur,Br,Gr,Kr,Vr,no,ro,oo,ao,io,so,lo,fo,yo,ho,jo,So,Po,_o,Ro,Oo,ko,vo,Mo,xo,Uo,Go,Ko,Qo,Zo,ta,na,ra,oa,aa,ia,sa,la,ua,za,pa,ga,S.ChatCreateRequestSchema,S.ChatListRequestSchema,S.ChatInspectRequestSchema,S.ChatDeleteRequestSchema,S.ChatPostRequestSchema,S.ChatReadRequestSchema,S.ChatWaitRequestSchema,P.ScheduleCreateRequestSchema,P.ScheduleListRequestSchema,P.ScheduleInspectRequestSchema,P.ScheduleLogsRequestSchema,P.SchedulePauseRequestSchema,P.ScheduleResumeRequestSchema,P.ScheduleDeleteRequestSchema,P.ScheduleRunOnceRequestSchema,P.ScheduleUpdateRequestSchema,_.SourceCatalogueRequestSchema,_.SourceConnectRequestSchema,_.SourceListRequestSchema,_.SourceCheckRequestSchema,_.SourceDisconnectRequestSchema,_.SourceSubscribeRequestSchema,_.SourceTriggersRequestSchema,_.IngestionBackfillRequestSchema,_.IngestionApplyRequestSchema,_.IngestionCohortInspectRequestSchema,_.IngestionCohortCancelRequestSchema,_.IngestionRunsRequestSchema,_.IngestionFilterListRequestSchema,_.IngestionFilterCreateRequestSchema,_.IngestionFilterUpdateRequestSchema,_.IngestionFilterDeleteRequestSchema,q.LoopRunRequestSchema,q.LoopListRequestSchema,q.LoopInspectRequestSchema,q.LoopLogsRequestSchema,q.LoopStopRequestSchema,I.FleetListRequestSchema,I.FleetInspectRequestSchema,I.FleetRunNowRequestSchema,I.FleetPauseRequestSchema,I.FleetResumeRequestSchema,I.FleetSetModeRequestSchema,I.FleetAskRequestSchema,I.FleetDecisionsRequestSchema,I.FleetResolveDecisionRequestSchema,I.FleetSetParamsRequestSchema,I.FleetCreateRequestSchema,I.FleetExecutionsRequestSchema,ar,ir,sr]),da=z.z.object({id:z.z.string(),timestamp:z.z.coerce.date(),type:z.z.enum(["transcript","assistant","tool_call","tool_result","error","system"]),content:z.z.string(),metadata:z.z.record(z.z.string(),z.z.unknown()).optional()}),ma=z.z.object({type:z.z.literal("activity_log"),payload:da}),fa=z.z.object({type:z.z.literal("assistant_chunk"),payload:z.z.object({chunk:z.z.string()})}),ya=z.z.object({type:z.z.literal("audio_output"),payload:z.z.object({audio:z.z.string(),format:z.z.string(),id:z.z.string(),isVoiceMode:z.z.boolean(),groupId:z.z.string().optional(),chunkIndex:z.z.number().int().nonnegative().optional(),isLastChunk:z.z.boolean().optional()})}),ha=z.z.object({type:z.z.literal("transcription_result"),payload:z.z.object({text:z.z.string(),language:z.z.string().optional(),duration:z.z.number().optional(),requestId:z.z.string(),avgLogprob:z.z.number().optional(),isLowConfidence:z.z.boolean().optional(),byteLength:z.z.number().optional(),format:z.z.string().optional(),debugRecordingPath:z.z.string().optional()})}),ja=z.z.object({type:z.z.literal("voice_input_state"),payload:z.z.object({isSpeaking:z.z.boolean()})}),Sa=z.z.object({type:z.z.literal("dictation_stream_ack"),payload:z.z.object({dictationId:z.z.string(),ackSeq:z.z.number().int()})}),Pa=z.z.object({type:z.z.literal("dictation_stream_finish_accepted"),payload:z.z.object({dictationId:z.z.string(),timeoutMs:z.z.number().int().positive()})}),_a=z.z.object({type:z.z.literal("dictation_stream_partial"),payload:z.z.object({dictationId:z.z.string(),text:z.z.string()})}),qa=z.z.object({type:z.z.literal("dictation_stream_final"),payload:z.z.object({dictationId:z.z.string(),text:z.z.string(),debugRecordingPath:z.z.string().optional()})}),Ia=z.z.object({type:z.z.literal("dictation_stream_error"),payload:z.z.object({dictationId:z.z.string(),error:z.z.string(),retryable:z.z.boolean(),reasonCode:z.z.string().optional(),missingModelIds:z.z.array(z.z.string()).optional(),debugRecordingPath:z.z.string().optional()})}),Ra=z.z.object({enabled:z.z.boolean(),reason:z.z.string()}),Oa=z.z.object({dictation:Ra,voice:Ra}),ka=z.z.object({voice:Oa.optional()}).passthrough(),wa=z.z.unknown().transform(e=>{if("string"!=typeof e)return null;const t=e.trim();return t.length>0?t:null}),va=z.z.unknown().transform(e=>{if("string"!=typeof e)return null;const t=e.trim();return t.length>0?t:null}),Aa=z.z.unknown().optional().transform(e=>{if(void 0===e)return;const t=ka.safeParse(e);return t.success?t.data:void 0}),Ma=z.z.object({agentId:z.z.string().trim().min(1),available:z.z.boolean(),shadow:z.z.boolean()}).passthrough(),Ca=z.z.object({status:z.z.literal("server_info"),serverId:z.z.string().trim().min(1),hostname:wa.optional(),version:va.optional(),capabilities:Aa.optional(),features:z.z.object({providersSnapshot:z.z.boolean().optional(),checkoutGithubSetAutoMerge:z.z.boolean().optional(),githubCheckDetails:z.z.boolean().optional(),daemonStatusRpc:z.z.boolean().optional(),"terminal-restore-modes":z.z.boolean().optional(),rewind:z.z.boolean().optional(),checkoutRefresh:z.z.boolean().optional(),recallSearch:z.z.boolean().optional(),fileUploads:z.z.boolean().optional(),sessionsListRpc:z.z.boolean().optional(),loopDecisions:z.z.boolean().optional(),workflows:z.z.boolean().optional(),extensions:z.z.boolean().optional(),sessionDigest:z.z.boolean().optional(),workspaceMultiplicity:z.z.boolean().optional(),projectRemove:z.z.boolean().optional(),projectAdd:z.z.boolean().optional(),worktreeRestore:z.z.boolean().optional(),providerUsageList:z.z.boolean().optional(),agentDetach:z.z.boolean().optional(),daemonDiagnostics:z.z.boolean().optional(),daemonSelfUpdate:z.z.boolean().optional(),agentForkContext:z.z.boolean().optional(),meetingsLiveCapture:z.z.boolean().optional(),kanbanBoardConfig:z.z.boolean().optional()}).optional(),jarvis:Ma.nullable().optional()}).passthrough().transform(e=>Object.assign({},e,{hostname:e.hostname??null,version:e.version??null})),Ta=z.z.object({type:z.z.literal("status"),payload:z.z.object({status:z.z.string()}).passthrough()}),xa=z.z.object({type:z.z.literal("pong"),payload:z.z.object({requestId:z.z.string(),clientSentAt:z.z.number().int().optional(),serverReceivedAt:z.z.number().int(),serverSentAt:z.z.number().int()})}),La=z.z.object({type:z.z.literal("rpc_error"),payload:z.z.object({requestId:z.z.string(),requestType:z.z.string().optional(),error:z.z.string(),code:z.z.string().optional()})}),Da=z.z.object({agentId:z.z.string(),requestId:z.z.string()}),Ea=Da.extend({timelineSize:z.z.number().optional()}),Wa=z.z.object({status:z.z.literal("agent_created"),agent:Ye,scheduleId:z.z.string().optional(),scheduleNextRunAt:z.z.string().nullable().optional()}).extend(Da.shape),Na=z.z.object({status:z.z.literal("agent_create_failed"),requestId:z.z.string(),error:z.z.string(),errorCode:z.z.string().optional()}),Fa=z.z.object({status:z.z.literal("agent_resumed"),agent:Ye}).extend(Ea.shape),Ua=z.z.object({status:z.z.literal("agent_refreshed")}).extend(Ea.shape),Ba=z.z.object({status:z.z.literal("restart_requested"),clientId:z.z.string(),reason:z.z.string().optional(),requestId:z.z.string()}),Ga=z.z.object({status:z.z.literal("shutdown_requested"),clientId:z.z.string(),requestId:z.z.string()}),Ha=z.z.object({status:z.z.literal("daemon_config_changed"),config:E}).passthrough(),Ka=z.z.discriminatedUnion("status",[Wa,Na,Fa,Ua,Ga,Ba,Ha]),Va=z.z.object({type:z.z.literal("artifact"),payload:z.z.object({type:z.z.enum(["markdown","diff","image","code"]),id:z.z.string(),title:z.z.string(),content:z.z.string(),isBase64:z.z.boolean()})}),Xa=z.z.object({cwd:z.z.string(),isGit:z.z.literal(!1),currentBranch:z.z.null(),remoteUrl:z.z.null(),worktreeRoot:z.z.null().optional(),isPaseoOwnedWorktree:z.z.literal(!1),mainRepoRoot:z.z.null()}).transform(e=>Object.assign({},e,{worktreeRoot:null})),Ya=z.z.object({cwd:z.z.string(),isGit:z.z.literal(!0),currentBranch:z.z.string().nullable(),remoteUrl:z.z.string().nullable(),worktreeRoot:z.z.string().optional(),isPaseoOwnedWorktree:z.z.literal(!1),mainRepoRoot:z.z.string().nullable().optional().default(null)}).transform(e=>Object.assign({},e,{worktreeRoot:e.worktreeRoot??e.cwd})),Ja=z.z.object({cwd:z.z.string(),isGit:z.z.literal(!0),currentBranch:z.z.string().nullable(),remoteUrl:z.z.string().nullable(),worktreeRoot:z.z.string().optional(),isPaseoOwnedWorktree:z.z.literal(!0),mainRepoRoot:z.z.string()}).transform(e=>Object.assign({},e,{worktreeRoot:e.worktreeRoot??e.cwd})),Qa=z.z.union([Xa,Ya,Ja]),$a=z.z.object({projectKey:z.z.string(),projectName:z.z.string(),workspaceName:z.z.string().nullable().optional(),checkout:Qa}),Za=z.z.enum(["running","stopped"]),ei=z.z.enum(["healthy","unhealthy"]),ti=z.z.object({scriptName:z.z.string(),type:z.z.enum(["script","service"]).optional().default("service"),hostname:z.z.string(),port:z.z.number().int().positive().nullable(),localProxyUrl:z.z.string().nullable().optional(),publicProxyUrl:z.z.string().nullable().optional(),proxyUrl:z.z.string().nullable().optional().default(null),lifecycle:Za,health:ei.nullable(),exitCode:z.z.number().nullable().optional().default(null),terminalId:z.z.string().nullable().optional().default(null)}),ni=z.z.object({currentBranch:z.z.string().nullable().optional(),remoteUrl:z.z.string().nullable().optional(),isPaseoOwnedWorktree:z.z.boolean().optional(),isDirty:z.z.boolean().nullable().optional(),aheadBehind:z.z.object({ahead:z.z.number(),behind:z.z.number()}).nullable().optional(),aheadOfOrigin:z.z.number().nullable().optional(),behindOfOrigin:z.z.number().nullable().optional()}).optional().nullable(),ri=z.z.object({featuresEnabled:z.z.boolean().optional(),pullRequest:z.z.object({number:z.z.number().optional(),url:z.z.string(),title:z.z.string(),state:z.z.string(),baseRefName:z.z.string(),headRefName:z.z.string(),isMerged:z.z.boolean(),isDraft:z.z.boolean().optional(),mergeable:z.z.enum(["MERGEABLE","CONFLICTING","UNKNOWN"]).catch("UNKNOWN").optional(),checks:z.z.array(z.z.object({name:z.z.string(),status:z.z.enum(["success","failure","pending","skipped","cancelled"]),url:z.z.string().nullable(),workflow:z.z.string().optional(),duration:z.z.string().optional()})).optional(),checksStatus:z.z.enum(["none","pending","success","failure"]).optional(),reviewDecision:z.z.enum(["approved","changes_requested","pending"]).nullable().optional(),repoOwner:z.z.string().optional(),repoName:z.z.string().optional(),github:z.z.unknown().optional()}).nullable().optional(),error:z.z.object({message:z.z.string()}).nullable().optional(),refreshedAt:z.z.string().nullable().optional()}).optional().nullable(),oi=z.z.object({id:z.z.string(),projectId:z.z.string(),projectDisplayName:z.z.string(),projectCustomName:z.z.string().nullable().optional(),projectRootPath:z.z.string(),workspaceDirectory:z.z.string().optional(),projectKind:z.z.enum(["git","non_git","directory"]),workspaceKind:z.z.enum(["directory","local_checkout","checkout","worktree"]),name:z.z.string(),title:z.z.string().nullable().optional(),archivingAt:z.z.string().nullable().optional().default(null),status:Ht,statusEnteredAt:z.z.string().nullish().transform(e=>e??null),activityAt:z.z.string().nullable(),diffStat:z.z.object({additions:z.z.number(),deletions:z.z.number()}).nullable().optional(),scripts:z.z.array(ti).default([]),gitRuntime:ni,githubRuntime:ri,project:$a.optional()}).transform(e=>Object.assign({},e,{workspaceDirectory:e.workspaceDirectory??e.projectRootPath})),ai=z.z.object({type:z.z.literal("agent_update"),payload:z.z.discriminatedUnion("kind",[z.z.object({kind:z.z.literal("upsert"),agent:Ye,project:$a.nullable().optional()}),z.z.object({kind:z.z.literal("remove"),agentId:z.z.string()})])}),ii=z.z.object({type:z.z.literal("open_url"),payload:z.z.object({url:z.z.string(),agentId:z.z.string().optional()})}),si=z.z.object({type:z.z.literal("agent_stream"),payload:z.z.object({agentId:z.z.string(),event:Ne,timestamp:z.z.string(),seq:z.z.number().int().nonnegative().optional(),epoch:z.z.string().optional()})}),li=z.z.object({type:z.z.literal("agent_status"),payload:z.z.object({agentId:z.z.string(),status:z.z.string(),info:Ye})}),ci=z.z.object({type:z.z.literal("agent_list"),payload:z.z.object({agents:z.z.array(Ye)})}),ui=z.z.object({agent:Ye,project:$a}),zi=z.z.object({nextCursor:z.z.string().nullable(),prevCursor:z.z.string().nullable(),hasMore:z.z.boolean()}),pi=z.z.object({type:z.z.literal("fetch_agents_response"),payload:z.z.object({requestId:z.z.string(),subscriptionId:z.z.string().nullable().optional(),entries:z.z.array(ui),pageInfo:zi})}),gi=z.z.object({type:z.z.literal("fetch_agent_history_response"),payload:z.z.object({requestId:z.z.string(),entries:z.z.array(ui),pageInfo:zi})}),bi=z.z.object({type:z.z.literal("fetch_recent_provider_sessions_response"),payload:z.z.object({requestId:z.z.string(),entries:z.z.array(Qe),filteredAlreadyImportedCount:z.z.number().int().nonnegative().optional()})}),di=z.z.object({projectId:z.z.string(),projectDisplayName:z.z.string(),projectCustomName:z.z.string().nullable().optional(),projectRootPath:z.z.string(),projectKind:z.z.enum(["git","non_git","directory"])}),mi=z.z.object({type:z.z.literal("fetch_workspaces_response"),payload:z.z.object({requestId:z.z.string(),subscriptionId:z.z.string().nullable().optional(),entries:z.z.array(oi),emptyProjects:z.z.array(di).optional().default([]),pageInfo:z.z.object({nextCursor:z.z.string().nullable(),prevCursor:z.z.string().nullable(),hasMore:z.z.boolean()})})}),fi=z.z.object({type:z.z.literal("workspace_update"),payload:z.z.discriminatedUnion("kind",[z.z.object({kind:z.z.literal("upsert"),workspace:oi}),z.z.object({kind:z.z.literal("remove"),id:z.z.string(),emptyProject:di.optional(),removedProjectId:z.z.string().optional()})])}),yi=z.z.object({type:z.z.literal("script_status_update"),payload:z.z.object({workspaceId:z.z.string(),scripts:z.z.array(ti)})}),hi=z.z.object({type:z.z.literal("workspace_setup_progress"),payload:z.z.object({workspaceId:z.z.string(),status:z.z.enum(["running","completed","failed"]),detail:Ae,error:z.z.string().nullable()})}),ji=z.z.object({status:z.z.enum(["running","completed","failed"]),detail:Ae,error:z.z.string().nullable()}),Si=z.z.object({type:z.z.literal("workspace_setup_status_response"),payload:z.z.object({requestId:z.z.string(),workspaceId:z.z.string(),snapshot:ji.nullable()})}),Pi=z.z.object({type:z.z.literal("open_project_response"),payload:z.z.object({requestId:z.z.string(),workspace:oi.nullable(),error:z.z.string().nullable(),errorCode:z.z.enum(["directory_not_found"]).nullish().catch(null)})}),_i=z.z.object({type:z.z.literal("project.add.response"),payload:z.z.object({requestId:z.z.string(),project:di.nullable(),error:z.z.string().nullable(),errorCode:z.z.enum(["directory_not_found"]).nullish().catch(null)})}),qi=z.z.object({type:z.z.literal("start_workspace_script_response"),payload:z.z.object({requestId:z.z.string(),workspaceId:z.z.string(),scriptName:z.z.string(),terminalId:z.z.string().nullable(),error:z.z.string().nullable()})}),Ii=z.z.object({type:z.z.literal("list_available_editors_response"),payload:z.z.object({requestId:z.z.string(),editors:z.z.array(z.z.object({id:z.z.string().trim().min(1),label:z.z.string()})),error:z.z.string().nullable()})}),Ri=z.z.object({type:z.z.literal("open_in_editor_response"),payload:z.z.object({requestId:z.z.string(),error:z.z.string().nullable()})}),Oi=z.z.object({type:z.z.literal("archive_workspace_response"),payload:z.z.object({requestId:z.z.string(),workspaceId:z.z.string(),archivedAt:z.z.string().nullable(),error:z.z.string().nullable()})}),ki=z.z.object({type:z.z.literal("fetch_agent_response"),payload:z.z.object({requestId:z.z.string(),agent:Ye.nullable(),project:$a.nullable().optional(),error:z.z.string().nullable()})}),wi=z.z.object({startSeq:z.z.number().int().nonnegative(),endSeq:z.z.number().int().nonnegative()}),vi=z.z.object({provider:m.AgentProviderSchema,item:We,timestamp:z.z.string(),seqStart:z.z.number().int().nonnegative(),seqEnd:z.z.number().int().nonnegative(),sourceSeqRanges:z.z.array(wi),collapsed:z.z.array(z.z.enum(["assistant_merge","reasoning_merge","tool_lifecycle"]))}),Ai=z.z.object({type:z.z.literal("fetch_agent_timeline_response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),agent:Ye.nullable(),direction:z.z.enum(["tail","before","after"]),projection:z.z.enum(["projected","canonical"]),epoch:z.z.string(),reset:z.z.boolean(),staleCursor:z.z.boolean(),gap:z.z.boolean(),window:z.z.object({minSeq:z.z.number().int().nonnegative(),maxSeq:z.z.number().int().nonnegative(),nextSeq:z.z.number().int().nonnegative()}),startCursor:kn.nullable(),endCursor:kn.nullable(),hasOlder:z.z.boolean(),hasNewer:z.z.boolean(),entries:z.z.array(vi),error:z.z.string().nullable()})}),Mi=z.z.object({type:z.z.literal("agent.fork_context.response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),attachment:Ct.nullable(),itemCount:z.z.number().int().nonnegative(),boundaryMessageId:z.z.string().nullable(),error:z.z.string().nullable()})}),Ci=z.z.object({type:z.z.literal("cancel_agent_response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),agent:Ye.nullable()})}),Ti=z.z.object({type:z.z.literal("clear_agent_attention_response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string().or(z.z.array(z.z.string())),agents:z.z.array(Ye)})}),xi=z.z.object({type:z.z.literal("workspace.create.response"),payload:z.z.object({workspace:oi.nullable(),setupTerminalId:z.z.string().nullable(),error:z.z.string().nullable(),errorCode:z.z.string().optional(),requestId:z.z.string()})}),Li=z.z.object({type:z.z.literal("workspace.clear_attention.response"),payload:z.z.object({requestId:z.z.string(),workspaceId:z.z.union([z.z.string(),z.z.array(z.z.string())]),clearedAgentIds:z.z.array(z.z.string()),results:z.z.array(z.z.object({workspaceId:z.z.string(),clearedAgentIds:z.z.array(z.z.string()),success:z.z.boolean(),error:z.z.string().nullable()})),success:z.z.boolean(),error:z.z.string().nullable()})}),Di=z.z.object({type:z.z.literal("send_agent_message_response"),payload:z.z.object({requestId:z.z.string(),agentId:z.z.string(),accepted:z.z.boolean(),error:z.z.string().nullable()})}),Ei=z.z.object({type:z.z.literal("wait_for_finish_response"),payload:z.z.object({requestId:z.z.string(),status:z.z.enum(["idle","error","permission","timeout"]),final:Ye.nullable(),error:z.z.string().nullable(),lastMessage:z.z.string().nullable()})}),Wi=z.z.object({type:z.z.literal("get_daemon_config_response"),payload:z.z.object({requestId:z.z.string(),config:E}).passthrough()}),Ni=z.z.object({type:z.z.literal("daemon.get_status.response"),payload:z.z.object({requestId:z.z.string(),serverId:z.z.string(),version:z.z.string().nullable().optional(),pid:z.z.number(),nodePath:z.z.string(),startedAt:z.z.string().nullable().optional(),listen:z.z.string().nullable(),relay:z.z.object({enabled:z.z.boolean(),endpoint:z.z.string(),publicEndpoint:z.z.string(),useTls:z.z.boolean(),publicUseTls:z.z.boolean()}).nullable().optional(),providers:z.z.array(z.z.object({provider:z.z.string(),available:z.z.boolean(),error:z.z.string().nullable().optional()}))}).passthrough()}),Fi=z.z.object({type:z.z.literal("daemon.get_pairing_offer.response"),payload:z.z.object({requestId:z.z.string(),url:z.z.string(),qr:z.z.string().nullable().optional(),relayEnabled:z.z.boolean()}).passthrough()}),Ui=z.z.object({type:z.z.literal("diagnostics.response"),payload:z.z.object({requestId:z.z.string(),diagnostic:z.z.string()}).passthrough()}),Bi=z.z.object({type:z.z.literal("set_daemon_config_response"),payload:z.z.object({requestId:z.z.string(),config:E}).passthrough()}),Gi=z.z.object({type:z.z.literal("read_project_config_response"),payload:z.z.union([z.z.object({requestId:z.z.string(),repoRoot:z.z.string(),ok:z.z.literal(!0),config:k.PaseoConfigRawSchema.nullable(),revision:k.PaseoConfigRevisionSchema.nullable()}),z.z.object({requestId:z.z.string(),repoRoot:z.z.string(),ok:z.z.literal(!1),error:k.ProjectConfigRpcErrorSchema})])}),Hi=z.z.object({type:z.z.literal("write_project_config_response"),payload:z.z.union([z.z.object({requestId:z.z.string(),repoRoot:z.z.string(),ok:z.z.literal(!0),config:k.PaseoConfigRawSchema,revision:k.PaseoConfigRevisionSchema}),z.z.object({requestId:z.z.string(),repoRoot:z.z.string(),ok:z.z.literal(!1),error:k.ProjectConfigRpcErrorSchema})])}),Ki=z.z.object({type:z.z.literal("agent_permission_request"),payload:z.z.object({agentId:z.z.string(),request:Oe})}),Vi=z.z.object({id:z.z.string(),label:z.z.string(),action:z.z.enum(["approve","deny","reply"])}),Xi=z.z.object({type:z.z.literal("watch.actionablePush"),notificationId:z.z.string(),sessionId:z.z.string(),kind:z.z.string(),summary:z.z.string(),actions:z.z.array(Vi)}),Yi=z.z.object({type:z.z.literal("watch.actionableResolved"),notificationId:z.z.string()}),Ji=z.z.object({id:z.z.string(),title:z.z.string(),lastActivity:z.z.string(),snippet:z.z.string()}),Qi=z.z.object({type:z.z.literal("watch.sessionSearchResult"),requestId:z.z.string(),results:z.z.array(Ji),error:z.z.string().optional()}),$i=z.z.object({type:z.z.literal("agent_permission_resolved"),payload:z.z.object({agentId:z.z.string(),requestId:z.z.string(),resolution:Re})}),Zi=z.z.object({type:z.z.literal("agent_deleted"),payload:z.z.object({agentId:z.z.string(),requestId:z.z.string()})}),es=z.z.object({type:z.z.literal("agent_archived"),payload:z.z.object({agentId:z.z.string(),archivedAt:z.z.string(),requestId:z.z.string()})}),ts=z.z.object({agentId:z.z.string(),archivedAt:z.z.string()}),ns=z.z.object({terminalId:z.z.string(),success:z.z.boolean()}),rs=z.z.object({type:z.z.literal("close_items_response"),payload:z.z.object({agents:z.z.array(ts),terminals:z.z.array(ns),requestId:z.z.string()})}),os=z.z.object({ahead:z.z.number(),behind:z.z.number()}),as=z.z.object({cwd:z.z.string(),error:cr.nullable(),requestId:z.z.string()}),is=as.extend({isGit:z.z.literal(!1),isPaseoOwnedWorktree:z.z.literal(!1),repoRoot:z.z.null(),currentBranch:z.z.null(),isDirty:z.z.null(),baseRef:z.z.null(),aheadBehind:z.z.null(),aheadOfOrigin:z.z.null(),behindOfOrigin:z.z.null(),hasRemote:z.z.boolean(),remoteUrl:z.z.null()}),ss=as.extend({isGit:z.z.literal(!0),isPaseoOwnedWorktree:z.z.literal(!1),repoRoot:z.z.string(),mainRepoRoot:z.z.string().nullable().optional().default(null),currentBranch:z.z.string().nullable(),isDirty:z.z.boolean(),baseRef:z.z.string().nullable(),aheadBehind:os.nullable(),aheadOfOrigin:z.z.number().nullable(),behindOfOrigin:z.z.number().nullable(),hasRemote:z.z.boolean(),remoteUrl:z.z.string().nullable()}),ls=as.extend({isGit:z.z.literal(!0),isPaseoOwnedWorktree:z.z.literal(!0),repoRoot:z.z.string(),mainRepoRoot:z.z.string(),currentBranch:z.z.string().nullable(),isDirty:z.z.boolean(),baseRef:z.z.string(),aheadBehind:os.nullable(),aheadOfOrigin:z.z.number().nullable(),behindOfOrigin:z.z.number().nullable(),hasRemote:z.z.boolean(),remoteUrl:z.z.string().nullable()}),cs=z.z.object({type:z.z.literal("checkout_status_response"),payload:z.z.union([is,ss,ls])}),us=z.z.object({enabledAt:z.z.string().nullable().optional().default(null),mergeMethod:z.z.string().nullable().optional().default(null),enabledBy:z.z.string().nullable().optional().default(null)}).nullable().optional().default(null),zs=z.z.object({autoMergeAllowed:z.z.boolean().optional().default(!1),mergeCommitAllowed:z.z.boolean().optional().default(!1),squashMergeAllowed:z.z.boolean().optional().default(!1),rebaseMergeAllowed:z.z.boolean().optional().default(!1),viewerDefaultMergeMethod:z.z.string().nullable().optional().default(null)}).optional().default({autoMergeAllowed:!1,mergeCommitAllowed:!1,squashMergeAllowed:!1,rebaseMergeAllowed:!1,viewerDefaultMergeMethod:null}),ps=z.z.object({mergeStateStatus:z.z.string().nullable().optional().default(null),autoMergeRequest:us,viewerCanEnableAutoMerge:z.z.boolean().optional().default(!1),viewerCanDisableAutoMerge:z.z.boolean().optional().default(!1),viewerCanMergeAsAdmin:z.z.boolean().optional().default(!1),viewerCanUpdateBranch:z.z.boolean().optional().default(!1),repository:zs,isMergeQueueEnabled:z.z.boolean().optional().default(!1),isInMergeQueue:z.z.boolean().optional().default(!1)}).optional(),gs=z.z.object({number:z.z.number().optional(),url:z.z.string(),title:z.z.string(),state:z.z.string(),baseRefName:z.z.string(),headRefName:z.z.string(),isMerged:z.z.boolean(),isDraft:z.z.boolean().optional().default(!1),mergeable:z.z.enum(["MERGEABLE","CONFLICTING","UNKNOWN"]).catch("UNKNOWN").optional().default("UNKNOWN"),checks:z.z.array(z.z.object({name:z.z.string(),status:z.z.string(),url:z.z.string().nullable(),workflow:z.z.string().optional(),duration:z.z.string().optional(),checkRunId:z.z.number().optional(),workflowRunId:z.z.number().optional()})).optional().default([]),checksStatus:z.z.string().optional(),reviewDecision:z.z.string().nullable().optional(),repoOwner:z.z.string().optional(),repoName:z.z.string().optional(),github:ps}),bs=z.z.object({cwd:z.z.string(),status:gs.nullable(),githubFeaturesEnabled:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()}),ds=z.z.object({prStatus:bs.optional()}),ms=z.z.object({type:z.z.literal("checkout_status_update"),payload:z.z.union([is,ss,ls]).and(ds)}),fs=z.z.object({subscriptionId:z.z.string(),cwd:z.z.string(),files:z.z.array(po),error:cr.nullable()}),ys=z.z.object({type:z.z.literal("subscribe_checkout_diff_response"),payload:fs.extend({requestId:z.z.string()})}),hs=z.z.object({type:z.z.literal("checkout_diff_update"),payload:fs}),js=z.z.object({type:z.z.literal("checkout_commit_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),Ss=z.z.object({type:z.z.literal("checkout_merge_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),Ps=z.z.object({type:z.z.literal("checkout_merge_from_base_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),_s=z.z.object({type:z.z.literal("checkout_pull_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),qs=z.z.object({type:z.z.literal("checkout_push_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),Is=z.z.object({type:z.z.literal("checkout.refresh.response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),Rs=z.z.object({type:z.z.literal("checkout_pr_create_response"),payload:z.z.object({cwd:z.z.string(),url:z.z.string().nullable(),number:z.z.number().nullable(),error:cr.nullable(),requestId:z.z.string()})}),Os=z.z.object({type:z.z.literal("checkout_pr_merge_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),ks=z.z.object({type:z.z.literal("checkout.github.set_auto_merge.response"),payload:z.z.object({cwd:z.z.string(),enabled:z.z.boolean(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),ws=z.z.object({type:z.z.literal("files.upload.begin.response"),payload:z.z.object({requestId:z.z.string(),uploadId:z.z.string(),accepted:z.z.boolean(),chunkSize:z.z.number().int().positive(),error:_r.nullable()})}),vs=z.z.object({type:z.z.literal("files.upload.chunk.ack"),payload:z.z.object({requestId:z.z.string(),uploadId:z.z.string(),chunkIndex:z.z.number().int().nonnegative(),bytesReceived:z.z.number().int().nonnegative()})}),As=z.z.object({type:z.z.literal("files.upload.complete.response"),payload:z.z.object({requestId:z.z.string(),uploadId:z.z.string(),fileId:z.z.string(),path:z.z.string(),size:z.z.number().int().nonnegative(),mimeType:z.z.string(),error:_r.nullable()})}),Ms=z.z.object({path:z.z.string().optional(),startLine:z.z.number().optional(),endLine:z.z.number().optional(),annotationLevel:z.z.string().optional(),message:z.z.string().optional(),title:z.z.string().optional(),rawDetails:z.z.string().optional()}),Cs=z.z.object({jobId:z.z.number(),name:z.z.string(),status:z.z.string().nullable().optional(),conclusion:z.z.string().nullable().optional(),url:z.z.string().nullable().optional(),logTail:z.z.string().optional(),logTruncated:z.z.boolean().optional()}),Ts=z.z.object({checkRunId:z.z.number(),workflowRunId:z.z.number().nullable().optional(),name:z.z.string(),status:z.z.string().nullable().optional(),conclusion:z.z.string().nullable().optional(),url:z.z.string().nullable().optional(),detailsUrl:z.z.string().nullable().optional(),output:z.z.object({title:z.z.string().nullable().optional(),summary:z.z.string().nullable().optional(),text:z.z.string().nullable().optional()}).nullable().optional(),annotations:z.z.array(Ms).optional().default([]),failedJobs:z.z.array(Cs).optional().default([]),truncated:z.z.boolean().optional().default(!1)}),xs=z.z.object({type:z.z.literal("checkout.github.get_check_details.response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),details:Ts.nullable().optional().default(null),error:cr.nullable(),requestId:z.z.string()})}),Ls=z.z.object({type:z.z.literal("checkout_pr_status_response"),payload:bs}),Ds=z.z.discriminatedUnion("kind",[z.z.object({kind:z.z.literal("not_found"),message:z.z.string().optional().default("")}),z.z.object({kind:z.z.literal("forbidden"),message:z.z.string().optional().default("")}),z.z.object({kind:z.z.literal("unknown"),message:z.z.string().optional().default("")})]),Es=z.z.preprocess(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return{kind:"unknown",message:""};const t=e;return"not_found"===t.kind||"forbidden"===t.kind||"unknown"===t.kind?t:Object.assign({},t,{kind:"unknown"})},Ds),Ws=z.z.object({id:z.z.string().optional().default(""),kind:z.z.literal("review"),author:z.z.string().optional().default("unknown"),authorUrl:z.z.string().nullable().optional(),avatarUrl:z.z.string().nullable().optional(),body:z.z.string().optional().default(""),createdAt:z.z.number().optional().default(0),url:z.z.string().optional().default(""),reviewState:z.z.enum(["approved","changes_requested","commented"]).optional().default("commented")}),Ns=z.z.object({id:z.z.string().optional().default(""),kind:z.z.literal("comment"),author:z.z.string().optional().default("unknown"),authorUrl:z.z.string().nullable().optional(),avatarUrl:z.z.string().nullable().optional(),body:z.z.string().optional().default(""),createdAt:z.z.number().optional().default(0),url:z.z.string().optional().default(""),reviewId:z.z.string().optional(),location:z.z.object({path:z.z.string(),line:z.z.number().optional(),startLine:z.z.number().optional(),threadId:z.z.string().optional(),isResolved:z.z.boolean().optional(),isOutdated:z.z.boolean().optional()}).optional()}),Fs=z.z.preprocess(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return e;const t=e;return"review"===t.kind||"comment"===t.kind?t:Object.assign({},t,{kind:"comment"})},z.z.discriminatedUnion("kind",[Ws,Ns])),Us=z.z.object({type:z.z.literal("pull_request_timeline_response"),payload:z.z.object({cwd:z.z.string().optional().default(""),prNumber:z.z.number().nullable().optional().default(null),items:z.z.array(Fs).optional().default([]),truncated:z.z.boolean().optional().default(!1),error:Es.nullable().optional().default(null),requestId:z.z.string().optional().default(""),githubFeaturesEnabled:z.z.boolean().optional().default(!0)}).optional().prefault({})}),Bs=z.z.object({type:z.z.literal("checkout_switch_branch_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),branch:z.z.string(),source:z.z.enum(["local","remote"]).optional(),error:cr.nullable(),requestId:z.z.string()})}),Gs=z.z.object({type:z.z.literal("checkout.rename_branch.response"),payload:z.z.object({requestId:z.z.string(),success:z.z.boolean(),cwd:z.z.string(),currentBranch:z.z.string().nullable(),error:cr.nullable()})}),Hs=z.z.object({index:z.z.number().int().min(0),message:z.z.string(),branch:z.z.string().nullable(),isPaseo:z.z.boolean()}),Ks=z.z.object({type:z.z.literal("stash_save_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),Vs=z.z.object({type:z.z.literal("stash_pop_response"),payload:z.z.object({cwd:z.z.string(),success:z.z.boolean(),error:cr.nullable(),requestId:z.z.string()})}),Xs=z.z.object({type:z.z.literal("stash_list_response"),payload:z.z.object({cwd:z.z.string(),entries:z.z.array(Hs),error:cr.nullable(),requestId:z.z.string()})}),Ys=z.z.object({type:z.z.literal("validate_branch_response"),payload:z.z.object({exists:z.z.boolean(),resolvedRef:z.z.string().nullable(),isRemote:z.z.boolean(),error:z.z.string().nullable(),requestId:z.z.string()})}),Js=z.z.object({type:z.z.literal("branch_suggestions_response"),payload:z.z.object({branches:z.z.array(z.z.string()),branchDetails:z.z.array(z.z.object({name:z.z.string(),committerDate:z.z.number(),hasLocal:z.z.boolean().optional(),hasRemote:z.z.boolean().optional()})).optional(),error:z.z.string().nullable(),requestId:z.z.string()})}),Qs=z.z.object({type:z.z.literal("github_search_response"),payload:z.z.object({items:z.z.array(Wr),githubFeaturesEnabled:z.z.boolean(),error:z.z.string().nullable(),requestId:z.z.string()})}),$s=z.z.object({type:z.z.literal("directory_suggestions_response"),payload:z.z.object({directories:z.z.array(z.z.string()),entries:z.z.array(z.z.object({path:z.z.string(),kind:z.z.enum(["file","directory"])})).optional().default([]),error:z.z.string().nullable(),requestId:z.z.string()})}),Zs=z.z.object({worktreePath:z.z.string(),createdAt:z.z.string(),branchName:z.z.string().nullable().optional(),head:z.z.string().nullable().optional()}),el=z.z.object({type:z.z.literal("paseo_worktree_list_response"),payload:z.z.object({worktrees:z.z.array(Zs),error:cr.nullable(),requestId:z.z.string()})}),tl=z.z.object({type:z.z.literal("paseo_worktree_archive_response"),payload:z.z.object({success:z.z.boolean(),removedAgents:z.z.array(z.z.string()).optional(),error:cr.nullable(),requestId:z.z.string()})}),nl=z.z.object({type:z.z.literal("create_paseo_worktree_response"),payload:z.z.object({workspace:oi.nullable(),error:z.z.string().nullable(),errorCode:z.z.string().optional(),setupTerminalId:z.z.string().nullable(),requestId:z.z.string()})}),rl=z.z.object({type:z.z.literal("file_explorer_response"),payload:z.z.object({cwd:z.z.string(),path:z.z.string(),mode:z.z.enum(["list","file"]),directory:mo.nullable(),file:bo.nullable(),error:z.z.string().nullable(),requestId:z.z.string()})}),ol=z.z.object({data:z.z.string(),mimeType:z.z.string()}),al=z.z.object({type:z.z.literal("project_icon_response"),payload:z.z.object({cwd:z.z.string(),icon:ol.nullable(),error:z.z.string().nullable(),requestId:z.z.string()})}),il=z.z.object({type:z.z.literal("file_download_token_response"),payload:z.z.object({cwd:z.z.string(),path:z.z.string(),token:z.z.string().nullable(),fileName:z.z.string().nullable(),mimeType:z.z.string().nullable(),size:z.z.number().nullable(),error:z.z.string().nullable(),requestId:z.z.string()})}),sl=z.z.object({type:z.z.literal("file.upload.response"),payload:z.z.object({requestId:z.z.string(),file:Et.nullable(),error:z.z.string().nullable()})}),ll=z.z.object({type:z.z.literal("list_provider_models_response"),payload:z.z.object({provider:m.AgentProviderSchema,models:z.z.array(de).optional(),error:z.z.string().nullable().optional(),fetchedAt:z.z.string(),requestId:z.z.string()})}),cl=z.z.object({type:z.z.literal("list_provider_modes_response"),payload:z.z.object({provider:m.AgentProviderSchema,modes:z.z.array(le).optional(),error:z.z.string().nullable().optional(),fetchedAt:z.z.string(),requestId:z.z.string()})}),ul=z.z.object({type:z.z.literal("list_provider_features_response"),payload:z.z.object({provider:m.AgentProviderSchema,features:z.z.array(be).optional(),error:z.z.string().nullable().optional(),fetchedAt:z.z.string(),requestId:z.z.string()})}),zl=z.z.object({provider:m.AgentProviderSchema,available:z.z.boolean(),error:z.z.string().nullable().optional()}),pl=z.z.object({type:z.z.literal("list_available_providers_response"),payload:z.z.object({providers:z.z.array(zl),error:z.z.string().nullable().optional(),fetchedAt:z.z.string(),requestId:z.z.string()})}),gl=z.z.object({type:z.z.literal("get_providers_snapshot_response"),payload:z.z.object({entries:z.z.array(me),generatedAt:z.z.string(),requestId:z.z.string()})}),bl=z.z.object({type:z.z.literal("providers.reload_config.response"),payload:z.z.object({added:z.z.array(z.z.string()),updated:z.z.array(z.z.string()),removed:z.z.array(z.z.string()),unchanged:z.z.array(z.z.string()),providers:z.z.array(z.z.object({provider:z.z.string(),label:z.z.string(),enabled:z.z.boolean()})),skipped:z.z.array(z.z.object({provider:z.z.string(),reason:z.z.string()})).optional(),requestId:z.z.string()})}),dl=z.z.object({type:z.z.literal("providers_snapshot_update"),payload:z.z.object({cwd:z.z.string().optional(),entries:z.z.array(me),generatedAt:z.z.string()})}),ml=z.z.object({type:z.z.literal("refresh_providers_snapshot_response"),payload:z.z.object({requestId:z.z.string(),acknowledged:z.z.boolean()})}),fl=z.z.object({type:z.z.literal("provider_diagnostic_response"),payload:z.z.object({provider:m.AgentProviderSchema,diagnostic:z.z.string(),requestId:z.z.string()})}),yl=z.z.enum(["default","ok","warning","danger"]),hl=z.z.enum(["available","unavailable","error"]),jl=z.z.object({id:z.z.string(),label:z.z.string(),usedPct:z.z.number().nullable().optional(),remainingPct:z.z.number().nullable().optional(),resetsAt:z.z.string().nullable().optional(),runsOutAt:z.z.string().nullable().optional(),shortfallPct:z.z.number().nullable().optional(),tone:yl.optional()}),Sl=z.z.object({id:z.z.string(),label:z.z.string(),used:z.z.number().nullable().optional(),remaining:z.z.number().nullable().optional(),limit:z.z.number().nullable().optional(),unit:z.z.enum(["usd","credits","requests","tokens"]),resetsAt:z.z.string().nullable().optional(),tone:yl.optional()}),Pl=z.z.object({id:z.z.string(),label:z.z.string(),value:z.z.string(),tone:yl.optional()}),_l=z.z.object({providerId:z.z.string(),displayName:z.z.string(),status:hl,planLabel:z.z.string().nullable(),sourceLabel:z.z.string().nullable().optional(),fetchedAt:z.z.string().nullable().optional(),nextRefreshAt:z.z.string().nullable().optional(),windows:z.z.array(jl),balances:z.z.array(Sl).optional(),details:z.z.array(Pl).optional(),error:z.z.string().nullable().optional()}),ql=z.z.object({type:z.z.literal("provider.usage.list.response"),payload:z.z.object({requestId:z.z.string(),fetchedAt:z.z.string(),providers:z.z.array(_l)})}),Il=z.z.object({name:z.z.string(),description:z.z.string(),argumentHint:z.z.string(),kind:z.z.enum(["command","skill"]).optional().catch("command")}),Rl=z.z.object({type:z.z.literal("list_commands_response"),payload:z.z.object({agentId:z.z.string(),commands:z.z.array(Il),error:z.z.string().nullable(),requestId:z.z.string()})}),Ol=z.z.object({id:z.z.string(),name:z.z.string(),cwd:z.z.string(),workspaceId:z.z.string().optional(),title:z.z.string().optional(),activity:p.TerminalActivitySchema.nullable().optional()}),kl=z.z.object({char:z.z.string(),fg:z.z.number().optional(),bg:z.z.number().optional(),fgMode:z.z.number().optional(),bgMode:z.z.number().optional(),bold:z.z.boolean().optional(),italic:z.z.boolean().optional(),underline:z.z.boolean().optional(),dim:z.z.boolean().optional(),inverse:z.z.boolean().optional(),strikethrough:z.z.boolean().optional()}),wl=z.z.enum(["block","underline","bar"]),vl=z.z.object({row:z.z.number(),col:z.z.number(),hidden:z.z.boolean().optional(),style:wl.optional(),blink:z.z.boolean().optional()}),Al=z.z.object({rows:z.z.number(),cols:z.z.number(),grid:z.z.array(z.z.array(kl)),scrollback:z.z.array(z.z.array(kl)),cursor:vl,title:z.z.string().optional(),gridWrapped:z.z.array(z.z.boolean()).optional(),scrollbackWrapped:z.z.array(z.z.boolean()).optional()}),Ml=z.z.object({type:z.z.literal("list_terminals_response"),payload:z.z.object({cwd:z.z.string().optional(),terminals:z.z.array(Ol.omit({cwd:!0})),requestId:z.z.string()})}),Cl=z.z.object({type:z.z.literal("terminals_changed"),payload:z.z.object({cwd:z.z.string(),terminals:z.z.array(Ol.omit({cwd:!0}))})}),Tl=z.z.object({type:z.z.literal("create_terminal_response"),payload:z.z.object({terminal:Ol.nullable(),error:z.z.string().nullable(),requestId:z.z.string()})}),xl=z.z.object({type:z.z.literal("terminal.rename.response"),payload:z.z.object({requestId:z.z.string(),success:z.z.boolean(),error:z.z.string().nullable()})}),Ll=z.z.object({type:z.z.literal("subscribe_terminal_response"),payload:z.z.union([z.z.object({terminalId:z.z.string(),slot:z.z.number().int().min(0).max(255),error:z.z.null(),requestId:z.z.string()}),z.z.object({terminalId:z.z.string(),error:z.z.string(),requestId:z.z.string()})])}),Dl=z.z.object({type:z.z.literal("kill_terminal_response"),payload:z.z.object({terminalId:z.z.string(),success:z.z.boolean(),requestId:z.z.string()})}),El=z.z.object({type:z.z.literal("capture_terminal_response"),payload:z.z.object({terminalId:z.z.string(),lines:z.z.array(z.z.string()),totalLines:z.z.number().int().nonnegative(),requestId:z.z.string()})}),Wl=z.z.object({type:z.z.literal("capture_agent_pane_response"),payload:z.z.object({agentId:z.z.string(),screen:z.z.string().nullable(),capturedAt:z.z.number().int().nonnegative(),requestId:z.z.string()})}),Nl=z.z.object({type:z.z.literal("terminal_stream_exit"),payload:z.z.object({terminalId:z.z.string()})}),Fl=z.z.object({type:z.z.literal("terminal_attention_required"),payload:z.z.object({serverId:z.z.string().optional(),terminalId:z.z.string(),cwd:z.z.string(),workspaceId:z.z.string().optional(),reason:z.z.enum(["finished","needs_input"]),title:z.z.string(),body:z.z.string(),shouldNotify:z.z.boolean()})}),Ul=z.z.object({type:z.z.literal("daemon.update.response"),payload:z.z.object({requestId:z.z.string(),success:z.z.boolean(),error:z.z.string().nullable(),previousVersion:z.z.string().nullable(),newVersion:z.z.string().nullable()})}),Bl=z.z.object({type:z.z.literal("daemon.update.progress"),payload:z.z.object({requestId:z.z.string(),phase:z.z.enum(["starting","downloading","installing","complete"])})}),Gl=z.z.discriminatedUnion("type",[R.BrowserAutomationExecuteRequestSchema,ma,fa,ya,ha,ja,Sa,Pa,_a,qa,Ia,Ta,xa,La,Va,ai,ii,fi,yi,hi,Si,si,li,pi,gi,bi,mi,_i,Pi,qi,Ii,Ri,Oi,ki,Ai,Mi,Ci,Ti,xi,Li,Di,rr,Ni,Fi,Q,Z,te,re,se,Ui,Wi,Bi,Gi,Hi,Cn,xn,Dn,En,Nn,Un,Gn,Vn,Xn,Jn,$n,er,nr,kt,It,Ei,Ki,$i,Zi,es,ft,st,ct,dt,gt,rs,cs,ms,ys,hs,js,Ss,Ps,_s,qs,Is,Rs,Os,ks,ws,vs,As,Or,xs,Ls,Us,Bs,Gs,Ks,Vs,Xs,Ys,Js,Qs,$s,el,tl,nl,rl,al,il,sl,ll,cl,ul,pl,gl,bl,dl,ml,fl,ql,Rl,Ml,Cl,Tl,xl,Ll,Dl,El,Wl,Nl,Fl,S.ChatCreateResponseSchema,S.ChatListResponseSchema,S.ChatInspectResponseSchema,S.ChatDeleteResponseSchema,S.ChatPostResponseSchema,S.ChatReadResponseSchema,S.ChatWaitResponseSchema,P.ScheduleCreateResponseSchema,P.ScheduleListResponseSchema,P.ScheduleInspectResponseSchema,P.ScheduleLogsResponseSchema,P.SchedulePauseResponseSchema,P.ScheduleResumeResponseSchema,P.ScheduleDeleteResponseSchema,P.ScheduleRunOnceResponseSchema,P.ScheduleUpdateResponseSchema,_.SourceCatalogueResponseSchema,_.SourceConnectResponseSchema,_.SourceListResponseSchema,_.SourceCheckResponseSchema,_.SourceDisconnectResponseSchema,_.SourceSubscribeResponseSchema,_.SourceTriggersResponseSchema,_.IngestionBackfillResponseSchema,_.IngestionApplyResponseSchema,_.IngestionCohortInspectResponseSchema,_.IngestionCohortCancelResponseSchema,_.IngestionRunsResponseSchema,_.IngestionFilterListResponseSchema,_.IngestionFilterCreateResponseSchema,_.IngestionFilterUpdateResponseSchema,_.IngestionFilterDeleteResponseSchema,q.LoopRunResponseSchema,q.LoopListResponseSchema,q.LoopInspectResponseSchema,q.LoopLogsResponseSchema,q.LoopStopResponseSchema,I.FleetListResponseSchema,I.FleetInspectResponseSchema,I.FleetRunNowResponseSchema,I.FleetPauseResponseSchema,I.FleetResumeResponseSchema,I.FleetSetModeResponseSchema,I.FleetAskResponseSchema,I.FleetDecisionsResponseSchema,I.FleetResolveDecisionResponseSchema,I.FleetSetParamsResponseSchema,I.FleetCreateResponseSchema,I.FleetExecutionsResponseSchema,wo,Ao,To,Do,Bo,Ho,Xo,$o,ea,Xi,Yi,Qi,Bl,Ul]),Hl=z.z.object({type:z.z.literal("ping")}),Kl=z.z.object({type:z.z.literal("pong")}),Vl=z.z.object({type:z.z.literal("hello"),clientId:z.z.string().min(1),clientType:z.z.enum(["mobile","browser","cli","mcp"]),protocolVersion:z.z.number().int(),appVersion:z.z.string().optional(),capabilities:z.z.object({voice:z.z.boolean().optional(),pushNotifications:z.z.boolean().optional(),[g.CLIENT_CAPS.reasoningMergeEnum]:z.z.boolean().optional(),[g.CLIENT_CAPS.customModeIcons]:z.z.boolean().optional(),[g.CLIENT_CAPS.terminalReflowableSnapshot]:z.z.boolean().optional(),[g.CLIENT_CAPS.browserHost]:O.BrowserAutomationHostCapabilitySchema.optional()}).passthrough().optional()}),Xl=z.z.object({type:z.z.literal("recording_state"),isRecording:z.z.boolean()}),Yl=z.z.object({type:z.z.literal("session"),message:ba}),Jl=z.z.object({type:z.z.literal("session"),message:Gl}),Ql=z.z.discriminatedUnion("type",[Hl,Vl,Xl,Yl]),$l=z.z.discriminatedUnion("type",[Kl,Jl]);const Zl=z.z.object({kind:z.z.literal("permission"),tool_name:z.z.string(),tool_input:z.z.unknown(),agent_id:z.z.string()}),ec=z.z.object({kind:z.z.literal("pre-tool"),tool_name:z.z.string(),tool_input:z.z.unknown(),agent_id:z.z.string()}),tc=z.z.object({kind:z.z.literal("post-tool"),tool_name:z.z.string(),tool_input:z.z.unknown(),tool_response:z.z.unknown(),agent_id:z.z.string()}),nc=z.z.object({kind:z.z.literal("status-line"),statusText:z.z.string(),agent_id:z.z.string()}),rc=z.z.object({kind:z.z.literal("session-start"),session_id:z.z.string(),transcript_path:z.z.string(),agent_id:z.z.string()}),oc=z.z.object({kind:z.z.literal("session-end"),session_id:z.z.string(),transcript_path:z.z.string(),agent_id:z.z.string()}),ac=z.z.object({kind:z.z.literal("assistant_message_delta"),delta:z.z.object({text:z.z.string()})}),ic=z.z.object({kind:z.z.literal("usage_update"),usage:z.z.object({input_tokens:z.z.number().optional(),output_tokens:z.z.number().optional(),cache_creation_input_tokens:z.z.number().optional(),cache_read_input_tokens:z.z.number().optional(),total_cost_usd:z.z.number().optional()})}),sc=z.z.discriminatedUnion("kind",[Zl,ec,tc,nc,rc,oc,ac,ic])},3284,[35,3285,3364,3283,3365,3366,3367,3368,3369,3370,3371,3373,3375,3377,3381,3382,3386,3387,3388]);
|
|
14930
14930
|
__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"z",{enumerable:!0,get:function(){return t}});var e=r(_d[0]);Object.keys(e).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(_e,t)||Object.defineProperty(_e,t,{enumerable:!0,get:function(){return e[t]}})});var t=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(n){var u=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,u.get?u:{enumerable:!0,get:function(){return e[n]}})}),t.default=e,t})(e),n=t},3285,[3286]);
|
|
@@ -15057,7 +15057,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
15057
15057
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"decodeOfferFragmentPayload",{enumerable:!0,get:function(){return n.decodeOfferFragmentPayload}}),Object.defineProperty(e,"buildDaemonWebSocketUrl",{enumerable:!0,get:function(){return t.buildDaemonWebSocketUrl}}),Object.defineProperty(e,"deriveLabelFromEndpoint",{enumerable:!0,get:function(){return t.deriveLabelFromEndpoint}}),Object.defineProperty(e,"extractHostPortFromWebSocketUrl",{enumerable:!0,get:function(){return t.extractHostPortFromWebSocketUrl}}),Object.defineProperty(e,"normalizeHostPort",{enumerable:!0,get:function(){return t.normalizeHostPort}}),Object.defineProperty(e,"parseConnectionUri",{enumerable:!0,get:function(){return t.parseConnectionUri}}),Object.defineProperty(e,"parseHostPort",{enumerable:!0,get:function(){return t.parseHostPort}}),Object.defineProperty(e,"serializeConnectionUri",{enumerable:!0,get:function(){return t.serializeConnectionUri}}),Object.defineProperty(e,"serializeConnectionUriForStorage",{enumerable:!0,get:function(){return t.serializeConnectionUriForStorage}}),Object.defineProperty(e,"shouldUseTlsForDefaultHostedRelay",{enumerable:!0,get:function(){return t.shouldUseTlsForDefaultHostedRelay}}),e.buildRelayWebSocketUrl=function(n){return(0,t.buildRelayWebSocketUrl)(Object.assign({},n,{role:"client"}))};var t=r(d[0]),n=r(d[1])},3412,[3392,3413]);
|
|
15058
15058
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ConnectionOfferV2Schema",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ConnectionOfferSchema",{enumerable:!0,get:function(){return o}}),e.decodeOfferFragmentPayload=l,e.parseConnectionOfferFromUrl=function(n){const t=f(n);if(!t)return null;const c=l(t);return o.parse(c)};var n=r(d[0]);const t=n.z.object({v:n.z.literal(2),serverId:n.z.string().min(1),daemonPublicKeyB64:n.z.string().min(1),relay:n.z.object({endpoint:n.z.string().min(1),useTls:n.z.boolean().optional()})}),o=t;function c(n){const t=n.replace(/-/g,"+").replace(/_/g,"/"),o=t.padEnd(t.length+(4-t.length%4)%4,"="),c=globalThis.atob(o),l=Uint8Array.from(c,n=>n.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!0}).decode(l)}function l(n){const t=c(n);return JSON.parse(t)}const u="#offer=";function f(n){const t=n.trim();if(!t)return null;const o=t.indexOf(u);if(-1===o)return null;const c=t.slice(o+u.length).trim();return c.length>0?c:null}},3413,[3285]);
|
|
15059
15059
|
__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.resolveAppVersion=function(){const e=u(t.default?.version);if(e)return e;const o=u(n.default.expoConfig?.version);if(o)return o;const f=u(n.default.manifest?.version);if(f)return f;return null};var n=e(r(d[0])),t=e(r(d[1]));function u(e){if("string"!=typeof e)return null;const n=e.trim();return 0===n.length?null:n}},3414,[718,3415]);
|
|
15060
|
-
__d(function(e,t,r,a,o,i,n){o.exports={name:"@hyperdrive.bot/fleet-app",version:"0.3.
|
|
15060
|
+
__d(function(e,t,r,a,o,i,n){o.exports={name:"@hyperdrive.bot/fleet-app",version:"0.3.155",private:!0,main:"index.ts",scripts:{start:"npm run start:expo","start:expo":"cross-env APP_VARIANT=development expo start","reset-project":"node ./scripts/reset-project.js","build:terminal-webview":"node ./scripts/build-terminal-webview-html.mjs","eas-build-post-install":"npm --prefix ../.. run build:app-deps && npm run build:terminal-webview",android:"npm run android:development","android:development":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=development expo prebuild --platform android --non-interactive && cross-env APP_VARIANT=development expo run:android --variant=debug","android:production":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=production expo prebuild --platform android --non-interactive && cross-env APP_VARIANT=production expo run:android --variant=release","android:release":"npm run android:production","android:clear":"node -e \"require('node:fs').rmSync('android', { recursive: true, force: true })\"",ios:"npm --prefix ../.. run build:client && expo run:ios","ios:release":"npm --prefix ../.. run build:client && expo run:ios --configuration Release",web:"npm --prefix ../.. run build:client && concurrently --kill-others --names protocol,client,expo --prefix-colors yellow,blue,magenta \"npm --prefix ../.. run watch:protocol\" \"npm --prefix ../.. run watch:client\" \"npm run web:expo\"","web:expo":"expo start --web",lint:"expo lint",typecheck:"tsgo --noEmit",test:"vitest run","test:browser":"vitest run --project browser","test:e2e":"playwright test --project='Desktop Chrome'","test:e2e:reels":"cross-env NODE_ENV=development playwright test --config playwright.reels.config.ts","test:e2e:real":"cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=real-provider","test:e2e:ui":"playwright test --ui","test:coverage":"vitest run --project unit --coverage",build:"npm run build:web","build:web":"npm --prefix ../.. run build:app-deps && expo export --platform web --source-maps","profile:workspace-tabs":"node ./scripts/profile-workspace-tabs.mjs","deploy:web":"npm run build:web && wrangler pages deploy dist --project-name paseo-app --branch main"},dependencies:{"@bacons/apple-targets":"4.0.6","@datadog/browser-rum":"^6.23.0","@datadog/browser-rum-react":"^6.23.0","@datadog/mobile-react-native":"^2.7.0","@datadog/mobile-react-native-session-replay":"^2.14.8","@dnd-kit/core":"^6.3.1","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@expo/image-utils":"0.8.8","@expo/plist":"0.4.9","@expo/prebuild-config":"54.0.8","@floating-ui/react-native":"^0.10.7","@gorhom/bottom-sheet":"^5.2.14","@gorhom/portal":"^1.0.14","@hyperdrive.bot/fleet-client":"*","@hyperdrive.bot/fleet-expo-two-way-audio":"*","@hyperdrive.bot/fleet-extension-sdk":"*","@hyperdrive.bot/fleet-highlight":"*","@react-native-async-storage/async-storage":"2.2.0","@react-native-masked-view/masked-view":"^0.3.2","@react-native/normalize-colors":"^0.81.5","@react-navigation/native":"^7.1.8","@sentry/electron":"^6.11.0","@sentry/react-native":"^6.20.0","@tanstack/react-query":"^5.90.11","@tanstack/react-virtual":"^3.13.21","@xterm/addon-clipboard":"^0.3.0-beta.213","@xterm/addon-fit":"^0.12.0-beta.213","@xterm/addon-image":"^0.10.0-beta.213","@xterm/addon-ligatures":"0.11.0-beta.213","@xterm/addon-search":"^0.17.0-beta.213","@xterm/addon-unicode11":"^0.10.0-beta.213","@xterm/addon-web-links":"^0.13.0-beta.213","@xterm/addon-webgl":"^0.20.0-beta.212","@xterm/xterm":"^6.1.0-beta.213",buffer:"^6.0.3",expo:"^54.0.18","expo-asset":"~12.0.12","expo-audio":"~1.0.13","expo-background-fetch":"~14.0.9","expo-build-properties":"^1.0.9","expo-camera":"~17.0.10","expo-clipboard":"~8.0.7","expo-constants":"~18.0.9","expo-crypto":"^15.0.8","expo-dev-client":"^6.0.15","expo-document-picker":"~14.0.8","expo-file-system":"~19.0.17","expo-haptics":"~15.0.7","expo-image":"~3.0.10","expo-image-manipulator":"~14.0.8","expo-image-picker":"^17.0.8","expo-keep-awake":"^15.0.7","expo-linking":"~8.0.8","expo-localization":"~17.0.9","expo-notifications":"^0.32.16","expo-router":"~6.0.13","expo-sharing":"^14.0.8","expo-speech":"~14.0.8","expo-speech-recognition":"^56.0.1","expo-splash-screen":"~31.0.10","expo-system-ui":"~6.0.7","expo-task-manager":"~14.0.9","expo-video":"~3.0.16","fast-deep-equal":"^3.1.3",htmlparser2:"^12.0.0",i18next:"^26.3.0","lucide-react-native":"^0.546.0","markdown-it":"^10.0.0","mnemonic-id":"^3.2.7","posthog-js":"^1.431.2","posthog-react-native":"^4.72.0",qrcode:"^1.5.4",react:"19.1.0","react-dom":"19.1.0","react-i18next":"^17.0.8","react-native":"0.81.5","react-native-draggable-flatlist":"^4.0.3","react-native-edge-to-edge":"^1.7.0","react-native-gesture-handler":"~2.28.0","react-native-keyboard-controller":"^1.21.7","react-native-markdown-display":"^7.0.2","react-native-nitro-modules":"0.35.5","react-native-reanimated":"~4.3.1","react-native-safe-area-context":"~5.6.0","react-native-screens":"~4.16.0","react-native-svg":"^15.14.0","react-native-uitextview":"^2.2.0","react-native-unistyles":"^3.2.4","react-native-web":"~0.21.0","react-native-webview":"^13.16.0","react-native-worklets":"~0.8.3","tiny-invariant":"^1.3.3","use-sync-external-store":"^1.6.0",zod:"^4.4.3",zustand:"^5.0.9"},devDependencies:{"@playwright/test":"^1.56.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2","@types/chai":"^5.2.2","@types/markdown-it":"^14.1.2","@types/qrcode":"^1.5.6","@types/react":"~19.2.0","@types/ws":"^8.18.1","@vitest/browser":"^4.1.7","@vitest/browser-playwright":"^4.1.7","@vitest/coverage-v8":"^4.1.7","@xterm/headless":"^6.1.0-beta.213",dotenv:"^17.2.3",eslint:"^9.25.0","eslint-config-expo":"~10.0.0",jsdom:"^20.0.3","material-icon-theme":"^5.32.0",playwright:"^1.56.1","serve-sim":"^0.1.40",typescript:"~5.9.2",vitest:"^4.1.6",wrangler:"^4.105.0",ws:"^8.20.0"}}},3415,[]);
|
|
15061
15061
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shouldUseDesktopDaemon=function(){return(0,n.isElectronRuntime)()},e.getDesktopDaemonStatus=async function(){return c(await(0,t.invokeDesktopCommand)("desktop_daemon_status"))},e.startDesktopDaemon=async function(){return c(await(0,t.invokeDesktopCommand)("start_desktop_daemon"))},e.stopDesktopDaemon=async function(n="manual_ipc"){return c(await(0,t.invokeDesktopCommand)("stop_desktop_daemon",{reason:n}))},e.restartDesktopDaemon=async function(){return c(await(0,t.invokeDesktopCommand)("restart_desktop_daemon"))},e.getDesktopDaemonLogs=async function(){return p(await(0,t.invokeDesktopCommand)("desktop_daemon_logs"))},e.getDesktopDaemonPairing=async function(){return k(await(0,t.invokeDesktopCommand)("desktop_daemon_pairing"))},e.getCliDaemonStatus=async function(){const n=await(0,t.invokeDesktopCommand)("cli_daemon_status");if("string"!=typeof n)throw new Error("Unexpected CLI daemon status response.");return n},e.listenToLocalTransportEvents=async function(t){const u=(0,n.getDesktopHost)()?.events?.on;if("function"!=typeof u)throw new Error("Desktop events API is unavailable.");const c=await u("local-daemon-transport-event",n=>{o(n)&&t({sessionId:s(n.sessionId)??"",kind:s(n.kind)??"error",text:s(n.text),binaryBase64:s(n.binaryBase64),code:l(n.code),reason:s(n.reason),error:s(n.error)})});return"function"==typeof c?c:()=>{}},e.openLocalTransportSession=async function(n){const o=await(0,t.invokeDesktopCommand)("open_local_daemon_transport",n);if("string"!=typeof o||0===o.trim().length)throw new Error("Unexpected local transport session response.");return o},e.sendLocalTransportMessage=async function(n){await(0,t.invokeDesktopCommand)("send_local_daemon_transport_message",Object.assign({sessionId:n.sessionId},n.text?{text:n.text}:{},n.binaryBase64?{binaryBase64:n.binaryBase64}:{}))},e.closeLocalTransportSession=async function(n){await(0,t.invokeDesktopCommand)("close_local_daemon_transport",{sessionId:n})},e.getCliInstallStatus=async function(){return f(await(0,t.invokeDesktopCommand)("get_cli_install_status"))},e.installCli=async function(){return f(await(0,t.invokeDesktopCommand)("install_cli"))},e.getSkillsStatus=async function(){return y(await(0,t.invokeDesktopCommand)("get_skills_status"))},e.installSkills=async function(){return y(await(0,t.invokeDesktopCommand)("install_skills"))},e.updateSkills=async function(){return y(await(0,t.invokeDesktopCommand)("update_skills"))},e.uninstallSkills=async function(){return y(await(0,t.invokeDesktopCommand)("uninstall_skills"))};var n=r(d[0]),t=r(d[1]);function o(n){return"object"==typeof n&&null!==n}function s(n){return"string"==typeof n&&n.trim().length>0?n:null}function l(n){return"number"==typeof n&&Number.isFinite(n)?n:null}function u(n){const t=s(n)?.toLowerCase();switch(t){case"starting":return"starting";case"running":return"running";case"errored":case"error":return"errored";default:return"stopped"}}function c(n){if(!o(n))throw new Error("Unexpected desktop daemon status response.");return{serverId:s(n.serverId)??"",status:u(n.status),listen:s(n.listen),hostname:s(n.hostname),pid:l(n.pid),home:s(n.home)??"",version:s(n.version),desktopManaged:!0===n.desktopManaged,error:s(n.error)}}function p(n){if(!o(n))throw new Error("Unexpected desktop daemon logs response.");return{logPath:s(n.logPath)??"",contents:"string"==typeof n.contents?n.contents:""}}function k(n){if(!o(n))throw new Error("Unexpected desktop daemon pairing response.");return{relayEnabled:!0===n.relayEnabled,url:s(n.url),qr:s(n.qr)}}function f(n){if(!o(n))throw new Error("Unexpected install status response.");return{installed:!0===n.installed}}function w(n){switch(n){case"not-installed":case"up-to-date":case"drift":return n;default:throw new Error(`Unexpected skills status state: ${String(n)}`)}}function _(n){if(!o(n))throw new Error("Unexpected skill op response.");const t=s(n.name);if(!t)throw new Error("Skill op missing name.");switch(n.kind){case"add":return{kind:"add",name:t};case"update":return{kind:"update",name:t};case"delete":return{kind:"delete",name:t};default:throw new Error(`Unexpected skill op kind: ${String(n.kind)}`)}}function y(n){if(!o(n))throw new Error("Unexpected skills status response.");const t=Array.isArray(n.ops)?n.ops.map(_):[];return{state:w(n.state),ops:t}}},3416,[3417,3419]);
|
|
15062
15062
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getDesktopHost=n,e.isElectronRuntime=o,e.isElectronRuntimeMac=function(){if(!o())return!1;if("undefined"==typeof navigator)return!1;const t=n()?.platform?.toLowerCase();if("darwin"===t||"mac"===t||"macos"===t)return!0;const u=navigator.userAgent;return u.includes("Mac OS")||u.includes("Macintosh")},r(d[0]);var t=r(d[1]);function n(){return(0,t.getElectronHost)()}function o(){return null!==n()}},3417,[25,3418]);
|
|
15063
15063
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getElectronHost=function(){if("undefined"==typeof window)return null;const t=window.paseoDesktop;if(!t||"object"!=typeof t)return null;return t}},3418,[]);
|
|
@@ -15141,7 +15141,7 @@ __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{
|
|
|
15141
15141
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_BINDINGS",{enumerable:!0,get:function(){return l}}),e.buildEffectiveBindings=function(o){return l.map(function(n){const s=o[n.id];if(void 0===s)return n;let c;try{c=(0,t.parseChordString)(s)}catch{return n}const l=c.at(-1);return!1===n.repeat&&l&&(l.repeat=!1),Object.assign({},n,{combo:s,parsedChord:c})})},e.resolveKeyboardShortcut=function(t){const{event:o,context:n,chordState:s,onChordReset:c,bindings:p=l}=t;if(0===s.step)return x({event:o,context:n,chordState:s,onChordReset:c,bindings:p});return T({event:o,context:n,chordState:s,onChordReset:c,bindings:p})},e.getBindingIdForAction=function(t,o){for(const n of l)if(n.help?.id===t&&C(n.when,o))return n.id;return null},e.getDefaultKeysForAction=function(t,o){for(const n of l)if(n.help?.id===t&&C(n.when,o))return n.help.keys;return null},e.getWorkspaceIndexJumpModifierKey=function(t){return t.isDesktop?t.isMac?"Meta":"Control":"Alt"},e.buildKeyboardShortcutHelpSections=function(t,p=l){const h=new Set,u=new Map([["navigation",[]],["tabs-panes",[]],["projects",[]],["panels",[]],["agent-input",[]]]);for(const o of p){const n=o.help;if(!n)continue;if(!C(o.when,t))continue;const l=`${n.section}:${n.id}`;if(h.has(l))continue;h.add(l);const p=u.get(n.section);p&&p.push(Object.assign({id:n.id,label:n.label,labelKey:s[n.id]??n.label,keys:n.keys},n.note?{note:n.note}:{},c[n.id]?{noteKey:c[n.id]}:{}))}return["navigation","tabs-panes","projects","panels","agent-input"].flatMap(t=>{const s=u.get(t)??[];return 0===s.length?[]:[{id:t,title:o[t],titleKey:n[t],rows:s}]})};var t=r(d[0]);const o={navigation:"Navigation","tabs-panes":"Tabs & Panes",projects:"Projects",panels:"Panels","agent-input":"Agent Input"},n={navigation:"settings.shortcuts.sections.navigation","tabs-panes":"settings.shortcuts.sections.tabsPanes",projects:"settings.shortcuts.sections.projects",panels:"settings.shortcuts.sections.panels","agent-input":"settings.shortcuts.sections.agentInput"},s={"new-agent":"settings.shortcuts.help.openProject","new-workspace":"settings.shortcuts.help.newWorkspace","archive-worktree":"settings.shortcuts.help.archiveWorktree","workspace-tab-new":"settings.shortcuts.help.newTab","workspace-tab-close-current":"settings.shortcuts.help.closeCurrentTab","workspace-jump-index":"settings.shortcuts.help.jumpToWorkspace","workspace-tab-jump-index":"settings.shortcuts.help.jumpToTab","workspace-prev":"settings.shortcuts.help.previousWorkspace","workspace-next":"settings.shortcuts.help.nextWorkspace","workspace-tab-prev":"settings.shortcuts.help.previousTab","workspace-tab-next":"settings.shortcuts.help.nextTab","workspace-pane-split-right":"settings.shortcuts.help.splitPaneRight","workspace-pane-split-down":"settings.shortcuts.help.splitPaneDown","workspace-pane-focus-left":"settings.shortcuts.help.focusPaneLeft","workspace-pane-focus-right":"settings.shortcuts.help.focusPaneRight","workspace-pane-focus-up":"settings.shortcuts.help.focusPaneUp","workspace-pane-focus-down":"settings.shortcuts.help.focusPaneDown","workspace-pane-move-tab-left":"settings.shortcuts.help.moveTabLeft","workspace-pane-move-tab-right":"settings.shortcuts.help.moveTabRight","workspace-pane-move-tab-up":"settings.shortcuts.help.moveTabUp","workspace-pane-move-tab-down":"settings.shortcuts.help.moveTabDown","workspace-pane-close":"settings.shortcuts.help.closePane","workspace-terminal-new":"settings.shortcuts.help.newTerminal","toggle-command-center":"settings.shortcuts.help.toggleCommandCenter","show-shortcuts":"settings.shortcuts.help.showKeyboardShortcuts","toggle-left-sidebar":"settings.shortcuts.help.toggleLeftSidebar","toggle-right-sidebar":"settings.shortcuts.help.toggleRightSidebar","toggle-both-sidebars":"settings.shortcuts.help.toggleBothSidebars","toggle-settings":"settings.shortcuts.help.toggleSettings","toggle-focus":"settings.shortcuts.help.toggleFocusMode","cycle-theme":"settings.shortcuts.help.cycleTheme","focus-message-input":"settings.shortcuts.help.focusMessageInput","cycle-agent-mode":"settings.shortcuts.help.cycleAgentMode","voice-toggle":"settings.shortcuts.help.toggleVoiceMode","dictation-toggle":"settings.shortcuts.help.startStopDictation","agent-interrupt":"settings.shortcuts.help.interruptAgent","voice-mute-toggle":"settings.shortcuts.help.muteUnmuteVoiceMode"},c={"show-shortcuts":"settings.shortcuts.helpNotes.showKeyboardShortcuts"};const l=[{id:"agent-new-cmd-shift-o-mac",action:"agent.new",combo:"Cmd+O",when:{mac:!0},help:{id:"new-agent",section:"projects",label:"Open project",keys:["mod","O"]}},{id:"agent-new-ctrl-shift-o-non-mac",action:"agent.new",combo:"Ctrl+O",when:{mac:!1,terminal:!1},help:{id:"new-agent",section:"projects",label:"Open project",keys:["mod","O"]}},{id:"workspace-new-cmd-n-mac",action:"workspace.new",combo:"Cmd+N",when:{mac:!0,commandCenter:!1},help:{id:"new-workspace",section:"projects",label:"New workspace",keys:["mod","N"]}},{id:"workspace-new-ctrl-n-non-mac",action:"workspace.new",combo:"Ctrl+N",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"new-workspace",section:"projects",label:"New workspace",keys:["mod","N"]}},{id:"worktree-archive-cmd-shift-backspace-mac",action:"worktree.archive",combo:"Cmd+Shift+Backspace",when:{mac:!0,commandCenter:!1},help:{id:"archive-worktree",section:"projects",label:"Archive worktree",keys:["mod","shift","Backspace"]}},{id:"worktree-archive-ctrl-shift-backspace-non-mac",action:"worktree.archive",combo:"Ctrl+Shift+Backspace",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"archive-worktree",section:"projects",label:"Archive worktree",keys:["mod","shift","Backspace"]}},{id:"workspace-tab-new-cmd-t-mac",action:"workspace.tab.new",combo:"Cmd+T",when:{mac:!0,commandCenter:!1},help:{id:"workspace-tab-new",section:"tabs-panes",label:"New tab",keys:["mod","T"]}},{id:"workspace-tab-new-ctrl-t-non-mac",action:"workspace.tab.new",combo:"Ctrl+T",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"workspace-tab-new",section:"tabs-panes",label:"New tab",keys:["mod","T"]}},{id:"workspace-tab-close-current-cmd-w-mac",action:"workspace.tab.close.current",combo:"Cmd+W",when:{mac:!0,desktop:!0,commandCenter:!1},help:{id:"workspace-tab-close-current",section:"tabs-panes",label:"Close current tab",keys:["meta","W"]}},{id:"workspace-tab-close-current-ctrl-w-non-mac",action:"workspace.tab.close.current",combo:"Ctrl+W",when:{mac:!1,desktop:!0,commandCenter:!1,terminal:!1},help:{id:"workspace-tab-close-current",section:"tabs-panes",label:"Close current tab",keys:["ctrl","W"]}},{id:"workspace-tab-close-current-alt-shift-w-web",action:"workspace.tab.close.current",combo:"Alt+Shift+W",when:{desktop:!1,commandCenter:!1},help:{id:"workspace-tab-close-current",section:"tabs-panes",label:"Close current tab",keys:["alt","shift","W"]}},{id:"workspace-navigate-index-cmd-digit-mac",action:"workspace.navigate.index",combo:"Cmd+Digit",when:{mac:!0,desktop:!0,commandCenter:!1},payload:{type:"index"},help:{id:"workspace-jump-index",section:"navigation",label:"Jump to workspace",keys:["mod","1-9"]}},{id:"workspace-navigate-index-ctrl-digit-non-mac",action:"workspace.navigate.index",combo:"Ctrl+Digit",when:{mac:!1,desktop:!0,commandCenter:!1,terminal:!1},payload:{type:"index"},help:{id:"workspace-jump-index",section:"navigation",label:"Jump to workspace",keys:["mod","1-9"]}},{id:"workspace-navigate-index-alt-digit-web",action:"workspace.navigate.index",combo:"Alt+Digit",when:{desktop:!1,commandCenter:!1},payload:{type:"index"},help:{id:"workspace-jump-index",section:"navigation",label:"Jump to workspace",keys:["alt","1-9"]}},{id:"workspace-tab-navigate-index-cmd-alt-digit-mac-desktop",action:"workspace.tab.navigate.index",combo:"Cmd+Alt+Digit",when:{mac:!0,desktop:!0,commandCenter:!1},payload:{type:"index"},help:{id:"workspace-tab-jump-index",section:"navigation",label:"Jump to tab",keys:["mod","alt","1-9"]}},{id:"workspace-tab-navigate-index-alt-digit-desktop",action:"workspace.tab.navigate.index",combo:"Alt+Digit",when:{mac:!1,desktop:!0,commandCenter:!1},payload:{type:"index"},help:{id:"workspace-tab-jump-index",section:"navigation",label:"Jump to tab",keys:["alt","1-9"]}},{id:"workspace-tab-navigate-index-alt-shift-digit-web",action:"workspace.tab.navigate.index",combo:"Alt+Shift+Digit",when:{desktop:!1,commandCenter:!1},payload:{type:"index"},help:{id:"workspace-tab-jump-index",section:"navigation",label:"Jump to tab",keys:["alt","shift","1-9"]}},{id:"workspace-navigate-relative-cmd-left-mac",action:"workspace.navigate.relative",combo:"Cmd+[",when:{mac:!0,desktop:!0,commandCenter:!1},payload:{type:"delta",delta:-1},help:{id:"workspace-prev",section:"navigation",label:"Previous workspace",keys:["mod","["]}},{id:"workspace-navigate-relative-ctrl-left-non-mac",action:"workspace.navigate.relative",combo:"Ctrl+[",when:{mac:!1,desktop:!0,commandCenter:!1,terminal:!1},payload:{type:"delta",delta:-1},help:{id:"workspace-prev",section:"navigation",label:"Previous workspace",keys:["mod","["]}},{id:"workspace-navigate-relative-cmd-right-mac",action:"workspace.navigate.relative",combo:"Cmd+]",when:{mac:!0,desktop:!0,commandCenter:!1},payload:{type:"delta",delta:1},help:{id:"workspace-next",section:"navigation",label:"Next workspace",keys:["mod","]"]}},{id:"workspace-navigate-relative-ctrl-right-non-mac",action:"workspace.navigate.relative",combo:"Ctrl+]",when:{mac:!1,desktop:!0,commandCenter:!1,terminal:!1},payload:{type:"delta",delta:1},help:{id:"workspace-next",section:"navigation",label:"Next workspace",keys:["mod","]"]}},{id:"workspace-navigate-relative-alt-left-web",action:"workspace.navigate.relative",combo:"Alt+[",when:{desktop:!1,commandCenter:!1},payload:{type:"delta",delta:-1},help:{id:"workspace-prev",section:"navigation",label:"Previous workspace",keys:["alt","["]}},{id:"workspace-navigate-relative-alt-right-web",action:"workspace.navigate.relative",combo:"Alt+]",when:{desktop:!1,commandCenter:!1},payload:{type:"delta",delta:1},help:{id:"workspace-next",section:"navigation",label:"Next workspace",keys:["alt","]"]}},{id:"workspace-tab-navigate-relative-alt-shift-left",action:"workspace.tab.navigate.relative",combo:"Alt+Shift+[",when:{commandCenter:!1},payload:{type:"delta",delta:-1},help:{id:"workspace-tab-prev",section:"navigation",label:"Previous tab",keys:["alt","shift","["]}},{id:"workspace-tab-navigate-relative-alt-shift-right",action:"workspace.tab.navigate.relative",combo:"Alt+Shift+]",when:{commandCenter:!1},payload:{type:"delta",delta:1},help:{id:"workspace-tab-next",section:"navigation",label:"Next tab",keys:["alt","shift","]"]}},{id:"workspace-pane-split-right-cmd-backslash",action:"workspace.pane.split.right",combo:"Cmd+\\",when:{mac:!0,commandCenter:!1},help:{id:"workspace-pane-split-right",section:"tabs-panes",label:"Split pane right",keys:["mod","\\"]}},{id:"workspace-pane-split-down-cmd-shift-backslash",action:"workspace.pane.split.down",combo:"Cmd+Shift+\\",when:{mac:!0,commandCenter:!1},help:{id:"workspace-pane-split-down",section:"tabs-panes",label:"Split pane down",keys:["mod","shift","\\"]}},{id:"workspace-pane-focus-left-cmd-shift-left",action:"workspace.pane.focus.left",combo:"Cmd+Shift+ArrowLeft",when:{mac:!0,commandCenter:!1,editable:!1},help:{id:"workspace-pane-focus-left",section:"tabs-panes",label:"Focus pane left",keys:["mod","shift","Left"]}},{id:"workspace-pane-focus-right-cmd-shift-right",action:"workspace.pane.focus.right",combo:"Cmd+Shift+ArrowRight",when:{mac:!0,commandCenter:!1,editable:!1},help:{id:"workspace-pane-focus-right",section:"tabs-panes",label:"Focus pane right",keys:["mod","shift","Right"]}},{id:"workspace-pane-focus-up-cmd-shift-up",action:"workspace.pane.focus.up",combo:"Cmd+Shift+ArrowUp",when:{mac:!0,commandCenter:!1,editable:!1},help:{id:"workspace-pane-focus-up",section:"tabs-panes",label:"Focus pane up",keys:["mod","shift","Up"]}},{id:"workspace-pane-focus-down-cmd-shift-down",action:"workspace.pane.focus.down",combo:"Cmd+Shift+ArrowDown",when:{mac:!0,commandCenter:!1,editable:!1},help:{id:"workspace-pane-focus-down",section:"tabs-panes",label:"Focus pane down",keys:["mod","shift","Down"]}},{id:"workspace-pane-move-tab-left-cmd-shift-alt-left",action:"workspace.pane.move-tab.left",combo:"Cmd+Alt+Shift+ArrowLeft",when:{mac:!0,commandCenter:!1},help:{id:"workspace-pane-move-tab-left",section:"tabs-panes",label:"Move tab left",keys:["mod","shift","alt","Left"]}},{id:"workspace-pane-move-tab-right-cmd-shift-alt-right",action:"workspace.pane.move-tab.right",combo:"Cmd+Alt+Shift+ArrowRight",when:{mac:!0,commandCenter:!1},help:{id:"workspace-pane-move-tab-right",section:"tabs-panes",label:"Move tab right",keys:["mod","shift","alt","Right"]}},{id:"workspace-pane-move-tab-up-cmd-shift-alt-up",action:"workspace.pane.move-tab.up",combo:"Cmd+Alt+Shift+ArrowUp",when:{mac:!0,commandCenter:!1},help:{id:"workspace-pane-move-tab-up",section:"tabs-panes",label:"Move tab up",keys:["mod","shift","alt","Up"]}},{id:"workspace-pane-move-tab-down-cmd-shift-alt-down",action:"workspace.pane.move-tab.down",combo:"Cmd+Alt+Shift+ArrowDown",when:{mac:!0,commandCenter:!1},help:{id:"workspace-pane-move-tab-down",section:"tabs-panes",label:"Move tab down",keys:["mod","shift","alt","Down"]}},{id:"workspace-pane-close-cmd-shift-w",action:"workspace.pane.close",combo:"Cmd+Shift+W",when:{mac:!0,commandCenter:!1},help:{id:"workspace-pane-close",section:"tabs-panes",label:"Close pane",keys:["mod","shift","W"]}},{id:"workspace-terminal-new-cmd-shift-t-mac",action:"workspace.terminal.new",combo:"Cmd+Shift+T",when:{mac:!0,commandCenter:!1},help:{id:"workspace-terminal-new",section:"panels",label:"New terminal",keys:["mod","shift","T"]}},{id:"workspace-terminal-new-ctrl-shift-t-non-mac",action:"workspace.terminal.new",combo:"Ctrl+Shift+T",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"workspace-terminal-new",section:"panels",label:"New terminal",keys:["mod","shift","T"]}},{id:"command-center-toggle-cmd-k-mac",action:"command-center.toggle",combo:"Cmd+K",when:{mac:!0},help:{id:"toggle-command-center",section:"panels",label:"Toggle command center",keys:["mod","K"]}},{id:"command-center-toggle-ctrl-k-non-mac",action:"command-center.toggle",combo:"Ctrl+K",when:{mac:!1,terminal:!1},help:{id:"toggle-command-center",section:"panels",label:"Toggle command center",keys:["mod","K"]}},{id:"shortcuts-dialog-toggle-question-mark",action:"shortcuts.dialog.toggle",combo:"Shift+?",repeat:!1,when:{focusScope:"other"},help:{id:"show-shortcuts",section:"panels",label:"Show keyboard shortcuts",keys:["?"],note:"Available when focus is not in a text field or terminal."}},{id:"sidebar-toggle-left-mac-cmd-b",action:"sidebar.toggle.left",combo:"Cmd+B",when:{mac:!0},help:{id:"toggle-left-sidebar",section:"panels",label:"Toggle left sidebar",keys:["mod","B"]}},{id:"sidebar-toggle-left-ctrl-period-non-mac",action:"sidebar.toggle.left",combo:"Ctrl+B",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"toggle-left-sidebar",section:"panels",label:"Toggle left sidebar",keys:["mod","B"]}},{id:"sidebar-toggle-right-cmd-e-mac",action:"sidebar.toggle.right",combo:"Cmd+E",when:{mac:!0,commandCenter:!1},help:{id:"toggle-right-sidebar",section:"panels",label:"Toggle right sidebar",keys:["mod","E"]}},{id:"sidebar-toggle-right-ctrl-e-non-mac",action:"sidebar.toggle.right",combo:"Ctrl+E",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"toggle-right-sidebar",section:"panels",label:"Toggle right sidebar",keys:["mod","E"]}},{id:"sidebar-toggle-right-ctrl-backquote",action:"sidebar.toggle.right",combo:"Ctrl+`",when:{commandCenter:!1}},{id:"sidebar-toggle-both-cmd-period-mac",action:"sidebar.toggle.both",combo:"Cmd+.",when:{mac:!0,commandCenter:!1},help:{id:"toggle-both-sidebars",section:"panels",label:"Toggle both sidebars",keys:["mod","."]}},{id:"sidebar-toggle-both-ctrl-period-non-mac",action:"sidebar.toggle.both",combo:"Ctrl+.",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"toggle-both-sidebars",section:"panels",label:"Toggle both sidebars",keys:["mod","."]}},{id:"settings-toggle-cmd-comma-mac",action:"settings.toggle",combo:"Cmd+,",when:{mac:!0,commandCenter:!1},help:{id:"toggle-settings",section:"panels",label:"Toggle settings",keys:["mod",","]}},{id:"settings-toggle-ctrl-comma-non-mac",action:"settings.toggle",combo:"Ctrl+,",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"toggle-settings",section:"panels",label:"Toggle settings",keys:["mod",","]}},{id:"view-toggle-focus-cmd-shift-f-mac",action:"view.toggle.focus",combo:"Cmd+Shift+F",when:{mac:!0,commandCenter:!1},help:{id:"toggle-focus",section:"panels",label:"Toggle focus mode",keys:["mod","shift","F"]}},{id:"view-toggle-focus-ctrl-shift-f-non-mac",action:"view.toggle.focus",combo:"Ctrl+Shift+F",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"toggle-focus",section:"panels",label:"Toggle focus mode",keys:["mod","shift","F"]}},{id:"theme-cycle-cmd-shift-t-mac",action:"theme.cycle",combo:"Cmd+Alt+T",when:{mac:!0,commandCenter:!1},help:{id:"cycle-theme",section:"panels",label:"Cycle theme",keys:["mod","alt","T"]}},{id:"theme-cycle-ctrl-alt-t-non-mac",action:"theme.cycle",combo:"Ctrl+Alt+T",when:{mac:!1,commandCenter:!1,terminal:!1},help:{id:"cycle-theme",section:"panels",label:"Cycle theme",keys:["mod","alt","T"]}},{id:"message-input-focus-cmd-l-mac",action:"message-input.action",combo:"Cmd+L",when:{mac:!0,commandCenter:!1},payload:{type:"message-input",kind:"focus"},help:{id:"focus-message-input",section:"agent-input",label:"Focus message input",keys:["mod","L"]}},{id:"message-input-focus-ctrl-l-non-mac",action:"message-input.action",combo:"Ctrl+L",when:{mac:!1,commandCenter:!1,terminal:!1},payload:{type:"message-input",kind:"focus"},help:{id:"focus-message-input",section:"agent-input",label:"Focus message input",keys:["mod","L"]}},{id:"message-input-mode-cycle-shift-tab",action:"message-input.action",combo:"Shift+Tab",repeat:!1,when:{commandCenter:!1,focusScope:"message-input"},payload:{type:"message-input",kind:"mode-cycle"},help:{id:"cycle-agent-mode",section:"agent-input",label:"Cycle agent mode",keys:["shift","Tab"]}},{id:"message-input-voice-toggle-cmd-shift-d-mac",action:"message-input.action",combo:"Cmd+Shift+D",repeat:!1,when:{mac:!0,commandCenter:!1,terminal:!1},payload:{type:"message-input",kind:"voice-toggle"},help:{id:"voice-toggle",section:"agent-input",label:"Toggle voice mode",keys:["mod","shift","D"]}},{id:"message-input-voice-toggle-ctrl-shift-d-non-mac",action:"message-input.action",combo:"Ctrl+Shift+D",repeat:!1,when:{mac:!1,commandCenter:!1,terminal:!1},payload:{type:"message-input",kind:"voice-toggle"},help:{id:"voice-toggle",section:"agent-input",label:"Toggle voice mode",keys:["mod","shift","D"]}},{id:"message-input-dictation-toggle-cmd-d-mac",action:"message-input.action",combo:"Cmd+D",when:{mac:!0,commandCenter:!1,terminal:!1},payload:{type:"message-input",kind:"dictation-toggle"},help:{id:"dictation-toggle",section:"agent-input",label:"Start/stop dictation",keys:["mod","D"]}},{id:"message-input-dictation-toggle-ctrl-d-non-mac",action:"message-input.action",combo:"Ctrl+D",when:{mac:!1,commandCenter:!1,terminal:!1},payload:{type:"message-input",kind:"dictation-toggle"},help:{id:"dictation-toggle",section:"agent-input",label:"Start/stop dictation",keys:["mod","D"]}},{id:"agent-interrupt",action:"agent.interrupt",combo:"Escape",when:{commandCenter:!1,terminal:!1},preventDefault:!1,stopPropagation:!1,help:{id:"agent-interrupt",section:"agent-input",label:"Interrupt agent",keys:["Esc"]}},{id:"message-input-dictation-confirm-enter",action:"message-input.action",combo:"Enter",when:{commandCenter:!1,terminal:!1},payload:{type:"message-input",kind:"dictation-confirm"}},{id:"message-input-voice-mute-toggle",action:"message-input.action",combo:"Space",repeat:!1,when:{commandCenter:!1,focusScope:"other"},payload:{type:"message-input",kind:"voice-mute-toggle"},help:{id:"voice-mute-toggle",section:"agent-input",label:"Mute/unmute voice mode",keys:["Space"]}}].map(function(o){const n=(0,t.parseChordString)(o.combo),s=n.at(-1);return!1===o.repeat&&s&&(s.repeat=!1),Object.assign({},o,{parsedChord:n})});function p(t){const o=t.code??"";if(o.startsWith("Digit")){const t=Number(o.slice(5));return Number.isFinite(t)&&t>=1&&t<=9?t:null}if(o.startsWith("Numpad")){const t=Number(o.slice(6));return Number.isFinite(t)&&t>=1&&t<=9?t:null}const n=t.key??"";return n>="1"&&n<="9"?Number(n):null}function h(t,o){if(void 0===t.key)return o.code===t.code;const n=o.key.toLowerCase();return n===t.key||(!0===t.shift&&void 0!==t.shiftedKey&&n===t.shiftedKey||(!0===t.alt&&o.code===t.code||!0===t.codeFallback&&o.code===t.code))}function u(t,o,n){if(t.mod)if(n){if(!o.metaKey)return!1;if(!!t.ctrl!==o.ctrlKey)return!1}else{if(!o.ctrlKey)return!1;if(!!t.meta!==o.metaKey)return!1}else{if(!!t.meta!==o.metaKey)return!1;if(!!t.ctrl!==o.ctrlKey)return!1}return!!t.alt===o.altKey&&(!!t.shift===o.shiftKey&&((!1!==t.repeat||!o.repeat)&&("Digit"===t.code?null!==p(o):h(t,o))))}function b(t,o){return!t||(void 0===t.mac||t.mac===o.isMac)&&((void 0===t.desktop||t.desktop===o.isDesktop)&&((!1!==t.editable||"message-input"!==o.focusScope&&"editable"!==o.focusScope)&&((!1!==t.terminal||"terminal"!==o.focusScope)&&((!1!==t.commandCenter||!o.commandCenterOpen)&&(void 0===t.focusScope||o.focusScope===t.focusScope)))))}function w(t,o){if(!t)return null;switch(t.type){case"index":{const t=p(o);return t?{index:t}:null}case"delta":return{delta:t.delta};case"message-input":return{kind:t.kind};default:throw new Error("unreachable")}}const k=1500;function f(t){null!==t&&clearTimeout(t)}function y(t){return setTimeout(t,k)}function v(t){return f(t.timeoutId),{candidateIndices:[],step:0,timeoutId:null}}function C(t,o){return(void 0===t?.mac||t.mac===o.isMac)&&(void 0===t?.desktop||t.desktop===o.isDesktop)}function S(t,o){return{action:t.action,payload:w(t.payload,o),preventDefault:t.preventDefault??!0,stopPropagation:t.stopPropagation??!0}}function x(t){const{event:o,context:n,chordState:s,onChordReset:c,bindings:l}=t,p=[];let h=null;for(const[t,s]of l.entries()){const c=s.parsedChord[0];c&&(u(c,o,n.isMac)&&b(s.when,n)&&(s.parsedChord.length>1?p.push(t):h||(h=S(s,o))))}return p.length>0?{match:null,nextChordState:{candidateIndices:p,step:1,timeoutId:y(c)},preventDefault:!0}:{match:h,nextChordState:v(s),preventDefault:!1}}function T(t){const{event:o,context:n,chordState:s,onChordReset:c,bindings:l}=t,p=[];let h=null;for(const t of s.candidateIndices){const c=l[t];if(!c)continue;const w=c.parsedChord[s.step];if(w&&(u(w,o,n.isMac)&&b(c.when,n))){if(s.step+1===c.parsedChord.length){h=S(c,o);break}p.push(t)}}return h?{match:h,nextChordState:v(s),preventDefault:!1}:p.length>0?(f(s.timeoutId),{match:null,nextChordState:{candidateIndices:p,step:s.step+1,timeoutId:y(c)},preventDefault:!0}):{match:null,nextChordState:v(s),preventDefault:!1}}},3496,[3495]);
|
|
15142
15142
|
__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useKeyboardShortcutOverrides=function(){const e=(0,s.useQueryClient)(),{data:o,isPending:f}=(0,s.useQuery)({queryKey:c,queryFn:y,staleTime:1/0,gcTime:1/0}),v=(0,r.useCallback)(async(t,r)=>{const s=e.getQueryData(c)??l,u=Object.assign({},s,{[t]:r});e.setQueryData(c,u),await i.default.setItem(n,JSON.stringify(u))},[e]),b=(0,r.useCallback)(async r=>{const s=e.getQueryData(c)??l,o=(0,t.default)(s,[r].map(u));e.setQueryData(c,o),await i.default.setItem(n,JSON.stringify(o))},[e]),O=(0,r.useCallback)(async()=>{e.setQueryData(c,l),await i.default.removeItem(n)},[e]),p=o??l;return{overrides:p,isLoading:f,setOverride:v,removeOverride:b,resetAll:O,hasOverrides:Object.keys(p).length>0}};var t=e(_r(d[0])),r=_r(d[1]),i=e(_r(d[2])),s=_r(d[3]);function u(e){var t=o(e,"string");return"symbol"==typeof t?t:t+""}function o(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}const n="@paseo:keyboard-shortcut-overrides",c=["keyboard-shortcut-overrides"],l={};async function y(){try{const e=await i.default.getItem(n);if(e)return JSON.parse(e)}catch(e){console.error("[KeyboardShortcutOverrides] Failed to load overrides:",e)}return l}},3497,[35,36,3275,3030]);
|
|
15143
15143
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getShortcutOs=function(){if(n.isNative)return"non-mac";if((0,t.getIsElectronRuntimeMac)())return"mac";if("undefined"==typeof navigator)return"non-mac";const o=navigator.userAgent??"",c=navigator.platform??"";return/Macintosh|Mac OS|iPhone|iPad|iPod/i.test(o)||/Mac|iPhone|iPad|iPod/i.test(c)?"mac":"non-mac"},r(d[0]);var t=r(d[1]),n=r(d[2])},3498,[25,3472,3420]);
|
|
15144
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.navigateToAgent=function(o){return(0,n.resolveNavigateToAgent)(o,{readAgentNavTarget:({serverId:t,agentId:o})=>{const n=s.useSessionStore.getState().sessions[t],c=n?.agents.get(o)??n?.agentDetails.get(o);return{agentWorkspaceId:c?.workspaceId}},navigateToHostAgent:s=>{t.router.navigate(s)},navigateToPreparedWorkspaceTab:c.navigateToPreparedWorkspaceTab,restoreArchivedWorkspace:({serverId:t,agentId:s,workspaceId:o})=>{S(t,s,o)}})};var t=r(d[0]),s=r(d[1]),o=r(d[2]),n=r(d[3]),c=r(d[4]);const u=
|
|
15144
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.navigateToAgent=function(o){return(0,n.resolveNavigateToAgent)(o,{readAgentNavTarget:({serverId:t,agentId:o})=>{const n=s.useSessionStore.getState().sessions[t],c=n?.agents.get(o)??n?.agentDetails.get(o);return{agentWorkspaceId:c?.workspaceId}},navigateToHostAgent:s=>{t.router.navigate(s)},navigateToPreparedWorkspaceTab:c.navigateToPreparedWorkspaceTab,restoreArchivedWorkspace:({serverId:t,agentId:s,workspaceId:o})=>{S(t,s,o)}})};var t=r(d[0]),s=r(d[1]),o=r(d[2]),n=r(d[3]),c=r(d[4]);const u=6e4;function S(t,n,c){const S=(0,o.getHostRuntimeStore)().getSnapshot(t),p=S?.client??null;if(!p||!(0,o.isHostRuntimeConnected)(S))return;const v=s.useSessionStore.getState(),k=v.sessions[t],f=k?.agents.get(n)??k?.agentDetails.get(n);f?.archivedAt&&(k?.workspaces.has(c)||"restoring"!==k?.restoringWorkspaces.get(c)&&(!0===k?.serverInfo?.features?.worktreeRestore?(v.setWorkspaceRestoreStatus(t,c,"restoring"),setTimeout(()=>s.useSessionStore.getState().setWorkspaceRestoreStatus(t,c,"failed"),u),p.refreshAgent(n).catch(()=>s.useSessionStore.getState().setWorkspaceRestoreStatus(t,c,"failed"))):v.setWorkspaceRestoreStatus(t,c,"needs-host-upgrade")))}},3499,[379,3427,3274,3500,3501]);
|
|
15145
15145
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.resolveNavigateToAgent=function(s,o){const I=s.workspaceId??o.readAgentNavTarget({serverId:s.serverId,agentId:s.agentId}).agentWorkspaceId,v=(0,n.normalizeWorkspaceOpaqueId)(I);if(!v){const n=(0,t.buildHostAgentDetailRoute)(s.serverId,s.agentId);return o.navigateToHostAgent(n),n}return o.restoreArchivedWorkspace({serverId:s.serverId,agentId:s.agentId,workspaceId:v}),o.navigateToPreparedWorkspaceTab({serverId:s.serverId,workspaceId:v,target:{kind:"agent",agentId:s.agentId},pin:s.pin})};var t=r(d[0]),n=r(d[1])},3500,[3492,3432]);
|
|
15146
15146
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.prepareWorkspaceTab=function(n){return(0,t.prepareWorkspaceTab)(n,p())},e.navigateToPreparedWorkspaceTab=function(o){return(0,t.navigateToPreparedWorkspaceTab)(o,Object.assign({},p(),{navigateToWorkspace:n.navigateToWorkspace}))};var n=r(d[0]),o=r(d[1]),t=r(d[2]);function p(){const n=o.useWorkspaceLayoutStore.getState();return{openTabFocused:n.openTabFocused,pinAgent:n.pinAgent}}},3501,[3502,3450,3508]);
|
|
15147
15147
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.hydrateLastWorkspaceSelection=T,_e.getLastWorkspaceSelection=_,_e.getIsLastWorkspaceSelectionHydrated=v,_e.navigateToWorkspace=function(e,t,s={}){(0,S.navigateToWorkspace)(e,t,E(),s)},_e.navigateToLastWorkspace=function(){return(0,S.navigateToLastWorkspace)(Object.assign({},E(),{getLastWorkspaceSelection:()=>L.getSelection()}))},_e.useActiveWorkspaceSelection=function(){const e=(0,t.c)(7),s=(0,n.useLocalSearchParams)(),o=(0,n.usePathname)();let u;e[0]!==s||e[1]!==o?(u=(0,S.parseActiveWorkspaceSelection)({pathname:o,params:s}),e[0]=s,e[1]=o,e[2]=u):u=e[2];const p=u,l=p?.serverId??null,k=p?.workspaceId??null;let W,f;e[3]!==l||e[4]!==k?(W=()=>{l&&k&&L.remember({serverId:l,workspaceId:k})},f=[l,k],e[3]=l,e[4]=k,e[5]=W,e[6]=f):(W=e[5],f=e[6]);return(0,c.useEffect)(W,f),p},_e.useLastWorkspaceSelection=function(){return(0,c.useSyncExternalStore)(L.subscribe,_,_)},_e.useIsLastWorkspaceSelectionHydrated=function(){return(0,c.useSyncExternalStore)(L.subscribe,v,v)};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),c=r(d[3]),u=r(d[4]),S=r(d[5]),p=r(d[6]),l=r(d[7]),k=r(d[8]),W=r(d[9]);const f={read:()=>o.default.getItem(u.LAST_WORKSPACE_SELECTION_STORAGE_KEY),write:e=>o.default.setItem(u.LAST_WORKSPACE_SELECTION_STORAGE_KEY,e)},L=(0,u.createLastWorkspaceSelectionStore)(f);function E(){return{getSessionWorkspaces:e=>p.useSessionStore.getState().sessions[e]?.workspaces,getSessionAgents:e=>p.useSessionStore.getState().sessions[e]?.agents.values()??[],openWorkspaceAgentTab:(e,t)=>{l.useWorkspaceLayoutStore.getState().openTabFocused(e,{kind:"agent",agentId:t})},rememberLastWorkspace:e=>L.remember(e),navigateToRoute:e=>{(0,W.navigateToHostWorkspaceRoute)(e),(0,k.stripHostWorkspaceRouteEchoSearchFromBrowserUrlAfterCommit)()}}}function T(){return L.hydrate()}function _(){return L.getSelection()}function v(){return L.isHydrated()}T()},3502,[350,3275,379,36,3503,3504,3427,3450,3506,3507]);
|
|
@@ -15611,7 +15611,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
15611
15611
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AgentScreenSheet=function({visible:s,onClose:u,serverId:_,agentId:j}){const{t:w}=(0,l.useTranslation)(),{theme:T}=(0,o.useUnistyles)(),{settings:C}=(0,S.useAppSettings)(),M=(0,h.useSessionStore)(e=>e.sessions[_]?.client??null),A=(0,n.useRef)(null),[F,I]=(0,n.useState)({kind:"loading"}),z=(0,n.useMemo)(()=>(0,x.toXtermTheme)(T.colors.terminal),[T]),E=(0,n.useMemo)(()=>{const e=C.monoFontFamily.trim();return e.length>0?e:void 0},[C.monoFontFamily]),V=(0,n.useMemo)(()=>`agent-screen:${_}:${j}`,[_,j]);(0,n.useEffect)(()=>{if(!s)return void I({kind:"loading"});if(!M)return void I({kind:"error"});let e=!1;const t=async()=>{try{const t=await M.captureAgentPane(j,{ansi:!0,scrollbackLines:v});if(e)return;I(null===t.screen?{kind:"unavailable"}:{kind:"ready",screen:t.screen,capturedAt:t.capturedAt})}catch{e||I({kind:"error"})}};t();const n=setInterval(()=>{t()},k);return()=>{e=!0,clearInterval(n)}},[s,M,j]),(0,n.useEffect)(()=>{if("ready"!==F.kind)return;const e=A.current;e&&(e.clear(),e.writeOutput((new TextEncoder).encode(F.screen)))},[F]);const H=(0,n.useMemo)(()=>({title:w("workspace.agentScreen.title")}),[w]),L=(0,n.useCallback)(()=>"unavailable"===F.kind?(0,y.jsx)(e.View,{style:b.centerState,children:(0,y.jsx)(t.Text,{style:b.stateText,children:w("workspace.agentScreen.unavailable")})}):"error"===F.kind?(0,y.jsx)(e.View,{style:b.centerState,children:(0,y.jsx)(t.Text,{style:b.stateText,children:w("workspace.agentScreen.error")})}):(0,y.jsx)(e.View,{style:b.terminalContainer,children:(0,y.jsx)(f.default,{ref:A,dom:p,streamKey:V,testId:"agent-screen-surface",xtermTheme:z,scrollbackLines:v,fontFamily:E,fontSize:C.codeFontSize})}),[F,w,V,z,E,C.codeFontSize]);return(0,y.jsx)(c.AdaptiveModalSheet,{header:H,visible:s,onClose:u,scrollable:!1,testID:"agent-screen-sheet",children:L()})};var e=r(d[0]),t=r(d[1]),n=r(d[2]);r(d[3]),r(d[4]);var s,o=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),f=(s=u)&&s.__esModule?s:{default:s},S=r(d[9]),h=r(d[10]),x=r(d[11]),y=r(d[12]);const k=1e3,v=200,p={style:{flex:1},matchContents:!1};const b=o.StyleSheet.create(e=>({terminalContainer:{flex:1,minHeight:320,backgroundColor:e.colors.background,uni__dependencies:[0]},centerState:{flex:1,minHeight:160,alignItems:"center",justifyContent:"center",padding:16},stateText:{color:e.colors.foregroundMuted,fontSize:e.fontSize.sm,textAlign:"center",uni__dependencies:[0]}}))},3956,[348,349,36,234,146,56,352,3481,3957,3590,3427,3976,279]);
|
|
15612
15612
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return F}});var t=r(d[0]),n=r(d[1]);r(d[2]);var o=r(d[3]),s=r(d[4]),u=r(d[5]),l=r(d[6]),c=r(d[7]),f=r(d[8]),p=r(d[9]);const v=6,h=9,b=18,w=8,S=.62,E=.78,y=.9,L=220,k=240,z=90,x=1200,R=110,T="terminal-emulator-webkit-scrollbar-style",M={flex:1,minHeight:0,minWidth:0,width:"100%",height:"100%",overflow:"hidden",overscrollBehavior:"none",paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},C={position:"absolute",top:0,right:0,bottom:0,width:12,display:"flex",alignItems:"center",justifyContent:"flex-start",zIndex:10,pointerEvents:"none"};function O(t,n,o){return Math.min(o,Math.max(n,t))}function D(){if("undefined"==typeof document)return;if(document.getElementById(T))return;const t=document.createElement("style");t.id=T,t.textContent="\n [data-terminal-scrollbar-root=\"true\"] .xterm-viewport {\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n\n [data-terminal-scrollbar-root=\"true\"] .xterm-viewport::-webkit-scrollbar {\n width: 0;\n height: 0;\n }\n ",document.head.appendChild(t)}function F({ref:T,streamKey:F,testId:P="terminal-surface",xtermTheme:I={background:"#0b0b0b",foreground:"#e6e6e6",cursor:"#e6e6e6"},scrollbackLines:H,fontFamily:j,fontSize:B,swipeGesturesEnabled:A=!1,onSwipeLeft:K,onSwipeRight:U,initialSnapshot:Y=null,onInput:q,onFocus:$,onResize:W,onTerminalKey:_,onPendingModifiersConsumed:G,onInputModeChange:V,onResolveLocalFileLink:X,onOpenLocalFileLink:J,onRendererReadyChange:N,pendingModifiers:Q={ctrl:!1,shift:!1,alt:!1},focusRequestToken:Z=0,resizeRequestToken:ee=0}){const te=(0,t.useRef)(null),ne=(0,t.useRef)(null),re=(0,t.useRef)(null),oe=(0,t.useRef)(I),ie=(0,t.useRef)(j),se=(0,t.useRef)(B),ae=(0,t.useRef)(H);ae.current=H,ie.current=j,se.current=B;const ue=(0,t.useRef)(null),le=(0,t.useRef)(0),ce=(0,t.useRef)(0),de=(0,t.useRef)(null),fe=(0,t.useRef)(null),pe=(0,t.useRef)(null),me=(0,t.useRef)({offset:0,viewportSize:0,contentSize:0}),ve=(0,t.useMemo)(()=>{return[(t=I).background,t.foreground,t.cursor,t.cursorAccent,t.selectionBackground,t.selectionForeground,t.black,t.red,t.green,t.yellow,t.blue,t.magenta,t.cyan,t.white,t.brightBlack,t.brightRed,t.brightGreen,t.brightYellow,t.brightBlue,t.brightMagenta,t.brightCyan,t.brightWhite].map(t=>"string"==typeof t?t:"").join("|");var t},[I]),ge=(0,t.useRef)(I);ge.current=I;const he=(0,t.useRef)(N);he.current=N;const be=(0,t.useRef)({onInput:q,onResize:W,onTerminalKey:_,onPendingModifiersConsumed:G,onInputModeChange:V,onResolveLocalFileLink:X,onOpenLocalFileLink:J});be.current={onInput:q,onResize:W,onTerminalKey:_,onPendingModifiersConsumed:G,onInputModeChange:V,onResolveLocalFileLink:X,onOpenLocalFileLink:J};const we=(0,t.useRef)(Y);we.current=Y;const Se=(0,t.useRef)(Q);Se.current=Q;const[Ee,ye]=(0,t.useState)({offset:0,viewportSize:0,contentSize:0}),[Le,ke]=(0,t.useState)(!1),[ze,xe]=(0,t.useState)(!1),[Re,Te]=(0,t.useState)(!1),[Me,Ce]=(0,t.useState)(!1),[Oe,De]=(0,t.useState)(!1),Fe=(0,t.useRef)(null),Pe=(0,t.useCallback)(t=>{const n=me.current;t.offset===n.offset&&t.viewportSize===n.viewportSize&&t.contentSize===n.contentSize||(me.current=t,ye(t))},[]),Ie=(0,t.useRef)(null);(0,n.useDOMImperativeHandle)(Ie,()=>({writeOutput:(...t)=>{const n=t[0];n instanceof Uint8Array&&re.current?.write({data:n})},restoreOutput:(...t)=>{const n=t[0];n instanceof Uint8Array&&re.current?.restoreOutput({data:n})},renderSnapshot:(...t)=>{const n=t[0];var o;null===n?re.current?.renderSnapshot({state:null}):"object"==typeof(o=n)&&null!==o&&"rows"in o&&"cols"in o&&"grid"in o&&re.current?.renderSnapshot({state:n})},clear:()=>{re.current?.clear()},blur:()=>{re.current?.blur()}}),[]),(0,t.useImperativeHandle)(T,()=>({writeOutput:t=>{re.current?.write({data:t})},restoreOutput:t=>{re.current?.restoreOutput({data:t})},renderSnapshot:t=>{re.current?.renderSnapshot({state:t})},clear:()=>{re.current?.clear()},blur:()=>{re.current?.blur()}}),[]),(0,t.useEffect)(()=>{const t=ge.current;oe.current=t,re.current?.setTheme({theme:t})},[ve]),(0,t.useEffect)(()=>{re.current?.setScrollback({lines:H})},[H]),(0,t.useEffect)(()=>{D()},[]),(0,t.useEffect)(()=>{const t=te.current;if(!t||!A)return()=>{};let n=!1,o=null,s=0,u=0,l=!1;const c=()=>{n=!1,o=null,s=0,u=0,l=!1},f=(t,n)=>{const o=Math.abs(t),s=Math.abs(n);return!(s<12)&&s>o},p=(t,n)=>{const o=Math.abs(t),s=Math.abs(n);return!(o<22)&&(0===s||o/s>=1.2)},v=t=>{t.isPrimary&&(n=!0,l=!1,o=t.pointerId,s=t.clientX,u=t.clientY)},h=t=>{if(!n||l)return;if(null!==o&&t.pointerId!==o)return;const v=t.clientX-s,h=t.clientY-u;f(v,h)?c():p(v,h)&&(l=!0,v>0?U?.():K?.(),t.cancelable&&t.preventDefault())},b=t=>{null!==o&&t.pointerId!==o||c()},w=t=>{null!==o&&t.pointerId!==o||c()};return t.addEventListener("pointerdown",v,{passive:!0}),t.addEventListener("pointermove",h,{passive:!1}),t.addEventListener("pointerup",b,{passive:!0}),t.addEventListener("pointercancel",w,{passive:!0}),()=>{t.removeEventListener("pointerdown",v),t.removeEventListener("pointermove",h),t.removeEventListener("pointerup",b),t.removeEventListener("pointercancel",w)}},[K,U,A]),(0,t.useEffect)(()=>{const t=ne.current,n=te.current;if(!t||!n)return()=>{};const u=new o.TerminalEmulatorRuntime;return re.current=u,u.setCallbacks({callbacks:Object.assign({},be.current,{onOpenExternalUrl:s.openExternalUrl})}),u.setPendingModifiers({pendingModifiers:Se.current}),u.mount({root:n,host:t,initialSnapshot:we.current,scrollback:ae.current,theme:oe.current,fontFamily:ie.current,fontSize:se.current}),he.current?.({streamKey:F,isReady:!0}),()=>{u.unmount(),he.current?.({streamKey:F,isReady:!1}),re.current===u&&(re.current=null)}},[F]),(0,t.useEffect)(()=>{re.current?.setCallbacks({callbacks:{onInput:q,onResize:W,onTerminalKey:_,onPendingModifiersConsumed:G,onInputModeChange:V,onResolveLocalFileLink:X,onOpenLocalFileLink:J,onOpenExternalUrl:s.openExternalUrl}})},[q,V,J,G,X,W,_]),(0,t.useEffect)(()=>{re.current?.setPendingModifiers({pendingModifiers:Q})},[Q]),(0,t.useEffect)(()=>{re.current?.setFont({fontFamily:j,fontSize:B})},[j,B]),(0,t.useEffect)(()=>Z<=0?()=>{}:(re.current?.resize({force:!0,shouldClaim:!0}),(0,u.focusWithRetries)({focus:()=>{re.current?.focus()},isFocused:()=>{const t=te.current;if(!t)return!1;const n="undefined"!=typeof document?document.activeElement:null;return n instanceof HTMLElement&&t.contains(n)}})),[Z]),(0,t.useEffect)(()=>{ee<=0||re.current?.resize({force:!0,shouldClaim:!0})},[ee]),(0,t.useEffect)(()=>{const t=ne.current;if(!t)return()=>{};const n=t.querySelector(".xterm-viewport");if(!n)return ue.current=null,Pe({offset:0,viewportSize:0,contentSize:0}),()=>{};ue.current=n;const o=()=>{const t=Math.max(0,n.scrollTop),o=Math.max(0,n.clientHeight),s=Math.max(0,n.scrollHeight);Pe({offset:t,viewportSize:o,contentSize:s})};o();let s=null;const u=()=>{null===s&&(s=requestAnimationFrame(()=>{s=null,o()}))},l=new ResizeObserver(()=>{o()});l.observe(n);const c=t.querySelector(".xterm-scroll-area");return c&&l.observe(c),n.addEventListener("scroll",u,{passive:!0}),()=>{null!==s&&(cancelAnimationFrame(s),s=null),n.removeEventListener("scroll",u),l.disconnect(),ue.current===n&&(ue.current=null)}},[F,Pe]),(0,t.useEffect)(()=>{const t=Math.max(0,Ee.contentSize-Ee.viewportSize),n=O(Ee.offset,0,t);if(t<=0||Ee.viewportSize<=0)return Te(!1),Ce(!1),void(pe.current=null);const o=pe.current;pe.current=n,null===o||Math.abs(o-n)<=.5||(Te(!0),null!==de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{Te(!1),de.current=null},x),Ce(!0),null!==fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{Ce(!1),fe.current=null},R))},[Ee.contentSize,Ee.offset,Ee.viewportSize]),(0,t.useEffect)(()=>()=>{null!==de.current&&clearTimeout(de.current),null!==fe.current&&clearTimeout(fe.current)},[]);const He=(0,t.useMemo)(()=>(0,l.computeVerticalScrollbarGeometry)({viewportSize:Ee.viewportSize,contentSize:Ee.contentSize,offset:Ee.offset}),[Ee.contentSize,Ee.offset,Ee.viewportSize]);(0,t.useEffect)(()=>{if(!ze)return()=>{};const t=t=>{const n=t.clientY-ce.current,o=(0,l.computeScrollOffsetFromDragDelta)({startOffset:le.current,dragDelta:n,maxScrollOffset:He.maxScrollOffset,maxHandleOffset:He.maxHandleOffset}),s=ue.current;s&&(s.scrollTop=o,Pe({offset:o,viewportSize:Math.max(0,s.clientHeight),contentSize:Math.max(0,s.scrollHeight)}))},n=()=>{xe(!1)};return window.addEventListener("pointermove",t),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n),()=>{window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n)}},[ze,He.maxHandleOffset,He.maxScrollOffset,Pe]);const je=He.isVisible&&(ze||Re||Le);let Be;Be=ze?y:Le?E:Re?S:0;const Ae=ze||Le?h:v,Ke=Math.max(0,He.handleOffset-w),Ue=Math.min(Ee.viewportSize-Ke,He.handleSize+16),Ye=Math.max(0,(Ue-He.handleSize)/2),qe=ze||Me?0:z,$e=(0,t.useCallback)(()=>{const t=window.paseoDesktop?.menu?.showContextMenu;if("function"!=typeof t)return;t({kind:"terminal",hasSelection:Boolean(window.getSelection()?.toString())})},[]),We=(0,t.useCallback)(()=>{$?.(),re.current?.focus()},[$]),_e=(0,t.useCallback)(t=>{t.preventDefault(),$e()},[$e]),Ge=He.maxScrollOffset,Ve=(0,t.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),le.current=O(Ee.offset,0,Ge),ce.current=t.clientY,xe(!0)},[Ge,Ee.offset]),Xe=(0,t.useCallback)(()=>{(Re||ze)&&ke(!0)},[Re,ze]),Je=(0,t.useCallback)(()=>{ke(!1)},[]),Ne=(0,t.useCallback)(()=>{null!==Fe.current&&(clearTimeout(Fe.current),Fe.current=null)},[]),Qe=(0,t.useCallback)(()=>{Ne(),De(!1)},[Ne]),Ze=(0,t.useCallback)(()=>{Ne(),De(!0),Fe.current=setTimeout(()=>{Fe.current=null,De(!1)},180)},[Ne]);(0,t.useEffect)(()=>{const t=te.current;if(!t)return()=>{};const n=t=>{(0,c.isTerminalFileDrag)(t.dataTransfer)&&(t.preventDefault(),t.stopPropagation(),Ze())},o=t=>{(0,c.isTerminalFileDrag)(t.dataTransfer)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer&&(t.dataTransfer.dropEffect="copy"),Ze())},s=t=>{if(!(0,c.isTerminalFileDrag)(t.dataTransfer))return;t.preventDefault(),t.stopPropagation(),Qe();const n=(0,f.getDesktopHost)(),o=(0,c.extractTerminalDropPaths)(t.dataTransfer,n);0!==o.length&&(re.current?.focus(),be.current.onInput?.((0,c.prepareDroppedPathsForTerminal)(o,n)))};return t.addEventListener("dragenter",n,{capture:!0}),t.addEventListener("dragover",o,{capture:!0}),t.addEventListener("drop",s,{capture:!0}),window.addEventListener("dragend",Qe),window.addEventListener("drop",Qe),()=>{t.removeEventListener("dragenter",n,{capture:!0}),t.removeEventListener("dragover",o,{capture:!0}),t.removeEventListener("drop",s,{capture:!0}),window.removeEventListener("dragend",Qe),window.removeEventListener("drop",Qe),Ne()}},[Ne,Qe,Ze]);const et=(0,t.useCallback)(t=>{(0,c.isTerminalFileDrag)(t.dataTransfer)&&(t.preventDefault(),t.stopPropagation(),(0,c.isTerminalDragLeaveOutside)({currentTarget:t.currentTarget,relatedTarget:t.relatedTarget})&&Qe())},[Qe]),tt=(0,t.useMemo)(()=>({position:"relative",display:"flex",width:"100%",height:"100%",minHeight:0,minWidth:0,backgroundColor:I.background??"#0b0b0b",overflow:"hidden",overscrollBehavior:"none",touchAction:"pan-y"}),[I.background]),nt=(0,t.useMemo)(()=>({position:"absolute",inset:0,zIndex:9,border:"1px solid rgba(78, 161, 255, 0.72)",backgroundColor:"rgba(78, 161, 255, 0.16)",opacity:Oe?1:0,pointerEvents:"none",transition:"opacity 120ms ease-out"}),[Oe]),rt=(0,t.useMemo)(()=>({position:"absolute",top:0,right:-3,width:b,height:Ue,transform:`translateY(${Ke}px)`,cursor:ze?"grabbing":"grab",touchAction:"none",userSelect:"none",transitionProperty:"transform",transitionDuration:`${qe}ms`,transitionTimingFunction:"linear",pointerEvents:je?"auto":"none"}),[Ue,Ke,ze,qe,je]),ot=(0,t.useMemo)(()=>({marginTop:Ye,height:He.handleSize,width:Ae,borderRadius:999,alignSelf:"center",backgroundColor:"rgba(113, 113, 122, 1)",opacity:Be,transitionProperty:"opacity, width, background-color",transitionDuration:`${L}ms, ${k}ms, ${L}ms`,transitionTimingFunction:"ease-out, cubic-bezier(0.22, 0.75, 0.2, 1), ease-out"}),[Ye,He.handleSize,Ae,Be]);return(0,p.jsxs)("div",{ref:te,"data-testid":P,"data-terminal-scrollbar-root":"true",style:tt,onPointerDown:We,onContextMenu:_e,onDragLeave:et,children:[(0,p.jsx)("div",{ref:ne,style:M}),(0,p.jsx)("div",{style:nt}),He.isVisible?(0,p.jsx)("div",{style:C,children:(0,p.jsx)("div",{style:rt,onPointerDown:Ve,onPointerEnter:Xe,onPointerLeave:Je,children:(0,p.jsx)("div",{style:ot})})}):null]})}},3957,[36,742,3958,3959,3577,3511,3487,3975,3417,279]);
|
|
15613
15613
|
__d(function(g,r,i,a,m,e,d){},3958,[]);
|
|
15614
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.encodeTerminalOutput=A,Object.defineProperty(e,"TerminalEmulatorRuntime",{enumerable:!0,get:function(){return I}});var t=r(d[0]),s=r(d[1]),o=r(d[2]),n=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]),w=r(d[11]),v=r(d[12]);const b="undefined"!=typeof navigator&&(/Macintosh|Mac OS/i.test(navigator.userAgent??"")||/Mac/i.test(navigator.platform??"")),O="undefined"!=typeof navigator&&(0,y.isAppleHandheldPlatform)({userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints}),T=[0,16,48,120,250,500,1e3,2e3],C=new Uint8Array(0),k=new Uint8Array([27,99]),M=new TextEncoder;function A(t){return M.encode(t)}function F(t,s){const o=new Uint8Array(t.length+s.length);return o.set(t,0),o.set(s,t.length),o}const z=["JetBrains Mono","JetBrainsMono Nerd Font","JetBrainsMono NF","MesloLGM Nerd Font","MesloLGM NF","Hack Nerd Font","FiraCode Nerd Font","Symbols Nerd Font","SF Mono","Menlo","Monaco","Consolas","'Liberation Mono'","monospace"].join(", ");function E(t){const s=t?.trim();return s&&s.length>0?s:z}function S(t){return"number"==typeof t&&Number.isFinite(t)&&t>0?t:13}function L(t){return Object.assign({},t,{overviewRulerBorder:t.background??"transparent"})}class I{callbacks={};pendingModifiers={ctrl:!1,shift:!1,alt:!1};terminal=null;fitAddon=null;fitAndEmitResize=null;lastSize=null;cleanup=null;outputOperations=[];inFlightOutputOperation=null;inFlightOutputOperationTimeout=null;pendingWriteCommits=new Set;hasUngatedWrites=!1;inputModeDecoder=new TextDecoder;suppressInput=!1;inputModeTracker=new f.TerminalInputModeTracker;lastInputModeState=this.inputModeTracker.getState();themeBackgroundElements=[];handleVisibilityRestore=()=>{"undefined"!=typeof document&&"visible"!==document.visibilityState||(this.fitAndEmitResize?.({force:!0,shouldClaim:!1}),"function"==typeof window.requestAnimationFrame&&window.requestAnimationFrame(()=>{this.fitAndEmitResize?.({force:!0,shouldClaim:!1})}))};setCallbacks(t){this.callbacks=t.callbacks}setPendingModifiers(t){this.pendingModifiers=t.pendingModifiers}mount(f){this.unmount(),f.host.innerHTML="",this.lastSize=null,this.inputModeTracker.reset(),this.emitInputModeChange();const w=new p.Terminal({allowProposedApi:!0,convertEol:!1,cursorBlink:!0,cursorStyle:"bar",fontFamily:E(f.fontFamily),fontSize:S(f.fontSize),lineHeight:1,macOptionIsMeta:!0,minimumContrastRatio:1,rescaleOverlappingGlyphs:!0,scrollbar:{width:8},scrollback:f.scrollback,theme:L(f.theme)}),C=new s.FitAddon,k=new l.Unicode11Addon;let M=null,A=null;w.loadAddon(C),w.loadAddon(k),w.loadAddon(new u.WebLinksAddon((t,s)=>{t.preventDefault(),this.callbacks.onOpenExternalUrl?.(s)}));const F=w.registerLinkProvider((0,v.createTerminalLocalFileLinkProvider)(w,{resolveLink:async t=>await(this.callbacks.onResolveLocalFileLink?.(t))??null,openLink:(t,s)=>{this.callbacks.onOpenLocalFileLink?.(t,s)}}));w.loadAddon(new n.SearchAddon({highlightLimit:2e4})),w.loadAddon(new t.ClipboardAddon);try{w.loadAddon(new h.LigaturesAddon)}catch{}w.open(f.host),this.themeBackgroundElements=this.collectThemeBackgroundElements(f),this.applyThemeBackground(f.theme);try{w.unicode.activeVersion="11"}catch{}const z=()=>{try{A?.dispose()}catch{}A=null},I=()=>{if(M){try{M.dispose()}catch{}M=null,z(),this.fitAndEmitResize?.({force:!0,shouldClaim:!1})}},R=()=>{w.parser.registerCsiHandler({final:"c"},()=>!0),w.parser.registerCsiHandler({prefix:">",final:"c"},()=>!0),w.parser.registerCsiHandler({prefix:"=",final:"c"},()=>!0),w.parser.registerCsiHandler({final:"n"},()=>!0),w.parser.registerCsiHandler({prefix:"?",final:"n"},()=>!0),w.parser.registerCsiHandler({final:"R"},()=>!0),w.parser.registerCsiHandler({intermediates:"$",final:"p"},()=>!0),w.parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},()=>!0);for(const t of[10,11,12])w.parser.registerOscHandler(t,t=>"?"===t.trim())};R();let x=requestAnimationFrame(()=>{x=null;try{I(),M=new c.WebglAddon,M.onContextLoss(()=>{I()}),w.loadAddon(M),A=new o.ImageAddon,w.loadAddon(A),R(),this.fitAndEmitResize?.({force:!0,shouldClaim:!1})}catch{I()}});const B=this.applyDocumentBoundsStyles({root:f.root}),K=this.applyViewportTouchStyles({host:f.host});this.terminal=w,this.fitAddon=C,window.__paseoTerminal=w;const P=t=>{const s=t?.force??!1,o=t?.shouldClaim??!0,n=this.terminal,l=this.fitAddon;if(!n||!l)return;if(0===f.root.offsetWidth||0===f.root.offsetHeight)return;try{l.fit()}catch{return}const u=n.rows,c=n.cols,h=this.lastSize;!s&&h&&h.rows===u&&h.cols===c||(this.lastSize={rows:u,cols:c},this.refreshVisibleRows(),this.callbacks.onResize?.({rows:u,cols:c,shouldClaim:o}))};this.fitAndEmitResize=P,P({force:!0,shouldClaim:!1});const V=w.onData(t=>{this.suppressInput||this.callbacks.onInput?.(t)});w.attachCustomKeyEventHandler(t=>{if("keydown"!==t.type||t.isComposing)return!0;if(!b&&t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey){const s=t.key.toLowerCase();return"c"===s&&w.hasSelection()?(navigator.clipboard.writeText(w.getSelection()),!1):"v"!==s||(t.preventDefault(),navigator.clipboard.readText().then(t=>{t&&w.paste(t)}),!1)}const s=(0,y.normalizeDomTerminalKey)(t.key);if(!s||(0,y.isTerminalModifierDomKey)(t.key))return!0;if(!(0,y.shouldInterceptDomTerminalKey)({key:s,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,pendingModifiers:this.pendingModifiers,enhancedInputActive:this.inputModeTracker.supportsModifiedEnter(),isAppleHandheld:O}))return!0;const o=(0,y.mergeTerminalModifiers)({pendingModifiers:this.pendingModifiers,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey});return this.callbacks.onTerminalKey?.(Object.assign({key:(0,y.normalizeTerminalTransportKey)(s)},o)),(this.pendingModifiers.ctrl||this.pendingModifiers.shift||this.pendingModifiers.alt)&&this.callbacks.onPendingModifiersConsumed?.(),t.preventDefault(),t.stopPropagation(),!1});const j=this.setupTouchScrollHandlers({root:f.root,host:f.host,terminal:w}),D=new ResizeObserver(()=>{P({shouldClaim:!0})});D.observe(f.root),D.observe(f.host);const W=()=>P({shouldClaim:!0});window.addEventListener("resize",W);const H=()=>{this.handleVisibilityRestore()};window.addEventListener("focus",H);const Y=()=>{this.handleVisibilityRestore()};document.addEventListener("visibilitychange",Y);const X=window.visualViewport,U=()=>P({shouldClaim:!0});X?.addEventListener("resize",U);const _=T.map(t=>window.setTimeout(()=>{P({force:!0,shouldClaim:!1})},t)),N=document.fonts,q=()=>{P({force:!0,shouldClaim:!1})};N?.addEventListener?.("loadingdone",q),N?.ready.then(()=>{P({force:!0,shouldClaim:!1})}).catch(()=>{}),window.setTimeout(()=>{P({force:!0,shouldClaim:!1})},0),f.initialSnapshot&&this.renderSnapshot({state:f.initialSnapshot}),this.processOutputQueue();const Q={disposeInput:()=>{V.dispose()},disconnectResizeObserver:()=>{D.disconnect()},removeWindowResize:()=>{window.removeEventListener("resize",W)},removeWindowFocus:()=>{window.removeEventListener("focus",H)},removeDocumentVisibilityChange:()=>{document.removeEventListener("visibilitychange",Y)},removeVisualViewportResize:()=>{X?.removeEventListener("resize",U)},clearFitTimeouts:()=>{for(const t of _)window.clearTimeout(t)},removeFontListeners:()=>{N?.removeEventListener?.("loadingdone",q)},removeTouchListeners:j,restoreDocumentStyles:B,restoreViewportStyles:K,disposeFitAddon:()=>{C.dispose()},disposeWebglAddon:()=>{null!==x&&(cancelAnimationFrame(x),x=null),I(),z()},disposeTerminal:()=>{F.dispose(),w.dispose()}};this.cleanup=()=>{Q.disposeInput(),Q.disconnectResizeObserver(),Q.removeWindowResize(),Q.removeWindowFocus(),Q.removeDocumentVisibilityChange(),Q.removeVisualViewportResize(),Q.clearFitTimeouts(),Q.removeFontListeners(),Q.removeTouchListeners(),Q.disposeFitAddon(),Q.disposeWebglAddon(),Q.disposeTerminal(),Q.restoreDocumentStyles(),Q.restoreViewportStyles()}}write(t){0!==t.data.length?(this.outputOperations.push(Object.assign({type:"write",data:t.data,suppressInput:t.suppressInput??!1},t.onCommitted?{onCommitted:t.onCommitted}:{})),this.processOutputQueue()):t.onCommitted?.()}clear(t){this.outputOperations.push(Object.assign({type:"clear",data:C,suppressInput:!1},t?.onCommitted?{onCommitted:t.onCommitted}:{})),this.processOutputQueue()}renderSnapshot(t){t.state?this.restoreOutput(Object.assign({data:A((0,w.renderTerminalSnapshotToAnsi)(t.state)),rows:t.state.rows,cols:t.state.cols},t.onCommitted?{onCommitted:t.onCommitted}:{})):this.clear(t)}restoreOutput(t){this.outputOperations.push(Object.assign({type:"snapshot",data:F(k,t.data),rows:t.rows,cols:t.cols,suppressInput:!0},t.onCommitted?{onCommitted:t.onCommitted}:{})),this.processOutputQueue()}resize(t){this.fitAndEmitResize?.(t)}setTheme(t){const s=this.terminal;if(s){try{s.options.theme=L(t.theme)}catch{return}this.applyThemeBackground(t.theme),this.refreshVisibleRows()}}setScrollback(t){const s=this.terminal;if(s){try{s.options.scrollback=t.lines}catch{return}this.refreshVisibleRows()}}setFont(t){const s=this.terminal;if(s){try{s.options.fontFamily=E(t.fontFamily),s.options.fontSize=S(t.fontSize)}catch{return}this.fitAndEmitResize?.({force:!0}),this.refreshVisibleRows()}}focus(t){const s=this.terminal;s&&(t?.forceRefocus&&s.blur(),s.focus())}blur(){this.terminal?.blur()}refreshVisibleRows(){const t=this.terminal;if(t&&!(t.rows<=0))try{t.refresh(0,t.rows-1)}catch{}}collectThemeBackgroundElements(t){return[t.root,t.host,...Array.from(t.host.querySelectorAll(".xterm, .xterm-screen, .xterm-viewport"))]}applyThemeBackground(t){const s=t.background??"#0b0b0b";for(const t of this.themeBackgroundElements)t.style.backgroundColor=s}unmount(){this.clearInFlightOutputTimeout();const t=this.inFlightOutputOperation;this.inFlightOutputOperation=null,t?.onCommitted&&t.onCommitted();const s=this.outputOperations.splice(0,this.outputOperations.length);for(const t of s)t.onCommitted?.();for(const t of Array.from(this.pendingWriteCommits))t();this.hasUngatedWrites=!1,this.cleanup?.(),this.cleanup=null,window.__paseoTerminal===this.terminal&&(window.__paseoTerminal=void 0),this.terminal=null,this.fitAddon=null,this.fitAndEmitResize=null,this.lastSize=null,this.themeBackgroundElements=[],this.suppressInput=!1,this.inputModeDecoder.decode(),this.inputModeTracker.reset(),this.emitInputModeChange()}isBarrierOperation(t){return"write"!==t.type||Boolean(t.suppressInput)}processOutputQueue(){if(this.inFlightOutputOperation)return;const t=this.terminal;if(!t)return;for(;this.outputOperations[0]&&!this.isBarrierOperation(this.outputOperations[0]);){const s=this.outputOperations.shift();if(!s)break;this.submitWrite(t,s)}const s=this.outputOperations.shift();if(!s)return;if(!this.hasUngatedWrites)return void this.startBarrierOperation(t,s);let o=!1;const n=()=>{o||this.inFlightOutputOperation!==s||this.terminal!==t||(o=!0,this.clearInFlightOutputTimeout(),this.startBarrierOperation(t,s))};this.inFlightOutputOperation=s,this.inFlightOutputOperationTimeout=setTimeout(n,5e3);try{t.write(C,n)}catch{n()}}submitWrite(t,s){const o=this.inputModeDecoder.decode(s.data,{stream:!0});this.inputModeTracker.feed(o).changed&&this.emitInputModeChange(),this.hasUngatedWrites=!0;const n=s.onCommitted;if(!n){try{t.write(s.data)}catch{}return}const l=()=>{this.pendingWriteCommits.delete(l)&&n()};this.pendingWriteCommits.add(l);try{t.write(s.data,l)}catch{l()}}startBarrierOperation(t,s){this.inFlightOutputOperation=s,this.hasUngatedWrites=!1;const o=this.suppressInput;s.suppressInput&&(this.suppressInput=Boolean(s.suppressInput));const n=t=>{this.inFlightOutputOperation===t&&(this.inFlightOutputOperation=null,this.clearInFlightOutputTimeout(),this.suppressInput=o,t.onCommitted?.(),this.processOutputQueue())};if("clear"===s.type)return this.inputModeDecoder.decode(),this.inputModeTracker.reset(),this.emitInputModeChange(),t.reset(),void n(s);if("snapshot"===s.type){this.inputModeDecoder.decode(),this.inputModeTracker.reset(),this.emitInputModeChange();try{"number"!=typeof s.cols||"number"!=typeof s.rows||t.cols===s.cols&&t.rows===s.rows||t.resize(s.cols,s.rows)}catch{return void n(s)}}const l=s.data;if("write"===s.type){const t=this.inputModeDecoder.decode(l,{stream:!0});this.inputModeTracker.feed(t).changed&&this.emitInputModeChange()}this.inFlightOutputOperationTimeout=setTimeout(()=>{n(s)},5e3);try{t.write(l,()=>{n(s)})}catch{n(s)}}clearInFlightOutputTimeout(){this.inFlightOutputOperationTimeout&&(clearTimeout(this.inFlightOutputOperationTimeout),this.inFlightOutputOperationTimeout=null)}emitInputModeChange(){const t=this.inputModeTracker.getState();(0,f.terminalInputModeStatesEqual)(t,this.lastInputModeState)||(this.lastInputModeState=t,this.callbacks.onInputModeChange?.(t))}applyDocumentBoundsStyles(t){const s=document.documentElement,o=document.body,n=t.root.parentElement,l=s.style.overflow,u=s.style.width,c=s.style.height,h=s.style.getPropertyValue("text-size-adjust"),p=s.style.getPropertyValue("-webkit-text-size-adjust"),f=o.style.overflow,y=o.style.width,w=o.style.height,v=o.style.margin,b=o.style.padding,O=o.style.getPropertyValue("text-size-adjust"),T=o.style.getPropertyValue("-webkit-text-size-adjust"),C=n?.style.overflow??"",k=n?.style.width??"",M=n?.style.height??"";return s.style.overflow="hidden",s.style.width="100%",s.style.height="100%",s.style.setProperty("text-size-adjust","100%"),s.style.setProperty("-webkit-text-size-adjust","100%"),o.style.overflow="hidden",o.style.width="100%",o.style.height="100%",o.style.margin="0",o.style.padding="0",o.style.setProperty("text-size-adjust","100%"),o.style.setProperty("-webkit-text-size-adjust","100%"),n&&(n.style.overflow="hidden",n.style.width="100%",n.style.height="100%"),()=>{s.style.overflow=l,s.style.width=u,s.style.height=c,s.style.setProperty("text-size-adjust",h),s.style.setProperty("-webkit-text-size-adjust",p),o.style.overflow=f,o.style.width=y,o.style.height=w,o.style.margin=v,o.style.padding=b,o.style.setProperty("text-size-adjust",O),o.style.setProperty("-webkit-text-size-adjust",T),n&&(n.style.overflow=C,n.style.width=k,n.style.height=M)}}applyViewportTouchStyles(t){const s=t.host.querySelector(".xterm-viewport"),o=s?.style.overscrollBehavior??"",n=s?.style.touchAction??"",l=s?.style.overflowY??"",u=s?.style.overflowX??"",c=s?.style.pointerEvents??"",h=s?.style.getPropertyValue("-webkit-overflow-scrolling")??"";return s&&(s.style.overscrollBehavior="none",s.style.touchAction="pan-y",s.style.overflowY="auto",s.style.overflowX="hidden",s.style.pointerEvents="auto",s.style.setProperty("-webkit-overflow-scrolling","touch")),()=>{s&&(s.style.overscrollBehavior=o,s.style.touchAction=n,s.style.overflowY=l,s.style.overflowX=u,s.style.pointerEvents=c,s.style.setProperty("-webkit-overflow-scrolling",h))}}setupTouchScrollHandlers(t){let s=0;const o=t.host.querySelector(".xterm-rows > div")?.getBoundingClientRect().height??0,n=o>0?o:18,l={identifier:-1,startX:0,startY:0,lastX:0,lastY:0,mode:null},u=t=>{if(1!==t.touches.length)return s=0,l.identifier=-1,void(l.mode=null);const o=t.touches[0];if(!o)return s=0,l.identifier=-1,void(l.mode=null);l.identifier=o.identifier,l.startX=o.clientX,l.startY=o.clientY,l.lastX=o.clientX,l.lastY=o.clientY,l.mode=null,s=0},c=o=>{if(1!==o.touches.length)return;const u=Array.from(o.touches).find(t=>t.identifier===l.identifier);if(!u)return;const c=u.clientX-l.startX,h=u.clientY-l.startY;if(null===l.mode){const t=Math.abs(c),s=Math.abs(h);(t>8||s>8)&&(l.mode=s>=t?"vertical":"horizontal")}const p=u.clientY-l.lastY;if(l.lastX=u.clientX,l.lastY=u.clientY,"vertical"!==l.mode)return;s+=p;const f=Math.trunc(s/n);0!==f&&(t.terminal.scrollLines(-f),s-=f*n),o.preventDefault()},h=t=>{(Array.from(t.changedTouches).some(t=>t.identifier===l.identifier)||0===t.touches.length)&&(s=0,l.identifier=-1,l.mode=null)},p=()=>{s=0,l.identifier=-1,l.mode=null};return t.root.addEventListener("touchstart",u,{passive:!0}),t.root.addEventListener("touchmove",c,{passive:!1}),t.root.addEventListener("touchend",h,{passive:!0}),t.root.addEventListener("touchcancel",p,{passive:!0}),()=>{t.root.removeEventListener("touchstart",u),t.root.removeEventListener("touchmove",c),t.root.removeEventListener("touchend",h),t.root.removeEventListener("touchcancel",p)}}}},3959,[3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3973]);
|
|
15614
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.encodeTerminalOutput=A,Object.defineProperty(e,"TerminalEmulatorRuntime",{enumerable:!0,get:function(){return I}});var t=r(d[0]),s=r(d[1]),o=r(d[2]),n=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]),w=r(d[11]),v=r(d[12]);const b="undefined"!=typeof navigator&&(/Macintosh|Mac OS/i.test(navigator.userAgent??"")||/Mac/i.test(navigator.platform??"")),O="undefined"!=typeof navigator&&(0,y.isAppleHandheldPlatform)({userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints}),T=[0,16,48,120,250,500,1e3,2e3],C=new Uint8Array(0),k=new Uint8Array([27,99]),M=new TextEncoder;function A(t){return M.encode(t)}function F(t,s){const o=new Uint8Array(t.length+s.length);return o.set(t,0),o.set(s,t.length),o}const z=["JetBrains Mono","JetBrainsMono Nerd Font","JetBrainsMono NF","MesloLGM Nerd Font","MesloLGM NF","Hack Nerd Font","FiraCode Nerd Font","Symbols Nerd Font","SF Mono","Menlo","Monaco","Consolas","'Liberation Mono'","monospace"].join(", ");function E(t){const s=t?.trim();return s&&s.length>0?s:z}function S(t){return"number"==typeof t&&Number.isFinite(t)&&t>0?t:13}function L(t){return Object.assign({},t,{overviewRulerBorder:t.background??"transparent"})}class I{callbacks={};pendingModifiers={ctrl:!1,shift:!1,alt:!1};terminal=null;fitAddon=null;fitAndEmitResize=null;lastSize=null;cleanup=null;outputOperations=[];inFlightOutputOperation=null;inFlightOutputOperationTimeout=null;pendingWriteCommits=new Set;hasUngatedWrites=!1;inputModeDecoder=new TextDecoder;suppressInput=!1;inputModeTracker=new f.TerminalInputModeTracker;lastInputModeState=this.inputModeTracker.getState();themeBackgroundElements=[];handleVisibilityRestore=()=>{"undefined"!=typeof document&&"visible"!==document.visibilityState||(this.fitAndEmitResize?.({force:!0,shouldClaim:!1}),"function"==typeof window.requestAnimationFrame&&window.requestAnimationFrame(()=>{this.fitAndEmitResize?.({force:!0,shouldClaim:!1})}))};setCallbacks(t){this.callbacks=t.callbacks}setPendingModifiers(t){this.pendingModifiers=t.pendingModifiers}mount(f){this.unmount(),f.host.innerHTML="",this.lastSize=null,this.inputModeTracker.reset(),this.emitInputModeChange();const w=new p.Terminal({allowProposedApi:!0,convertEol:!1,cursorBlink:!0,cursorStyle:"bar",fontFamily:E(f.fontFamily),fontSize:S(f.fontSize),lineHeight:1,macOptionIsMeta:!0,minimumContrastRatio:1,rescaleOverlappingGlyphs:!0,scrollbar:{width:8},scrollback:f.scrollback,theme:L(f.theme)}),C=new s.FitAddon,k=new l.Unicode11Addon;let M=null,A=null;w.loadAddon(C),w.loadAddon(k),w.loadAddon(new u.WebLinksAddon((t,s)=>{t.preventDefault(),this.callbacks.onOpenExternalUrl?.(s)}));const F=w.registerLinkProvider((0,v.createTerminalLocalFileLinkProvider)(w,{resolveLink:async t=>await(this.callbacks.onResolveLocalFileLink?.(t))??null,openLink:(t,s)=>{this.callbacks.onOpenLocalFileLink?.(t,s)}}));w.loadAddon(new n.SearchAddon({highlightLimit:2e4})),w.loadAddon(new t.ClipboardAddon);try{w.loadAddon(new h.LigaturesAddon)}catch{}w.open(f.host),this.themeBackgroundElements=this.collectThemeBackgroundElements(f),this.applyThemeBackground(f.theme);try{w.unicode.activeVersion="11"}catch{}const z=()=>{try{A?.dispose()}catch{}A=null},I=()=>{if(M){try{M.dispose()}catch{}M=null,z(),this.fitAndEmitResize?.({force:!0,shouldClaim:!1})}},R=()=>{w.parser.registerCsiHandler({final:"c"},()=>!0),w.parser.registerCsiHandler({prefix:">",final:"c"},()=>!0),w.parser.registerCsiHandler({prefix:"=",final:"c"},()=>!0),w.parser.registerCsiHandler({final:"n"},()=>!0),w.parser.registerCsiHandler({prefix:"?",final:"n"},()=>!0),w.parser.registerCsiHandler({final:"R"},()=>!0),w.parser.registerCsiHandler({intermediates:"$",final:"p"},()=>!0),w.parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},()=>!0);for(const t of[10,11,12])w.parser.registerOscHandler(t,t=>"?"===t.trim())};R();let x=requestAnimationFrame(()=>{x=null;try{I(),M=new c.WebglAddon,M.onContextLoss(()=>{I()}),w.loadAddon(M),A=new o.ImageAddon,w.loadAddon(A),R(),this.fitAndEmitResize?.({force:!0,shouldClaim:!1})}catch{I()}});const B=this.applyDocumentBoundsStyles({root:f.root}),K=this.applyViewportTouchStyles({host:f.host});this.terminal=w,this.fitAddon=C,window.__paseoTerminal=w;const P=t=>{const s=t?.force??!1,o=t?.shouldClaim??!0,n=this.terminal,l=this.fitAddon;if(!n||!l)return;if(0===f.root.offsetWidth||0===f.root.offsetHeight)return;try{l.fit()}catch{return}const u=n.rows,c=n.cols,h=this.lastSize;!s&&h&&h.rows===u&&h.cols===c||(this.lastSize={rows:u,cols:c},this.refreshVisibleRows(),this.callbacks.onResize?.({rows:u,cols:c,shouldClaim:o}))};this.fitAndEmitResize=P,P({force:!0,shouldClaim:!1});const V=w.onData(t=>{this.suppressInput||this.callbacks.onInput?.(t)});w.attachCustomKeyEventHandler(t=>{if("keydown"!==t.type||t.isComposing)return!0;if(!b&&t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey){const s=t.key.toLowerCase();return"c"===s&&w.hasSelection()?(navigator.clipboard.writeText(w.getSelection()),!1):"v"!==s||(t.preventDefault(),navigator.clipboard.readText().then(t=>{t&&w.paste(t)}),!1)}const s=(0,y.normalizeDomTerminalKey)(t.key);if(!s||(0,y.isTerminalModifierDomKey)(t.key))return!0;if(!(0,y.shouldInterceptDomTerminalKey)({key:s,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,pendingModifiers:this.pendingModifiers,enhancedInputActive:this.inputModeTracker.supportsModifiedEnter(),isAppleHandheld:O}))return!0;const o=(0,y.mergeTerminalModifiers)({pendingModifiers:this.pendingModifiers,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey});return this.callbacks.onTerminalKey?.(Object.assign({key:(0,y.normalizeTerminalTransportKey)(s)},o)),(this.pendingModifiers.ctrl||this.pendingModifiers.shift||this.pendingModifiers.alt)&&this.callbacks.onPendingModifiersConsumed?.(),t.preventDefault(),t.stopPropagation(),!1});const j=this.setupTouchScrollHandlers({root:f.root,host:f.host,terminal:w}),D=new ResizeObserver(()=>{P({shouldClaim:!0})});D.observe(f.root),D.observe(f.host);const W=()=>P({shouldClaim:!0});window.addEventListener("resize",W);const H=()=>{this.handleVisibilityRestore()};window.addEventListener("focus",H);const Y=()=>{this.handleVisibilityRestore()};document.addEventListener("visibilitychange",Y);const X=window.visualViewport,U=()=>P({shouldClaim:!0});X?.addEventListener("resize",U);const _=T.map(t=>window.setTimeout(()=>{P({force:!0,shouldClaim:!1})},t)),N=document.fonts,q=()=>{P({force:!0,shouldClaim:!1})};N?.addEventListener?.("loadingdone",q),N?.ready.then(()=>{P({force:!0,shouldClaim:!1})}).catch(()=>{}),window.setTimeout(()=>{P({force:!0,shouldClaim:!1})},0),f.initialSnapshot&&this.renderSnapshot({state:f.initialSnapshot}),this.processOutputQueue();const Q={disposeInput:()=>{V.dispose()},disconnectResizeObserver:()=>{D.disconnect()},removeWindowResize:()=>{window.removeEventListener("resize",W)},removeWindowFocus:()=>{window.removeEventListener("focus",H)},removeDocumentVisibilityChange:()=>{document.removeEventListener("visibilitychange",Y)},removeVisualViewportResize:()=>{X?.removeEventListener("resize",U)},clearFitTimeouts:()=>{for(const t of _)window.clearTimeout(t)},removeFontListeners:()=>{N?.removeEventListener?.("loadingdone",q)},removeTouchListeners:j,restoreDocumentStyles:B,restoreViewportStyles:K,disposeFitAddon:()=>{C.dispose()},disposeWebglAddon:()=>{null!==x&&(cancelAnimationFrame(x),x=null),I(),z()},disposeTerminal:()=>{F.dispose(),w.dispose()}};this.cleanup=()=>{Q.disposeInput(),Q.disconnectResizeObserver(),Q.removeWindowResize(),Q.removeWindowFocus(),Q.removeDocumentVisibilityChange(),Q.removeVisualViewportResize(),Q.clearFitTimeouts(),Q.removeFontListeners(),Q.removeTouchListeners(),Q.disposeFitAddon(),Q.disposeWebglAddon(),Q.disposeTerminal(),Q.restoreDocumentStyles(),Q.restoreViewportStyles()}}write(t){0!==t.data.length?(this.outputOperations.push(Object.assign({type:"write",data:t.data,suppressInput:t.suppressInput??!1},t.onCommitted?{onCommitted:t.onCommitted}:{})),this.processOutputQueue()):t.onCommitted?.()}clear(t){this.outputOperations.push(Object.assign({type:"clear",data:C,suppressInput:!1},t?.onCommitted?{onCommitted:t.onCommitted}:{})),this.processOutputQueue()}renderSnapshot(t){t.state?this.restoreOutput(Object.assign({data:A((0,w.renderTerminalSnapshotToAnsi)(t.state)),rows:t.state.rows,cols:t.state.cols},t.onCommitted?{onCommitted:t.onCommitted}:{})):this.clear(t)}restoreOutput(t){this.outputOperations.push(Object.assign({type:"snapshot",data:F(k,t.data),rows:t.rows,cols:t.cols,suppressInput:!0},t.onCommitted?{onCommitted:t.onCommitted}:{})),this.processOutputQueue()}resize(t){this.fitAndEmitResize?.(t)}setTheme(t){const s=this.terminal;if(s){try{s.options.theme=L(t.theme)}catch{return}this.applyThemeBackground(t.theme),this.refreshVisibleRows()}}setScrollback(t){const s=this.terminal;if(s){try{s.options.scrollback=t.lines}catch{return}this.refreshVisibleRows()}}setFont(t){const s=this.terminal;if(s){try{s.options.fontFamily=E(t.fontFamily),s.options.fontSize=S(t.fontSize)}catch{return}this.fitAndEmitResize?.({force:!0}),this.refreshVisibleRows()}}focus(t){const s=this.terminal;s&&(t?.forceRefocus&&s.blur(),s.focus())}blur(){this.terminal?.blur()}refreshVisibleRows(){const t=this.terminal;if(t&&!(t.rows<=0))try{t.refresh(0,t.rows-1)}catch{}}collectThemeBackgroundElements(t){return[t.root,t.host,...Array.from(t.host.querySelectorAll(".xterm, .xterm-screen, .xterm-viewport"))]}applyThemeBackground(t){const s=t.background??"#0b0b0b";for(const t of this.themeBackgroundElements)t.style.backgroundColor=s}unmount(){this.clearInFlightOutputTimeout();const t=this.inFlightOutputOperation;this.inFlightOutputOperation=null,t?.onCommitted&&t.onCommitted();const s=this.outputOperations.splice(0,this.outputOperations.length);for(const t of s)t.onCommitted?.();for(const t of Array.from(this.pendingWriteCommits))t();this.hasUngatedWrites=!1,this.cleanup?.(),this.cleanup=null,window.__paseoTerminal===this.terminal&&(window.__paseoTerminal=void 0),this.terminal=null,this.fitAddon=null,this.fitAndEmitResize=null,this.lastSize=null,this.themeBackgroundElements=[],this.suppressInput=!1,this.inputModeDecoder.decode(),this.inputModeTracker.reset(),this.emitInputModeChange()}isBarrierOperation(t){return"write"!==t.type||Boolean(t.suppressInput)}processOutputQueue(){if(this.inFlightOutputOperation)return;const t=this.terminal;if(!t)return;for(;this.outputOperations[0]&&!this.isBarrierOperation(this.outputOperations[0]);){const s=this.outputOperations.shift();if(!s)break;this.submitWrite(t,s)}const s=this.outputOperations.shift();if(!s)return;if(!this.hasUngatedWrites)return void this.startBarrierOperation(t,s);let o=!1;const n=()=>{o||this.inFlightOutputOperation!==s||this.terminal!==t||(o=!0,this.clearInFlightOutputTimeout(),this.startBarrierOperation(t,s))};this.inFlightOutputOperation=s,this.inFlightOutputOperationTimeout=setTimeout(n,1e4);try{t.write(C,n)}catch{n()}}submitWrite(t,s){const o=this.inputModeDecoder.decode(s.data,{stream:!0});this.inputModeTracker.feed(o).changed&&this.emitInputModeChange(),this.hasUngatedWrites=!0;const n=s.onCommitted;if(!n){try{t.write(s.data)}catch{}return}const l=()=>{this.pendingWriteCommits.delete(l)&&n()};this.pendingWriteCommits.add(l);try{t.write(s.data,l)}catch{l()}}startBarrierOperation(t,s){this.inFlightOutputOperation=s,this.hasUngatedWrites=!1;const o=this.suppressInput;s.suppressInput&&(this.suppressInput=Boolean(s.suppressInput));const n=t=>{this.inFlightOutputOperation===t&&(this.inFlightOutputOperation=null,this.clearInFlightOutputTimeout(),this.suppressInput=o,t.onCommitted?.(),this.processOutputQueue())};if("clear"===s.type)return this.inputModeDecoder.decode(),this.inputModeTracker.reset(),this.emitInputModeChange(),t.reset(),void n(s);if("snapshot"===s.type){this.inputModeDecoder.decode(),this.inputModeTracker.reset(),this.emitInputModeChange();try{"number"!=typeof s.cols||"number"!=typeof s.rows||t.cols===s.cols&&t.rows===s.rows||t.resize(s.cols,s.rows)}catch{return void n(s)}}const l=s.data;if("write"===s.type){const t=this.inputModeDecoder.decode(l,{stream:!0});this.inputModeTracker.feed(t).changed&&this.emitInputModeChange()}this.inFlightOutputOperationTimeout=setTimeout(()=>{n(s)},1e4);try{t.write(l,()=>{n(s)})}catch{n(s)}}clearInFlightOutputTimeout(){this.inFlightOutputOperationTimeout&&(clearTimeout(this.inFlightOutputOperationTimeout),this.inFlightOutputOperationTimeout=null)}emitInputModeChange(){const t=this.inputModeTracker.getState();(0,f.terminalInputModeStatesEqual)(t,this.lastInputModeState)||(this.lastInputModeState=t,this.callbacks.onInputModeChange?.(t))}applyDocumentBoundsStyles(t){const s=document.documentElement,o=document.body,n=t.root.parentElement,l=s.style.overflow,u=s.style.width,c=s.style.height,h=s.style.getPropertyValue("text-size-adjust"),p=s.style.getPropertyValue("-webkit-text-size-adjust"),f=o.style.overflow,y=o.style.width,w=o.style.height,v=o.style.margin,b=o.style.padding,O=o.style.getPropertyValue("text-size-adjust"),T=o.style.getPropertyValue("-webkit-text-size-adjust"),C=n?.style.overflow??"",k=n?.style.width??"",M=n?.style.height??"";return s.style.overflow="hidden",s.style.width="100%",s.style.height="100%",s.style.setProperty("text-size-adjust","100%"),s.style.setProperty("-webkit-text-size-adjust","100%"),o.style.overflow="hidden",o.style.width="100%",o.style.height="100%",o.style.margin="0",o.style.padding="0",o.style.setProperty("text-size-adjust","100%"),o.style.setProperty("-webkit-text-size-adjust","100%"),n&&(n.style.overflow="hidden",n.style.width="100%",n.style.height="100%"),()=>{s.style.overflow=l,s.style.width=u,s.style.height=c,s.style.setProperty("text-size-adjust",h),s.style.setProperty("-webkit-text-size-adjust",p),o.style.overflow=f,o.style.width=y,o.style.height=w,o.style.margin=v,o.style.padding=b,o.style.setProperty("text-size-adjust",O),o.style.setProperty("-webkit-text-size-adjust",T),n&&(n.style.overflow=C,n.style.width=k,n.style.height=M)}}applyViewportTouchStyles(t){const s=t.host.querySelector(".xterm-viewport"),o=s?.style.overscrollBehavior??"",n=s?.style.touchAction??"",l=s?.style.overflowY??"",u=s?.style.overflowX??"",c=s?.style.pointerEvents??"",h=s?.style.getPropertyValue("-webkit-overflow-scrolling")??"";return s&&(s.style.overscrollBehavior="none",s.style.touchAction="pan-y",s.style.overflowY="auto",s.style.overflowX="hidden",s.style.pointerEvents="auto",s.style.setProperty("-webkit-overflow-scrolling","touch")),()=>{s&&(s.style.overscrollBehavior=o,s.style.touchAction=n,s.style.overflowY=l,s.style.overflowX=u,s.style.pointerEvents=c,s.style.setProperty("-webkit-overflow-scrolling",h))}}setupTouchScrollHandlers(t){let s=0;const o=t.host.querySelector(".xterm-rows > div")?.getBoundingClientRect().height??0,n=o>0?o:18,l={identifier:-1,startX:0,startY:0,lastX:0,lastY:0,mode:null},u=t=>{if(1!==t.touches.length)return s=0,l.identifier=-1,void(l.mode=null);const o=t.touches[0];if(!o)return s=0,l.identifier=-1,void(l.mode=null);l.identifier=o.identifier,l.startX=o.clientX,l.startY=o.clientY,l.lastX=o.clientX,l.lastY=o.clientY,l.mode=null,s=0},c=o=>{if(1!==o.touches.length)return;const u=Array.from(o.touches).find(t=>t.identifier===l.identifier);if(!u)return;const c=u.clientX-l.startX,h=u.clientY-l.startY;if(null===l.mode){const t=Math.abs(c),s=Math.abs(h);(t>8||s>8)&&(l.mode=s>=t?"vertical":"horizontal")}const p=u.clientY-l.lastY;if(l.lastX=u.clientX,l.lastY=u.clientY,"vertical"!==l.mode)return;s+=p;const f=Math.trunc(s/n);0!==f&&(t.terminal.scrollLines(-f),s-=f*n),o.preventDefault()},h=t=>{(Array.from(t.changedTouches).some(t=>t.identifier===l.identifier)||0===t.touches.length)&&(s=0,l.identifier=-1,l.mode=null)},p=()=>{s=0,l.identifier=-1,l.mode=null};return t.root.addEventListener("touchstart",u,{passive:!0}),t.root.addEventListener("touchmove",c,{passive:!1}),t.root.addEventListener("touchend",h,{passive:!0}),t.root.addEventListener("touchcancel",p,{passive:!0}),()=>{t.root.removeEventListener("touchstart",u),t.root.removeEventListener("touchmove",c),t.root.removeEventListener("touchend",h),t.root.removeEventListener("touchcancel",p)}}}},3959,[3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3973]);
|
|
15615
15615
|
__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"Base64",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"BrowserClipboardProvider",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"ClipboardAddon",{enumerable:!0,get:function(){return E}});
|
|
15616
15616
|
/**
|
|
15617
15617
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
@@ -15929,7 +15929,7 @@ __d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{
|
|
|
15929
15929
|
__d(function(g,r,i,a,m,_e,d){"use strict";const e=["onWatchMessage"];Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"WatchInboundToDaemonSchema",{enumerable:!0,get:function(){return l}}),_e.relayWatchAction=h,_e.installWatchActionRelay=function(t){const{onWatchMessage:n}=t,s=(0,o.default)(t,e);return n(e=>h(e,s))};var t,n=r(d[0]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[1]),c=r(d[2]);const l=s.z.discriminatedUnion("type",[c.WatchNotificationActionMessageSchema,c.WatchSessionSearchMessageSchema,c.WatchComposerDictateMessageSchema]);function u(e){console.warn("[watch-relay] dropped watch payload",e)}function h(e,t){const n=t.logDropped??u,o=l.safeParse(e);if(o.success)try{t.sendToDaemon(o.data)}catch(t){n({reason:"send_failed",error:t,raw:e})}else n({reason:"invalid_payload",issues:o.error.issues,raw:e})}},4170,[35,3285,3284]);
|
|
15930
15930
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARCHIVE_AGENT_PENDING_QUERY_KEY",{enumerable:!0,get:function(){return c}}),e.toArchiveKey=y,e.readPendingState=v,e.selectPendingArchiveAgentIds=A,e.setAgentArchiving=I,e.isAgentArchiving=function(t){const n=y(t);if(!n)return!1;return v(t.queryClient)[n]??!1},e.removeAgentFromListPayload=f,e.removeAgentFromCachedLists=h,e.markAgentArchivedInHistoryPayload=Q,e.markAgentArchivedInHistoryCache=b,e.clearArchiveAgentPending=q,e.applyArchivedAgentCloseResults=p,e.usePendingArchiveAgentIds=function(n){const s=(0,t.c)(5),u=w();let o,c;s[0]!==u.data?(o=u.data??{},s[0]=u.data,s[1]=o):o=s[1];s[2]!==n||s[3]!==o?(c=A(o,n),s[2]=n,s[3]=o,s[4]=c):c=s[4];return c},e.useArchiveAgent=function(){const c=(0,t.c)(19),l=(0,n.useQueryClient)(),{t:v}=(0,s.useTranslation)(),A=w();let f,h,Q,b,C;c[0]!==v?(f=async t=>{const n=u.useSessionStore.getState().sessions[t.serverId]?.client??null;if(!n)throw new Error(v("common.errors.daemonClientUnavailable"));return await n.archiveAgent(t.agentId)},c[0]=v,c[1]=f):f=c[1];c[2]!==l?(h=t=>{const n={agent:(s=t,u.useSessionStore.getState().sessions[s.serverId]?.agents.get(s.agentId)),lists:S(l,t.serverId)};var s;const o=(new Date).toISOString();return p({queryClient:l,serverId:t.serverId,results:[{agentId:t.agentId,archivedAt:o}],invalidateQueries:!1}),I({queryClient:l,serverId:t.serverId,agentId:t.agentId,isArchiving:!0}),n},c[2]=l,c[3]=h):h=c[3];c[4]!==l?(Q=(t,n,s)=>{s&&(K({serverId:n.serverId,agentId:n.agentId,agent:s.agent}),D(l,n.serverId,s.lists))},b=(t,n,s)=>{q({queryClient:l,serverId:s.serverId,agentId:s.agentId}),l.invalidateQueries({queryKey:["sidebarAgentsList",s.serverId]}),l.invalidateQueries({queryKey:["allAgents",s.serverId]}),l.invalidateQueries({queryKey:(0,o.agentHistoryQueryKey)(s.serverId)}),l.invalidateQueries({queryKey:(0,o.allAgentHistoryQueryRootKey)()})},c[4]=l,c[5]=Q,c[6]=b):(Q=c[5],b=c[6]);c[7]!==f||c[8]!==h||c[9]!==Q||c[10]!==b?(C={mutationFn:f,onMutate:h,onSuccess:_,onError:Q,onSettled:b},c[7]=f,c[8]=h,c[9]=Q,c[10]=b,c[11]=C):C=c[11];const H=(0,n.useMutation)(C).mutateAsync;let O;c[12]!==H?(O=async t=>{await H(t)},c[12]=H,c[13]=O):O=c[13];const j=O;let L;c[14]!==A.data?(L=t=>{const n=y(t);return!!n&&((A.data??{})[n]??!1)},c[14]=A.data,c[15]=L):L=c[15];const N=L;let P;c[16]!==j||c[17]!==N?(P={archiveAgent:j,isArchivingAgent:N},c[16]=j,c[17]=N,c[18]=P):P=c[18];return P};var t=r(d[0]);r(d[1]);var n=r(d[2]),s=r(d[3]),u=r(d[4]),o=r(d[5]);const c=["archive-agent-pending"],l=new Set;function y(t){const n=t.serverId.trim(),s=t.agentId.trim();return n&&s?`${n}:${s}`:""}function v(t){return t.getQueryData(c)??{}}function A(t,n){const s=n.trim();if(!s)return l;const u=`${s}:`;let o=null;for(const n of Object.keys(t)){if(!n.startsWith(u))continue;const t=n.slice(u.length);t&&(o??=[],o.push(t))}return o&&0!==o.length?new Set(o):l}function I(t){const n=y(t);n&&t.queryClient.setQueryData(c,s=>{const u=s??{};if(t.isArchiving)return u[n]?u:Object.assign({},u,{[n]:!0});if(!u[n])return u;const o=Object.assign({},u);return delete o[n],o})}function f(t,n){if(!t||!Array.isArray(t.entries)||!n)return t;const s=t.entries.filter(t=>t?.agent?.id!==n);return s.length===t.entries.length?t:Object.assign({},t,{entries:s})}function h(t,n){const s=n.agentId.trim();s&&(t.setQueryData(["sidebarAgentsList",n.serverId],t=>f(t,s)),t.setQueryData(["allAgents",n.serverId],t=>f(t,s)))}function Q(t,n){if(!t||!Array.isArray(t.pages)||!n.agentId)return t;const s=new Date(n.archivedAt);if(Number.isNaN(s.getTime()))return t;let u=!1;const o=t.pages.map(t=>{if(!Array.isArray(t.agents))return t;let o=!1;const c=t.agents.map(t=>t.id!==n.agentId||null!=t.serverId&&t.serverId!==n.serverId?t:(o=!0,u=!0,Object.assign({},t,{archivedAt:s})));return o?Object.assign({},t,{agents:c}):t});return u?Object.assign({},t,{pages:o}):t}function b(t,n){t.setQueryData((0,o.agentHistoryQueryKey)(n.serverId),t=>Q(t,n)),t.setQueriesData({queryKey:(0,o.allAgentHistoryQueryRootKey)()},t=>Q(t,n))}function q(t){I(Object.assign({},t,{isArchiving:!1}))}function K(t){(0,u.useSessionStore.getState().setAgents)(t.serverId,n=>{const s=n.has(t.agentId);if(!t.agent){if(!s)return n;const u=new Map(n);return u.delete(t.agentId),u}if(n.get(t.agentId)===t.agent)return n;const u=new Map(n);return u.set(t.agentId,t.agent),u})}function S(t,n){return{sidebarAgentsList:t.getQueryData(["sidebarAgentsList",n]),allAgents:t.getQueryData(["allAgents",n]),agentHistory:t.getQueryData((0,o.agentHistoryQueryKey)(n)),allAgentHistory:t.getQueriesData({queryKey:(0,o.allAgentHistoryQueryRootKey)()})}}function C(t,n,s){void 0!==s?t.setQueryData(n,s):t.removeQueries({queryKey:n,exact:!0})}function D(t,n,s){C(t,["sidebarAgentsList",n],s.sidebarAgentsList),C(t,["allAgents",n],s.allAgents),C(t,(0,o.agentHistoryQueryKey)(n),s.agentHistory);for(const[n,u]of s.allAgentHistory)C(t,n,u)}function H(t){const n=new Date(t.archivedAt);if(Number.isNaN(n.getTime()))return;(0,u.useSessionStore.getState().setAgents)(t.serverId,s=>{const u=s.get(t.agentId);if(!u)return s;if(u.archivedAt&&u.archivedAt.getTime()===n.getTime())return s;const o=new Map(s);return o.set(t.agentId,Object.assign({},u,{archivedAt:n})),o})}function p(t){if(0!==t.results.length){for(const n of t.results)H({serverId:t.serverId,agentId:n.agentId,archivedAt:n.archivedAt}),h(t.queryClient,{serverId:t.serverId,agentId:n.agentId}),b(t.queryClient,{serverId:t.serverId,agentId:n.agentId,archivedAt:n.archivedAt});(t.invalidateQueries??1)&&(t.queryClient.invalidateQueries({queryKey:["sidebarAgentsList",t.serverId]}),t.queryClient.invalidateQueries({queryKey:["allAgents",t.serverId]}),t.queryClient.invalidateQueries({queryKey:(0,o.agentHistoryQueryKey)(t.serverId)}),t.queryClient.invalidateQueries({queryKey:(0,o.allAgentHistoryQueryRootKey)()}))}}function w(){const s=(0,t.c)(2);let u,o;return s[0]===Symbol.for("react.memo_cache_sentinel")?(u={},s[0]=u):u=s[0],s[1]===Symbol.for("react.memo_cache_sentinel")?(o={queryKey:c,queryFn:O,initialData:u,staleTime:1/0,gcTime:1/0},s[1]=o):o=s[1],(0,n.useQuery)(o)}async function O(){return{}}function _(t,n){H({serverId:n.serverId,agentId:n.agentId,archivedAt:t.archivedAt})}},4171,[350,36,3030,352,3427,4015]);
|
|
15931
15931
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createHistorySyncTimeoutError=u,e.refreshAgentInitializationTimeout=I,e.ensureAgentIsInitialized=f,e.refreshAgent=h,e.createSetAgentInitializing=A,e.useAgentInitialization=function(o){const c=(0,t.c)(15),{serverId:l,client:u}=o,{t:I}=(0,n.useTranslation)(),T=(0,s.useSessionStore)(y);let p;c[0]!==l||c[1]!==T?(p=A(l,T),c[0]=l,c[1]=T,c[2]=p):p=c[2];const w=p;let D;c[3]!==u||c[4]!==l||c[5]!==w||c[6]!==I?(D=t=>f({serverId:l,agentId:t,client:u,setAgentInitializing:w,hostDisconnectedMessage:I("workspace.terminal.hostDisconnected")}),c[3]=u,c[4]=l,c[5]=w,c[6]=I,c[7]=D):D=c[7];const z=D;let S;c[8]!==u||c[9]!==w||c[10]!==I?(S=t=>h({agentId:t,client:u,setAgentInitializing:w,hostDisconnectedMessage:I("workspace.terminal.hostDisconnected")}),c[8]=u,c[9]=w,c[10]=I,c[11]=S):S=c[11];const M=S;let k;c[12]!==z||c[13]!==M?(k={ensureAgentIsInitialized:z,refreshAgent:M},c[12]=z,c[13]=M,c[14]=k):k=c[14];return k};var t=r(d[0]);r(d[1]);var n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),l=r(d[6]);function u(){return new Error(`History sync timed out after ${Math.round(o.INIT_TIMEOUT_MS/1e3)}s`)}function I(t){(0,o.refreshInitTimeout)({key:t.key,onTimeout:()=>{t.setAgentInitializing(t.agentId,!1),(0,o.rejectInitDeferred)(t.key,u())}})}function f(t){const{serverId:n,agentId:u,client:f,setAgentInitializing:h}=t,A=(0,o.getInitKey)(n,u),y=(0,o.getInitDeferred)(A);if(y)return y.promise;const T=s.useSessionStore.getState().sessions[n],p=T?.agentTimelineCursor.get(u),w=!0===T?.agentAuthoritativeHistoryApplied.get(u),D=(0,c.planInitialAgentTimelineSync)({cursor:p,hasAuthoritativeHistory:w}),z=(0,o.createInitDeferred)(A,D.direction);return I({key:A,agentId:u,setAgentInitializing:h}),h(u,!0),f?(f.fetchAgentTimeline(u,D).catch(t=>{h(u,!1),(0,o.rejectInitDeferred)(A,t instanceof Error?t:new Error(String(t)))}),z.promise):(h(u,!1),(0,o.rejectInitDeferred)(A,new Error(t.hostDisconnectedMessage??l.i18n.t("workspace.terminal.hostDisconnected"))),z.promise)}async function h(t){const{agentId:n,client:s,setAgentInitializing:o}=t;if(!s)throw new Error(t.hostDisconnectedMessage??l.i18n.t("workspace.terminal.hostDisconnected"));o(n,!0);try{await s.refreshAgent(n),await s.fetchAgentTimeline(n,(0,c.planTimelineTailFetch)())}catch(t){throw o(n,!1),t}}function A(t,n){return(s,o)=>{n(t,t=>{if(t.get(s)===o)return t;const n=new Map(t);return n.set(s,o),n})}}function y(t){return t.setInitializingAgents}},4172,[350,36,352,3427,4173,4174,3549]);
|
|
15932
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"INIT_TIMEOUT_MS",{enumerable:!0,get:function(){return n}}),e.getInitKey=function(t,n){return`${t}:${n}`},e.getInitDeferred=function(n){return t.get(n)},e.createInitDeferred=function(n,o){let u,c;const f={promise:new Promise((t,n)=>{u=t,c=n}),resolve:u,reject:c,timeoutId:null,requestDirection:o};return t.set(n,f),f},e.refreshInitTimeout=function(o){const u=setTimeout(o.onTimeout,o.timeoutMs??n),c=t.get(o.key);if(!c)return void clearTimeout(u);c.timeoutId&&clearTimeout(c.timeoutId);c.timeoutId=u},e.resolveInitDeferred=function(n){const o=t.get(n);if(!o)return;o.timeoutId&&clearTimeout(o.timeoutId);t.delete(n),o.resolve()},e.rejectInitDeferred=function(n,o){const u=t.get(n);if(!u)return;u.timeoutId&&clearTimeout(u.timeoutId);t.delete(n),u.reject(o)};const t=new Map,n=
|
|
15932
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"INIT_TIMEOUT_MS",{enumerable:!0,get:function(){return n}}),e.getInitKey=function(t,n){return`${t}:${n}`},e.getInitDeferred=function(n){return t.get(n)},e.createInitDeferred=function(n,o){let u,c;const f={promise:new Promise((t,n)=>{u=t,c=n}),resolve:u,reject:c,timeoutId:null,requestDirection:o};return t.set(n,f),f},e.refreshInitTimeout=function(o){const u=setTimeout(o.onTimeout,o.timeoutMs??n),c=t.get(o.key);if(!c)return void clearTimeout(u);c.timeoutId&&clearTimeout(c.timeoutId);c.timeoutId=u},e.resolveInitDeferred=function(n){const o=t.get(n);if(!o)return;o.timeoutId&&clearTimeout(o.timeoutId);t.delete(n),o.resolve()},e.rejectInitDeferred=function(n,o){const u=t.get(n);if(!u)return;u.timeoutId&&clearTimeout(u.timeoutId);t.delete(n),u.reject(o)};const t=new Map,n=13e4},4173,[]);
|
|
15933
15933
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planInitialAgentTimelineSync=function(n){if(n.hasAuthoritativeHistory&&n.cursor)return t({epoch:n.cursor.epoch,seq:n.cursor.endSeq});return o()},e.planResumeTimelineSync=function(n){if(n.cursor)return t({epoch:n.cursor.epoch,seq:n.cursor.endSeq});return o()},e.planTimelineCatchUpAfter=t,e.planTimelineTailFetch=o,e.planTimelineOlderFetch=function(t){return{direction:"before",cursor:t,limit:n.TIMELINE_FETCH_PAGE_SIZE,projection:"projected"}},e.planTimelineCatchUpFollowUp=function(n){if(n.error||"after"!==n.direction||!n.hasNewer||!n.endCursor)return null;return t(n.endCursor)},e.isTimelineCatchUpComplete=function(n){if(n.error)return!1;return"after"!==n.direction||!n.hasNewer};var n=r(d[0]);function t(t){return{direction:"after",cursor:t,limit:n.TIMELINE_FETCH_PAGE_SIZE,projection:"projected"}}function o(){return{direction:"tail",limit:n.TIMELINE_FETCH_PAGE_SIZE,projection:"projected"}}},4174,[4175]);
|
|
15934
15934
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TIMELINE_FETCH_PAGE_SIZE",{enumerable:!0,get:function(){return t}});const t=100},4175,[]);
|
|
15935
15935
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.processTimelineResponse=function(t){const{payload:n,currentTail:s,currentHead:c,currentCursor:l,isInitializing:p,hasActiveInitDeferred:f,initRequestDirection:q}=t;if(n.error)return{tail:s,head:c,cursor:l,cursorChanged:!1,initResolution:f?"reject":null,clearInitializing:p,error:n.error,sideEffects:[]};const S=n.entries.map(t=>({seq:t.seqStart,seqEnd:t.seqEnd,sourceSeqRanges:t.sourceSeqRanges&&t.sourceSeqRanges.length>0?t.sourceSeqRanges:[{startSeq:t.seqStart,endSeq:t.seqEnd}],event:{type:"timeline",provider:t.provider,item:t.item},timestamp:new Date(t.timestamp)})),C=o({direction:n.direction,reset:n.reset,epoch:n.epoch,endCursor:n.endCursor,isInitializing:p,hasActiveInitDeferred:f}),v=C.replace,y=[],A=v?h({timelineUnits:S,payload:n,bootstrapPolicy:C,currentTail:s,currentHead:c,toHydratedEvents:t=>t.map(({event:t,timestamp:n})=>({event:t,timestamp:n}))}):T({timelineUnits:S,payload:n,currentTail:s,currentHead:c,currentCursor:l}),E=A.tail,_=A.head,U=A.cursor,x=A.cursorChanged;y.push(...A.sideEffects),y.push({type:"flush_pending_updates"});const H=u({hasActiveInitDeferred:f,hasNewer:n.hasNewer,isInitializing:p,initRequestDirection:q,responseDirection:n.direction,reset:n.reset}),b="after"!==n.direction||!n.hasNewer;return{tail:E,head:_,cursor:U,cursorChanged:x,initResolution:H?"resolve":null,clearInitializing:(H||p&&!f)&&b,error:null,sideEffects:y}},e.processAgentStreamEvent=U,e.processAgentStreamEvents=x,e.createAgentStreamReducerQueue=H,e.createSessionAgentStreamReducerQueue=function(n){const{serverId:s,setAgentStreamState:c,setAgentTimelineCursor:o,setAgents:u,requestCanonicalCatchUp:l}=n;return H({getSnapshot:n=>{const c=t.useSessionStore.getState().sessions[s],o=c?.agents.get(n);return{currentTail:c?.agentStreamTail.get(n)??[],currentHead:c?.agentStreamHead.get(n)??[],currentCursor:c?.agentTimelineCursor.get(n),currentAgent:o?{status:o.status,updatedAt:o.updatedAt,lastActivityAt:o.lastActivityAt}:null}},commit:(t,n,l)=>{if((n.changedTail||n.changedHead)&&c(s,t,Object.assign({},n.changedTail?{tail:n.tail}:{},n.changedHead?{head:n.head}:{})),n.cursorChanged&&n.cursor){const c=n.cursor,u=l.at(-1);o(s,n=>{const s=n.get(t);if(s&&u&&"number"==typeof u.seq&&"string"==typeof u.epoch&&s.epoch===u.epoch&&u.seq>=s.startSeq&&u.seq<=s.endSeq)return n;if(s&&s.epoch===c.epoch&&s.startSeq===c.startSeq&&s.endSeq===c.endSeq)return n;const o=new Map(n);return o.set(t,c),o})}if(n.agentChanged&&n.agent){const c=n.agent;u(s,n=>{const s=n.get(t);if(!s)return n;const o=new Map(n);return o.set(t,Object.assign({},s,{status:c.status,updatedAt:c.updatedAt,lastActivityAt:c.lastActivityAt})),o})}},handleSideEffects:(t,n)=>{for(const s of n)"catch_up"===s.type&&l(t,s.cursor)},scheduleFlush:b,cancelFlush:I})};var t=r(d[0]),n=r(d[1]);const s=48;function c({cursor:t,epoch:n,seq:s}){return t?t.epoch!==n?"drop_epoch":s<=t.endSeq?"drop_stale":s===t.endSeq+1?"accept":"gap":"init"}function o({direction:t,reset:n,epoch:s,endCursor:c,isInitializing:o,hasActiveInitDeferred:u}){if(n)return{replace:!0,catchUpCursor:null};return"tail"===t&&o&&u?{replace:!0,catchUpCursor:c?{epoch:s,endSeq:c.seq}:null}:{replace:!1,catchUpCursor:null}}function u({hasActiveInitDeferred:t,hasNewer:n,isInitializing:s,initRequestDirection:c,responseDirection:o,reset:u}){return!(!t||!s)&&(!!u||("after"!==o||!n)&&o===c)}function l(t,n){if("running"!==t)return null;switch(n.type){case"turn_completed":return"idle";case"turn_failed":return"error";default:return null}}function p(t){const{tail:n,currentHead:s}=t,c=s.findLast(t=>"assistant_message"===t.kind);if(!c)return{tail:n,head:[]};const o=n.at(-1);return o&&"assistant_message"===o.kind?c.text.startsWith(o.text)?{tail:n.slice(0,-1),head:[Object.assign({},c,{text:o.text})]}:{tail:n,head:[]}:{tail:n,head:s}}function h(t){const{timelineUnits:s,payload:c,bootstrapPolicy:o,currentTail:u,currentHead:l,toHydratedEvents:h}=t,f=S({canonicalTail:(0,n.hydrateStreamState)(h(s),{source:"canonical"}),previousTail:u,previousHead:l}),{tail:q,head:C}=p({tail:f,currentHead:l}),v=c.startCursor&&c.endCursor?{epoch:c.epoch,startSeq:c.startCursor.seq,endSeq:c.endCursor.seq}:null,y=[];return o.catchUpCursor&&y.push({type:"catch_up",cursor:o.catchUpCursor}),{tail:q,head:C,cursor:v,cursorChanged:!0,sideEffects:y}}function f(t){const n=[];let s=0;for(const c of t)"user_message"===c.kind&&(c.optimistic&&n.push({ordinal:s,item:c}),s+=1);return n}function q(t,n){return Object.assign({kind:"user_message",id:t.id,text:n.text,timestamp:n.timestamp},n.images&&n.images.length>0?{images:n.images}:{},n.attachments&&n.attachments.length>0?{attachments:n.attachments}:{})}function S(t){const n=f([...t.previousTail,...t.previousHead]);if(0===n.length)return t.canonicalTail;const s=[];t.canonicalTail.forEach((t,n)=>{"user_message"===t.kind&&s.push(n)});let c=!1;const o=[...t.canonicalTail];let u=0;const l=[];for(const t of n){const n=s.findIndex((n,s)=>s>=Math.max(t.ordinal,u));if(n<0){l.push(t.item);continue}const p=s[n],h=void 0!==p?o[p]:void 0;h&&"user_message"===h.kind?(o[p]=q(h,t.item),u=n+1,c=!0):l.push(t.item)}return 0===l.length?c?o:t.canonicalTail:[...o,...l]}function C(t){const{timelineUnits:n,payload:s,currentCursor:c}=t,o=n[0],u=n[n.length-1],l=s.startCursor?.seq??o?.seq,p=s.endCursor?.seq??u?.seqEnd;return void 0===l||void 0===p?{acceptedUnits:[],cursor:c,gapCursor:null}:c?c.epoch!==s.epoch?{acceptedUnits:[],cursor:c,gapCursor:null}:(!s.startCursor||!s.endCursor)&&l<=c.endSeq&&p>c.endSeq?{acceptedUnits:[],cursor:c,gapCursor:{epoch:c.epoch,endSeq:c.endSeq}}:p<=c.endSeq?{acceptedUnits:[],cursor:c,gapCursor:null}:l>c.endSeq+1?{acceptedUnits:[],cursor:c,gapCursor:{epoch:c.epoch,endSeq:c.endSeq}}:{acceptedUnits:n,cursor:Object.assign({},c,{endSeq:p}),gapCursor:null}:{acceptedUnits:n,cursor:{epoch:s.epoch,startSeq:l,endSeq:p},gapCursor:null}}function v(t){const{timelineUnits:n,payload:s,currentCursor:c}=t;if(!c||c.epoch!==s.epoch)return{acceptedUnits:[],cursor:c,gapCursor:null};const o=n[0],u=n[n.length-1],l=s.startCursor?.seq??o?.seq,p=s.endCursor?.seq??u?.seqEnd;return void 0===l||void 0===p||p>=c.startSeq?{acceptedUnits:[],cursor:c,gapCursor:null}:{acceptedUnits:n,cursor:Object.assign({},c,{startSeq:l}),gapCursor:null}}function y(t,s){if(0===t.length)return s;if(0===s.length)return t;const c=t.at(-1),o=s[0];return c&&o&&(0,n.isAgentToolCallItem)(c)&&(0,n.isAgentToolCallItem)(o)&&c.payload.data.callId===o.payload.data.callId?[...t.slice(0,-1),(0,n.mergeAgentToolCallItem)(c,o.payload.data,o.timestamp),...s.slice(1)]:"assistant_message"!==c?.kind||"assistant_message"!==o?.kind?[...t,...s]:[...t.slice(0,-1),Object.assign({},c,{text:`${c.text}${o.text}`,timestamp:o.timestamp}),...s.slice(1)]}function A(t){const{head:n,event:s,timestamp:c}=t;if("timeline"!==s.type||"assistant_message"!==s.item.type)return null;const o=n.findLastIndex(t=>"assistant_message"===t.kind),u=n[o];if(!u||"assistant_message"!==u.kind)return null;if(!s.item.text.startsWith(u.text))return null;const l=[...n];return l[o]=Object.assign({},u,{text:s.item.text,timestamp:c}),l}function T(t){const{timelineUnits:s,payload:c,currentTail:o,currentHead:u,currentCursor:l}=t;let p=o,h=u,f=l,q=!1;const S=[];if(0===s.length)return{tail:p,head:h,cursor:f,cursorChanged:q,sideEffects:S};const{acceptedUnits:T,cursor:E,gapCursor:_}="before"===c.direction?v({timelineUnits:s,payload:c,currentCursor:l}):C({timelineUnits:s,payload:c,currentCursor:l});if(T.length>0)if("before"===c.direction){p=y((0,n.hydrateStreamState)(T.map(({event:t,timestamp:n})=>({event:t,timestamp:n})),{source:"canonical"}),o)}else if(u.length>0)for(const{event:t,timestamp:s}of T){const c=A({head:h,event:t,timestamp:s});if(c){h=c;continue}const o=(0,n.applyStreamEvent)({tail:p,head:h,event:t,timestamp:s,source:"canonical"});p=o.tail,h=o.head}else p=T.reduce((t,{event:s,timestamp:c})=>(0,n.reduceStreamUpdate)(t,s,c,{source:"canonical"}),o);return!E||l&&l.epoch===E.epoch&&l.startSeq===E.startSeq&&l.endSeq===E.endSeq||(f=E,q=!0),_&&S.push({type:"catch_up",cursor:_}),{tail:p,head:h,cursor:f,cursorChanged:q,sideEffects:S}}function E(t,n){return t&&n?{status:n.status,updatedAt:n.updatedAt,lastActivityAt:n.lastActivityAt}:t}function _(t){const{event:n,seq:s,epoch:o,currentCursor:u}=t,l={shouldApplyStreamEvent:!0,nextTimelineCursor:null,cursorChanged:!1,resetLiveTimeline:!1,sideEffects:[]};if("timeline"!==n.type||"number"!=typeof s||"string"!=typeof o)return l;const p=c({cursor:u?{epoch:u.epoch,endSeq:u.endSeq}:null,epoch:o,seq:s});return"init"===p?Object.assign({},l,{nextTimelineCursor:{epoch:o,startSeq:s,endSeq:s},cursorChanged:!0}):"accept"===p?Object.assign({},l,{nextTimelineCursor:Object.assign({},u??{epoch:o,startSeq:s,endSeq:s},{epoch:o,endSeq:s}),cursorChanged:!0}):"gap"===p?Object.assign({},l,{shouldApplyStreamEvent:!1,sideEffects:u?[{type:"catch_up",cursor:{epoch:u.epoch,endSeq:u.endSeq}}]:[]}):"drop_epoch"===p&&1===s?Object.assign({},l,{nextTimelineCursor:{epoch:o,startSeq:s,endSeq:s},cursorChanged:!0,resetLiveTimeline:!0}):Object.assign({},l,{shouldApplyStreamEvent:!1})}function U(t){const{event:s,seq:c,epoch:o,currentTail:u,currentHead:p,currentCursor:h,currentAgent:f,timestamp:q}=t,S=_({event:s,seq:c,epoch:o,currentCursor:h}),{tail:C,head:v,changedTail:y,changedHead:A}=S.shouldApplyStreamEvent?(0,n.applyStreamEvent)({tail:S.resetLiveTimeline?[]:u,head:S.resetLiveTimeline?[]:p,event:s,timestamp:q,source:"live"}):{tail:u,head:p,changedTail:!1,changedHead:!1};let T=null,E=!1;if(f&&("turn_completed"===s.type||"turn_canceled"===s.type||"turn_failed"===s.type)){const t=l(f.status,s);if(t){const n=Math.max(f.updatedAt.getTime(),q.getTime()),s=Math.max(f.lastActivityAt.getTime(),q.getTime());T={status:t,updatedAt:new Date(n),lastActivityAt:new Date(s)},E=!0}}return{tail:C,head:v,changedTail:y,changedHead:A,cursor:S.nextTimelineCursor,cursorChanged:S.cursorChanged,agent:T,agentChanged:E,sideEffects:S.sideEffects}}function x(t){let n=t.currentTail,s=t.currentHead,c=t.currentCursor,o=t.currentAgent,u=!1,l=!1,p=!1,h=null,f=!1;const q=[];for(const S of t.events){const t=U({event:S.event,seq:S.seq,epoch:S.epoch,currentTail:n,currentHead:s,currentCursor:c,currentAgent:o,timestamp:S.timestamp});n=t.tail,s=t.head,u=u||t.changedTail,l=l||t.changedHead,q.push(...t.sideEffects),t.cursorChanged&&(c=t.cursor??void 0,p=!0),t.agentChanged&&(h=t.agent,f=!0,o=E(o,t.agent))}return{tail:n,head:s,changedTail:u,changedHead:l,cursor:c??null,cursorChanged:p,agent:h,agentChanged:f,sideEffects:q}}function H(t){const n=new Map;let s=null;const c=()=>{null!==s&&(t.cancelFlush(s),s=null)},o=s=>{const o=n.get(s);if(!o||0===o.length)return;n.delete(s),0===n.size&&c();const u=x(Object.assign({events:o},t.getSnapshot(s)));t.commit(s,u,o),u.sideEffects.length>0&&t.handleSideEffects(s,u.sideEffects)},u=()=>{const t=Array.from(n.keys());for(const n of t)o(n)};return{enqueue(c,o){const l=n.get(c);l?l.push(o):n.set(c,[o]),null===s&&(s=t.scheduleFlush(()=>{s=null,u()}))},flush:u,flushAgent:o,dispose(t){c(),t?.flush?u():n.clear()}}}function b(t){return setTimeout(t,s)}function I(t){clearTimeout(t)}},4176,[3427,3429]);
|
|
@@ -16238,7 +16238,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
16238
16238
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDurationVital",{enumerable:!0,get:function(){return n}});var t=r(d[0]);const n=(n,u)=>{(0,t.onRumInit)((t,o)=>{o.addDurationVital(n,u)})}},4479,[4475]);
|
|
16239
16239
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.initializePostHog=function(){if(s)return!0;if("undefined"==typeof window||"undefined"==typeof document)return!1;try{const c="phc_tbTqBgZgqNyuMQ6R2ZBXnpGtWKMNTZwhSKLLZxb7KTmj",u=n;return o.posthog.init(c,{api_host:u,disable_session_recording:!0,autocapture:!0,persistence:"localStorage",cross_subdomain_cookie:!1,person_profiles:"identified_only",capture_pageview:"history_change",loaded:o=>{o.register({paseo_app_version:(0,t.resolveAppVersion)()??"unknown"})}}),s=!0,console.log(`[PostHog] initialized (host=${u}, recording=off, autocapture=ON (trial))`),!0}catch(o){return console.error("[PostHog] failed to initialize:",o),!1}},e.captureEvent=function(t,n){if(!s)return;try{o.posthog.capture(t,n)}catch(o){console.error("[PostHog] capture failed:",o)}},e.identifyUser=function(t,n){if(!s)return;try{o.posthog.identify(t,n)}catch(o){console.error("[PostHog] identify failed:",o)}},e.resetAnalytics=function(){if(!s)return;try{o.posthog.reset()}catch(o){console.error("[PostHog] reset failed:",o)}};var o=r(d[0]),t=r(d[1]);const n="https://eu.i.posthog.com";let s=!1},4480,[4481,3414]);
|
|
16240
16240
|
__d(function(e,t,i,s,n,r,o){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"Compression",{enumerable:!0,get:function(){return ha}}),Object.defineProperty(r,"DEFAULT_PRODUCT_TOUR_APPEARANCE",{enumerable:!0,get:function(){return Sa}}),Object.defineProperty(r,"DisplaySurveyType",{enumerable:!0,get:function(){return Ea}}),Object.defineProperty(r,"PostHog",{enumerable:!0,get:function(){return kc}}),Object.defineProperty(r,"ProductTourEventName",{enumerable:!0,get:function(){return ka}}),Object.defineProperty(r,"ProductTourEventProperties",{enumerable:!0,get:function(){return Pa}}),Object.defineProperty(r,"SurveyEventName",{enumerable:!0,get:function(){return wa}}),Object.defineProperty(r,"SurveyEventProperties",{enumerable:!0,get:function(){return xa}}),Object.defineProperty(r,"SurveyEventType",{enumerable:!0,get:function(){return pa}}),Object.defineProperty(r,"SurveyPosition",{enumerable:!0,get:function(){return fa}}),Object.defineProperty(r,"SurveyQuestionBranchingType",{enumerable:!0,get:function(){return ya}}),Object.defineProperty(r,"SurveyQuestionType",{enumerable:!0,get:function(){return ma}}),Object.defineProperty(r,"SurveySchedule",{enumerable:!0,get:function(){return ba}}),Object.defineProperty(r,"SurveyTabPosition",{enumerable:!0,get:function(){return ga}}),Object.defineProperty(r,"SurveyType",{enumerable:!0,get:function(){return _a}}),Object.defineProperty(r,"SurveyWidgetType",{enumerable:!0,get:function(){return va}}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return ld}}),Object.defineProperty(r,"posthog",{enumerable:!0,get:function(){return ad}}),Object.defineProperty(r,"severityLevels",{enumerable:!0,get:function(){return Ca}});const a="u">typeof window?window:void 0,l="u">typeof globalThis?globalThis:a,c=null==l?void 0:l.navigator,u=null==l?void 0:l.document,d=null==l?void 0:l.location,h=null==l?void 0:l.fetch,p=(null==l?void 0:l.XMLHttpRequest)&&"withCredentials"in new l.XMLHttpRequest?l.XMLHttpRequest:void 0,v=null==l?void 0:l.AbortController,f=null==l?void 0:l.CompressionStream,g=null==c?void 0:c.userAgent;function _(){return!(!a||!1===a.navigator.onLine)}const m="undefined"!=typeof globalThis?globalThis:a;m&&"undefined"==typeof self&&(m.self=m),m&&"undefined"==typeof File&&(m.File=function(){});const y=null!=a?a:{},b="0.8.3",w={DEBUG:!1,LIB_VERSION:b,LIB_NAME:"browser-common",JS_SDK_VERSION:b};var x=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e})({}),E=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const $=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],S=["token"];function k(e,t){return-1!==e.indexOf(t)}const P=function(e){return e.trim()},M=function(e){return e.replace(/^\$/,"")};function O(e){var t;const i=[];return null!==(t=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}}))&&void 0!==t?t:"null"}const T=Object.prototype,F=T.hasOwnProperty,C=T.toString,I=Array.isArray||function(e){return"[object Array]"===C.call(e)},R=e=>"function"==typeof e,A=e=>e===Object(e)&&!I(e),L=e=>{if(A(e)){for(const t in e)if(F.call(e,t))return!1;return!0}return!1},D=e=>void 0===e,N=e=>"[object String]"==C.call(e),j=e=>N(e)&&0===e.trim().length,B=e=>null===e,U=e=>D(e)||B(e),H=e=>"[object Number]"==C.call(e)&&e==e,z=e=>H(e)&&e>0,q=e=>"[object Boolean]"===C.call(e),V=e=>k($,e),W=e=>k(S,e);function G(e){return null===e||"object"!=typeof e}function K(e,t){return{}.toString.call(e)===`[object ${t}]`}function Y(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Z(e,Error)}}function J(e){return"u">typeof Event&&Z(e,Event)}function Z(e,t){try{return e instanceof t}catch(e){return!1}}const X=[!0,"true",1,"1","yes"],Q=e=>k(X,e),ee=[!1,"false",0,"0","no"];function te(e,t,i,s,n,r,o){try{var a=e[r](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,n)}function ie(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var r=e.apply(t,i);function o(e){te(r,s,n,o,a,"next",e)}function a(e){te(r,s,n,o,a,"throw",e)}o(void 0)})}}const se=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],ne=function(e,t=[]){if(!e)return!1;const i=e.toLowerCase();return se.concat(t).some(e=>{const t=e.toLowerCase();return-1!==i.indexOf(t)})};function re(e,t,i,s,n){return t>i&&(s.warn("min cannot be greater than max."),t=i),H(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),re(null!=n?n:i,t,i,s))}var oe=class{constructor(e){this.C={},this.I=e.I,this.R=re(e.bucketSize,0,100,e.$),this.A=re(e.refillRate,0,this.R,e.$),this.O=re(e.refillInterval,0,864e5,e.$)}F(e,t){const i=Math.floor((t-e.lastAccess)/this.O);i>0&&(e.tokens=Math.min(e.tokens+i*this.A,this.R),e.lastAccess=e.lastAccess+i*this.O)}consumeRateLimit(e){var t;const i=Date.now(),s=String(e);let n=this.C[s];return n?this.F(n,i):(n={tokens:this.R,lastAccess:i},this.C[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(t=this.I)||void 0===t||t.call(this,e)),0===n.tokens)}stop(){this.C={}}};const ae="Mobile",le="Android",ce="Tablet",ue="Android Tablet",de="iPad",he="Apple Watch",pe="Safari",ve="BlackBerry",fe="Samsung Internet",ge="Chrome",_e="Chrome iOS",me="Internet Explorer",ye="Internet Explorer Mobile",be="Opera",we="Microsoft Edge",xe="Firefox",Ee="Firefox iOS",$e="Nintendo",Se="PlayStation",ke="Xbox",Pe="Android Mobile",Me="Mobile Safari",Oe="Windows",Te="Windows Phone",Fe="Nokia",Ce="Ouya",Ie="Generic "+ae.toLowerCase(),Re="Generic "+ce.toLowerCase(),Ae="Konqueror",Le="Oculus Browser",De="Vivaldi",Ne="Yandex",je="Whale",Be="DuckDuckGo",Ue="Pale Moon",He="Waterfox",ze="Brave",qe="Claude",Ve="Codex",We="ChatGPT",Ge="Google Search App",Ke=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ye=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Je=new RegExp(ke,"i"),Ze=new RegExp("PlayStation \\w+","i"),Xe=new RegExp("Nintendo \\w+","i"),Qe=new RegExp("BlackBerry|PlayBook|BB10","i"),et={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},tt=function(e,t,i,s){t=t||"";const n=(function(e){return(null==e?void 0:e.brave)?ze:null})(i);return n||((null==s?void 0:s.detectGoogleSearchApp)&&k(e,"GSA/")?Ge:k(e," OPR/")&&k(e,"Mini")?"Opera Mini":k(e," OPR/")?be:Qe.test(e)?ve:k(e,"IEMobile")||k(e,"WPDesktop")?ye:k(e,"OculusBrowser")?Le:k(e,"SamsungBrowser")?fe:k(e,"Edge")||k(e,"Edg/")?we:k(e,"Vivaldi/")?De:k(e,"YaBrowser/")?Ne:k(e,"Whale/")?je:k(e,"DuckDuckGo/")||k(e,"Ddg/")?Be:k(e,"Claude/")?qe:k(e,"Codex/")?Ve:k(e,"ChatGPT/")?We:k(e,"FBIOS")?"Facebook Mobile":k(e,"UCWEB")||k(e,"UCBrowser")?"UC Browser":k(e,"CriOS")?_e:k(e,"CrMo")||k(e,ge)?ge:k(e,le)&&k(e,pe)?Pe:k(e,"FxiOS")?Ee:k(e.toLowerCase(),Ae.toLowerCase())?Ae:k(e,"Brave/")?ze:((e,t)=>t&&k(t,"Apple")||(function(e){return k(e,pe)&&!k(e,ge)&&!k(e,le)})(e))(e,t)?k(e,ae)?Me:pe:k(e,"PaleMoon/")?Ue:k(e,"Waterfox/")?He:k(e,xe)?xe:k(e,"MSIE")||k(e,"Trident/")?me:k(e,"Gecko")?xe:"")},it={[ye]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[we]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[ge]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[_e]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[pe]:[Ke],[Me]:[Ke],[be]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[xe]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Ee]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ae]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[ve]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ke],[Pe]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[fe]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Le]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[De]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Ne]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[je]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[ze]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[qe]:[Ye],[Ve]:[Ye],[We]:[Ye],[Be]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Ue]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[He]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Ge]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[me]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},st=function(e,t,i,s){const n=tt(e,t,i,s),r=it[n];if(D(r))return null;for(let t=0;r.length>t;t++){const i=e.match(r[t]);if(i)return parseFloat(i[i.length-2])}return null},nt=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[ke,e&&e[1]||""]],[new RegExp($e,"i"),[$e,""]],[new RegExp(Se,"i"),[Se,""]],[Qe,[ve,""]],[new RegExp(Oe,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Te,""];if(new RegExp(ae).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let e=et[i[1]]||"";return/arm/i.test(t)&&(e="RT"),[Oe,e]}return[Oe,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=D(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[le,[e[2],e[3],e[4]||"0"].join(".")]:[le,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],rt=function(e){for(let t=0;nt.length>t;t++){const[i,s]=nt[t],n=i.exec(e),r=n&&(R(s)?s(n,e):s);if(r)return r}return["",""]},ot=function(e){return Xe.test(e)?$e:Ze.test(e)?Se:Je.test(e)?ke:new RegExp(Ce,"i").test(e)?Ce:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?Te:/iPad/.test(e)?de:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?he:Qe.test(e)?ve:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Fe,"i").test(e)?Fe:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(ae).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?le:ue:new RegExp("(pda|Mobile)","i").test(e)?Ie:new RegExp(ce,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?Re:""},at=function(e,t){var i;const s=ot(e);return s===de||s===ue||"Kobo"===s||"Kindle Fire"===s||s===Re?ce:s===$e||s===ke||s===Se||s===Ce?"Console":s===he?"Wearable":s?ae:"Android"===(null==t?void 0:t.userAgentDataPlatform)&&(null!==(i=null==t?void 0:t.maxTouchPoints)&&void 0!==i?i:0)>0?600>Math.min(null!==(n=null==t?void 0:t.screenWidth)&&void 0!==n?n:0,null!==(r=null==t?void 0:t.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==t?void 0:t.devicePixelRatio)&&void 0!==o?o:1)?ae:ce:"Desktop";var n,r,o},lt=/\bFBAV\/(\d+(?:\.\d+)*)/i,ct=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",lt],[/\bFBAN\/EMA\b/i,"Facebook Lite",lt],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",lt],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],ut="[Truncated]",dt="[Unserializable]";function ht(e){let t="";for(let i=0;e.length>i;i++){const s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"\ufffd";else{const s=e.charCodeAt(i+1);56320>s||s>57343?t+="\ufffd":(t+=e[i]+e[i+1],i++)}}return t}function pt(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch(e){i=[]}for(const s of i){let i;try{i=t[s]}catch(e){i=dt}Object.defineProperty(e,s,{value:i,enumerable:!0,writable:!0,configurable:!0})}return e}Date,Date;const vt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ft(e,t){return"string"==typeof(i=e)&&vt.test(i)?e:t();var i}function gt(e,t){const i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function _t(e){return e?e.split("#")[0]:e}function mt(e){try{return e()}catch(e){return}}function yt(e,t){const i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function bt(e,t,i){return wt.apply(this,arguments)}function wt(){return(wt=ie(function*(e,t,i){let s;try{return yield Promise.race([e,new Promise((e,n)=>{s=yt(()=>{try{null==i||i(),e()}catch(e){n(e)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}let xt,Et,$t;function St(e){const t=globalThis._posthogChunkIds;if(!t)return;const i=Object.keys(t);return $t&&i.length===Et||(Et=i.length,$t=i.reduce((i,s)=>{xt||(xt={});const n=xt[s];if(n)i[n[0]]=n[1];else{const n=e(s);for(let e=n.length-1;e>=0;e--){const r=n[e],o=null==r?void 0:r.filename,a=t[s];if(o&&a){i[o]=a,xt[s]=[o,a];break}}}return i},{})),$t}function kt(e){return kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kt(e)}function Pt(e,t,i){return(t=(function(e){var t=(function(e){if("object"!=kt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=kt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)})(e);return"symbol"==kt(t)?t:t+""})(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Mt(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function Ot(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Mt(Object(i),!0).forEach(function(t){Pt(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Mt(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var Tt=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){const i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return ie(function*(){for(const i of e)i.stacktrace&&i.stacktrace.frames&&I(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null===(t=e.syntheticException)||void 0===t?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){let i,s;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),Ot(Ot({},e),{},{cause:i,stack:s})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(const i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return ie(function*(){let i=e;for(const e of t.modifiers)i=yield e(i);return i})()}convertToExceptionList(e,t){var i,s,n;const r={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(r.stacktrace={type:"raw",frames:e.stack});const o=[r];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,Ot(Ot({},t),{},{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:St(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i=0){const s=(i,s)=>{if(4>=s){const n=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,n)}};return Ot(Ot({},t),{},{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,i),next:e=>s(e,i+1)})}};const Ft=/^([a-z][a-z0-9.+-]+):/i,Ct=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function It(e){if(!e||"<anonymous>"===e)return!1;const t=Ft.exec(e);return!t||Ct.includes(t[1].toLowerCase())}function Rt(e,t,i,s,n){const r={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:It(t)};return D(s)||(r.lineno=s),D(n)||(r.colno=n),r}const At=(e,t)=>{const i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:"?",i?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Lt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Dt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Nt=/\((\S*)(?::(\d+))(?::(\d+))\)/,jt=(e,t)=>{const i=Lt.exec(e);if(i){const[,e,s,n]=i;return Rt(t,e,"?",+s,+n)}const s=Dt.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){const e=Nt.exec(s[2]);e&&(s[2]=e[1],s[3]=e[2],s[4]=e[3])}const[e,i]=At(s[1]||"?",s[2]);return Rt(t,i,e,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},Bt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ut=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ht=(e,t)=>{const i=Bt.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){const e=Ut.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="")}let e=i[3],s=i[1]||"?";return[s,e]=At(s,e),Rt(t,e,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},zt=/\(error: (.*)\)/;function qt(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Vt(e){for(let t=1;10>=t;t++){const i=e.length-2*t;if(0>i)break;let s=!0;for(let n=0;t>n;n++)if(!qt(e[i+n],e[i+t+n])){s=!1;break}if(s){for(let s=0;t>s;s++)e[i+s]=e[i+t+s];return e.length=i+t,{start:i,length:t}}}}function Wt(e,t){const i=t.start+t.length,s=Kt(e,t);s&&e.splice(i+s===e.length?i:t.start,s)}function Gt(e,t){let i=t.start;for(;i>0&&qt(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function Kt(e,t){const i=t.start+t.length;let s=i;for(;e.length>s&&qt(e[s],e[s-t.length]);)s++;return s-i}function Yt(e,t){const i=t[0];let s=e.length-(i?Gt(e,i):0);for(const i of t)s-=Kt(e,i);return s}function Jt(e,t,i){for(let s=0;e.length>s;s++){const n=e[(t+s)%e.length],r=e[(i+s)%e.length];if(n!==r)return r>n}return!1}var Zt=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const i=N(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return K(e,"DOMException")}isDOMError(e){return K(e,"DOMError")}},Xt=class{match(e){return Y(e)}coerce(e,t){var i;const s=this.getStack(e),n=void 0===s;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=s?s:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},Qt=class{match(e){return!!K(e,"ErrorEvent")&&(null!=e.error||this.lr(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);const s=t.apply(e.message);return Ot(Ot({},s),{},{stack:null!==(i=this.ur(e))&&void 0!==i?i:s.stack,synthetic:!0})}lr(e){return N(e.message)&&e.message.length>0}ur(e){var t,i;const s=e,n=null!==(t=s.lineno)&&void 0!==t?t:0,r=null!==(i=s.colno)&&void 0!==i?i:0;if(N(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const ei=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var ti=class{match(e){return"string"==typeof e}coerce(e,t){var i;const[s,n]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=n?n:e,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e;const s=e.match(ei);return s&&(t=s[1],i=s[2]),[t,i]}};const ii=["fatal","error","warning","log","info","debug"];function si(e,t=40){const i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let e=i.length;e>0;e--){const s=i.slice(0,e).join(", ");if(t>=s.length)return e===i.length?s:s.length>t?`${s.slice(0,t)}...`:s}return""}var ni=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s;const n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null===(s=t.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(J(e))return e.constructor.name;const t="name"in e?e.name:void 0;return N(t)&&!j(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){let t=`'${e.name}' captured as exception`;return"message"in e&&"string"==typeof e.message&&(t+=` with message: '${e.message}'`),t}if("message"in e&&"string"==typeof e.message)return e.message;const t=this.getObjectClassName(e);return`${t&&"Object"!==t?`'${t}'`:"Object"} captured as exception with keys: ${si(e)}`}isSeverityLevel(e){return N(e)&&!j(e)&&ii.indexOf(e)>=0}getStack(e){try{return N(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:N(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=e[t];if(Y(i))return i}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},ri=class{match(e){return J(e)}coerce(e,t){var i;const s=e.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${si(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},oi=class{match(e){return G(e)}coerce(e,t){var i;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},ai=class{match(e){return K(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!J(e))return!1;try{const t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i;const s=this.getUnhandledRejectionReason(e);return G(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}};const li="$message",ci="$timestamp",ui=new Set([li,ci]),di={enabled:!0,max_bytes:32768};function hi(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:di.enabled,max_bytes:vi(e.max_bytes,di.max_bytes)}:Ot({},di)}var pi=class{constructor(e){this.ts=[],this.es=0,this.Mr=hi(e)}setConfig(e){this.Mr=hi(e),this.ns()}add(e){const t=(function(e){let t;try{t=O(e)}catch(e){return}try{const e=JSON.parse(t);if(!A(e))return;const i=e,s=i[li],n=i[ci];if(!N(s)||0===s.trim().length)return;if(!N(n)&&!H(n))return;return{step:i,json:t}}catch(e){return}})(e);if(!t)return;const i=(function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;const t=encodeURIComponent(e);let i=0;for(let e=0;t.length>e;e++)"%"===t[e]?(i+=1,e+=2):i+=1;return i})(t.json);i>this.Mr.max_bytes||(this.ts.push({step:t.step,bytes:i}),this.es+=i,this.ns())}getAttachable(){return this.ts.map(e=>e.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}ns(){for(;this.es>this.Mr.max_bytes&&this.ts.length>0;){const e=this.ts.shift();e&&(this.es-=e.bytes)}}};function vi(e,t){if(!H(e)||1/0===e||-1/0===e)return t;const i=Math.floor(e);return 0>i?t:i}const fi=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function gi(e){return"string"==typeof e||e}function _i(e){return"string"==typeof e?e:void 0}const mi=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],yi="NativeGzipValidationError",bi=e=>e.length>=2&&31===e[0]&&139===e[1],wi=(e,t)=>e===E.GZipJS||t===E.GZipJS||"gzip"===t,xi=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):"");let Ei;const $i=e=>{throw gt(yi,`Native gzip produced invalid output: ${e}`)},Si=(ki=ie(function*(e,t){18>e.size&&$i("too-short");const i=new Uint8Array(yield e.slice(0,10).arrayBuffer());bi(i)&&8===i[2]||$i("invalid-header");const s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{const t=(()=>{if(Ei)return Ei;Ei=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;Ei[e]=t>>>0}return Ei})();let i=4294967295;for(let s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&$i("invalid-crc");const n=t.length>>>0;s.getUint32(4,!0)!==n&&$i("invalid-size")}),function(e,t){return ki.apply(this,arguments)});var ki;function Pi(){return Pi=ie(function*(e,t=!0,i){try{const t=(new TextEncoder).encode(e),i=new globalThis.CompressionStream("gzip"),n=i.writable.getWriter(),r=n.write(t).then(()=>n.close()).catch((s=ie(function*(e){try{yield n.abort(e)}catch(e){}throw e}),function(e){return s.apply(this,arguments)})),o=new Response(i.readable).blob(),[a]=yield Promise.all([o,r]);return yield Si(a,t),a}catch(e){if(null==i?void 0:i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}var s}),Pi.apply(this,arguments)}const Mi=3e5;var Oi=class{record(e){if("too-large"===e.kind)return;if("retry-later"!==e.kind)return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),i=Date.now(),s=Math.min(e.retryAfterMs,Mi);if(!t)return this.ss=i,void(this.rs=i+s);this.rs=Math.max(this.rs,Math.min(i+s,this.ss+Mi))}remainingMs(){const e=Date.now();if(this.ss-5e3>e)return this.reset(),0;const t=Math.min(Mi,Math.max(0,this.rs-e));return 0===t&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.rs=0,this.ss=0}constructor(){this.rs=0,this.ss=0}};function Ti(e,t){if(null==e)return{};var i,s,n=(function(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;i[s]=e[s]}return i})(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(s=0;r.length>s;s++)t.includes(i=r[s])||{}.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}const Fi={}.propertyIsEnumerable;function Ci(e,t){try{return Ai(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function Ii(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:ut};if(i.remainingNodes--,q(e))return{boolValue:e};if("bigint"==typeof e)return(function(e,t){const i=e.toString(),s=BigInt("9223372036854775808");return e>=s||-s>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}})(e,t);if("number"==typeof e){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};const i=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:ht(e)};if("function"==typeof e)return{stringValue:"[Function]"};if("symbol"==typeof e)return{stringValue:String(e)};if("object"==typeof e&&null!==e){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ut};if(e instanceof Date){const t=e.getTime(),i=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:"string"==typeof i?ht(i):String(i)}}i.ancestors.add(e);try{try{const n=e.toJSON;if("function"==typeof n)return Ii(n.call(e),t,i,s+1)}catch(e){}return I(e)?{arrayValue:{values:Ri(e,t,i,s+1)}}:{kvlistValue:{values:Ai(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:ht(String(e))}}function Ri(e,t,i,s){const n=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&i.remainingNodes>0;o++)try{const r=o in e?e[o]:void 0;if(U(r))continue;n.push(Ii(r,t,i,s))}catch(e){n.push({stringValue:dt})}return e.length>o&&n.push({stringValue:ut}),n}function Ai(e,t,i,s){const n=[];for(const r in e)if(Fi.call(e,r)){if(!r){null==t||t.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(B(o)||D(o))continue;n.push({key:ht(r),value:Ii(o,t,i,s)})}catch(e){n.push({key:ht(r),value:{stringValue:dt}})}}return n}function Li(e,t,i){return Ot(Ot(Ot(Ot({},pt({},e.resourceAttributes)),{},{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":i})}const Di=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Ni(e,t){const i=pt({},e),s={};for(const e of Di)({}).hasOwnProperty.call(i,e)&&(s[e]=i[e],delete i[e]);return[...Ci(i,t),...Ci(s,t)]}const ji={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},Bi={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Ui=Bi.info;function Hi(e){try{return ht(String(e))}catch(e){return dt}}function zi(e,t,i,s){const n=e.level||"info",{text:r,number:o}=Bi[n]||Ui,a=(function(e=Date.now()){return String(e)+"000000"})(H(s)?s:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),U(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),U(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=Ot({},l),u=e.attributes;if(u){let e=[];try{e=Object.keys(u)}catch(t){e=[]}for(const i of e){let e;try{e=u[i]}catch(t){e=dt}Object.defineProperty(c,i,{value:e,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:Hi(e.body)},attributes:Ci(c,i)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),D(e.trace_flags)||(d.flags=e.trace_flags),d}function qi(e,t,i){return Li(e,t,i)}function Vi(e,t,i,s){return{resourceLogs:[{resource:{attributes:Ni(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var Wi=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=yt(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function Gi(){return.75+.5*Math.random()}function Ki(e,t,i,s){const n=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,e)))*i)}var Yi=class{constructor(e,t,i,s,n,r=()=>Promise.resolve(),o){var a;this._instance=e,this.Mr=t,this.$=i,this.cs=s,this.ds=n,this.vs=r,this.fs=o,this.ps=new Wi(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Oi,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=t.maxBufferSize,this.Is=Math.max(null!==(a=t.maxQueueSize)&&void 0!==a?a:t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(x.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){var i;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==e?void 0:e.body))return;const s=this.Os(e);if(null===s)return;if(!s.body)return void this.$.info("Log was rejected in beforeSend function");if(!this.Ds())return;const n={record:zi(s,null!==(i=null==t?void 0:t.context)&&void 0!==i?i:this.cs(),this.$,null==t?void 0:t.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(e){const t=this.Mr.beforeSend;if(!t)return e;const i=I(t)?t:[t];let s=e;for(const t of i)try{const e=t(s);if(!e)return this.$.info("Log was rejected in beforeSend function"),null;s=e}catch(e){return this.$.error("Error in beforeSend function for log:",e),null}return s}Ds(){if(void 0===this.Rs)return!0;const e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.$s=!0),!1)}flush(){var e=this;return ie(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return ie(function*(){var t;e.ps.clear();let i=null!==(t=e._instance.getPersistedProperty(x.LogsQueue))&&void 0!==t?t:[];if(0===i.length)return;const s=i.length;let n=0;for(;i.length>0&&s>n;){var r,o;const t=e._s;e.bs=0;const s=Math.min(i.length,e.Es),a=i.slice(0,s),l=Vi(a.map(e=>e.record),e.qs(),null!==(r=e.fs)&&void 0!==r?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance.js(l);if(e._s!==t)return;if("too-large"===c.kind&&a.length>1)e.Es=Math.max(1,Math.floor(a.length/2)),e.$.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else{if(e.ws.record(c),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),"retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e.$.warn("Dropping a single log record with batch size 1 \u2014 the record is larger than the server cap and cannot be split further."):"ok"===c.kind&&e.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(a.length),i=null!==(o=e._instance.getPersistedProperty(x.LogsQueue))&&void 0!==o?o:[],n+=a.length,"fatal"===c.kind)throw c.error}}})()}Bs(e){var t=this;return ie(function*(){var i;const s=Math.max(0,e-t.bs),n=null!==(i=t._instance.getPersistedProperty(x.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(x.LogsQueue,n.slice(s)),yield t.vs()})()}qs(){return qi(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;const i=null!==(t=this._instance.getPersistedProperty(x.LogsQueue))&&void 0!==t?t:[];this.Is>i.length||(i.shift(),this.bs++,this.$.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(x.LogsQueue,i),this.Ts>i.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(Ki(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(x.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return ie(function*(){t.ps.clear();const i=t.flush().catch(()=>{});void 0!==e?yield bt(i,e):yield i})()}flushWithTimeout(e){var t=this;return ie(function*(){const i=t.flush();yield bt(i,e,()=>{i.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=Gi(),this.$.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const Ji=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Zi(e){return String(e)+"000000"}function Xi(e,t,i,s){let n="";return s&&(n=Object.keys(s).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(s[e])}`).join(",")),`${e}\0${t}\0${null!=i?i:""}\0${n}`}var Qi=class{constructor(e,t,i){this._instance=e,this.Mr=t,this.$=i,this.zs=new Map,this.ps=new Wi(()=>this.flush().catch(e=>{this.$.error("Metrics flush failed:",e)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Oi,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,i){this.Zs({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this.Zs({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this.Zs({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var e=this;const t=this.ys,i=(function(){var i=ie(function*(){t&&(yield t.catch(()=>{})),yield e.Qs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===i&&(this.ys=null)});return this.ys=i,i}drainWindow(){if(0===this.zs.size)return null;const e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this.Os(e);if(null===t)return;if(!t.name||"string"!=typeof t.name)return void this.$.warn("Dropping metric with empty name");if("number"!=typeof t.value||!Number.isFinite(t.value))return void this.$.warn(`Dropping metric '${t.name}': value must be a finite number`);if("count"===t.type&&0>t.value)return void this.$.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,s;try{i=t.attributes?Ot({},t.attributes):void 0,s=Xi(t.type,t.name,t.unit,i)}catch(e){return void this.$.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e)}let n=this.zs.get(s);if(!n){if(!this.Ks())return;n={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now()},this.zs.set(s,n)}const r=this.Ws.get(t.name);void 0===r?this.Ws.set(t.name,t.type):r===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.$.warn(`Metric name '${t.name}' is already used as a ${r}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(n,t.value),this.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,t){switch(e.type){case"count":var i;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":{e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(Ji.length+1).fill(0)});const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[(function(e,t){for(let i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length})(t,Ji)]+=1;break}}}Os(e){const t=this.Mr.beforeSend;if(!t)return e;const i=I(t)?t:[t];let s=e;for(const t of i)try{const e=t(s);if(!e)return this.$.info("Metric was rejected in beforeSend function"),null;s=e}catch(e){return this.$.error("Error in beforeSend function for metric:",e),null}return s}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(Ki(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var e=this;return ie(function*(){if(e.ps.clear(),0===e.zs.size)return;const t=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const i=e.Gs,s=yield e._instance.Ys(e.Js(t));if(i===e.Gs)switch(e.ws.record(s),"retry-later"===s.kind?(e.ks++,e.Ss=Gi()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),s.kind){case"ok":return;case"retry-later":return e.lo(t),void e.ps.armNoEarlierThan(e.Hs());case"too-large":return void e.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.$.error("Failed to send metrics batch:",s.error)}})()}Js(e){return t=this.ao(e),i=(function(e,t,i){return Li(e,t,i)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ni(i)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,i,s,n}ao(e){const t=Zi(Date.now()),i=new Map;for(const o of e.values()){var s;const e=Xi(o.type,o.name,o.unit,void 0);let a=i.get(e);a||(a=Ot({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(e,a));const l=Ci(null!==(s=o.attributes)&&void 0!==s?s:{},this.$),c=Zi(o.windowStartMs);if("count"===o.type){var n;const e={attributes:l,startTimeUnixNano:c,timeUnixNano:t,asDouble:null!==(n=o.total)&&void 0!==n?n:0};a.sum.dataPoints.push(e)}else if("gauge"===o.type){var r;const e={attributes:l,timeUnixNano:t,asDouble:null!==(r=o.last)&&void 0!==r?r:0};a.gauge.dataPoints.push(e)}else o.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:c,timeUnixNano:t,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Ji})}return Array.from(i.values())}lo(e){for(const[s,n]of e){const e=this.zs.get(s);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,n.windowStartMs),e.type){case"count":var t,i;e.total=(null!==(t=e.total)&&void 0!==t?t:0)+(null!==(i=n.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(e.hist){e.hist.count+=n.hist.count,e.hist.sum+=n.hist.sum,e.hist.min=Math.min(e.hist.min,n.hist.min),e.hist.max=Math.max(e.hist.max,n.hist.max);for(let t=0;e.hist.bucketCounts.length>t;t++)e.hist.bucketCounts[t]+=n.hist.bucketCounts[t]}else e.hist=n.hist}else this.Ks()&&this.zs.set(s,n)}}};const es=(e,{debugEnabled:t}={})=>{const i={N(i,...s){a&&(w.DEBUG||a.POSTHOG_DEBUG||t)&&!D(a.console)&&a.console&&("__rrweb_original__"in a.console[i]?a.console[i].__rrweb_original__:a.console[i])(e,...s)},debug(...e){i.N("debug",...e)},info(...e){i.N("log",...e)},warn(...e){i.N("warn",...e)},error(...e){i.N("error",...e)},critical(...t){console.error(e,...t)},uninitializedWarning(e){i.error(`You must initialize PostHog before calling ${e}`)},createLogger:(t,i)=>es(`${e} ${t}`,i)};return i},ts=es("[PostHog.js]"),is=ts.createLogger,ss=is("[ExternalScriptsLoader]"),ns=e=>{const t=null==u?void 0:u.querySelectorAll("script");if(t)for(let i=0;t.length>i;i++)if(t[i].src===e||t[i].getAttribute("src")===e)return t[i]},rs=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return ss.warn(`${t} was requested but loading of external scripts is disabled.`),i("Loading of external scripts is disabled");const s=ns(t);if(s){if(s.__posthog_loading_callback_fired)return i();const e=s.__posthog_loading_error;return e?i(e):(s.addEventListener("load",e=>{s.__posthog_loading_callback_fired=!0,i(void 0,e)}),void s.addEventListener("error",e=>{s.__posthog_loading_error=e,i(e)}))}const n=()=>{if(!u)return i("document not found");if(ns(t))return rs(e,t,i);let s=u.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=t,s.onload=e=>{s.__posthog_loading_callback_fired=!0,i(void 0,e)},s.onerror=e=>{s.__posthog_loading_error=e,i(e)},e.config.prepare_external_dependency_script&&(s=e.config.prepare_external_dependency_script(s)),!s)return i("prepare_external_dependency_script returned null");if("head"===e.config.external_scripts_inject_target)u.head.appendChild(s);else{const e=u.querySelectorAll("body > script");var n;e.length>0?null===(n=e[0].parentNode)||void 0===n||n.insertBefore(s,e[0]):u.body.appendChild(s)}};(null==u?void 0:u.body)?n():null==u||u.addEventListener("DOMContentLoaded",n)},os={},as=(e,t)=>{let i=`/static/${t}.js?v=${e.version}`;if("toolbar"===t){const e=3e5;i=`${i}&t=${Math.floor(Date.now()/e)*e}`}return e.requestRouter.endpointFor("assets",i)};y.__PosthogExtensions__=y.__PosthogExtensions__||{},y.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{if("remote-config"===t){const t=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void rs(e,t,i)}const s=e.config.strict_script_versioning;if(s){const n=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),r=os[n];if("fallback"===s&&r){if(ns(r))return void rs(e,r,i);delete os[n]}return void rs(e,n,"fallback"===s?(s,r)=>{if(s)if("string"==typeof s)i(s);else{var o;const s=as(e,t);os[n]=s;const r=ns(n);null==r||null===(o=r.parentNode)||void 0===o||o.removeChild(r),rs(e,s,i)}else i(void 0,r)}:i)}rs(e,as(e,t),i)},y.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{const s=e.requestRouter.endpointFor("api",t);rs(e,s,i)},w.DEBUG=!1,w.LIB_VERSION="1.431.2",w.LIB_NAME="web";var ls=w;const cs="$people_distinct_id",us="distinct_id",ds="$device_id",hs="$device_model",ps="__alias",vs="__cmpns",fs="$fbc",gs="$fbc_persistence",_s="__timers",ms="$autocapture_disabled_server_side",ys="$heatmaps_enabled_server_side",bs="$exception_capture_enabled_server_side",ws="$error_tracking_suppression_rules",xs="$error_tracking_capture_extension_exceptions",Es="$web_vitals_enabled_server_side",$s="$dead_clicks_enabled_server_side",Ss="$product_tours_enabled_server_side",ks="$logs_capture_enabled_server_side",Ps="$web_vitals_allowed_metrics",Ms="$session_recording_remote_config",Os="$session_recording_enabled_server_side",Ts="$replay_sample_rate",Fs="$replay_override_sampling",Cs="$replay_override_linked_flag",Is="$replay_override_url_trigger",Rs="$replay_override_event_trigger",As="$sesid",Ls="$session_is_sampled",Ds="$session_past_minimum_duration",Ns="$session_recording_url_trigger_activated_session",js="$session_recording_event_trigger_activated_session",Bs="$debug_first_full_snapshot_timestamp",Us="$sess_rec_flush_size",Hs="$enabled_feature_flags",zs="$active_feature_flags",qs="$early_access_features",Vs="$feature_flag_details",Ws="$feature_flag_payloads",Gs="$feature_flag_request_id",Ks="$minimal_flag_called_events",Ys="$override_feature_flags",Js="$override_feature_flag_payloads",Zs="$stored_person_properties",Xs="$stored_group_properties",Qs="$groups",en="$surveys",tn="$surveys_loaded_at",sn="$surveys_activated",nn="$surveys_activated_session",rn="$surveys_activated_timestamps",on="ph_product_tours",an="$product_tours_activated",ln="$product_tours_activated_session",cn="$conversations_widget_session_id",un="$conversations_ticket_id",dn="$conversations_widget_state",hn="$conversations_user_traits",pn="$flag_call_reported",vn="$flag_call_reported_session_id",fn="$feature_flag_errors",gn="$feature_flag_evaluated_at",_n="$user_state",mn="$client_session_props",yn="$capture_rate_limit",bn="$initial_campaign_params",wn="$initial_referrer_info",xn="$initial_person_info",En="$epp",$n="$posthog_cookieless",Sn="$cookieless_mode",kn="$sdk_debug_extensions_init_method",Pn="$sdk_debug_extensions_init_time_ms",Mn="$sdk_debug_recording_script_not_loaded",On="$sdk_debug_replay_event_trigger_status",Tn="$sdk_debug_replay_linked_flag_trigger_status",Fn="$sdk_debug_replay_matched_recording_trigger_groups",Cn="$sdk_debug_replay_pending_trigger_conditions",In="$sdk_debug_replay_remote_trigger_matching_config",Rn="$sdk_debug_replay_trigger_groups_count",An="$sdk_debug_replay_url_trigger_status",Ln="$session_recording_start_reason",Dn="PostHog loadExternalDependency extension not found.",Nn="anonymous",jn="identified",Bn="identified_only",Un="visibilitychange",Hn="beforeunload",zn="$pageview",qn="$pageleave",Vn="$identify",Wn="$groupidentify";function Gn(e,t){I(e)&&e.forEach(t)}function Kn(e,t){if(!U(e))if(I(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,i)=>t(e,i));else for(const i in e)F.call(e,i)&&t(e[i],i)}const Yn=function(e,...t){for(const i of t)for(const t in i)void 0!==i[t]&&(e[t]=i[t]);return e};function Jn(e){const t=Object.keys(e);let i=t.length;const s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}const Zn=function(e){return function(...t){try{return e.apply(this,t)}catch(e){ts.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),ts.critical(e)}}},Xn=function(e){const t={};return Kn(e,function(e,i){(N(e)&&e.length>0||H(e))&&(t[i]=e)}),t};function Qn(e){const t=Ot({},e);for(const i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}const er=["herokuapp.com","vercel.app","netlify.app"];function tr(e){const t=null==e?void 0:e.hostname;if(!N(t))return!1;const i=t.split(".").slice(-2).join(".");for(const e of er)if(i===e)return!1;return!0}function ir(e,t,i,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:n,passive:r})}function sr(e){return"ph_toolbar_internal"===e.name}const nr=e=>{if(u){try{const t=e+"=",i=u.cookie.split(";").filter(e=>e.length);for(let e=0;i.length>e;e++){let s=i[e];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return H(e)&&isFinite(e)&&Math.floor(e)===e});var rr=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,n){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(n)||0>t||0>i||0>s||0>n||t>0xffffffffffff||i>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|i>>>8,r[7]=i,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new e(r)}toString(){let e="";for(let t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;16>t;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},or=class{generate(){const e=this.generateOrAbort();if(!D(e))return e;{this.Ct=0;const e=this.generateOrAbort();if(D(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){const e=(()=>{const e=Date.now();return H(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return rr.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(2,30)-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new lr}};let ar=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};a&&!D(a.crypto)&&crypto.getRandomValues&&(ar=e=>crypto.getRandomValues(e));var lr=class{nextUint32(){return this.Rt.length>this.$t||(ar(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}};let cr;const ur=()=>dr().toString(),dr=()=>(cr||(cr=new or)).generate();let hr="";const pr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let vr=null;const fr={Et(){if(!B(vr))return vr;if(vr=!1,u)try{const e=`__ph_cookie_support_${ur()}`;fr.At(e,"xyz"),vr='"xyz"'===nr(e),fr.Lt(e)}catch(e){vr=!1}return vr},Pt(e){ts.error("cookieStore error: "+e)},Ot:nr,Dt(e){let t;try{t=JSON.parse(fr.Ot(e))||{}}catch(e){}return t},At(e,t,i,s,n){if(!u)return!1;try{let r="",o="";const a=(function(e,t){if(t){let t=(function(e,t=u){if(hr)return hr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let s=Math.min(i.length,8);const n="dmn_chk_"+ur();for(;!hr&&s--;){const e=i.slice(s).join("."),r=n+"=1;domain=."+e+";path=/";t.cookie=r+";max-age=3",t.cookie.includes(n)&&(t.cookie=r+";max-age=0",hr=e)}return hr})(e);if(!t){const i=(e=>{const t=e.match(pr);return t?t[0]:""})(e);i!==t&&ts.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""})(u.location.hostname,s);if(i){const e=new Date;e.setTime(e.getTime()+864e5*i),r="; expires="+e.toUTCString()}n&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&ts.warn("cookieStore warning: large cookie, len="+l.length),u.cookie=l,!0}catch(e){return!1}},Lt(e,t){if(null==u?void 0:u.cookie)try{fr.At(e,"",-1,t)}catch(e){return}}};let gr=null;const _r={Et(){if(!B(gr))return gr;let e=!0;if(D(a))e=!1;else try{const t="__mplssupport__";_r.At(t,"xyz"),'"xyz"'!==_r.Ot(t)&&(e=!1),_r.Lt(t)}catch(t){e=!1}return e||ts.error("localStorage unsupported; falling back to cookie store"),gr=e,e},Pt(e){ts.error("localStorage error: "+e)},Ot(e){try{return null==a?void 0:a.localStorage.getItem(e)}catch(e){_r.Pt(e)}return null},Dt(e){try{return JSON.parse(_r.Ot(e))||{}}catch(e){}return null},At(e,t){try{return null==a||a.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){_r.Pt(e)}return!1},Lt(e){try{null==a||a.localStorage.removeItem(e)}catch(e){_r.Pt(e)}}},mr=[Zs,zs,Hs,Vs,Ws,Gs,gn,fn,pn],yr=[ds,us,As,Ls,En,xn,gs,_n],br=e=>e+"_cpm",wr=["__proto__","constructor","prototype"],xr=e=>{if(!A(e))return{};const t={};return Object.keys(e).forEach(i=>{-1===wr.indexOf(i)&&(t[i]=e[i])}),t},Er=(e,t=[])=>{const i={};return[...yr,...t].forEach(t=>{const s=e[t];D(s)||B(s)||""===s||(i[t]=s)}),i},$r=e=>{let t=5381,i=2166136261;for(let s=0;e.length>s;s++){const n=e.charCodeAt(s);t=33*t^n,i=Math.imul(i^n,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},Sr=(e,t)=>({p:t,f:$r(JSON.stringify(e))}),kr=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const i=fr.Dt(br(e)),s=(null==i?void 0:i.f)===$r(t)&&I(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},Pr=(e,t)=>t+"|"+(fr.Ot(br(e))||""),Mr={},Or={Et:()=>!0,Pt(e){ts.error("memoryStorage error: "+e)},Ot:e=>e in Mr?Mr[e]:null,Dt:e=>e in Mr?Mr[e]:null,At:(e,t)=>(Mr[e]=t,!0),Lt(e){delete Mr[e]}};let Tr=null;const Fr={Et(){if(!B(Tr))return Tr;if(Tr=!0,D(a))Tr=!1;else try{const e="__support__";Fr.At(e,"xyz"),'"xyz"'!==Fr.Ot(e)&&(Tr=!1),Fr.Lt(e)}catch(e){Tr=!1}return Tr},Pt(e){ts.error("sessionStorage error: ",e)},Ot(e){try{return null==a?void 0:a.sessionStorage.getItem(e)}catch(e){Fr.Pt(e)}return null},Dt(e){try{return JSON.parse(Fr.Ot(e))||null}catch(e){}return null},At(e,t){try{return null==a||a.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Fr.Pt(e)}return!1},Lt(e){try{null==a||a.sessionStorage.removeItem(e)}catch(e){Fr.Pt(e)}}};var Cr=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Ro()?0:this.Ao}isOptedOut(){return"always"===this.Mr.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.Mr.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.Fo.At(this.Oo,e?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.Fo.Lt(this.Oo,this.Mr.cross_subdomain_cookie)}get Oo(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get Ao(){const e=this.Fo.Ot(this.Oo);return Q(e)?1:k(ee,e)?0:-1}get Fo(){const e=this.Mr.opt_out_capturing_persistence_type,t="localStorage"===e?_r:fr,i=t.Et()?t:Or;if(!this.Do||this.Do!==i){this.Do=i;const t="localStorage"===e?fr:_r;t.Ot(this.Oo)&&(this.Do.Ot(this.Oo)||this.optInOut(Q(t.Ot(this.Oo))),t.Lt(this.Oo,this.Mr.cross_subdomain_cookie))}return this.Do}Ro(){return!!this.Mr.respect_dnt&&[null==c?void 0:c.doNotTrack,null==c?void 0:c.msDoNotTrack,y.doNotTrack,null==c?void 0:c.globalPrivacyControl].some(e=>Q(e))}};function Ir(e,t){var i;const s=null==e||null===(i=e.config)||void 0===i?void 0:i.get_current_url;if(!R(s))return t;try{const e=s(t);return N(e)&&e?e:t}catch(e){return ts.error("Error in get_current_url, falling back to window.location.href",e),t}}function Rr(e){var t;return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!!(null===(t=e.closest)||void 0===t?void 0:t.call(e,".toolbar-global-fade-container")))}function Ar(e){return!!e&&1===e.nodeType}function Lr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Dr(e){return!!e&&3===e.nodeType}function Nr(e){return!!e&&11===e.nodeType&&Ar(e.host)}function jr(e){return e?P(e).split(/\s+/):[]}function Br(e,t){const i=(function(e){var t;const i=null==a||null===(t=a.location)||void 0===t?void 0:t.href;return D(i)?void 0:Ir(e,i)})(t);return!!(i&&e&&e.some(e=>i.match(e)))}function Ur(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return jr(t)}function Hr(e){return U(e)?null:P(e).split(/(\s+)/).filter(e=>vo(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function zr(e){let t="";return no(e)&&!ro(e)&&e.childNodes&&e.childNodes.length&&Kn(e.childNodes,function(e){var i;Dr(e)&&e.textContent&&(t+=null!==(i=Hr(e.textContent))&&void 0!==i?i:"")}),P(t)}function qr(e){var t;return D(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}const Vr=["a","button","form","input","select","textarea","label"];function Wr(e,t){const i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}function Gr(e,t){if(D(t))return!0;for(const i of e)if(t.some(e=>Wr(i,e)))return!0;return!1}function Kr(e){const t=e.parentNode;return!(!t||!Ar(t))&&t}const Yr=[".ph-no-autocapture","[data-ph-no-autocapture]"],Jr=["next","previous","prev",">","<"],Zr=[...Jr,"+","-","\u2212","\u2013"],Xr=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Qr=[".ph-no-rageclick",".ph-no-capture"],eo=["","text","search","email","password","url","tel","number"];function to(e,t){if(!a||io(e))return!1;let i,s,n;var r,o;if(q(t)?(i=!!t&&Qr,s=void 0,n=!1):(i=null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:Qr,s=null==t?void 0:t.content_ignorelist,n=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&(function(e){return!(!e||!Ar(e))&&(!!Lr(e,"textarea")||(Lr(e,"input")?k(eo,(e.getAttribute("type")||"").toLowerCase()):(function(e){var t;if(e.isContentEditable)return!0;const i=null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return"true"===i||""===i})(e)))})(e))return!1;const{targetElementList:l}=so(e,!1);return!(function(e,t){if(!1===e||D(e))return!1;let i;if(!0===e)i=Jr;else{if(!I(e))return!1;if(e.length>10)return ts.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map(e=>e.toLowerCase())}return t.some(({safeText:e,ariaLabel:t})=>i.some(i=>Xr(e,i)||Xr(t,i)))})(s,l.map(e=>{var t;return{safeText:zr(e).toLowerCase(),ariaLabel:(null===(t=e.getAttribute("aria-label"))||void 0===t?void 0:t.toLowerCase().trim())||""}}))&&!Gr(l,i)}const io=e=>!e||Lr(e,"html")||!Ar(e),so=(e,t)=>{if(!a||io(e))return{parentIsUsefulElement:!1,targetElementList:[]};let i=!1;const s=[e];let n=e;for(;n.parentNode&&!Lr(n,"body");){if(Nr(n.parentNode)){s.push(n.parentNode.host),n=n.parentNode.host;continue}const e=Kr(n);if(!e)break;if(t||Vr.indexOf(e.tagName.toLowerCase())>-1)i=!0;else try{const t=a.getComputedStyle(e);t&&"pointer"===t.getPropertyValue("cursor")&&(i=!0)}catch(e){}s.push(e),n=e}return{parentIsUsefulElement:i,targetElementList:s}};function no(e){const t=new Set;let i=0;for(let s=e;s.parentNode&&!Lr(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);const e=Ur(s);if(k(e,"ph-sensitive")||k(e,"ph-no-capture"))return!1}if(k(Ur(e),"ph-include"))return!0;const s=e.type||"";if(N(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=e.name||e.id||"";return!N(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function ro(e){return!!(Lr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Lr(e,"select")||Lr(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const oo=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),ao=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,lo=[16,15,14,13],co=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),uo=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),ho=/[0-9A-Za-z_]/;function po(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function vo(e,t=!0){if(U(e))return!1;if(N(e)){if(e=P(e),t?oo.test((e||"").replace(/[- ]/g,"")):(function(e){let t;for(ao.lastIndex=0;t=ao.exec(e);){const e=t[2];if(!e)continue;const i=e.replace(/[- ]/g,"");for(let e=0;i.length>e;e++)for(const t of lo){const s=e+t;if(i.length>=s){const t=i.slice(e,s);if(oo.test(t)&&po(t))return!0}}}return!1})(e))return!1;if(t?co.test(e):(function(e){let t;for(uo.lastIndex=0;t=uo.exec(e);){const e=t[1],i=t[3];if(!(e&&i&&ho.test(e)&&ho.test(i)))return!0}return!1})(e))return!1}return!0}function fo(e){let t=zr(e);return t=`${t} ${go(e)}`.trim(),vo(t)?t:""}function go(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Kn(e.childNodes,function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=zr(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${go(e)}`.trim())}catch(e){ts.error("[AutoCapture]",e)}}),t}function _o(e){return e.replace(/"|\\"/g,'\\"')}function mo(e){const t=e.attr__class;if(t)return I(t)?t:jr(t)}const yo=is("[Dead Clicks]"),bo=()=>!0,wo=e=>{var t;const i=!!(null===(t=e.instance.persistence)||void 0===t?void 0:t.get_property($s)),s=e.instance.config.capture_dead_clicks;return q(s)?s:!!A(s)||i};var xo=class{get lazyLoadedDeadClicksAutocapture(){return this.Lo}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[$s]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.No(()=>{this.qo()}):this.stop()}No(e){var t,i,s;(null===(t=y.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)?e():null===(i=y.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"dead-clicks-autocapture",t=>{t?yo.error("failed to load script",t):e()})}qo(){var e;if(u){if(!this.Lo&&(null===(e=y.__PosthogExtensions__)||void 0===e?void 0:e.initDeadClicksAutocapture)){const e=A(this.instance.config.capture_dead_clicks)?Ot({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Lo=y.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Lo.start(u),yo.info("starting...")}}else yo.error("`document` not found. Cannot start.")}stop(){this.Lo&&(this.Lo.stop(),this.Lo=void 0,yo.info("stopping..."))}};const Eo=is("[SegmentIntegration]");function $o(e,t,i=!0){const s=e.config.segment;if(!s)return t();const{analytics:n,filterProperties:r}=(e=>R(e.register))(o=s)?{analytics:o}:o;var o;!(function(e,t,i,s){const n=t=>{const n=()=>t.anonymousId()||ur();e.config.get_device_id=n,s&&t.id()&&(e.register({distinct_id:t.id(),$device_id:n()}),e.persistence.set_property(_n,jn)),i(s?void 0:t.anonymousId()||void 0)},r=t.user();"then"in r&&R(r.then)?r.then(n):n(r)})(e,n,i=>{n.register(((e,t,{filterProperties:i}={})=>{"undefined"!=typeof Promise&&Promise.resolve||Eo.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!t&&s.event.anonymousId===t&&!s.event.userId;r||s.event.userId||s.event.anonymousId===e.get_distinct_id()||(Eo.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),s.event.userId&&s.event.userId!==e.get_distinct_id()&&(Eo.info("UserId set, identifying with PostHog"),e.identify(s.event.userId));let o=e.calculateEventProperties(n,s.event.properties);if(!U(i)){const e=s.event.properties||{},t={};for(const i of Object.keys(o))F.call(e,i)||(t[i]=o[i]);const n=((e,t)=>{const i=I(e)?e:[e];let s=Ot({},t);for(const t of i)try{if(s=t(s),U(s))return null}catch(e){return Eo.error("Error in Segment filterProperties:",e),null}return s})(i,t);if(U(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>s(e,e.event.event),page:e=>s(e,zn),identify:e=>s(e,Vn),screen:e=>s(e,"$screen")}})(e,i,{filterProperties:r})).then(()=>{t()},e=>{Eo.error("Failed to register the Segment integration",e),t()})},i)}const So="posthog-js";function ko(e,{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,d;if("*"!==n&&!n.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const p=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],v=p.map(e=>Ot(Ot({},e),{},{stacktrace:e.stacktrace?Ot(Ot({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>Ot(Ot({},e),{},{platform:"web:javascript"}))}):void 0})),f={$exception_message:(null===(l=p[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=p[0])||void 0===c?void 0:c.type,$exception_level:o.level,$exception_list:v,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=p[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=p[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var g;return t&&i&&(f.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&(null===(g=e.exceptions)||void 0===g||g.sendExceptionEvent(f)),o}}var Po=class{constructor(e,t,i,s,n,r){this.name=So,this.setupOnce=function(o){o(ko(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},Mo=class{constructor(e){this.jo=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(ts.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.Bo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Ho()}Ho(){var e;this.zo=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(this.jo)}destroy(){var e;null===(e=this.zo)||void 0===e||e.call(this),this.zo=void 0}doPageView(e,t){var i;const s=this.Uo(e,t);return this.Bo={pathname:null!==(i=null==a?void 0:a.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this.Uo(e,null===(t=this.Bo)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this.Bo)||void 0===e?void 0:e.pageViewId}}Uo(e,t){const i=this.Bo;if(!i)return{$pageview_id:t};let s={$pageview_id:t,$prev_pageview_id:i.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=n;if(!(D(e)||D(t)||D(i)||D(r)||D(o)||D(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);const n=e>1?re(t/e,0,1,ts):1,l=e>1?re(i/e,0,1,ts):1,c=r>1?re(o/r,0,1,ts):1,u=r>1?re(a/r,0,1,ts):1;s=Yn(s,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:l,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:u})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}};const Oo=["flags","surveys"],To={[cs]:{exposure:"hidden"},[ps]:{exposure:"hidden"},[vs]:{exposure:"hidden"},[_s]:{exposure:"hidden"},[gs]:{exposure:"hidden"},[ms]:{exposure:"event"},[ys]:{exposure:"hidden"},[ks]:{exposure:"hidden"},[bs]:{exposure:"event"},[ws]:{exposure:"hidden"},[xs]:{exposure:"event"},[Es]:{exposure:"event"},[$s]:{exposure:"event"},[Ss]:{exposure:"hidden"},[Ps]:{exposure:"event"},[Ms]:{exposure:"hidden"},[Os]:{exposure:"hidden"},[As]:{exposure:"hidden"},[Ls]:{exposure:"event"},[Ts]:{exposure:"event",shouldSkipFromEventProperties:e=>B(e)},[Ds]:{exposure:"event"},[Ns]:{exposure:"event"},[js]:{exposure:"event"},[Bs]:{exposure:"event"},[Us]:{exposure:"hidden"},[Hs]:{exposure:"hidden",storageGroup:"flags"},[zs]:{exposure:"hidden",storageGroup:"flags"},[qs]:{exposure:"hidden"},[Vs]:{exposure:"hidden",storageGroup:"flags"},[Ws]:{exposure:"hidden",storageGroup:"flags"},[Gs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Ks]:{exposure:"hidden",storageGroup:"flags"},[Ys]:{exposure:"hidden"},[Js]:{exposure:"hidden"},[Zs]:{exposure:"hidden"},[Xs]:{exposure:"hidden"},[en]:{exposure:"hidden",storageGroup:"surveys"},[tn]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[sn]:{exposure:"event"},[nn]:{exposure:"hidden"},[rn]:{exposure:"hidden"},[on]:{exposure:"hidden"},[an]:{exposure:"hidden"},[ln]:{exposure:"hidden"},[cn]:{exposure:"event"},[un]:{exposure:"event"},[dn]:{exposure:"event"},[hn]:{exposure:"event"},[pn]:{exposure:"hidden"},[vn]:{exposure:"hidden"},[Qs]:{exposure:"event"},[fn]:{exposure:"hidden"},[gn]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[_n]:{exposure:"hidden"},[mn]:{exposure:"hidden"},[yn]:{exposure:"hidden"},[bn]:{exposure:"hidden"},[wn]:{exposure:"hidden"},[xn]:{exposure:"hidden"},[En]:{exposure:"hidden"},[Fs]:{exposure:"event"},[Cs]:{exposure:"event"},[Is]:{exposure:"event"},[Rs]:{exposure:"event"},[kn]:{exposure:"event"},[Pn]:{exposure:"event"},[Mn]:{exposure:"event"},[On]:{exposure:"event"},[Tn]:{exposure:"event"},[Fn]:{exposure:"event"},[Cn]:{exposure:"event"},[In]:{exposure:"event"},[Rn]:{exposure:"event"},[An]:{exposure:"event"},[Ln]:{exposure:"event"}},Fo=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Co=e=>{const t=To[e];if(t)return t;for(const[t,i]of Fo)if(0===e.indexOf(t))return i},Io=(e,t)=>{try{let i;return JSON.stringify(e,(e,t)=>{var s;return Y(t)?(null!==(s=i)&&void 0!==s||(i=new WeakMap),i.has(t)||i.set(t,Qn(t)),i.get(t)):"bigint"==typeof t?t.toString():t},t)}catch(t){return O(e)}},Ro=e=>{const t=null==u?void 0:u.createElement("a");return D(t)?null:(t.href=e,t)},Ao=function(e,t){const i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let e=0;i.length>e;e++){const n=i[e].split("=");if(n[0]===t){s=n;break}}if(!I(s)||2>s.length)return"";{let e=s[1];try{e=decodeURIComponent(e)}catch(t){ts.error("Skipping decoding for malformed query param: "+e)}return e.replace(/\+/g," ")}},Lo=function(e,t,i){if(!e||!t||!t.length)return e;const s=e.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let e=0;l.length>e;e++){const s=l[e].split("=");I(s)&&(t.includes(s[0])?c.push(s[0]+"="+i):c.push(l[e]))}let u=a;return null!=o&&(u+="?"+c.join("&")),null!=n&&(u+="#"+n),u},Do=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},No=(e,t)=>e>=t&&_(),jo=(e,t,i,s)=>{if(0===e){if(_()){const e=t+1;return e===i&&s(),e}return t}return 0},Bo=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Uo=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Bo],Ho="<masked>",zo=["li_fat_id"];function qo(e,t,i){if(!u)return{};const s=t?[...Bo,...i||[]]:[],n=Vo(Lo(u.URL,s,Ho),e),r=(function(){const e={};return Kn(zo,function(t){const i=nr(t);e[t]=i||null}),e})();return Yn(r,n)}function Vo(e,t){const i=Uo.concat(t||[]),s={};return Kn(i,function(t){const i=Ao(e,t);s[t]=i||null}),s}function Wo(e){const t=(function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null})(e),i="yahoo"!=t?"q":"p",s={};if(!B(t)){s.$search_engine=t;const e=u?Ao(u.referrer,i):"";e.length&&(s.ph_keyword=e)}return s}function Go(){return navigator.language||navigator.userLanguage}function Ko(){const e=Go();return"string"==typeof e?e.split("-")[0]:void 0}const Yo="$direct";function Jo(){return(null==u?void 0:u.referrer)||Yo}function Zo(e,t,i=!1){const s=e?[...Bo,...t||[]]:[],n=i?_t(null==d?void 0:d.href):null==d?void 0:d.href,r=null==n?void 0:n.substring(0,1e3);return{r:Jo().substring(0,1e3),u:r?Lo(r,s,Ho):void 0}}function Xo(e,t=!1){var i;const{r:s,u:n}=e,r=t?_t(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==Yo?Yo:null===(i=Ro(s))||void 0===i?void 0:i.host};if(r){o.$current_url=r;const e=Ro(r);o.$host=null==e?void 0:e.host,o.$pathname=null==e?void 0:e.pathname;const t=Vo(r);Yn(o,t)}if(s){const e=Wo(s);Yn(o,e)}return o}function Qo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function ea(){try{return(new Date).getTimezoneOffset()}catch(e){return}}const ta={flags:gn,surveys:tn},ia=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],sa=e=>`${e}_cookie_identity_change_pending`,na=e=>{let t="",i=0;for(const s of e){const e=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+e>1e3)break;t+=s,i+=e}return t},ra="main",oa=[Hs,zs,Vs,Ws,Gs,gn,Ks,Zs],aa=e=>-1!==oa.indexOf(e),la=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},ca=e=>{if(!e)return{};const t=JSON.parse(e);return A(t)?t:{}},ua=(e,t)=>{Kn(e,(i,s)=>{const n=Co(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})};var da=class{constructor(e,t,i=!0){if(this.Wo={},this.Vo=!1,this.Go=!1,this.Zo=!1,this.Qo=!1,this.Jo=!1,this.Ko=new Map,this.Xo=!1,this.Yo=!1,this.tl=!1,this.el=!1,this.il=new Set,this.Mr=e,this.nl=i,this.props={},this.sl=void 0,this.rl=(e=>{let t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this.Fo=this.ol(e),this.Zo=this.ll(e),this.load(),this.al(),e.debug&&ts.info("Persistence loaded",e.persistence,Ot({},this.props)),this.update_config(e,e,t),this.save(),a){const e=()=>this.flush();ir(a,"beforeunload",e,{capture:!1}),ir(a,"pagehide",e,{capture:!1}),this.ul=e=>{if(this.Vo&&(!e.storageArea||e.storageArea===(null==a?void 0:a.localStorage))&&e.key)if(e.key!==this.rl){if(this.Zo){const t=Oo.find(t=>e.key===this.hl(t));t&&this.cl(e.key,t)}}else this.cl(e.key,ra)},ir(a,"storage",this.ul)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{const i=this.Ko.get(e);if(!aa(e)||!0===i)return;if(!0===t)return void this.dl(e,!0);const s=new Set(i||[]);t.forEach(e=>s.add(e)),s.size&&this.dl(e,s)})}onCrossTabFeatureFlagChange(e){return this.il.add(e),()=>this.il.delete(e)}destroy(){this.ul&&a&&(a.removeEventListener("storage",this.ul),this.ul=void 0),this.il.clear()}cl(e,t,i=!0){if(this.pi)return!1;let s,n;try{if(n=_r.Ot(e),B(n)){const e=this.vl(t);return e.storageValue=null,t!==ra&&(e.persisted=!1),!1}s=ca(n)}catch(e){return!1}const r=t===ra?s:_r.Dt(this.rl);if(r&&this.fl(r))return!1;const o=this.pl(s,t,i);return t===ra&&this.Zo&&!la(this.gl().main,s)||this.ml(s,t,!0,n),o}fl(e){const t=this.props[us],i=e[us];return!D(t)&&!D(i)&&t!==i}ml(e,t,i,s){const n=this.vl(t);n.storageValue=s,t!==ra&&(n.persisted=i);try{n.fingerprint=this.yl(e,t)}catch(e){n.fingerprint=void 0}}pl(e,t,i){let s=!1;return oa.forEach(i=>{var n;const r=null===(n=Co(i))||void 0===n?void 0:n.storageGroup;if(t===ra&&this.Zo&&r||t!==ra&&r!==t)return;const o=i in e,a=this.bl(i,o?e[i]:void 0),l=this.Ko.has(i)?i in this.props:o;l===i in this.props&&la(a,this.props[i])||(l?this._l(i,a,!1):this.wl(i,!1),s=!0)}),s&&i&&this.il.forEach(e=>e()),s}kl(){if(!this.Vo)return!1;try{this.tl=!1;const e=_r.Ot(this.rl),t=this.vl(ra);let i,s=!1,n=!1;if(e!==t.storageValue)if(B(e))t.storageValue=null;else{if(i=ca(e),this.tl=!this.Yo&&this.fl(i),this.tl)return!1;n=this.pl(i,ra,!1),!this.Zo||la(this.gl().main,i)?this.ml(i,ra,!0,e):t.storageValue=e,s=!0}return this.Zo&&Oo.forEach(e=>{const t=_r.Ot(this.hl(e)),r=this.vl(e),o=i||{},a=s&&oa.some(t=>{var i;return(null===(i=Co(t))||void 0===i?void 0:i.storageGroup)===e&&t in o});if(t===r.storageValue&&!a)return;if(B(t))return r.storageValue=null,r.persisted=!1,void(a&&(n=this.pl(o,e,!1)||n));const l=ca(t);n=this.pl(l,e,!1)||n,this.ml(l,e,!0,t)}),n}catch(e){return!1}}dl(e,t){this.Ko.set(e,t);const i=Co(e);(null==i?void 0:i.volatile)||(this.vl((this.Zo?null==i?void 0:i.storageGroup:void 0)||ra).fingerprint=void 0,this.Sl(e))}xl(){oa.forEach(e=>this.Ko.set(e,!0))}al(){if(this.Vo)try{const e=_r.Ot(this.rl),t=ca(e);this.vl(ra).storageValue=e,oa.forEach(e=>{var i;const s=this.Zo?null===(i=Co(e))||void 0===i?void 0:i.storageGroup:void 0,n=s?_r.Ot(this.hl(s)):null;if(s){const e=this.vl(s);e.storageValue=n,e.persisted=!B(n)}const r=s&&!B(n)?ca(n):t;e in this.props?this.Cl(e,r[e],this.props[e]):e in r&&this.dl(e,!0)})}catch(e){}}bl(e,t){const i=this.Ko.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){const s=new Set(I(t)?t:[]),n=new Set(I(this.props[e])?this.props[e]:[]);return i.forEach(e=>n.has(e)?s.add(e):s.delete(e)),Array.from(s)}const s=A(t)?Ot({},t):{},n=A(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in n?s[e]=n[e]:delete s[e]}),s}Cl(e,t,i){if(!aa(e))return;const s=this.Ko.get(e);if(!0===s)return;let n=t;if(this.Vo)try{var r;const t=this.Zo?null===(r=Co(e))||void 0===r?void 0:r.storageGroup:void 0,i=t?this.hl(t):this.rl;n=ca(_r.Ot(i))[e]}catch(e){}const o=new Set(s||[]);if("$active_feature_flags"===e){if(!D(t)&&!I(t)||!D(n)&&!I(n)||!I(i))return void this.dl(e,!0);const s=new Set(t||[]),r=new Set(n||[]),a=new Set(i);new Set([...s,...a]).forEach(e=>{s.has(e)!==a.has(e)&&o.add(e)}),o.forEach(e=>{r.has(e)===a.has(e)&&o.delete(e)})}else{if(!A(i))return void(la(n,i)?this.Ko.delete(e):this.dl(e,!0));{if(!D(t)&&!A(t)||D(t)&&L(i)&&D(n))return void this.dl(e,!0);const s=A(t)?t:{},r=A(n)?n:{};new Set([...Object.keys(s),...Object.keys(i)]).forEach(e=>{e in s==e in i&&la(s[e],i[e])||o.add(e)}),o.forEach(e=>{e in r==e in i&&la(r[e],i[e])&&o.delete(e)})}}o.size?this.dl(e,o):this.Ko.delete(e)}$l(){var e;const t=null===(e=this.Mr)||void 0===e?void 0:e.persistence_save_debounce_ms;return H(t)&&t>0?t:0}Tl(e){if(this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase())if(e)try{const t=Er(e,this.Mr.cookie_persisted_properties||[]),i=Sr(t,this.Mr.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),n=fr.Ot(this.rl)||void 0;n&&Pr(this.rl,n)===s&&(this.Il=s,this.Ml=n)}catch(e){}else try{const e=fr.Ot(this.rl)||void 0;this.Il=e?Pr(this.rl,e):void 0,this.Ml=e}catch(e){}}syncCookieProperties(){return this.El(this.Mr)}El(e,t=!1){if(this.pi&&!t||this.Jo||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;let i;try{i=fr.Ot(this.rl)||void 0}catch(e){}if(!i||i===this.Ml)return!1;const s=Pr(this.rl,i);let n;try{n=xr(JSON.parse(i))}catch(e){return!1}if((fr.Ot(this.rl)||void 0)!==i)return!1;this.Il=s,this.Ml=i;const r=kr(this.rl,i),o=[...yr,...r.properties],a={};if(Object.keys(n).forEach(e=>{const t=n[e];(D(t)||B(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete n[e])}),L(n))return!1;const l="distinct_id"in n||"anonymous"===n.$user_state||"identified"===n.$user_state,c=this.props,u=c[us],d=c[_n],h=Yn({},c);[...yr,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in n)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){const t=h[e];(r.isValid||-1===yr.indexOf(e)||!1!==t&&0!==t)&&delete h[e]}}),this.props=Yn(h,n),oa.forEach(e=>{const t=e in this.props;e in c===t&&la(c[e],this.props[e])||(t?this.Cl(e,c[e],this.props[e]):this.dl(e,!0))}),!l||"$user_state"in n||"$user_state"in this.props||this._l(_n,Nn);const p=this.props[us],v=this.props[_n];return!l||p===u&&v===d||(this.Yo=!0,this.Qo=!0,Fr.At(sa(this.rl),!0),this.wl(Zs),this.wl(zs),this.wl(Hs),this.wl(Vs),this.wl(Ws),this.wl(Gs),this.wl(gn),this.wl(fn),this.wl(pn),"anonymous"!==v||"identified"!==d&&"anonymous"!==n.$user_state&&(D(u)||p===u)||(ua(this.props,n),this.wl(Xs)),"identified"===v?this.props.$user_id=p:delete this.props.$user_id,this.wl(ps)),!0}consumeCookieIdentityChange(){const e=sa(this.rl),t=this.Qo||!!Fr.Ot(e);return this.Qo=!1,t&&Fr.Lt(e),t}Pl(e=!1){return!(this.Jo||this.pi&&!e||!this.Mr.cookieWinsOnConflict||"localstorage+cookie"!==this.Mr.persistence.toLowerCase()||(this.Jo=!0,0))}Rl(){this.Jo&&(D(this.Al)||(clearTimeout(this.Al),this.Al=void 0),delete this.Wo[ra],this.Fl(!0))}Ol(e=!0){if(this.Jo)try{e?this.Rl():D(this.Al)||(clearTimeout(this.Al),this.Al=void 0)}finally{this.Jo=!1}}isDisabled(){return!!this.pi}ol(e){-1===ia.indexOf(e.persistence.toLowerCase())&&(ts.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((e=[],t=!1)=>{const i=[...yr,...e];return Ot(Ot({},_r),{},{Dt(e){try{let n,r={};try{n=fr.Ot(e)||void 0,r=n?xr(JSON.parse(n)):{}}catch(e){}const o=JSON.parse(_r.Ot(e)||"{}");let a;if(t){const t=kr(e,n),l=[...yr,...t.properties],c={};Object.keys(r).forEach(e=>{const t=r[e];B(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(c[e]=t)});const u="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state;if(Object.keys(c).length>0){var s;const e=o[us],n=null!==(s=o.$user_state)&&void 0!==s?s:Nn;i.forEach(e=>{if(-1!==l.indexOf(e)&&!(e in r)&&(u||"distinct_id"!==e&&"$user_state"!==e)){const i=o[e];(t.isValid||-1===yr.indexOf(e)||!1!==i&&0!==i)&&delete o[e]}}),!u||"$user_state"in r||"$user_state"in o||(o[_n]=Nn),!u||("distinct_id"in c?c[us]:o[us])===e&&("$user_state"in c?c[_n]:o[_n])===n||(mr.forEach(e=>delete o[e]),"identified"===c.$user_state&&"distinct_id"in c?o.$user_id=c[us]:delete o.$user_id,"identified"!==c.$user_state&&(delete o[Qs],delete o[Xs]),delete o.__alias)}a=Yn(o,c)}else a=Yn(r,o);return _r.At(e,a),a}catch(e){}return null},At(i,s,n,r,o,a){const l=_r.At(i,s,void 0,void 0,a);try{const c=Er(s,e);if(Object.keys(c).length){if(t){const t=br(i),u=Sr(c,e);if(fr.At(t,u,n,r,o,a),fr.Ot(t)!==JSON.stringify(u)){fr.Lt(t,r);const e=Er(s);return fr.At(i,e,n,r,o,a),l}}fr.At(i,c,n,r,o,a)}}catch(i){_r.Pt(i)}return l},Lt(e,t){try{null==a||a.localStorage.removeItem(e),fr.Lt(e,t),fr.Lt(br(e),t)}catch(e){_r.Pt(e)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict);let i,s=!1,n=!1;const r=e.persistence.toLowerCase();return"localstorage"===r&&_r.Et()?(i=_r,n=!0):"localstorage+cookie"===r&&t.Et()?(i=t,n=!0,s=!0):"sessionstorage"===r&&Fr.Et()?i=Fr:"memory"===r?i=Or:"cookie"===r&&fr.Et()?(i=fr,s=!0):t.Et()?(i=t,n=!0,s=!0):fr.Et()?(i=fr,s=!0):i=Or,this.Vo=n,this.Go=s,i}hl(e){return`${this.rl}__${e}`}ll(e){return this.Vo&&!!e.split_storage}properties(){const e={};return Kn(this.props,(t,i)=>{const s=Co(i);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,t))return;e[i]=t}}),e}load(e=!1){if(this.pi&&!e)return;const t=this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase(),i=t?_r.Dt(this.rl):null;let s={};if(t)try{s=xr(fr.Dt(this.rl)),Kn(s,(e,t)=>{(D(e)||B(e)||""===e)&&delete s[t]})}catch(e){}const n=this.Fo.Dt(this.rl);if(n&&(this.props=Yn({},n)),this.Zo&&this.Dl(),t&&n){var r,o;const e=null==i?void 0:i[us],t=null!==(r=null==i?void 0:i.$user_state)&&void 0!==r?r:Nn,a=n[us],l=null!==(o=n.$user_state)&&void 0!==o?o:Nn;if(a!==e||l!==t){this.Qo=!0,Fr.At(sa(this.rl),!0);const i=Yn({},this.props);mr.forEach(e=>delete i[e]),"anonymous"!==l||"identified"!==t&&"anonymous"!==s.$user_state&&(D(e)||a===e)||(ua(i,s),delete i[Xs]),this.props=i;const n=new Set;mr.forEach(e=>{var t;const i=null===(t=Co(e))||void 0===t?void 0:t.storageGroup;i&&n.add(i)}),n.forEach(e=>{const t={};Kn(this.props,(i,s)=>{var n;(null===(n=Co(s))||void 0===n?void 0:n.storageGroup)===e&&(t[s]=i)}),L(t)?(_r.Lt(this.hl(e)),this.Wo[e]={}):_r.At(this.hl(e),t)&&(this.Wo[e]={persisted:!0,fingerprint:this.yl(t,e)})})}}Fr.Ot(sa(this.rl))&&(this.Qo=!0)}Dl(){for(const e of Oo){const t=_r.Dt(this.hl(e));if(t&&!L(t)){const i=this.vl(e);i.persisted=!0,this.Ll(e)||(i.fingerprint=this.yl(t,e)),this.Nl(e,t)||Yn(this.props,t)}}}Ll(e){return Object.keys(this.props).some(t=>{var i;return(null===(i=Co(t))||void 0===i?void 0:i.storageGroup)===e})}Nl(e,t){const i=ta[e];if(!i)return!1;const s=t[i],n=this.props[i];return H(s)&&H(n)&&n>s}refreshKey(e){var t;if(this.pi)return;if("$fbc_persistence"===e&&this.el)return;const i=this.Zo?null===(t=Co(e))||void 0===t?void 0:t.storageGroup:void 0,s=i?_r.Dt(this.hl(i)):this.Fo.Dt(this.rl);if(s&&e in s)this._l(e,s[e],!1);else{if(i){const t=this.Fo.Dt(this.rl);if(t&&e in t)return void this._l(e,t[e],!1)}this.wl(e,!1)}}save(){if(this.pi)return;const e=this.$l();e>0?D(this.Al)&&(this.Al=setTimeout(()=>{this.Al=void 0,this.Fl()},e)):this.Fl()}flush(){D(this.Al)||(clearTimeout(this.Al),this.Al=void 0,this.Fl())}Fl(e=!1){if(this.pi||this.Jo&&!e)return;e||(this.syncCookieProperties(),this.el||this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase()||this.refreshKey(gs));const t=!e&&!this.Xo;t||(this.tl=!1);const i=!!t&&this.kl();if(this.tl)return void(this.Mr.debug&&ts.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Zo)return this.ql(),void(i&&this.il.forEach(e=>e()));const s=this.jl(this.Fo,this.rl,this.props,ra);"written"===s&&this.Tl(this.props),"failed"!==s&&(this.Ko.clear(),this.Yo=!1,this.el=!1),i&&this.il.forEach(e=>e())}ql(){const{main:e,groups:t}=this.gl(),i=this.jl(this.Fo,this.rl,e,ra);"written"===i&&this.Tl(e),"failed"!==i&&(this.Yo=!1,this.el=!1,oa.forEach(e=>{var t;(null===(t=Co(e))||void 0===t?void 0:t.storageGroup)||this.Ko.delete(e)}));for(const e of Oo){var s;const i=t[e];if(L(i)&&!(null===(s=this.Wo[e])||void 0===s?void 0:s.persisted)){oa.forEach(t=>{var i;(null===(i=Co(t))||void 0===i?void 0:i.storageGroup)===e&&this.Ko.delete(t)});continue}const n=this.jl(_r,this.hl(e),i,e);"failed"!==n&&oa.forEach(t=>{const i=Co(t);(null==i?void 0:i.storageGroup)!==e||"written"!==n&&i.volatile||this.Ko.delete(t)})}}gl(){const e={},t={flags:{},surveys:{}};return Kn(this.props,(i,s)=>{var n;const r=null===(n=Co(s))||void 0===n?void 0:n.storageGroup;r?t[r][s]=i:e[s]=i}),{main:e,groups:t}}yl(e,t){if(t===ra)return JSON.stringify(e)+"|"+this.Bl+"|"+this.Hl+"|"+this.zl;const i={};return Kn(e,(e,t)=>{var s;i[t]=(null===(s=Co(t))||void 0===s?void 0:s.volatile)?"__volatile__":e}),JSON.stringify(i)}jl(e,t,i,s){const n=this.vl(s);if(s!==ra&&!n.dirty&&!D(n.fingerprint))return"skipped";let r;try{if(r=this.yl(i,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(e){r=void 0}return e.At(t,i,this.Bl,this.Hl,this.zl,this.Mr.debug)?(n.dirty=!1,s!==ra&&(n.persisted=!0),D(r)||(n.fingerprint=r),this.Vo&&(n.storageValue=_r.Ot(t)),"written"):(this.Mr.debug&&ts.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.xl(),D(this.Al)||(clearTimeout(this.Al),this.Al=void 0),this.Fo.Lt(this.rl,!1),this.Fo.Lt(this.rl,!0),!e&&this.nl)for(const e of Oo)_r.Lt(this.hl(e));e?delete this.Wo[ra]:this.Wo={},this.Il=void 0,this.Ml=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(A(e)){this.syncCookieProperties(),D(t)&&(t="None"),this.Bl=D(i)?this.Ul:i;let s=!1;if(Kn(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._l(i,e),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(A(e)){this.syncCookieProperties(),this.Bl=D(t)?this.Ul:t;let i=!1;if(Kn(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||A(t)||I(t))&&(this._l(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t="string"==typeof e?[e]:e;let i=!1;for(const e of t)e in this.props&&(this.wl(e),i=!0);i&&this.save()}update_campaign_params(){const e=null==u?void 0:u.URL;if(e===this.sl)return;const t=qo(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),i=!L(Xn(t));return i&&this.register(t),this.sl=e,i?t:void 0}update_search_keyword(){this.register((function(){const e=null==u?void 0:u.referrer;return e?Wo(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:Jo(),$referring_domain:(null==u?void 0:u.referrer)&&(null===(e=Ro(u.referrer))||void 0===e?void 0:e.host)||Yo},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Zo(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[xn]:this.Go?{r:na(e.r),u:e.u?na(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Kn([wn,bn],t=>{const i=this.props[t];i&&Kn(i,function(t,i){e["$initial_"+M(i)]=t})});const t=this.props[xn];if(t){const i=(function(e,t=!1){const i=Xo(e,t),s={};return Kn(i,function(e,t){s[`$initial_${M(t)}`]=e}),s})(t,this.Mr.disable_capture_url_hashes);Yn(e,i)}return e}safe_merge(e){return Kn(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){const s=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;const i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=s||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this.pi&&!a;a||this.El(t,l),this.Mr=e,!a&&(s||n||o)&&(this.Il=void 0,this.Ml=void 0,this.El(Ot(Ot({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=r||o?this.ol(e):this.Fo;this.Wl();const u=this.ll(e),d=r||u!==this.Zo,h=!a&&(d||e.cross_subdomain_cookie!==this.Hl||e.secure_cookie!==this.zl)&&this.Pl(l);this.Xo=d;try{if(this.Ul=this.Bl=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const e=this.props;this.clear(),this.Fo=c,this.Zo=u,this.props=e,this.save()}else o&&(this.Fo=c,a||(delete this.Wo[ra],this.Fl()))}finally{this.Xo=!1,h&&this.Ol()}}Wl(){const e=this.props[xn];if(!this.Go||!A(e)||"string"!=typeof e.r)return;const t=na(e.r),i="string"==typeof e.u?na(e.u):e.u;t===e.r&&i===e.u||this._l(xn,Ot(Ot({},e),{},{r:t,u:i}))}set_disabled(e){this.pi=e,this.pi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Hl&&(this.Hl=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.zl&&(this.zl=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const i=this.props.__timers||{};i[e]=t,this._l(_s,i),this.save()}remove_event_timer(e){const t=this.props.__timers||{},i=t[e];return D(i)||(delete t[e],this._l(_s,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._l(e,t),this.save()}_l(e,t,i=!0){var s;const n=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||n===t||(this.Yo=!0),"$fbc_persistence"!==e||la(n,t)||(this.el=!0),this.Cl(e,n,t),(null===(s=Co(e))||void 0===s?void 0:s.volatile)||this.Sl(e))}wl(e,t=!0){delete this.props[e],t&&(aa(e)&&this.dl(e,!0),"$fbc_persistence"===e&&(this.el=!0),this.Sl(e))}Sl(e){var t;const i=null===(t=Co(e))||void 0===t?void 0:t.storageGroup;i&&(this.vl(i).dirty=!0)}vl(e){return this.Wo[e]||(this.Wo[e]={})}};const ha={GZipJS:"gzip-js",Base64:"base64"},pa={Activation:"events",Cancellation:"cancelEvents"},va={Button:"button",Tab:"tab",Selector:"selector"},fa={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},ga={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},_a={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ma={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},ya={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},ba={Once:"once",Recurring:"recurring",Always:"always"},wa={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},xa={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Ea={Popover:"popover",Inline:"inline"};function $a(e){let t=!0;return{dispose(){if(t){t=!1;const i=e();i&&R(i.then)&&i.then(void 0,()=>{})}}}}const Sa={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},ka={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Pa={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Ma=is("[RateLimiter]");var Oa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Ma.info(`${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void Ma.warn(`could not rate limit - continuing. Error: "${null==e?void 0:e.message}"`,{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t,i,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),a=null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_property("$capture_rate_limit"))&&void 0!==t?t:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*r,a.last=o,a.tokens>n&&(a.tokens=n);const l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){const e=(H(a.dropped)?a.dropped:0)+1;a.dropped=e,!this.lastEventRateLimited&&this.Vl(e)&&(a.dropped=0)}return this.lastEventRateLimited=l,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}Gl(e){const t=this.instance.config.property_denylist;return!I(t)||!t.includes(e)}Zl(){var e;if(this.Gl("$current_url")&&this.Gl("$pathname")&&(null==d?void 0:d.pathname))return`${null!==(e=d.origin)&&void 0!==e?e:""}${d.pathname}`}Vl(e){var t,i;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.Zl(),o=this.Gl("$session_id")?null===(t=(i=this.instance).get_session_id)||void 0===t?void 0:t.call(i):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}};const Ta=is("[RemoteConfig]");var Fa=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null===(e=y._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config}Ql(e){var t,i,s;(null===(t=y.__PosthogExtensions__)||void 0===t?void 0:t.loadExternalDependency)?null===(i=y.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}Jl(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return Ta.info("Using preloaded remote config",this.remoteConfig),void this.Kl(this.remoteConfig);if(this._instance.Xl())return void Ta.warn("Remote config is disabled. Falling back to local config.");this.Ql(e=>{if(!e)return Ta.info("No config found after loading remote JS config. Falling back to JSON."),void this.Jl(e=>{this.Kl(e.json,e)});this.Kl(e)})}catch(e){Ta.error("Error loading remote config",e),this.Kl()}}Kl(e,t){!e&&t&&(0===t.statusCode?t.error||Ta.warn("Failed to fetch remote config from PostHog."):Ta.error("Failed to fetch remote config from PostHog."));try{this._instance.Kl(e?{ok:!0,config:e}:{ok:!1})}catch(e){Ta.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null===(i=this._instance.featureFlags)||void 0===i||i.ensureFlagsLoaded()}catch(e){Ta.error("Error loading feature flags",e)}}};const Ca=["fatal","error","warning","log","info","debug"];var Ia=Uint8Array,Ra=Uint16Array,Aa=Uint32Array,La=new Ia([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Da=new Ia([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Na=new Ia([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ja=function(e,t){for(var i=new Ra(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var n=new Aa(i[30]);for(s=1;30>s;++s)for(var r=i[s];i[s+1]>r;++r)n[r]=r-i[s]<<5|s;return[i,n]},Ba=ja(La,2),Ua=Ba[1];Ba[0][28]=258,Ua[258]=28;for(var Ha=ja(Da,0)[1],za=new Ra(32768),qa=0;32768>qa;++qa){var Va=(43690&qa)>>>1|(21845&qa)<<1;za[qa]=((65280&(Va=(61680&(Va=(52428&Va)>>>2|(13107&Va)<<2))>>>4|(3855&Va)<<4))>>>8|(255&Va)<<8)>>>1}var Wa=function(e,t,i){for(var s=e.length,n=0,r=new Ra(t);s>n;++n)++r[e[n]-1];var o,a=new Ra(t);for(n=0;t>n;++n)a[n]=a[n-1]+r[n-1]<<1;if(i){o=new Ra(1<<t);var l=15-t;for(n=0;s>n;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],d=a[e[n]-1]++<<u,h=d|(1<<u)-1;h>=d;++d)o[za[d]>>>l]=c}else for(o=new Ra(s),n=0;s>n;++n)o[n]=za[a[e[n]-1]++]>>>15-e[n];return o},Ga=new Ia(288);for(qa=0;144>qa;++qa)Ga[qa]=8;for(qa=144;256>qa;++qa)Ga[qa]=9;for(qa=256;280>qa;++qa)Ga[qa]=7;for(qa=280;288>qa;++qa)Ga[qa]=8;var Ka=new Ia(32);for(qa=0;32>qa;++qa)Ka[qa]=5;var Ya=Wa(Ga,9,0),Ja=Wa(Ka,5,0),Za=function(e){return(e/8|0)+(7&e&&1)},Xa=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Ra?Ra:e instanceof Aa?Aa:Ia)(i-t);return s.set(e.subarray(t,i)),s},Qa=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},el=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},tl=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new Ia(0),0];if(1==n){var o=new Ia(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f>i[c].f?c++:d++],l=i[c!=u&&i[d].f>i[c].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(s=1;n>s;++s)r[s].s>h&&(h=r[s].s);var p=new Ra(h+1),v=il(i[u-1],p,0);if(v>t){s=0;var f=0,g=v-t,_=1<<g;for(r.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});n>s;++s){var m=r[s].s;if(t>=p[m])break;f+=_-(1<<v-p[m]),p[m]=t}for(f>>>=g;f>0;){var y=r[s].s;t>p[y]?f-=1<<t-p[y]++-1:++s}for(;s>=0&&f;--s){var b=r[s].s;p[b]==t&&(--p[b],++f)}v=t}return[new Ia(p),v]},il=function(e,t,i){return-1==e.s?Math.max(il(e.l,t,i+1),il(e.r,t,i+1)):t[e.s]=i},sl=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ra(++t),s=0,n=e[0],r=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[i.subarray(0,s),t]},nl=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},rl=function(e,t,i){var s=i.length,n=Za(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;s>r;++r)e[n+r+4]=i[r];return 8*(n+4+s)},ol=function(e,t,i,s,n,r,o,a,l,c,u){Qa(t,u++,i),++n[256];for(var d=tl(n,15),h=d[0],p=d[1],v=tl(r,15),f=v[0],g=v[1],_=sl(h),m=_[0],y=_[1],b=sl(f),w=b[0],x=b[1],E=new Ra(19),$=0;m.length>$;++$)E[31&m[$]]++;for($=0;w.length>$;++$)E[31&w[$]]++;for(var S=tl(E,7),k=S[0],P=S[1],M=19;M>4&&!k[Na[M-1]];--M);var O,T,F,C,I=c+5<<3,R=nl(n,Ga)+nl(r,Ka)+o,A=nl(n,h)+nl(r,f)+o+14+3*M+nl(E,k)+(2*E[16]+3*E[17]+7*E[18]);if(R>=I&&A>=I)return rl(t,u,e.subarray(l,l+c));if(Qa(t,u,1+(R>A)),u+=2,R>A){O=Wa(h,p,0),T=h,F=Wa(f,g,0),C=f;var L=Wa(k,P,0);for(Qa(t,u,y-257),Qa(t,u+5,x-1),Qa(t,u+10,M-4),u+=14,$=0;M>$;++$)Qa(t,u+3*$,k[Na[$]]);u+=3*M;for(var D=[m,w],N=0;2>N;++N){var j=D[N];for($=0;j.length>$;++$)Qa(t,u,L[B=31&j[$]]),u+=k[B],B>15&&(Qa(t,u,j[$]>>>5&127),u+=j[$]>>>12)}}else O=Ya,T=Ga,F=Ja,C=Ka;for($=0;a>$;++$)if(s[$]>255){var B;el(t,u,O[257+(B=s[$]>>>18&31)]),u+=T[B+257],B>7&&(Qa(t,u,s[$]>>>23&31),u+=La[B]);var U=31&s[$];el(t,u,F[U]),u+=C[U],U>3&&(el(t,u,s[$]>>>5&8191),u+=Da[U])}else el(t,u,O[s[$]]),u+=T[s[$]];return el(t,u,O[256]),u+T[256]},al=new Aa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ll=(new Ia(0),(function(){for(var e=new Aa(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e})()),cl=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ul(e,t){void 0===t&&(t={});var i=(function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=ll[255&i^t[s]]^i>>>8;e=i},d:()=>4294967295^e}})(),s=e.length;i.p(e);var n,r,o,a,l=(a=10+((n=t).filename&&n.filename.length+1||0),(function(e,t,i,s,n,r){var o=e.length,a=new Ia(s+o+5*(1+Math.floor(o/7e3))+8),l=a.subarray(s,a.length-8),c=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?c=rl(l,c,e.subarray(u,d)):(l[u]=r,c=rl(l,c,e.subarray(u,o)))}else{for(var h=al[t-1],p=h>>>13,v=8191&h,f=(1<<i)-1,g=new Ra(32768),_=new Ra(f+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&f},w=new Aa(25e3),x=new Ra(288),E=new Ra(32),$=0,S=0,k=(u=0,0),P=0,M=0;o>u;++u){var O=b(u),T=32767&u,F=_[O];if(g[T]=F,_[O]=T,u>=P){var C=o-u;if(($>7e3||k>24576)&&C>423){c=ol(e,l,0,w,x,E,S,k,M,u-M,c),k=$=S=0,M=u;for(var I=0;286>I;++I)x[I]=0;for(I=0;30>I;++I)E[I]=0}var R=2,A=0,L=v,D=T-F&32767;if(C>2&&O==b(u-D))for(var N=Math.min(p,C)-1,j=Math.min(32767,u),B=Math.min(258,C);j>=D&&--L&&T!=F;){if(e[u+R]==e[u+R-D]){for(var U=0;B>U&&e[u+U]==e[u+U-D];++U);if(U>R){if(R=U,A=D,U>N)break;var H=Math.min(D,U-2),z=0;for(I=0;H>I;++I){var q=u-D+I+32768&32767,V=q-g[q]+32768&32767;V>z&&(z=V,F=q)}}}D+=(T=F)-(F=g[T])+32768&32767}if(A){w[k++]=268435456|Ua[R]<<18|Ha[A];var W=31&Ua[R],G=31&Ha[A];S+=La[W]+Da[G],++x[257+W],++E[G],P=u+R,++$}else w[k++]=e[u],++x[e[u]]}}c=ol(e,l,r,w,x,E,S,k,M,u-M,c)}return Xa(a,0,s+Za(c)+8)})(r=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,a,0,!0)),c=l.length;return(function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&cl(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}})(l,t),cl(l,c-8,i.d()),cl(l,c-4,s),l}const dl=!!p||!!h,hl=new WeakMap,pl="text/plain";let vl=!1;const fl=(e,t)=>{const[i,s]=e.split("#"),[n,r]=i.split("?");if(!r)return e;const o=r.split("&").filter(e=>e.split("=")[0]!==t).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},gl=(e,t,i=!0)=>{var s;const[n,r]=e.split("?"),o=Ot({},t),a=null!==(s=null==r?void 0:r.split("&").map(e=>{var t;const[s,n]=e.split("="),r=i&&null!==(t=o[s])&&void 0!==t?t:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],l=(function(e,t="&"){let i,s;const n=[];return Kn(e,function(e,t){D(e)||D(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),n[n.length]=s+"="+i)}),n.join(t)})(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},_l=e=>{if(e.Yl)return e.Yl;const{data:t,compression:i}=e;if(!t)return;if(i===ha.GZipJS){const e=ul((function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new Ia(e.length+(e.length>>>1)),s=0,n=function(e){i[s++]=e},r=0;t>r;++r){if(s+5>i.length){var o=new Ia(s+8+(t-r<<1));o.set(i),i=o}var a=e.charCodeAt(r);128>a?n(a):2048>a?(n(192|a>>>6),n(128|63&a)):a>55295&&57344>a?(n(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++r))>>>18),n(128|a>>>12&63),n(128|a>>>6&63),n(128|63&a)):(n(224|a>>>12),n(128|a>>>6&63),n(128|63&a))}return Xa(i,0,s)})(Io(t)),{mtime:0});return{contentType:pl,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(i===ha.Base64){const e=(function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e})(Io(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:Io(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const s=Io(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},ml=e=>{const t=()=>"sendBeacon"===e.transport?{url:gl(e.url,{compression:ha.Base64}),encodedBody:_l(Ot(Ot({},e),{},{compression:ha.Base64,Yl:void 0}))}:{url:fl(e.url,"compression"),encodedBody:_l(Ot(Ot({},e),{},{compression:void 0,Yl:void 0}))};let i;try{i=_l(e)}catch(i){if(wi(e.compression,Ao(e.url,"compression")))return ts.error("Failed to gzip request body, sending uncompressed payload",i),t();throw i}return i&&wi(e.compression,Ao(e.url,"compression"))&&!((s=i.body)instanceof ArrayBuffer?bi(new Uint8Array(s)):ArrayBuffer.isView(s)&&bi(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(vl=!0,t()):{url:e.url,encodedBody:i};var s},yl=e=>{try{return ml(e)}catch(i){var t;return ts.error(i),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0,error:i}))}},bl=(function(){var e=ie(function*(e){const t=yield(function(e){return Pi.apply(this,arguments)})(Io(e.data),ls.DEBUG,{rethrow:!0});if(!t)return e;const i=yield t.arrayBuffer();return Ot(Ot({},e),{},{Yl:{contentType:pl,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}})(),wl=/Failed to fetch|NetworkError|Load failed/i,xl=e=>"TypeError"===(null==e?void 0:e.name)&&wl.test((null==e?void 0:e.message)||""),El=e=>{const t=yl(e);if(!t)return;const i=new p;hl.set(i,!0);const{url:s,encodedBody:n}=t;i.open(e.method||"GET",s,!0);const{contentType:r,body:o}=null!=n?n:{};Kn(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t;const s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,s)}},i.send(o)},$l=e=>{const t=yl(e);if(!t)return;const{url:i,encodedBody:s}=t,{contentType:n,body:r,estimatedSize:o}=null!=s?s:{},a=new Headers;Kn(e.headers,function(e,t){a.append(t,e)}),n&&a.append("Content-Type",n);let l=null,c=!1;if(v){const t=new v;l={signal:t.signal,timeout:setTimeout(()=>{var i;c=!0,t.abort(gt("AbortError","PostHog request timed out"+((i=e.timeout)?` after ${i}ms`:"")))},e.timeout)}}const u=t=>{var i;c&&"AbortError"===(null==t?void 0:t.name)||xl(t)?ts.warn(t):ts.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,error:t})};try{h(i,Ot({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&!e.ta&&52428.8>(o||0),body:r,signal:null==l?void 0:l.signal},e.fetchOptions)).then(t=>t.text().then(i=>{var s;const n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){ts.error(e)}null===(s=e.callback)||void 0===s||s.call(e,n)})).catch(u).finally(()=>l?clearTimeout(l.timeout):null)}catch(e){l&&clearTimeout(l.timeout),u(e)}},Sl=e=>{try{var t;const{url:i,encodedBody:s}=ml(e),{contentType:n,body:r,estimatedSize:o}=null!=s?s:{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:n});if(c.sendBeacon(i,a))return;const l=I(e.data)?e.data:null===(t=e.data)||void 0===t?void 0:t.batch;if(I(l)&&l.length>1&&(null!=o?o:0)>16384){const t=Math.ceil(l.length/2),i=t=>I(e.data)?t:Ot(Ot({},e.data),{},{batch:t});return Sl(Ot(Ot({},e),{},{data:i(l.slice(0,t))})),void Sl(Ot(Ot({},e),{},{data:i(l.slice(t))}))}ts.warn(`Beacon of ~${null!=o?o:0} bytes was rejected by the browser, falling back to ${h?"fetch":"XHR"}`),h?$l(Ot(Ot({},e),{},{ta:!0})):El(e)}catch(e){ts.warn("Beacon send failed",e)}},kl=(e,t,i,s)=>{const n="query"===s?"POST"===t?"sent_at":"_":void 0;return gl(i===ha.GZipJS?fl(e,"compression"):e,Ot(Ot({},n?{[n]:Date.now().toString()}:{}),i===ha.GZipJS?{}:{compression:i}))},Pl=(()=>{const e=[];return h&&e.push({transport:"fetch",method:$l}),p&&e.push({transport:"XHR",method:El}),(null==c?void 0:c.sendBeacon)&&e.push({transport:"sendBeacon",method:Sl}),e})();var Ml=class{constructor(e,t){this.ea=!0,this.ia=[],this.na=re((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,ts.createLogger("flush interval"),3e3),this.sa=e}enqueue(e){this.ia.push(e),this.ra||this.oa()}unload(){this.la();const e=this.ia.length>0?this.aa():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this.ua(Ot(Ot({},e),{},{transport:"sendBeacon"}))})}enable(){this.ea=!1,this.oa()}oa(){this.ea||(this.ra=setTimeout(()=>{if(this.la(),this.ia.length>0){const e=this.aa();for(const t in e)this.ua(e[t])}},this.na))}ua(e){try{this.sa(e)}catch(e){ts.error(e)}}la(){clearTimeout(this.ra),this.ra=void 0}aa(){const e={};return Kn(this.ia,t=>{var i;const s=t,n=((s?s.batchKey:null)||s.url)+(s.batchGroup?`:${s.batchGroup}`:"");D(e[n])&&(e[n]=Ot(Ot({},s),{},{data:[]})),null===(i=e[n].data)||void 0===i||i.push(s.data)}),this.ia=[],e}};const Ol=["retriesPerformedSoFar"];var Tl=class{constructor(e){this._instance=e,this.ha=!1,this.ca=3e3,this.ia=[],this.ia=[],this.da=!0,this.resume()}resume(){if(!D(a)&&"onLine"in a.navigator){if(this.da=a.navigator.onLine,this.va)return;this.va=()=>{this.da=!0,this.fa()},this.pa=()=>{this.da=!1},ir(a,"online",this.va),ir(a,"offline",this.pa)}}get length(){return this.ia.length}retriableRequest(e){let{retriesPerformedSoFar:t}=e,i=Ti(e,Ol);z(t)&&(i.url=gl(i.url,{retry_count:t})),this._instance._send_request(Ot(Ot({},i),{},{callback:e=>{var s;if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=t?t:0))return void this.Ls(Ot({retriesPerformedSoFar:t},i));0===e.statusCode&&ts.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${null!=t?t:0} retries.`)}null===(s=i.callback)||void 0===s||s.call(i,e)}}))}Ls(e){const t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;const i=(function(e){const t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),n=(Math.random()-.5)*(s-i);return Math.ceil(s+n)})(t),s=Date.now()+i;this.ia.push({retryAt:s,requestOptions:e});let n=`Enqueued failed request for retry in ${i}`;navigator.onLine||(n+=" (Browser is offline)"),ts.warn(n),this.ha||(this.ha=!0,this.ga())}ga(){if(this.ma&&clearTimeout(this.ma),0===this.ia.length)return this.ha=!1,void(this.ma=void 0);this.ma=setTimeout(()=>{this.da&&this.ia.length>0&&this.fa(),this.ga()},this.ca)}fa(){const e=Date.now(),t=[],i=this.ia.filter(i=>e>i.retryAt||(t.push(i),!1));if(this.ia=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this.ma&&(clearTimeout(this.ma),this.ma=void 0),this.ha=!1,D(a)||(this.va&&(a.removeEventListener("online",this.va),this.va=void 0),this.pa&&(a.removeEventListener("offline",this.pa),this.pa=void 0));for(const{requestOptions:e}of this.ia)try{this._instance._send_request(Ot(Ot({},e),{},{transport:"sendBeacon"}))}catch(e){ts.error(e)}this.ia=[]}},Fl=class{constructor(e){this._instance=e,this.ya=()=>{var e,t,i,s;this.ba||(this.ba={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=r+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this.ba.lastScrollY=Math.ceil(r),this.ba.maxScrollY=Math.max(r,null!==(e=this.ba.maxScrollY)&&void 0!==e?e:0),this.ba.maxScrollHeight=Math.max(o,null!==(t=this.ba.maxScrollHeight)&&void 0!==t?t:0),this.ba.lastContentY=a,this.ba.maxContentY=Math.max(a,null!==(i=this.ba.maxContentY)&&void 0!==i?i:0),this.ba.maxContentHeight=Math.max(l,null!==(s=this.ba.maxContentHeight)&&void 0!==s?s:0)}}get _a(){return this._instance.config.scroll_root_selector}getContext(){return this.ba}resetContext(){const e=this.ba;return this.ba=void 0,setTimeout(this.ya,0),e}startMeasuringScrollPosition(){ir(a,"scroll",this.ya,{capture:!0}),ir(a,"scrollend",this.ya,{capture:!0}),ir(a,"resize",this.ya)}scrollElement(){if(this._a){const t=I(this._a)?this._a:[this._a];for(const i of t){var e;const t=null==a||null===(e=a.document)||void 0===e?void 0:e.querySelector(i);if(t)return t}return}var t;return null==a||null===(t=a.document)||void 0===t?void 0:t.documentElement}wa(e){var t,i;const s="y"===e?"scrollTop":"scrollLeft";if(this._a){const e=this.scrollElement();return e&&e[s]||0}return a?"y"===e?a.scrollY||a.pageYOffset||(null===(t=a.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.scrollTop)||0:a.scrollX||a.pageXOffset||(null===(i=a.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollLeft)||0:0}scrollY(){return this.wa("y")}scrollX(){return this.wa("x")}};const Cl=e=>Zo(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes);var Il=class{constructor(e,t,i,s){this.je=e=>{const t=this.ka();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this.Sa(this._instance)};this.xa.register({[mn]:i})},this._instance=e,this.Ca=t,this.xa=i,this.Sa=s||Cl,this.Ca.onSessionId(this.je)}ka(){return this.xa.props[mn]}getSetOnceProps(){var e;const t=null===(e=this.ka())||void 0===e?void 0:e.props;return t?"r"in t?Xo(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){const e={};return Kn(Xn(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e[`$session_entry_${M(i)}`]=t}),e}},Rl=class{on(e,t){return this.$a[e]||(this.$a[e]=[]),this.$a[e].push(t),()=>{this.$a[e]=this.$a[e].filter(e=>e!==t)}}emit(e,t){for(const i of this.$a[e]||[])i(t);for(const i of this.$a["*"]||[])i(e,t)}constructor(){this.$a={}}};const Al=is("[SessionId]"),Ll=864e5;var Dl=class{on(e,t){return this.Ta.on(e,t)}constructor(e,t,i){var s;if(this.Ia=null,this.Ma=null,this.Ea=[],this.Pa=void 0,this.Ra=!1,this.Ta=new Rl,this.Aa=(e,t)=>!(!z(e)||!z(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=e.config,this.xa=e.persistence,this.Be=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Fa=void 0,this._sessionActivityTimestamp=null,this.Oa=t||ur,this.Da=i||ur;const n=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*re(this.Mr.session_idle_timeout_seconds||1800,60,36e3,Al.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.La(),this.Na="ph_"+n+"_window_id",this.qa="ph_"+n+"_primary_window_exists",this.ja()){const e=Fr.Dt(this.Na),t=Fr.Dt(this.qa);e&&!t?this.Be=e:Fr.Lt(this.Na),Fr.At(this.qa,!0)}(null===(s=this.Mr.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Ba()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return D(this.Ea)&&(this.Ea=[]),this.Ea.push(e),this.Xt&&e(this.Xt,this.Be),()=>{this.Ea=this.Ea.filter(t=>t!==e)}}ja(){return"memory"!==this.Mr.persistence&&!this.xa.pi&&Fr.Et()}Ha(e){e!==this.Be&&(this.Be=e,this.ja()&&Fr.At(this.Na,e))}za(){return this.Be?this.Be:this.ja()?Fr.Dt(this.Na):null}Ua(e){const t=this.Ia;return!B(t)&&!B(e)&&5e3>Math.abs(e-t)}Wa(e,t,i){const s=t!==this._sessionActivityTimestamp,n=!(e!==this.Xt||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.Xt=e,n&&!s||n&&this.Ua(t)||(this.Ia=t,this.xa.register({[As]:[t,e,i]}))}Va(){var e;const t=null===(e=this.Mr)||void 0===e?void 0:e.persistence_save_debounce_ms;return z(t)&&t>0}Ga(){this.Va()?this.xa.refreshKey(As):(this.xa.flush(),this.xa.load())}Za(){var e;if(B(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Ia)return;this.Ga();const[,t,i]=this.Qa();t===this.Xt&&i===this._sessionStartTimestamp&&(this.Ia=this._sessionActivityTimestamp,this.xa.register({[As]:[this._sessionActivityTimestamp,null!==(e=this.Xt)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this.xa.flush())}Ja(){const[e]=this.Qa(),t=z(e)?e:0,i=z(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}Ka(e){return this.Ga(),this.Aa(e,this.Ja())}Qa(){const e=this.xa.props[As];return I(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Ia=null,this.Fa=void 0,clearTimeout(this.Xa),this.Xa=void 0,this.Wa(null,null,null)}setBootstrapSessionId(e,t=!1){const i=((e,t=(new Date).getTime())=>{try{const i=(e=>{const t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void Al.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Al.error("Invalid sessionID in bootstrap",e)}})(e);return!D(i)&&(t?this.Fa={sessionId:e,sessionStartTimestamp:i}:this.Wa(e,(new Date).getTime(),i),!0)}destroy(){this.Ra=!0,this.Za(),clearTimeout(this.Xa),this.Xa=void 0,this.Pa&&a&&(a.removeEventListener(Hn,this.Pa,{capture:!1}),this.Pa=void 0),this.Ea=[]}Ba(){this.Pa=()=>{this.Za(),this.ja()&&Fr.Lt(this.qa)},ir(a,Hn,this.Pa,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if("always"===this.Mr.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=t||(new Date).getTime(),n=this.Xt;if(i)this.Ma=s;else if(B(this.Ma)||this.Ma>s||s-this.Ma>=1e3){var r,o;null===(r=(o=this.xa).syncCookieProperties)||void 0===r||r.call(o),this.Ma=s}let[,a,l]=this.Qa();const c=!D(n)&&a!==n,u=this.Ja();let d=this.za();const h=this.Fa,p=!!h&&(h.sessionStartTimestamp>s+6e4||s-h.sessionStartTimestamp>Ll),v=h?p:z(l)&&Math.abs(s-l)>Ll;let f=!1,g=c;const _=!a||!!h,m=a;let y=!_&&!e&&this.Aa(s,u);if(y&&(y=this.Ka(s),y||Al.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.Qa()),_||y||v){g=!1;const e=h&&!p;a=e?h.sessionId:this.Oa(),d=this.Da(),Al.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:_,activityTimeout:y,sessionPastMaximumLength:v}}),l=e?h.sessionStartTimestamp:s,this.Fa=void 0,f=!0}else d||(d=this.Da(),f=!0),g=g||a!==m,g&&(Al.info("adopted cross-tab session id",{sessionId:a,windowId:d}),f=!0);const b=z(u)&&e&&!v?u:s,w=z(l)?l:(new Date).getTime();this.Ha(d),this.Wa(a,b,w),e||this.La();const x={noSessionId:_,activityTimeout:y,sessionPastMaximumLength:v,crossTabAdoption:g};return f&&this.Ea.forEach(e=>e(a,d,x)),{sessionId:a,windowId:d,sessionStartTimestamp:w,changeReason:f?x:void 0,lastActivityTimestamp:u}}La(){this.Ra||(clearTimeout(this.Xa),this.Xa=setTimeout(()=>{if(!this.Ra)if(this.Ka((new Date).getTime())){const e=this.Xt;this.resetSessionId(),this.Ta.emit("forcedIdleReset",{idleSessionId:e})}else this.La()},1.1*this.sessionTimeoutMs))}};const Nl=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&ne(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if((null==i?void 0:i.brands)&&i.brands.some(e=>ne(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function jl(){return(jl=ie(function*(){const e=null==c?void 0:c.userAgentData;if(null==e?void 0:e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return N(i)&&i.length>0?i:void 0}catch(e){return void ts.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function Bl(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function Ul(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}const Hl=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch(e){return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}},zl=e=>e.toLowerCase(),ql={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Hl(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Hl(t,e))),icontains:(e,t)=>t.map(zl).some(t=>e.map(zl).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(zl).every(t=>e.map(zl).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function Vl(e,t){return!e||Object.entries(e).every(([e,i])=>{const s=null==t?void 0:t[e];if(null==s)return!1;const n=ql[i.operator];return!!n&&n(i.values,[String(s)])})}function Wl(e,t,i){return Io({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}const Gl="custom",Kl="i.posthog.com",Yl=/^\/static\//,Jl=["/s/","/e/","/i/"];var Zl=class{constructor(e){this.Ya={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${Kl}`,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this.Ya[this.apiHost]||(this.Ya[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Gl),this.Ya[this.apiHost]}tu(e){if(!Yl.test(e))return;const t=this.instance.config.asset_host;return"string"==typeof t&&t.trim().replace(/\/$/,"")||void 0}eu(e){const t=Ro(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}iu(e,t,i){if("ui"===e)return i;let s=i;const n=this.instance.config.rewriteRequestPath;if(n){var r;const e=(null===(r=Ro(i))||void 0===r?void 0:r.href)||i;s=n(new URL(e)).toString()}if(n&&"api"===e&&Jl.some(e=>0===t.indexOf(e))){const e=this.eu(s);if(e){const t=this.apiHost;let i=this.nu;(null==i?void 0:i.apiHost)===t&&i.rewriteRequestPath===n||(i={apiHost:t,rewriteRequestPath:n,urls:new Set},this.nu=i),i.urls.add(e)}}return s}isIngestionEndpoint(e){const t=this.nu,i=this.eu(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t=""){if(t&&(t="/"===t[0]?t:`/${t}`),"ui"===e)return this.iu(e,t,this.uiHost+t);if("flags"===e)return this.iu(e,t,this.flagsApiHost+t);if("assets"===e){const i=this.tu(t);if(i)return this.iu(e,t,`${i}${t}`)}if(this.region===Gl)return this.iu(e,t,this.apiHost+t);const i=Kl+t;switch(e){case"assets":return this.iu(e,t,`https://${this.region}-assets.${i}`);case"api":return this.iu(e,t,`https://${this.region}.${i}`)}}};const Xl=is("[Surveys]"),Ql=e=>{try{const t=(e=>((e,t)=>`seenSurvey_${(function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id})(t)}`)(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){Xl.error("Failed to persist survey seen state",e)}},ec=[_a.Popover,_a.Widget,_a.API],tc={ignoreConditions:!1,ignoreDelay:!1,displayType:Ea.Popover},ic=is("[PostHog ExternalIntegrations]"),sc={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var nc=class{constructor(e){this._instance=e}No(e,t){var i,s;null===(i=y.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,e,e=>{if(e)return ic.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e;for(const[n,r]of Object.entries(null!==(e=this._instance.config.integrations)&&void 0!==e?e:{})){var t,i,s;r&&!(null===(t=y.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t?void 0:t[n])&&this.No(sc[n],()=>{var e;null===(e=y.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e||null===(e=e[n])||void 0===e||e.start(this._instance)}),!r&&(null===(i=y.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&(null===(s=y.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},rc=class{constructor(e,t){this.$=e,this.po=t,this.su=new Map,this.So=!1}add(e){var t=this;return ie(function*(){if(t.So)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.su.has(e.name))throw new Error(`Browser extension "${e.name}" is already registered`);t.su.set(e.name,e);try{const i=e.setup(t.po);i&&(yield i)}catch(i){const s=t.su.get(e.name)===e;s&&t.su.delete(e.name),t.$.error(`Failed to set up browser extension "${e.name}"`,i),s&&t.ru(e)}})()}getExtension(e){return this.su.get(e)}dispose(){if(this.So)return;this.So=!0;const e=Array.from(this.su.values()).reverse();this.su.clear();for(const t of e)this.ru(t)}ru(e){try{var t;const i=null===(t=e.dispose)||void 0===t?void 0:t.call(e);i&&R(i.then)&&i.then(void 0,t=>{this.$.error(`Failed to dispose browser extension "${e.name}"`,t)})}catch(t){this.$.error(`Failed to dispose browser extension "${e.name}"`,t)}}},oc=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);const i={};for(const s of e){const e=null==t?void 0:t.get_property(s);D(e)||(i[s]=e)}return i}set(e,t){var i;null===(i=this._instance.persistence)||void 0===i||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null===(t=this._instance.persistence)||void 0===t||t.unregister(e)}};const ac="extensionsRemoteConfig";var lc=class{constructor(e){this.instance=e,this.So=!1,this.$=ts,this.ou=e.lu,this.kv=new oc(e),this.onEvent=e=>$a(this.instance.on("eventCaptured",t=>{try{e({event:t.event,properties:t.properties})}catch(e){this.$.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{if(this.So)return $a(()=>{});const t=t=>{try{e(t)}catch(e){this.$.error("Browser extension remote config listener failed",e)}},i=this.instance.au.on(ac,t);return this.ou&&t(this.ou),$a(i)},this.uu=new rc(ts.createLogger("[BrowserExtensions]"),this)}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){const e=this.instance.get_property(ds);return"string"==typeof e?e:void 0}get library(){return{name:ls.LIB_NAME,version:ls.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s;const n=null===(e=this.instance.sessionManager)||void 0===e?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==n?void 0:n.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==n?void 0:n.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==n?void 0:n.sessionStartTimestamp)&&void 0!==s?s:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.uu.add(e)}getExtension(e){return this.uu.getExtension(e)}capture(e,t,i){var s=this;return ie(function*(){i?s.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):s.instance.capture(e,t)})()}registerDynamicEventProperties(e){return $a(this.instance.hu(e))}handleRemoteConfig(e){this.So||(this.ou=e,this.instance.au.emit(ac,e))}sendRequest(e){var t=this;return ie(function*(e,i={}){var s;const n=t.instance.requestRouter.endpointFor(null!==(s=i.target)&&void 0!==s?s:"api",e),r={method:i.method,url:i.query?gl(n,i.query):n,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:"flags"===i.target&&"best-available"===i.compression?E.Base64:void 0,timestampMode:i.sentAt};return"sendBeacon"===i.transport?(t.instance._send_request(r),{statusCode:202}):new Promise(e=>{r.callback=e,t.instance._send_request(r)})}).apply(this,arguments)}dispose(){this.So||(this.So=!0,this.uu.dispose())}};const cc={};let uc=0;const dc=()=>{},hc='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',pc="Surveys module not available",vc="sanitize_properties is deprecated. Use before_send instead",fc="Invalid value for property_denylist config: ",gc=/^[A-Za-z0-9_-]{1,400}$/,_c=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,mc=["token","distinct_id",Sn],yc="posthog";let bc=!dl&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla"));const wc=e=>{const t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},xc=e=>{var t;return Ot({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:tr(null==u?void 0:u.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:dc,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:d&&N(null==d?void 0:d.search)&&-1!==d.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==a||null===(t=a.location)||void 0===t?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){ts.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Bn,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:dc},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Zr,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:wc(e),external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(e))},Ec=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],$c=e=>{const t={};for(const[i,s]of Ec)D(e[i])||(t[s]=e[i]);const i=Yn({},t,e),s=e.__preview_external_dependency_versioned_paths;return D(s)||(D(e.strict_script_versioning)&&(i.strict_script_versioning=!!s),N(s)&&D(e.asset_host)&&(i.asset_host=s)),I(e.property_blacklist)&&(D(e.property_denylist)?i.property_denylist=e.property_blacklist:I(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:ts.error(fc+e.property_denylist)),i};var Sc=class{constructor(){this.__forceAllowLocalhost=!1}get cu(){return this.__forceAllowLocalhost}set cu(e){ts.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},kc=class e{du(e){if(!e)return;const t=this.su.indexOf(e);-1!==t&&this.su.splice(t,1)}vu(e,t){var i;return this.du(e),this.su.push(t),null===(i=t.initialize)||void 0===i||i.call(t),t}fu(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}pu(){if(this.gu)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this.fu())return;const e="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!e&&!this.config.disable_persistence)return;if(this.mu)return;let t,i,s;e?(t=`persistence is set to '${this.config.persistence}'`,i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.gu=!0,console.warn("[PostHog.js]",`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${s}`)}yu(){if(this.fu()||"$posthog_cookieless"!==this.get_distinct_id())return;const e=this.persistence;if(!e)return;this.bu()||e.load(!0);const t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){const t=this.config.get_device_id(ur());this.register({distinct_id:t,$device_id:t}),e.set_property(_n,Nn)}this._u()}get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var t;this.wu=!1,this.ku=!1,this.webPerformance=new Sc,this.Su=!1,this.version=ls.LIB_VERSION,this.xu=new Set,this.Cu="",this.au=new Rl,this.su=[],this.$u=[],this.mu=!1,this.gu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=xc(),this.SentryIntegration=Po,this.sentryIntegration=e=>(function(e,t){const i=ko(e,t);return{name:So,processEvent:e=>i(e)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Tu=!1,this.Iu=null,this.Mu=null,this.Eu=null,this.scrollManager=new Fl(this),this.pageViewManager=new Mo(this),this.rateLimiter=new Oa(this),this.requestRouter=new Zl(this),this.consent=new Cr(this),this.externalIntegrations=new nc(this);const i=null!==(t=e.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(e,t,i)=>{const s=N(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{const s=N(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>ts.info(`send "${null==e?void 0:e.event}"`,e))}init(t,i,s){if(s&&s!==yc){var n;const r=null!==(n=cc[s])&&void 0!==n?n:new e;return r._init(t,i,s),cc[s]=r,cc[yc][s]=r,r}return this._init(t,i,s)}_init(e,t={},i){var s,n,r;const o=N(e)?e.trim():"";if(!o)return ts.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return o!==(null===(l=this.config)||void 0===l?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${o}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=xc(t.defaults),t.debug=this.Pu(t.debug),this.Ru=t,this.Au=[],t.person_profiles?this.Mu=t.person_profiles:t.process_person&&(this.Mu=t.process_person);const c=xc(t.defaults),u=$c(t),d=Yn({},c,u,{name:i,token:o});A(c.rageclick)&&A(u.rageclick)&&(d.rageclick=Yn({},c.rageclick,u.rageclick)),A(c.session_recording)&&A(u.session_recording)&&(d.session_recording=Yn({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&ts.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ha.GZipJS;const h=this.bu();if(this.persistence=new da(this.config,h),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new da(Ot(Ot({},this.config),{},{persistence:"sessionStorage"}),h,!1),this.Cu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!h&&Fr.Et()){const e=Fr.Dt(this.Cu);I(e)&&e.forEach(e=>{N(e)&&this.xu.add(e)})}else Fr.Lt(this.Cu);const p=Ot({},this.persistence.props),v=Ot({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Fu=new Ml(e=>this.Ou(e),this.config.request_queue_config),this.Du=new Tl(this),this.__request_queue=[];const f=this.fu();f||(this.sessionManager=new Dl(this),this.sessionPropsManager=new Il(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{((null==i?void 0:i.activityTimeout)||(null==i?void 0:i.sessionPastMaximumLength)||(null==i?void 0:i.crossTabAdoption))&&this.Lu()})),this.Nu(),this.config.__preview_deferred_init_extensions?(ts.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.qu(f)},0)):(ts.info("Initializing extensions synchronously"),this.qu(f)),ls.DEBUG=ls.DEBUG||this.config.debug,ls.DEBUG&&ts.info("Starting in debug mode",{this:this,config:t,thisC:Ot({},this.config),p:p,s:v}),this.config.identity_distinct_id&&!(null===(s=t.bootstrap)||void 0===s?void 0:s.distinctID)&&(t.bootstrap=Ot(Ot({},t.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const g=null===(n=t.bootstrap)||void 0===n?void 0:n.distinctID;if(this.mu=!!g&&!j(g),null===(r=t.bootstrap)||void 0===r?void 0:r.distinctID){const e=t.bootstrap.distinctID,i=this.get_distinct_id(),s=this.persistence.get_property(_n);if(t.bootstrap.isIdentifiedID&&null!=i&&i!==e&&"anonymous"===s)this.identify(e);else if(t.bootstrap.isIdentifiedID&&null!=i&&i!==e&&"identified"===s)ts.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const i=this.config.get_device_id(ur()),s=t.bootstrap.isIdentifiedID?i:e;this.persistence.set_property(_n,t.bootstrap.isIdentifiedID?jn:Nn),this.register({distinct_id:e,$device_id:s})}}if(f)this.register_once({distinct_id:$n,$device_id:null},"");else if(!this.get_distinct_id()){const e=this.config.get_device_id(ur());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(_n,Nn)}return ir(a,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),ir(a,"pageshow",()=>{var e;this.wu=!1,this.ku||null===(e=this.Du)||void 0===e||e.resume()}),t.segment?$o(this,()=>this.ju()):this.ju(),R(this.config._onCapture)&&this.config._onCapture!==dc&&(ts.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&ts.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||(function(){return jl.apply(this,arguments)})().then(e=>{e&&this.register({[hs]:e})}).catch(dc),this}Bu(e){const t=e;return N(t.name)&&R(t.setup)}Hu(e,t){this.Bu(e)?t.push(()=>{this.zu().add(e).catch(()=>{var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)}).catch(t=>{ts.error(`Failed to dispose browser extension "${e.name}"`,t)})}):this.su.push(e)}Nu(){var t,i,s;const n=null!==(t=null===(i=this.config.__extensionClasses)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:null===(s=e.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var r,o,a;n&&(this.featureFlags&&this.featureFlags instanceof n||(null===(r=this.Uu)||void 0===r||r.call(this),this.Uu=void 0,this.featureFlags=new n(this)),R(this.featureFlags.onReloading)&&R(this.featureFlags.setup)?this.Uu||(this.Uu=this.featureFlags.onReloading(()=>{this.au.emit("featureFlagsReloading",!0)}),this.zu().add(this.featureFlags)):null===(o=(a=this.featureFlags).initialize)||void 0===o||o.call(a))}qu(t){const i=performance.now(),s=Ot(Ot({},e.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,d;s.exceptions&&this.su.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this.su.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.su.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.su.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this.su.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Hu(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Hu(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this.Hu(this.logs=null!==(a=this.logs)&&void 0!==a?a:new s.logs(this),n),s.metrics&&this.su.push(this.metrics=null!==(l=this.metrics)&&void 0!==l?l:new s.metrics(this)),s.conversations&&this.su.push(this.conversations=null!==(c=this.conversations)&&void 0!==c?c:new s.conversations(this)),s.productTours&&this.su.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.su.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.su.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.su.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.su.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,wo)),s.toolbar&&this.su.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new s.toolbar(this)),s.experiments&&this.su.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),this.su.forEach(e=>{e.initialize&&n.push(()=>{var t;null===(t=e.initialize)||void 0===t||t.call(e)})}),n.push(()=>{if(this.Wu){const e=this.Wu;this.Wu=void 0,this.su.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}}),this.Vu(n,i)}Vu(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.Vu(e,t)},0);const i=e.shift();if(i)try{i()}catch(e){ts.error("Error initializing extension:",e)}}const i=Math.round(performance.now()-t);this.register_for_session({[kn]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Pn]:i}),this.config.__preview_deferred_init_extensions&&ts.info(`PostHog extensions initialized (${i}ms)`)}Kl(e){var t;if(!u||!u.body)return ts.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Kl(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Wu=e),this.lu=e,this.compression=void 0,e.ok){var i;const t=e.config;t.supportedCompression&&!this.config.disable_compression&&(this.compression=k(t.supportedCompression,ha.GZipJS)?ha.GZipJS:k(t.supportedCompression,ha.Base64)?ha.Base64:void 0),(null===(i=t.analytics)||void 0===i?void 0:i.endpoint)&&(this.analyticsDefaultEndpoint=t.analytics.endpoint)}this.set_config({person_profiles:this.Mu?this.Mu:Bn}),null===(t=this.Gu)||void 0===t||t.handleRemoteConfig(e),this.su.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}ju(){try{this.config.loaded(this)}catch(e){ts.critical("`loaded` function failed",e)}if(this.Zu(),this.config.internal_or_test_user_hostname&&(null==d?void 0:d.hostname)){const e=d.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.fu())&&this.Qu()},1),this.Ju=new Fa(this),this.Ju.load()}Zu(){var e;this.is_capturing()&&this.config.request_batching&&(null===(e=this.Fu)||void 0===e||e.enable())}_dom_loaded(){this.is_capturing()&&Gn(this.__request_queue,e=>this.Ou(e)),this.__request_queue=[],this.Zu()}_handle_unload(){var e,t,i,s,n,r;this.wu=!0,null===(e=this.surveys)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e),null===(i=this.metrics)||void 0===i||i.flush("sendBeacon"),this.config.request_batching?(this.Ku()&&this.capture(qn),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this.Fu)||void 0===n||n.unload(),null===(r=this.Du)||void 0===r||r.unload()):this.Ku()&&this.capture(qn,null,{transport:"sendBeacon"})}_send_request(e){var t,i,s;this.__loaded?bc?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(null===(i=e.callback)||void 0===i||i.call(e,{statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=Ot(Ot({},this.config.request_headers),e.headers),e.compression="best-available"===e.compression?null!==(t=this.compression)&&void 0!==t?t:e.compressionFallback:e.compression,(D(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,s;const n=Ot({},e);n.timeout=n.timeout||6e4;const r=null!==(t=n.transport)&&void 0!==t?t:"fetch";"sendBeacon"===r&&D(n.compression)&&n.data&&(n.compression=ha.Base64),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data=(e=>{var t,i;const s=(I(e)?e:[e]).map(e=>Ot(Ot({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(t=null==n||null===(i=n.properties)||void 0===i?void 0:i.token)&&void 0!==t?t:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(n.data):"body"===n.timestampMode&&(n.data=((e,t=(new Date).toISOString())=>I(e)?e.map(e=>Ot(Ot({},e),{},{sent_at:t})):Ot(Ot({},e),{},{sent_at:t}))(n.data))),n.url=kl(n.url,n.method,n.compression,n.timestampMode);const o=Pl.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),a=null!==(i=null===(s=(function(e,t){for(let i=0;e.length>i;i++)if(t(e[i]))return e[i]})(o,e=>e.transport===r))||void 0===s?void 0:s.method)&&void 0!==i?i:o[0].method;if(!a)throw new Error("No available transport method");const l=e=>{try{a(e)}catch(e){var t;xl(e)?ts.warn(e):ts.error(e),null===(t=n.callback)||void 0===t||t.call(n,{statusCode:0,error:e})}};"sendBeacon"!==r&&n.data&&n.compression===ha.GZipJS&&f&&"undefined"!=typeof Promise&&!vl?bl(n).then(e=>{l(e)}).catch(t=>{if(xi(t))return vl=!0,void l(Ot(Ot({},n),{},{compression:void 0,url:kl(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;const t="name"in e?String(e.name):"";return xi(e)||t===yi})(t)&&(vl=!0),l(n)}):a(n)})(Ot(Ot({},e),{},{callback:t=>{var i,s,n;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null===(s=(n=this.config).on_request_error)||void 0===s||s.call(n,t),null===(i=e.callback)||void 0===i||i.call(e,t)}}))):e.fireCallbackOnDrop&&(null===(s=e.callback)||void 0===s||s.call(e,{statusCode:0}))}Ou(e){this.Du?this.Du.retriableRequest(e):this._send_request(e)}_execute_array(e){uc++;try{let t;const i=[],s=[],n=[];Gn(e,e=>{if(e)if(t=e[0],I(t))n.push(e);else if(R(e))try{e.call(this)}catch(t){ts.error("Error executing queued PostHog call",e,t)}else I(e)&&"alias"===t?i.push(e):I(e)&&-1!==t.indexOf("capture")&&R(this[t])?n.push(e):s.push(e)});const r=function(e,t){Gn(e,function(e){try{if(I(e[0])){let i=t;Kn(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){ts.error("Error executing queued PostHog call",e,t)}})};r(i,this),r(s,this),r(n,this)}finally{uc--}}push(t){if(uc>0&&I(t)&&N(t[0])){const i=e.prototype[t[0]];return void(R(i)&&i.apply(this,t.slice(1)))}this._execute_array([t])}Xu(){var e;const t=null===(e=this.persistence)||void 0===e?void 0:e.get_property(gs);return N(t)&&_c.test(t)?{value:t,delivered:!1}:A(t)&&N(t.value)&&_c.test(t.value)?{value:t.value,delivered:!0===t.delivered}:void 0}Yu(e,t,i,s){if(!this.persistence)return;this.persistence.refreshKey(gs);const n=this.Xu();if(!s){if(i)return N(t)&&_c.test(t)?(t!==(null==n?void 0:n.value)&&this.persistence.register({[gs]:{value:t,delivered:!1}}),{value:t,pending:t!==(null==n?void 0:n.value)||!n.delivered}):void this.persistence.unregister(gs);if(N(e)&&gc.test(e)){if((null==n?void 0:n.value.split(".")[3])===e)return{value:n.value,pending:!n.delivered};const t=`fb.1.${Date.now()}.${e}`;return this.persistence.register({[gs]:{value:t,delivered:!1}}),{value:t,pending:!0}}return n?{value:n.value,pending:!n.delivered}:void 0}this.persistence.unregister(gs)}th(e){if(!this.persistence)return;this.persistence.refreshKey(gs);const t=this.Xu();(null==t?void 0:t.value)!==e||t.delivered||this.persistence.register({[gs]:{value:e,delivered:!0}})}capture(e,t,i){var s,n,r,o,a,l;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Fu))return void ts.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(D(e)||!N(e))return void ts.error("No event name provided to posthog.capture");this.yu();const c=!this.config.opt_out_useragent_filter&&this._is_bot();if(c&&!this.config.__preview_capture_bot_pageviews)return;const u=(null==i?void 0:i.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==u?void 0:u.isRateLimited)return void ts.critical("This capture call is ignored due to client rate limiting.");let d;(null==t?void 0:t.$current_url)&&!N(null==t?void 0:t.$current_url)&&(ts.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||(null==i?void 0:i.eh)||ts.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(d=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const h=new Date,p=(null==i?void 0:i.timestamp)||h,v=ft(null==i?void 0:i.uuid,ur);let f={uuid:v,event:e,properties:this.calculateEventProperties(e,t||{},p,v)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&c&&(f.event="$bot_pageview",f.properties.$browser_type="bot"),u&&(f.properties.$lib_rate_limit_remaining_tokens=u.remainingTokens);const g="$feature_flag_called"===e&&!1===f.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==i?void 0:i.$set)&&!g&&(f.$set=null==i?void 0:i.$set);const _=A(null==t?void 0:t.$set)?t.$set:void 0,m=!!(null==i?void 0:i.$set)&&"$fbc"in i.$set,y=m||!!_&&"$fbc"in _,b=m?null==i||null===(s=i.$set)||void 0===s?void 0:s[fs]:null==_?void 0:_[fs],w=I(null==t?void 0:t.$unset)?t.$unset:[],x=(null==i?void 0:i.$unset)||[],E=-1!==w.indexOf("$fbc")||-1!==x.indexOf("$fbc"),$=this.Yu(null==d?void 0:d.fbclid,b,y,E);$&&!0===f.properties.$process_person_profile&&$.pending&&!y&&!g&&(f.$set=Ot({[fs]:$.value},f.$set));const S=null==i?void 0:i.$unset;S&&(f.$unset=S);const k=g?void 0:this.ih(null==i?void 0:i.$set_once,e!==Wn,e===Vn);if(k&&(f.$set_once=k),(null==i?void 0:i._noTruncate)||(P=this.config.properties_string_max_length,f=(function(e,t){const i=new Set;return(function e(s,n){if(s!==Object(s))return t?t(s):s;if(i.has(s))return;let r;if(i.add(s),I(s))r=[],Gn(s,t=>{r.push(e(t))});else{const t={};Kn(Y(s)?Qn(s):s,(s,n)=>{i.has(s)||(t[n]=e(s,n))}),r=t}return r})(e)})(f,e=>N(e)?e.slice(0,P):e)),f.timestamp=p,D(null==i?void 0:i.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=h),g&&(f.properties=((e,t=[])=>{const i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return mi.forEach(s),t.forEach(s),i})(f.properties,mc)),e===wa.DISMISSED||e===wa.SENT){const i=null==t?void 0:t[xa.SURVEY_ID],s=null==t?void 0:t[xa.SURVEY_ITERATION];Ql({id:i,current_iteration:s}),f.$set=Ot(Ot({},f.$set),{},{[Bl({id:i,current_iteration:s},e===wa.SENT?"responded":"dismissed")]:!0})}else e===wa.SHOWN&&(f.$set=Ot(Ot({},f.$set),{},{[xa.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var P;if(e===ka.SHOWN){const e=null==t?void 0:t[Pa.TOUR_TYPE];e&&(f.$set=Ot(Ot({},f.$set),{},{[`${Pa.TOUR_LAST_SEEN_DATE}/${e}`]:(new Date).toISOString()}))}const M=Ot(Ot({},f.properties.$set),f.$set);if(L(M)||this.setPersonPropertiesForFlags(M),!U(this.config.before_send)){const e=this.Os(f);if(!e)return;f=e,f.uuid=ft(f.uuid,ur)}const O=null!==(n=null===(r=f.$set)||void 0===r?void 0:r.$fbc)&&void 0!==n?n:A(null===(o=f.properties)||void 0===o?void 0:o.$set)?f.properties.$set[fs]:void 0,T=(null==$?void 0:$.pending)&&O===$.value?$.value:void 0;this.au.emit("eventCaptured",f);const F=null!==(a=null==i?void 0:i._url)&&void 0!==a?a:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),C="recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(F),R=Ot(Ot(Ot({method:"POST",url:F,data:f,compression:"best-available",timestampMode:C?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},C&&(null===(l=f.properties)||void 0===l?void 0:l.$session_id)?{batchGroup:f.properties.$session_id}:{}),(null==i?void 0:i.transport)?{transport:i.transport}:{}),T?{fireCallbackOnDrop:!0,callback:e=>{e.statusCode>=200&&300>e.statusCode&&this.th(T)}}:{});var j;return!this.config.request_batching||i&&!(null==i?void 0:i._batchKey)||(null==i?void 0:i.send_instantly)||T?(!R.transport&&!R.callback&&L(null!==(j=this.config.request_headers)&&void 0!==j?j:{})&&this.wu&&(R.transport="sendBeacon"),this.Ou(R)):this.Fu.enqueue(R),f}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null===(t=this.Gu)||void 0===t?void 0:t.getExtension(e)}zu(){var e;return null!==(e=this.Gu)&&void 0!==e?e:this.Gu=new lc(this)}hu(e){this.$u.push(e);let t=!0;return()=>{if(!t)return;t=!1;const i=this.$u.indexOf(e);-1!==i&&this.$u.splice(i,1)}}nh(e=!0){var t,i,s;return!!(null===(t=this.persistence)||void 0===t?void 0:t.consumeCookieIdentityChange())&&(this.Eu=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this.xu.clear(),this.sh()),null===(i=this.featureFlags)||void 0===i||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,t,i,s,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;this.persistence.syncCookieProperties(),this.nh();const r=n?void 0:this.persistence.remove_event_timer(e);let o=Ot({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.fu()&&(o[Sn]=!0),"$snapshot"===e){const e=Ot(Ot({},this.persistence.properties()),this.sessionPersistence.properties());return o.distinct_id=e.distinct_id,(!N(o.distinct_id)&&!H(o.distinct_id)||j(o.distinct_id))&&ts.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}const l=(function(e,t,i,s=!1){var n,r,o,l;if(!g)return{};const c=e?[...Bo,...t||[]]:[],[u,h]=rt(g),[p,v]=(function(e){for(let t=0;ct.length>t;t++){const[i,s,n]=ct[t],r=e.match(i);if(r){const t=n&&e.match(n)||r;return[s,(null==t?void 0:t[1])||""]}}return["",""]})(g),f=(function(){const e="u">typeof navigator?navigator:void 0;return(null==e?void 0:e.brave)?{brave:!0}:{}})(),_={};D(i)||(_.detectGoogleSearchApp=i);const m={},y=null===(n=navigator)||void 0===n||null===(n=n.userAgentData)||void 0===n?void 0:n.platform,b=null===(r=navigator)||void 0===r?void 0:r.maxTouchPoints,x=null==a||null===(o=a.screen)||void 0===o?void 0:o.width,E=null==a||null===(l=a.screen)||void 0===l?void 0:l.height,$=null==a?void 0:a.devicePixelRatio;D(y)||(m.userAgentDataPlatform=y),D(b)||(m.maxTouchPoints=b),D(x)||(m.screenWidth=x),D(E)||(m.screenHeight=E),D($)||(m.devicePixelRatio=$);const S=Yn(Xn({$os:u,$os_version:h,$browser:tt(g,navigator.vendor,f,_),$webview_app:p,$webview_app_version:v,$device:ot(g),$device_type:at(g,m),$timezone:Qo(),$timezone_offset:ea()}),{$current_url:Lo(s?_t(null==d?void 0:d.href):null==d?void 0:d.href,c,Ho),$host:null==d?void 0:d.host,$pathname:null==d?void 0:d.pathname,$raw_user_agent:g.length>1e3?g.substring(0,997)+"...":g,$browser_version:st(g,navigator.vendor,f,_),$browser_language:Go(),$browser_language_prefix:Ko(),$screen_height:null==a?void 0:a.screen.height,$screen_width:null==a?void 0:a.screen.width,$viewport_height:null==a?void 0:a.innerHeight,$viewport_width:null==a?void 0:a.innerWidth,$lib:w.LIB_NAME,$lib_version:w.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return w.SDK_DIST_CHANNEL&&(S.$sdk_dist_channel=w.SDK_DIST_CHANNEL),S})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0);o.$session_id=e,o.$window_id=t}this.sessionPropsManager&&Yn(o,this.sessionPropsManager.getSessionProps());try{var c;this.sessionRecording&&Yn(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=null===(c=this.Du)||void 0===c?void 0:c.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}let h;if(this.requestRouter.region===Gl&&(o.$lib_custom_api_host=this.config.api_host),h="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,s),o=Yn(o,h),"$pageview"===e&&u&&(o.title=u.title),!D(r)){const e=i.getTime()-r;o.$duration=parseFloat((e/1e3).toFixed(3))}g&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser");const p=this.persistence.properties(),v=this.sessionPersistence.properties(),f=o.$groups,_=p.$groups;A(f)&&!L(f)&&(o.$groups=Ot(Ot({},A(_)?_:{}),f)),Kn(["$referrer","$referring_domain"],e=>{e in p&&delete v[e]});const m={};if(this.$u.length>0)for(const e of this.$u.slice())try{Yn(m,e())}catch(e){ts.error("Failed to produce browser extension event properties",e)}o=Yn({},l,p,v,Ot(Ot({},m),o)),o.$is_identified=this._isIdentified(),I(this.config.property_denylist)?Kn(this.config.property_denylist,function(e){delete o[e]}):ts.error(fc+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(ts.error(vc),o=y(o,e));const b=this.rh();return o.$process_person_profile=b,b&&!n&&this.oh("_calculate_event_properties"),o}ih(e,t=!0,i=!1){var s;if(!this.persistence||!this.rh())return e;if(this.Su&&!i)return e;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=Yn({},n,r||{},e||{});const a=this.config.sanitize_properties;return a&&(ts.error(vc),o=a(o,"$set_once")),t&&(this.Su=!0),L(o)?void 0:o}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t,i;null===(t=this.persistence)||void 0===t||t.syncCookieProperties(),this.nh(),null===(i=this.sessionPersistence)||void 0===i||i.register(e),Object.keys(e).forEach(e=>this.xu.add(e)),this.sh()}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e),this.xu.delete(e),this.sh()}ah(e,t){this.register({[e]:t})}Lu(){this.xu.forEach(e=>{var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}),this.xu.clear(),this.sh()}sh(){var e;if(!this.Cu)return;if("memory"===this.config.persistence||(null===(e=this.sessionPersistence)||void 0===e?void 0:e.pi)||!Fr.Et())return void Fr.Lt(this.Cu);const t=[];this.xu.forEach(e=>t.push(e)),t.length>0?Fr.At(this.Cu,t):Fr.Lt(this.Cu)}getFeatureFlag(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null===(t=this.featureFlags)||void 0===t?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null===(e=this.featureFlags)||void 0===e||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t=!1,i){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.au.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:pc}),()=>{})}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:pc})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:pc})}renderSurvey(e,t){var i;null===(i=this.surveys)||void 0===i||i.renderSurvey(e,t)}displaySurvey(e,t=tc){var i;null===(i=this.surveys)||void 0===i||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null===(t=this.surveys)||void 0===t||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null===(i=this.surveys)||void 0===i?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:pc}}canRenderSurveyAsync(e,t=!1){var i,s;return null!==(i=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:pc})}uh(e){return!e||j(e)?(ts.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(ts.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(ts.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return ts.uninitializedWarning("posthog.identify");if(H(e)&&(e=e.toString(),ts.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.uh(e))return;if(!this.oh("posthog.identify"))return;this.yu();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this.nh(!1),o=this.persistence.Pl();let a=!1;try{const s=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property("__alias")&&(this.unregister(ps),this.register({distinct_id:e}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Nn,c=e!==s,u=!c&&o;if(c&&o){var l;const n=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:s};this.persistence.set_property(_n,jn),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Rl(),this.capture(Vn,n,{$set:t||{},$set_once:i||{}}),this.Eu=Wl(e,t,i),null===(l=this.featureFlags)||void 0===l||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(u){this.persistence.set_property(_n,jn);const s=t||{},n=i||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence.Rl(),this.capture("$set",{$set:s,$set_once:n}),this.Eu=Wl(e,t,i)}else(t||i)&&this.setPersonProperties(t,i);c||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(pn)):u&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.Ol(a)}}setPersonProperties(e,t){if(!e&&!t)return;if(!this.oh("posthog.setPersonProperties"))return;const i=Wl(this.get_distinct_id(),e,t);this.Eu!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Eu=i):ts.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var t;const i=(I(e)?e:[e]).filter(e=>N(e)&&e.length>0);0!==i.length&&this.oh("posthog.unsetPersonProperties")&&(null===(t=this.featureFlags)||void 0===t||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Eu=null)}group(e,t,i){var s;if(!e||!t)return void ts.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this.nh();const n=this.getGroups(),r=n[e]!==t;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Ot(Ot({},n),{},{[e]:t})}),(r||i)&&this.rh()){const s={$group_type:e,$group_key:t};i&&(s.$group_set=i),this.capture(Wn,s)}i&&this.setGroupPropertiesForFlags({[e]:i}),r&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;null===(t=this.featureFlags)||void 0===t||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var i;this.oh("posthog.setGroupPropertiesForFlags")&&(null===(i=this.featureFlags)||void 0===i||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null===(t=this.featureFlags)||void 0===t||t.resetGroupPropertiesForFlags(e)}reset(e){const t=q(e)?e:null==e?void 0:e.resetDeviceID,i=q(e)||null==e?void 0:e.bootstrap;this.hh(t,!1,i)}hh(e,t=!1,i){var s,n,r,o,a,l;if(ts.info("reset"),!this.__loaded)return ts.uninitializedWarning("posthog.reset");const c=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null===(s=this.Ru)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this.Xl());const u=this.get_property(ds),d=this.get_property(hs),h=this.get_property(Ms);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const p=this.is_capturing();this.consent.reset(),t||!p||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const v=null===(a=this.persistence)||void 0===a||null===(l=a.Pl)||void 0===l?void 0:l.call(a);let f=!1;try{var g,_,m,y,b,w,x,E,$,S,k,P,M;if(null===(g=this.persistence)||void 0===g||g.clear(),null===(_=this.sessionPersistence)||void 0===_||_.clear(),this.xu.clear(),this.sh(),D(h)||null===(S=this.persistence)||void 0===S||S.register({$session_recording_remote_config:h}),null===(m=this.surveys)||void 0===m||m.reset(),null===(y=this.featureFlags)||void 0===y||y.reset(),null===(b=this.conversations)||void 0===b||b.reset(),null===(w=this.logs)||void 0===w||w.reset(),null===(x=this.metrics)||void 0===x||x.reset(),null===(E=this.persistence)||void 0===E||E.set_property("$user_state","anonymous"),null===($=this.sessionManager)||void 0===$||$.resetSessionId(),this.Eu=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:$n,$device_id:null},"");else{const t=this.config.get_device_id(ur());this.register_once({distinct_id:t,$device_id:e?t:u},""),e||D(d)||this.register({[hs]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i&&(i.distinctID&&!this.fu()&&(null===(M=this.persistence)||void 0===M||M.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),null===(k=this.featureFlags)||void 0===k||k.initialize(),!U(c)&&!(null===(P=this.sessionManager)||void 0===P?void 0:P.setBootstrapSessionId(c,!0)))){const e=Ot({},i);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,f=!0}finally{var O,T;v&&(null===(O=this.persistence)||void 0===O||null===(T=O.Ol)||void 0===T||T.call(O,f))}this.reloadFeatureFlags()}shutdown(e){var t=this;return ie(function*(){var e,i,s,n,r,o,a,l;if(t.__loaded){t.ku=!0,t.zu().dispose(),null===(e=t.sessionRecording)||void 0===e||e.dispose(),null===(i=t.logs)||void 0===i||i.flushLogs("sendBeacon"),null===(s=t.metrics)||void 0===s||s.flush("sendBeacon"),null===(n=t.metrics)||void 0===n||n.dispose(),null===(r=t.Fu)||void 0===r||r.unload(),null===(o=t.Du)||void 0===o||o.unload();try{var c;null===(c=t.featureFlags)||void 0===c||c.destroy()}catch(e){ts.error("Error while destroying feature flags",e)}null===(a=t.persistence)||void 0===a||a.destroy(),null===(l=t.sessionPersistence)||void 0===l||l.destroy()}else ts.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null===(i=this.conversations)||void 0===i||i.dh()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(e=this.conversations)||void 0===e||e.fh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null===(t=this.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if((null==e?void 0:e.withTimestamp)&&i){var n;const t=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(ts.critical("Attempting to create alias for existing People user - aborting."),-2):this.oh("posthog.alias")?(D(t)&&(t=this.get_distinct_id()),e!==t?(this.ah(ps,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(ts.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const t=Ot({},this.config);if(A(e)){var i,s,n,r,o,a,l,c,u,d,h,p,v,f;Yn(this.config,$c(e));const _=this.bu();null===(i=this.persistence)||void 0===i||i.update_config(this.config,t,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new da(Ot(Ot({},this.config),{},{persistence:"sessionStorage"}),_,!1);const m=this.Pu(this.config.debug);var g;q(m)&&(this.config.debug=m),q(this.config.debug)&&(this.config.debug?(ls.DEBUG=!0,_r.Et()&&_r.At("ph_debug",!0),ts.info("set_config",{config:e,oldConfig:t,newConfig:Ot({},this.config)})):(ls.DEBUG=!1,_r.Et()&&_r.Lt("ph_debug"))),null===(s=this.featureFlags)||void 0===s||null===(n=s.updateConfig)||void 0===n||n.call(s,this.config,this.Xl()),null===(r=this.exceptionObserver)||void 0===r||r.onConfigChange(),null===(o=this.exceptions)||void 0===o||o.onConfigChange(),null===(a=this.metrics)||void 0===a||a.onConfigChange(),null===(l=this.sessionRecording)||void 0===l||l.startIfEnabledOrStop(),null===(c=this.tracingHeaders)||void 0===c||c.startIfEnabledOrStop(),null===(u=this.autocapture)||void 0===u||u.startIfEnabled(),null===(d=this.heatmaps)||void 0===d||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null===(g=this.historyAutocapture)||void 0===g||g.startIfEnabledOrStop()),null===(h=this.exceptionObserver)||void 0===h||h.startIfEnabledOrStop(),null===(p=this.deadClicksAutocapture)||void 0===p||p.startIfEnabledOrStop(),null===(v=this.surveys)||void 0===v||v.loadIfEnabled(),this._u(),null===(f=this.externalIntegrations)||void 0===f||f.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&$o(this,dc,!1)}}_overrideSDKInfo(e,t){ls.LIB_NAME=e,ls.LIB_VERSION=t}startSessionRecording(e){const t=!0===e,i={sampling:t||!!(null==e?void 0:e.sampling),linked_flag:t||!!(null==e?void 0:e.linked_flag),url_trigger:t||!!(null==e?void 0:e.url_trigger),event_trigger:t||!!(null==e?void 0:e.event_trigger)};var s,n,r,o,a;Object.values(i).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),i.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),i.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),i.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),i.event_trigger&&(null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!!(null===(e=this.sessionRecording)||void 0===e?void 0:e.started)}captureException(e,t){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(Ot(Ot({},i),t))}catch(e){return}}addExceptionStep(e,t){var i;null===(i=this.exceptions)||void 0===i||i.addExceptionStep(e,t)}captureLog(e){var t;null===(t=this.logs)||void 0===t||t.captureLog(e)}get logger(){var t,i;return null!==(t=null===(i=this.logs)||void 0===i?void 0:i.logger)&&void 0!==t?t:e.ph}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null===(i=this.toolbar)||void 0===i?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:yc;return t!==yc&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property("$user_state"))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property("$user_state"))}rh(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&L(this.getGroups())&&!(null===(e=this.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.__alias)&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.$epp))}Ku(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.rh()||this.oh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.oh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}oh(e){return"never"===this.config.person_profiles?(ts.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.pu(),this.ah(En,!0),!0)}bu(){if("always"===this.config.cookieless_mode)return!0;const e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_u(){var e,t;const i=this.bu();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s.gh(),(null===(e=this.persistence)||void 0===e?void 0:e.pi)!==i&&(null===(n=this.persistence)||void 0===n||n.set_disabled(i)),(null===(t=this.sessionPersistence)||void 0===t?void 0:t.pi)!==i&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(i)),i&&(this.xu.clear(),this.sh()),i}opt_in_capturing(t){var i;if("always"!==this.config.cookieless_mode){if(this.fu()){var s,n,r,o,a,l;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this.hh(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new Dl(this),this.pageViewManager=new Mo(this),this.persistence&&(this.sessionPropsManager=new Il(this,this.sessionManager,this.persistence));const t=null!==(o=null===(a=this.config.__extensionClasses)||void 0===a?void 0:a.sessionRecording)&&void 0!==o?o:null===(l=e.__defaultExtensionClasses)||void 0===l?void 0:l.sessionRecording;var c,u;t&&(this.sessionRecording=this.vu(this.sessionRecording,new t(this)),this.lu&&(null===(c=this.sessionRecording)||void 0===c||null===(u=c.onRemoteConfig)||void 0===u||u.call(c,this.lu)))}var d,h;this.consent.optInOut(!0),this._u(),this.Zu(),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(D(null==t?void 0:t.captureEventName)||(null==t?void 0:t.captureEventName))&&this.capture(null!==(h=null==t?void 0:t.captureEventName)&&void 0!==h?h:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Qu()}else ts.warn(hc)}opt_out_capturing(){if("always"===this.config.cookieless_mode)return void ts.warn(hc);const e="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;var t,i;null==e||e.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.hh(!0,!0),this.consent.optInOut(!1),this._u(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:$n,$device_id:null}),this.du(e),this.sessionRecording=void 0,null===(t=this.sessionManager)||void 0===t||t.destroy(),null===(i=this.pageViewManager)||void 0===i||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Qu(),this.Zu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._u()}_is_bot(){return c?Nl(c,this.config.custom_blocked_useragents):void 0}Qu(){u&&("visible"===u.visibilityState?this.Tu||(this.Tu=!0,this.capture(zn,{title:u.title},{send_instantly:!0}),this.Iu&&(u.removeEventListener(Un,this.Iu),this.Iu=null)):this.Iu||(this.Iu=this.Qu.bind(this),ir(u,Un,this.Iu)))}debug(e){!1===e?(null==a||a.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==a||a.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Xl(){const e=this.Ru||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(ts.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(function(e,t,i,s,n){const r=t in e&&!U(e[t]),o=i in e&&!U(e[i]);return r?e[t]:!!o&&(n&&n.warn(`Config field '${i}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[i])})(e,"advanced_disable_flags","advanced_disable_decide",0,ts)}Os(e){var t;if(U(this.config.before_send))return e;const i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(W),s=I(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=e;for(const i of s)try{if(n=i(n),U(n)){const t=`Event '${e.event}' was rejected in beforeSend function`;return V(e.event)?ts.warn(`${t}. This can cause unexpected behavior.`):ts.info(t),null}n.properties&&!L(n.properties)||ts.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return ts.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(const t of i)if(n.properties&&U(n.properties[t]))return ts.warn(`Event '${e.event}' had its '${t}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var e;return null===(e=this.pageViewManager.Bo)||void 0===e?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Pu(e){const t=q(e)&&!e,i=_r.Et()&&"true"===_r.Ot("ph_debug");return!t&&(!!i||e)}};kc.__defaultExtensionClasses={},kc.ph=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Zn(e.prototype[t[i]])})(kc,["identify"]);var Pc=class{constructor(e){this.disabled=!1===e;const t=A(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&this.timeoutMs>i-s.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}};const Mc="$copy_autocapture",Oc=is("[AutoCapture]");function Tc(e,t){return t.length>e?t.slice(0,e)+"...":t}function Fc(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!Ar(t));return t}function Cc(e,{e:t,maskAllElementAttributes:i,maskAllText:s,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var l,c;if(!Ar(e))return{props:{}};const u=[e],d=new Set([e]);let h=e;for(;h.parentNode&&!Lr(h,"body")&&1e3>u.length;){if(Nr(h.parentNode)){const e=h.parentNode.host;if(d.has(e))break;d.add(e),u.push(e),h=e;continue}if(!Ar(h.parentNode))break;if(d.has(h.parentNode))break;d.add(h.parentNode),u.push(h.parentNode),h=h.parentNode}const p="click"===t.type&&"http://www.w3.org/2000/svg"===e.namespaceURI?u.findIndex(e=>Lr(e,"button")||Lr(e,"a")):-1;p>0&&(s=s||u.slice(0,p+1).some(e=>!no(e)||ro(e)));const v=[],f={};let g,_=!1,m=!1;if(Kn(u,e=>{const t=no(e);if(Lr(e,"a")){const i=e.getAttribute("href");_=!!(t&&i&&vo(i))&&(o?_t(i):i)}k(Ur(e),"ph-no-capture")&&(m=!0),v.push((function(e,t,i,s,n=!1){const r=e.tagName.toLowerCase(),o={tag_name:r};Vr.indexOf(r)>-1&&!i&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?Tc(1024,fo(e)):Tc(1024,zr(e)));const a=Ur(e);a.length>0&&(o.classes=a.filter(function(e){return""!==e})),Kn(e.attributes,function(i){var r;if((!ro(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&!(null==s?void 0:s.includes(i.name))&&!t&&vo(i.value)&&(!N(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let e=i.value;"class"===i.name&&(e=jr(e).join(" ")),o["attr__"+i.name]=Tc(1024,"href"===i.name&&n?_t(e):e)}});let l=1,c=1,u=e;for(;u=Fc(u);)l++,u.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o})(e,i,s,n,o)),Kn((function(e){if(!no(e))return{};const t={};return Kn(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&vo(s)&&(t[i]=s)}}),t})(e),(e,t)=>{({}).hasOwnProperty.call(f,t)||(f[t]=e)})}),m)return{props:{},explicitNoCapture:m};if(p>0&&(e=u[p],v.splice(0,p)),s||(v[0].$el_text=Lr(e,"a")||Lr(e,"button")?fo(e):zr(e)),_){var y,b;v[0].attr__href=_;const e=null===(y=Ro(_))||void 0===y?void 0:y.host,t=null==a||null===(b=a.location)||void 0===b?void 0:b.host;e&&t&&e!==t&&(g=_)}return{props:Yn((x=t.type,{$event_type:x,$ce_version:1}),r?{}:{$elements:v},{$elements_chain:(w=v,I(w)?(function(e){return e.map(e=>{var t,i;let s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)s+=`.${t.replace(/"/g,"")}`}const n=Ot(Ot(Ot(Ot({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return Jn(n).sort(([e],[t])=>(function(e,t){return t>e?-1:e>t?1:0})(e,t)).forEach(([e,t])=>r[_o(e.toString())]=_o(t.toString())),s+=":",s+=Jn(r).map(([e,t])=>`${e}="${t}"`).join(""),s}).join(";")})((function(e){return e.map(e=>{var t,i;const s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:mo(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Jn(e).filter(([e])=>0===e.indexOf("attr__")).forEach(([e,t])=>s.attributes[e]=t),s})})(w)):"")},(null===(l=v[0])||void 0===l?void 0:l.$el_text)?{$el_text:null===(c=v[0])||void 0===c?void 0:c.$el_text}:{},g&&"click"===t.type?{$external_click_url:g}:{},f),target:e};var w,x}var Ic=class{uo(){this.ho=void 0,clearTimeout(this.co),this.co=void 0}do(e){var t;if(!no(e))return!0;const i=null!==(t=this.vo().css_selector_ignorelist)&&void 0!==t?t:Yr,s=new Set;let n=e;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const e=n,t=Ur(e);if(k(t,"ph-no-capture")||k(t,"ph-sensitive")||ro(e)||i.some(t=>Wr(e,t)))return!0;const r=n.parentNode;n=Nr(r)?r.host:r&&Ar(r)?r:null}return!1}fo(e){if(!this.isEnabled||"pointercancel"===e.type)return void this.uo();if("pointerdown"===e.type){this.uo();const i=qr(e);var t;return void(e.isPrimary&&0===e.button&&!e.ctrlKey&&i&&Ar(i)&&(this.ho={target:i,excluded:this.do(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null===(t=this.po)||void 0===t?void 0:t.distinctId}))}const i=this.ho;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this.uo():"pointerup"===e.type&&(i.released=!0,this.co=setTimeout(()=>this.uo(),0)))}mo(e){var t;const i=this.ho;this.uo();const s=qr(e);if((null==i?void 0:i.released)&&i.target.isConnected&&i.distinctId===(null===(t=this.po)||void 0===t?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||"touch"===e.pointerType||"pen"===e.pointerType)&&0===e.button&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&s&&(Lr(s,"html")||Lr(s,"body"))){var n;if(i.excluded)return null;const e=null!==(n=this.vo().css_selector_ignorelist)&&void 0!==n?n:Yr;return[s,null==u?void 0:u.documentElement,null==u?void 0:u.body].some(t=>{if(!t)return!1;const i=Ur(t);return k(i,"ph-no-capture")||k(i,"ph-sensitive")||!no(t)||ro(t)||e.some(e=>Wr(t,e))})?null:i.target}}constructor(e){this.yo=e,this.name="autocapture",this.bo=!1,this._o=null,this.wo=!1,this.ko=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.So=!1,this.yo.refresh(this.Mr),this.rageclicks=new Pc(this.Mr.rageclick),this.xo=null}setup(e){this.Co(),this.po=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.So?t.dispose():(this.$o=t,this.startIfEnabled())}dispose(){var e;this.So||(this.So=!0,this.po=void 0,null===(e=this.$o)||void 0===e||e.dispose(),this.$o=void 0,this.To())}vo(){return this.yo.refresh(this.Mr),this.Mr}Co(){var e,t;return this.vo(),this.Mr.url_allowlist=null===(e=this.Mr.url_allowlist)||void 0===e?void 0:e.map(e=>new RegExp(e)),this.Mr.url_ignorelist=null===(t=this.Mr.url_ignorelist)||void 0===t?void 0:t.map(e=>new RegExp(e)),this.Mr}Io(){if(!this.isBrowserSupported())return void Oc.info("Disabling Automatic Event Collection because this browser is not supported");if(!a||!u)return;const e=this.Mo=e=>{e=e||(null==a?void 0:a.event);try{if("blur"===e.type)return void this.uo();if(0===e.type.indexOf("pointer"))return void this.fo(e);const t="click"===e.type?this.mo(e):void 0;if(B(t))return;this.Eo(e,"$autocapture",t)}catch(e){Oc.error("Failed to capture event",e)}};if(ir(a,"blur",e),ir(u,"submit",e,{capture:!0}),ir(u,"change",e,{capture:!0}),ir(u,"click",e,{capture:!0}),Kn(["pointerdown","pointermove","pointerup","pointercancel"],t=>{ir(u,t,e,{capture:!0})}),this.vo().capture_copied_text){const e=this.Po=e=>{e=e||(null==a?void 0:a.event);try{this.Eo(e,Mc)}catch(e){Oc.error("Failed to capture clipboard event",e)}};ir(u,"copy",e,{capture:!0}),ir(u,"cut",e,{capture:!0}),ir(u,"paste",e,{capture:!0})}}To(){this.uo(),this.Mo&&(null==a||a.removeEventListener("blur",this.Mo),Kn(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==u||u.removeEventListener(e,this.Mo,!0)}),null==u||u.removeEventListener("submit",this.Mo,!0),null==u||u.removeEventListener("change",this.Mo,!0),null==u||u.removeEventListener("click",this.Mo,!0),this.Mo=void 0),this.Po&&(null==u||u.removeEventListener("copy",this.Po,!0),null==u||u.removeEventListener("cut",this.Po,!0),null==u||u.removeEventListener("paste",this.Po,!0),this.Po=void 0),this.bo=!1}startIfEnabled(){this.isEnabled||this.uo(),!this.So&&this.po&&this.isEnabled&&!this.bo&&(this.Io(),this.bo=!0)}onRemoteConfig(e){if(this.So)return;if(this.wo=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this.ko=t.elementsChainAsString);const i=t.autocapture_opt_out;var s;q(i)&&(null===(s=this.po)||void 0===s||s.kv.set("$autocapture_disabled_server_side",i),this._o=i),this.startIfEnabled()}setElementSelectors(e){this.xo=e}getElementSelectors(e,t){var i;const s=[];return null===(i=this.xo)||void 0===i||i.forEach(i=>{const n=null==u?void 0:u.querySelectorAll(i);null==n||n.forEach(n=>{e!==n&&t!==n||k(s,i)||s.push(i)})}),s}get isEnabled(){var e,t;if(this.So)return!1;const i=null===(e=this.po)||void 0===e?void 0:e.kv.get(ms),s=this._o,n=this.vo();if(!n.remoteRequestsDisabled&&!this.wo)return!1;const r=n.remoteRequestsDisabled&&!this.wo;if(B(s)&&!q(i)&&!r)return!1;const o=null!==(t=this._o)&&void 0!==t?t:!!i;return!!n.enabled&&!o}Eo(e,t="$autocapture",i){if(!this.isEnabled)return void this.uo();let s=i||qr(e);Dr(s)&&(s=s.parentNode||null);const n=this.Co();var r;"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&n.rageclick&&(null===(r=this.rageclicks)||void 0===r?void 0:r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime()))&&to(s,n.rageclick)&&this.Eo(e,"$rageclick",i);const o=t===Mc,l=o?Ot(Ot({},n),{},{dom_event_allowlist:void 0}):n;if(s&&(function(e,t,i,s,n,r){var o;if(!a||io(e))return!1;if((null==i?void 0:i.url_allowlist)&&!Br(i.url_allowlist,r))return!1;if((null==i?void 0:i.url_ignorelist)&&Br(i.url_ignorelist,r))return!1;if(null==i?void 0:i.dom_event_allowlist){const e=i.dom_event_allowlist;if(e&&!e.some(e=>t.type===e))return!1}const{parentIsUsefulElement:l,targetElementList:c}=so(e,s);if(!(function(e,t){const i=null==t?void 0:t.element_allowlist;if(D(i))return!0;for(const t of e)if(i.some(e=>t.tagName.toLowerCase()===e))return!0;return!1})(c,i))return!1;if(!Gr(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Gr(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Yr))return!1;try{const i=a.getComputedStyle(e);if(i&&"pointer"===i.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}const u=e.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return l?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Vr.indexOf(u)>-1||"true"===e.getAttribute("contenteditable"))}})(s,e,l,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var c;const{props:i,explicitNoCapture:r,target:o}=Cc(s,{e:e,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.ko,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(r)return!1;const l=this.getElementSelectors(s,o);if(l&&l.length>0&&(i.$element_selectors=l),t===Mc){const t=e.type||"clipboard";if("paste"!==t){var u,d;const e=null==a||null===(u=a.getSelection())||void 0===u?void 0:u.toString(),t=Hr(e);if(!t)return!1;i.$selected_content=t,i.$clipboard_text_length=null!==(d=null==e?void 0:e.length)&&void 0!==d?d:0}i.$copy_type=t}return null===(c=this.po)||void 0===c||c.capture(t,i).catch(e=>Oc.error("Failed to capture event",e)),!0}}isBrowserSupported(){return R(null==u?void 0:u.querySelectorAll)}},Rc=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,i=A(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance.Xl(),e.url_allowlist=null==i?void 0:i.url_allowlist,e.url_ignorelist=null==i?void 0:i.url_ignorelist,e.dom_event_allowlist=null==i?void 0:i.dom_event_allowlist,e.element_allowlist=null==i?void 0:i.element_allowlist,e.css_selector_allowlist=null==i?void 0:i.css_selector_allowlist,e.css_selector_ignorelist=null==i?void 0:i.css_selector_ignorelist,e.element_attribute_ignorelist=null==i?void 0:i.element_attribute_ignorelist,e.capture_copied_text=null==i?void 0:i.capture_copied_text}};const Ac=is("[ExceptionAutocapture]"),Lc=()=>{},Dc=e=>{var t;if(R(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Nc(e,t,i){try{if(!(t in e))return Lc;const s={next:e[t]},n=i(function(...e){return s.next.apply(this,e)});return R(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=n,()=>{if(e[t]===n)return void(e[t]=s.next);let i=e[t],r=Dc(i);for(;r;){if(r.next===n)return void(r.next=s.next);i=r.next,r=Dc(i)}}}catch(e){return Lc}}const jc=is("[TracingHeaders]"),Bc=is("[Web Vitals]"),Uc=9e5,Hc=["CLS","FCP","INP","LCP"],zc=["INP","LCP"],qc=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Vc="disabled",Wc="lazy_loading",Gc=is("[SessionRecording]"),Kc=is("[Heatmaps]");function Yc(e){return A(e)&&"clientX"in e&&"clientY"in e&&H(e.clientX)&&H(e.clientY)}const Jc=is("[Product Tours]"),Zc=e=>{var t;return!e.config.disable_product_tours&&!!(null===(t=e.persistence)||void 0===t?void 0:t.get_property(Ss))},Xc=["$set_once","$set"],Qc=is("[SiteApps]"),eu="Error while initializing PostHog app with config id ",tu=(e,t)=>(null==e?void 0:e.then)?e.then(t):t(e),iu="SDK is not enabled or survey functionality is not yet loaded",su="Disabled. Not loading surveys.";var nu=class{constructor(e,t){this.yo=e,this.mh=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.yh=!1,this.bh=[],this._h=null,this.wh=null,this.So=!1,this.kh=new Set,this.onRemoteConfig=e=>{if(this.So)return;if(this.Mr.disableSurveys)return;if(!e.ok)return Xl.warn("Remote config unavailable. Not loading surveys.");const t=e.config.surveys;if(U(t))return Xl.warn("Flags not loaded yet. Not loading surveys.");this.Sh=q(t)?t:t.length>0,Xl.info(`flags response received, isSurveysEnabled: ${this.Sh}`),this.loadIfEnabled()}}setup(e){if(!this.So)return this.xh=e,tu(e.kv.initialize(),()=>{if(this.xh!==e||this.So)return;this.xh=void 0,this.po=e;const t=e.onRemoteConfig(this.onRemoteConfig);this.So?t.dispose():(this.$o=t,this.loadIfEnabled())})}dispose(){var e,t,i,s;this.So||(this.So=!0,this.xh=void 0,this.po=void 0,null===(e=this.$o)||void 0===e||e.dispose(),this.$o=void 0,null===(t=this._surveyEventReceiver)||void 0===t||t.dispose(),this._surveyEventReceiver=null,null===(i=this._surveyManager)||void 0===i||null===(s=i.dispose)||void 0===s||s.call(i),this._surveyManager=null,this.bh=[],this._h=null,this.kh.forEach(e=>clearTimeout(e)),this.kh.clear())}get Mr(){return this.yo.get()}initialize(){this.loadIfEnabled()}reset(){try{var e;null===(e=this._surveyEventReceiver)||void 0===e||e.reset(),localStorage.removeItem("lastSeenSurveyDate");const t=[];for(let e=0;e<localStorage.length;e++){const i=localStorage.key(e);((null==i?void 0:i.startsWith("seenSurvey_"))||(null==i?void 0:i.startsWith("inProgressSurvey_")))&&t.push(i)}t.forEach(e=>localStorage.removeItem(e))}catch(e){}}loadIfEnabled(){if(this.So||!this.po)return;const e=this.Mr;if(this._surveyManager)return;if(this.yh)return void Xl.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void Xl.info(su);if(e.cookielessMode&&this.yo.isOptedOut())return void Xl.info("Not loading surveys in cookieless mode without consent.");const t=this.yo.getExtensions();if(!t)return void Xl.error("PostHog Extensions not found.");if(D(this.Sh)&&!e.advancedEnableSurveys)return;const i=this.Sh||e.advancedEnableSurveys;this.yh=!0;try{const e=t.generateSurveys;if(e)return this.Ch(e,i),void(this.yh=!1);const s=t.loadExternalDependency;if(!s)return this.$h(Dn),void(this.yh=!1);s(e=>{try{if(this.So)return;const t=this.yo.getExtensions();e||!(null==t?void 0:t.generateSurveys)?this.$h("Could not load surveys script",e):this.Ch(t.generateSurveys,i)}finally{this.yh=!1}})}catch(e){throw this.yh=!1,this.$h("Error initializing surveys",e),e}}Ch(e,t){this.So||(this._surveyManager=e(t),this._surveyEventReceiver=this.yo.createEventReceiver(),Xl.info("Surveys loaded successfully"),this.Th({isLoaded:!0}))}$h(e,t){Xl.error(e,t),this.Th({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.bh.push(e),this._surveyManager&&this.Th({isLoaded:!0}),()=>{this.bh=this.bh.filter(t=>t!==e)}}getSurveys(e,t=!1){var i;const s=null!==(i=this.po)&&void 0!==i?i:this.mh;if(!s||this.So)return;if(this.Mr.disableSurveys)return Xl.info(su),e([]);const n=s.kv.get(en);if(n&&!t)return e(n,{isLoaded:!0}),void(this.Ih()&&this.getSurveys(()=>{},!0));if(this._h)return void this._h.then(({surveys:t,context:i})=>{this.So||e(t,i)}).catch(e=>Xl.error("Error in survey callback",e));const r=this.Mh("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(e=>{try{return this.Eh(s,e)}catch(e){return Xl.error("Error processing surveys response",e),this.Eh(s,{statusCode:0,error:e})}},e=>this.Eh(s,{statusCode:0,error:e}));this._h=r;const o=()=>{this._h===r&&(this._h=null)};r.then(t=>{o(),this.So||e(t.surveys,t.context)},o).catch(e=>Xl.error("Error in survey callback",e))}Mh(e,t){const i=this.po;return i?i.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:new Error(iu)}))}Eh(e,t){if(this.So)return{surveys:[],context:{isLoaded:!1,error:iu}};const i=t.statusCode;if(200!==i||!t.json){const e=`Surveys API could not be loaded, status: ${i}`;return 0!==i?Xl.error(e):t.error||Xl.warn(e),this.wh=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this.wh=null;const s=t.json.surveys||[],n=s.filter(e=>(function(e){return!(!e.start_date||e.end_date)})(e)&&(Ul(e)||(function(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)})(e)));var r;return n.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(n)),e.kv.set({[en]:s,[tn]:Date.now()}),{surveys:s,context:{isLoaded:!0}}}Ih(){return this.Ph()&&!this._h&&!this.Rh()}Ph(){var e,t;const i=null===(e=null!==(t=this.po)&&void 0!==t?t:this.mh)||void 0===e?void 0:e.kv.get(tn);return H(i)&&Date.now()-i>3e5}Rh(){return H(this.wh)&&3e5>Date.now()-this.wh}markSurveyAsSeen(e,t){var i;const s={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};Ql(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}}Th(e){for(const t of this.bh)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Xl.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t=!1){if(!U(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Xl.warn("init was not called")}Ah(e){let t=null;return this.getSurveys(i=>{var s;t=null!==(s=i.find(t=>t.id===e))&&void 0!==s?s:null}),t}Fh(e){if(U(this._surveyManager))return{eligible:!1,reason:iu};const t="string"==typeof e?this.Ah(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}Oh(e){if(!this.yo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(U(this._surveyManager))return{eligible:!1,reason:iu};const t="string"==typeof e?this.Ah(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(U(this._surveyManager))return Xl.warn("init was not called"),{visible:!1,disabledReason:iu};const t=this.Oh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return U(this._surveyManager)?(Xl.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:iu})):new Promise(i=>{this.getSurveys(t=>{var s;const n=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(n){const e=this.Oh(n);i({visible:e.eligible,disabledReason:e.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var s;if(!this.yo.isCapturing())return;if(U(this._surveyManager))return void Xl.warn("init was not called");const n="string"==typeof e?this.Ah(e):e;if(!(null==n?void 0:n.id))return void Xl.warn("Survey not found");if(!ec.includes(n.type))return void Xl.warn(`Surveys of type ${n.type} cannot be rendered in the app`);const r=null==u?void 0:u.querySelector(t);if(r){if(null===(s=n.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds){Xl.info(`Rendering survey ${n.id} with delay of ${n.appearance.surveyPopupDelaySeconds} seconds`);const e=setTimeout(()=>{var t,s;this.kh.delete(e),!this.So&&this.yo.isCapturing()&&(Xl.info(`Rendering survey ${n.id} with delay of ${null===(t=n.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(n,r,i),Xl.info(`Survey ${n.id} rendered`))},1e3*n.appearance.surveyPopupDelaySeconds);return void this.kh.add(e)}this._surveyManager.renderSurvey(n,r,i)}else Xl.warn("Survey element not found")}displaySurvey(e,t){var i;if(!this.yo.isCapturing())return;if(U(this._surveyManager))return void Xl.warn("init was not called");const s=this.Ah(e);if(!s)return void Xl.warn("Survey not found");let n=s;if((null===(i=s.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds)&&t.ignoreDelay&&(n=Ot(Ot({},s),{},{appearance:Ot(Ot({},s.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==Ea.Popover&&t.initialResponses&&Xl.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){const e=this.Fh(s);if(!e.eligible)return void Xl.warn("Survey is not eligible to be displayed: ",e.reason)}t.displayType!==Ea.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}cancelPendingSurvey(e){U(this._surveyManager)?Xl.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e)}};function ru(e,t,i){if(U(e))return!1;switch(i){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var ou=class{constructor(e){this._instance=e,this.Dh=new Set,this.Lh=new Set,this.Nh=new Rl,this.qh=(e,t)=>this.jh(e,t)&&this.Bh(e,t)&&this.Hh(e,t)&&this.zh(e,t),this.jh=(e,t)=>!(null==t?void 0:t.event)||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;D(null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook)||(this.Uh=null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;null===(e=this.Uh)||void 0===e||e.call(this),this.Uh=void 0,this.Nh=new Rl}register(e){var t,i;if(!D(null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t;this.Dh.add(e),null===(t=e.steps)||void 0===t||t.forEach(e=>{this.Lh.add((null==e?void 0:e.event)||"")})}),null===(i=this._instance)||void 0===i?void 0:i.autocapture)){const e=new Set;this.Dh.forEach(t=>{var i;null===(i=t.steps)||void 0===i||i.forEach(t=>{(null==t?void 0:t.selector)&&e.add(t.selector)})}),this._instance.autocapture.setElementSelectors(e)}}replace(e){this.Dh.clear(),this.Lh.clear(),this.register(e)}on(e,t){null!=t&&0!=e.length&&(this.Lh.has(e)||this.Lh.has(t.event))&&this.Dh.forEach(e=>{this.Wh(t,e)&&this.Nh.emit("actionCaptured",e.name)})}Vh(e){this.onAction("actionCaptured",t=>e(t))}Wh(e,t){if(null==(null==t?void 0:t.steps))return!1;for(const i of t.steps)if(this.qh(e,i))return!0;return!1}onAction(e,t){return this.Nh.on(e,t)}Bh(e,t){if(null==t?void 0:t.url){var i;const s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!ru(s,t.url,t.url_matching||"contains"))return!1}return!0}Hh(e,t){return!!this.Gh(e,t)&&!!this.Zh(e,t)&&!!this.Qh(e,t)}Gh(e,t){var i;if(!(null==t?void 0:t.href))return!0;const s=this.Jh(e);if(s.length>0)return s.some(e=>ru(e.href,t.href,t.href_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&ru((function(e){const t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:""})(n),t.href,t.href_matching||"exact")}Zh(e,t){var i;if(!(null==t?void 0:t.text))return!0;const s=this.Jh(e);if(s.length>0)return s.some(e=>ru(e.text,t.text,t.text_matching||"exact")||ru(e.$el_text,t.text,t.text_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&(r=(function(e){const t=[],i=/(?::|")text="(.*?)"/g;let s;for(;!U(s=i.exec(e));)t.includes(s[1])||t.push(s[1]);return t})(n),o=t.text,a=t.text_matching||"exact",r.some(e=>ru(e,o,a)));var r,o,a}Qh(e,t){var i,s;if(!(null==t?void 0:t.selector))return!0;const n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(null==n?void 0:n.includes(t.selector))return!0;const r=(null==e||null===(s=e.properties)||void 0===s?void 0:s.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch(e){return!1}return!1}Jh(e){var t;return null==(null==e||null===(t=e.properties)||void 0===t?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}zh(e,t){return!(null==t?void 0:t.properties)||0===t.properties.length||Vl(t.properties.reduce((e,t)=>{const i=I(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}},au=class{constructor(e){var t,i;this.Kh=[],this._instance=e,this.Xh=new Map,this.Yh=new Map,this.tc=new Map,this.ec=null===(t=this._instance)||void 0===t||null===(i=t.onSessionId)||void 0===i?void 0:i.call(t,e=>this.nc(e))}sc(e){return!1}rc(){return null}oc(e){}lc(){}ac(e,t){return!!e&&Vl(e.propertyFilters,null==t?void 0:t.properties)}uc(e,t){const i=new Map;return e.forEach(e=>{var s;null===(s=e.conditions)||void 0===s||null===(s=s[t])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(t=>{if(null==t?void 0:t.name){const s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}})}),i}hc(e,t,i){const s=(i===pa.Activation?this.Xh:this.Yh).get(e);let n=[];return this.cc(e=>{n=e.filter(e=>null==s?void 0:s.includes(e.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[i])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(t=>t.name===e);return this.ac(r,t)})}register(e){this.dc(e,!1)}replace(e){this.dc(e,!0)}dc(e,t){var i;D(null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook)||(this.vc(e,t),this.fc(e,t))}fc(e,t){const i=e.filter(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length});var s;if(t&&this.tc.clear(),0===i.length)return void(t&&(null===(s=this.gc)||void 0===s||s.replace([])));this.gc||(this.gc=new ou(this._instance),this.gc.init(),this.gc.Vh(e=>this.onAction(e)));const n=[];i.forEach(e=>{var t;null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||t.values.forEach(t=>{if(n.push(t),t.name){var i;const s=null!==(i=this.tc.get(t.name))&&void 0!==i?i:[];s.includes(e.id)||s.push(e.id),this.tc.set(t.name,s)}})}),t?this.gc.replace(n):this.gc.register(n)}mc(e,t){t.forEach((t,i)=>{var s;const n=null!==(s=e.get(i))&&void 0!==s?s:[];t.forEach(e=>{n.includes(e)||n.push(e)}),e.set(i,n)})}vc(e,t){var i,s;const n=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),r=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.cancelEvents)&&(null===(i=e.conditions)||void 0===i||null===(i=i.cancelEvents)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),o=this.uc(e,pa.Activation),a=this.uc(e,pa.Cancellation);t?(this.Xh=o,this.Yh=a):(this.mc(this.Xh,o),this.mc(this.Yh,a)),(0!==n.length||0!==r.length)&&(null!==(i=this.Uh)&&void 0!==i||(this.Uh=null===(s=this._instance)||void 0===s?void 0:s._addCaptureHook((e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,s;const n=this.yc(),r=(null==t||null===(i=t.properties)||void 0===i?void 0:i.$survey_id)||(null==t||null===(s=t.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const t=this.bc(e,r);if("consume"===t)return n.info("event consumed activated item, removing it",{event:e,itemId:r}),void this._c([r]);if("persist"===t)return n.info("shown item promoted to persisted activation",{event:e,itemId:r}),this.wc(r),void this.kc([r])}if(this.Yh.has(e)){const i=this.hc(e,t,pa.Cancellation);i.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:i.map(e=>e.id)}),this._c(i.map(e=>e.id)),i.forEach(e=>this.Sc(e.id)))}if(!this.Xh.has(e))return;n.info("event name matched",{event:e,eventPayload:t,items:this.Xh.get(e)});const o=this.hc(e,t,pa.Activation);this.xc(o.map(e=>e.id))}onAction(e){this.tc.has(e)&&this.xc(this.tc.get(e)||[])}xc(e){var t,i;if(0===e.length)return;const s=!!(null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t)),n=[];for(const t of e)s&&this.sc(t)?this.wc(t)&&this.Cc(t):n.push(t);n.length>0&&(this.Kh=[...new Set([...this.Kh,...n])]),this.yc().info("updating activated items",{activatedItems:this.getActivatedIds()})}wc(e){this.Kh=this.Kh.filter(t=>t!==e);const t=this.$c();return!t.includes(e)&&(this.Tc([...t,e]),this.Ic(),!0)}_c(e){const t=new Set(e);this.Kh=this.Kh.filter(e=>!t.has(e));const i=this.Mc(),s=i.filter(e=>!t.has(e));s.length!==i.length&&(this.Tc(s),0===s.length&&this.Ec()),this.kc(e)}Pc(){var e;const t=this.rc();if(!t)return{};const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[t];return i&&"object"==typeof i?i:{}}Cc(e){if(!this.rc())return;const t=this.Pc();this.oc(Ot(Ot({},t),{},{[e]:Date.now()}))}kc(e){if(!this.rc())return;const t=this.Pc(),i={};let s=!1;for(const[n,r]of Object.entries(t))e.includes(n)?s=!0:i[n]=r;s&&(L(i)?this.lc():this.oc(i))}Rc(){this.rc()&&this.lc()}getActivationTimestamp(e){if(!this.$c().includes(e))return;const t=this.Pc()[e];return H(t)?t:void 0}Mc(){var e;const t=this.Ac();return(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[t])||[]}$c(){var e,t,i;const s=this.Mc();if(0===s.length)return[];const n=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.props[this.Fc()],r=null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t);return r&&n===r?s:[]}Ic(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(t=e.get_session_id)||void 0===t?void 0:t.call(e);i&&this.Oc(i)}Ec(){this.Dc()}nc(e){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[this.Fc()];if(i&&i!==e){const e=this.Mc(),t=this.Pc();e.length>0&&(this.Tc([]),e.filter(e=>H(t[e])).forEach(e=>this.Sc(e))),this.Ec(),this.Rc()}}getActivatedIds(){return[...new Set([...this.$c(),...this.Kh])].filter(e=>!this.Lc(e))}dispose(){var e,t,i;null===(e=this.ec)||void 0===e||e.call(this),this.ec=void 0,null===(t=this.Uh)||void 0===t||t.call(this),this.Uh=void 0,null===(i=this.gc)||void 0===i||i.dispose(),this.gc=void 0}reset(){this.Kh=[],this.Mc().length>0&&this.Tc([]),this.Ec(),this.Rc()}getEventToItemsMap(){return this.Xh}Nc(){return this.gc}},lu=class extends au{constructor(e){super(e)}Ac(){return sn}Fc(){return nn}rc(){return rn}oc(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated_timestamps:e})}lc(){var e;null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.unregister("$surveys_activated_timestamps")}sc(e){var t;let i;this.cc(t=>{i=t.find(t=>t.id===e)});const s=null==i||null===(t=i.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds;return H(s)&&s>0}qc(){return wa.SHOWN}cc(e){var t;null===(t=this._instance)||void 0===t||t.getSurveys(e)}Sc(e){var t;null===(t=this._instance)||void 0===t||t.cancelPendingSurvey(e)}yc(){return Xl}Tc(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated:e})}Oc(e){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.register({$surveys_activated_session:e})}Dc(){var e;null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.unregister("$surveys_activated_session")}Lc(){return!1}bc(e,t){let i;return this.cc(e=>{i=e.find(e=>e.id===t)}),!i||(function(e){var t;return Ul(e)&&!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t?void 0:t.repeatedActivation)||"always"===e.schedule})(i)?e===wa.SHOWN?"consume":"ignore":e===wa.SHOWN?"persist":e===wa.DISMISSED||e===wa.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},cu=class{constructor(e){this._instance=e}initialize(){}get(e){if("string"==typeof e)return this._instance.get_property(e);const t={};for(const i of e){const e=this._instance.get_property(i);D(e)||(t[i]=e)}return t}set(e,t){this._instance.register("string"==typeof e?{[e]:t}:e)}remove(e){"string"!=typeof e?e.forEach(e=>this._instance.unregister(e)):this._instance.unregister(e)}},uu=class{constructor(e){this._instance=e}get(){const e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=null==y?void 0:y.__PosthogExtensions__;if(!e)return;const{generateSurveys:t,loadExternalDependency:i}=e;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:i?e=>i(this._instance,"surveys",e):void 0}}createEventReceiver(){return new lu(this._instance)}};const du=(null==a?void 0:a.location)?Do(a.location.hash,"__posthog")||Do(location.hash,"state"):null,hu="_postHogToolbarParams",pu=is("[Toolbar]"),vu=is("[FeatureFlags]");var fu=class{constructor(e,t=!1){this.jc=!1,this.update(e,t)}update(e,t){this.Bc=((e,t)=>{var i,s,n,r,o,a,l;return{bootstrap:{featureFlags:null!==(i=null===(s=e.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=e.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:D(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(a=null!==(l=e.evaluation_contexts)&&void 0!==l?l:e.evaluation_environments)&&void 0!==a?a:[],flagKeys:I(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.jc||(vu.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.jc=!0),D(e.flag_keys)||I(e.flag_keys)||vu.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.Bc}};const gu=is("[FeatureFlags]"),_u=is("[FeatureFlags]",{debugEnabled:!0}),mu="\" failed. Feature flags didn't load in time.",yu=["click","keydown","wheel","touchstart","pointerdown"],bu="connection_error",wu=e=>{const t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},xu=e=>{const t={};for(const[i,s]of Jn(e||{}))s&&(t[i]=s);return t},Eu=e=>Y(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),$u=is("[Error tracking]"),Su="webkit-masked-url:",ku=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Pu=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Su],Mu=["__firefox__","__gCrWeb"],Ou="Refusing to render web experiment since the viewer is a likely bot",Tu={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>Hl(t,e),not_regex:(e,t)=>!Hl(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Fu=is("[Conversations]"),Cu="Conversations not available yet.";function Iu(e,t){var i,s,n,r,o,a,l;const u=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,d=null!==(s=null==e?void 0:e.maxBufferSize)&&void 0!==s?s:100,h=(null==t?void 0:t.consoleCapture)?void 0:null!==(n=null==e?void 0:e.maxLogsPerInterval)&&void 0!==n?n:1e3,p=D(h)?Math.max(d,2048):Math.max(d,h),v=Ot(Ot({},(function(){let e="",t="";try{const i=null==c?void 0:c.userAgent;i&&([e,t]=rt(i))}catch(e){}return(function(e,t){const i=(function(e){if(e)return{}.hasOwnProperty.call(ji,e)?ji[e]:e})(e);return Ot(Ot({},i?{"os.name":i}:{}),t?{"os.version":t}:{})})(e,t)})()),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==v?void 0:v["service.name"])&&void 0!==o?o:null==e?void 0:e.serviceName)&&void 0!==r?r:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(a=null==v?void 0:v["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==v?void 0:v["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:v,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:u,maxBufferSize:d,maxQueueSize:p,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Ru=["debug","log","warn","error","info"],Au=e=>{for(;null==e?void 0:e.__rrweb_original__;)e=e.__rrweb_original__;return e},Lu="console",Du="__posthogHandledLogsRequestError",Nu=(e,t)=>{const i=e instanceof Error?e:new Error(t);return i[Du]=!0,i},ju=e=>!!e&&"object"==typeof e&&!0===e[Du],Bu=is("[NetworkMetrics]"),Uu=()=>{var e;return(null==a||null===(e=a.performance)||void 0===e?void 0:e.now)?a.performance.now():Date.now()},Hu=e=>e?`${Math.floor(e/100)}xx`:"missing",zu=(e,t)=>{var i;const s=String(t);return{method:String(e).toUpperCase(),url:(null===(i=Ro(s))||void 0===i?void 0:i.href)||s}},qu=(e,t,i,s,n)=>{try{var r,o,a;const c=n();if(!c)return;const u=i||void 0,d=Uu()-s,h=Ro(t.url);if(h&&"http:"!==h.protocol&&"https:"!==h.protocol)return;const p={url:(null==h?void 0:h.href)||t.url,method:t.method},v=R(c.name)?c.name(p):N(c.name)?c.name:"http.client.request.duration";if(!v)return;const f=Ot({method:p.method,host:null!==(r=null==h?void 0:h.hostname)&&void 0!==r?r:"",path:h?(l=h.pathname,l.split("/").map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?":id":e).join("/")):"",status_class:Hu(u)},null===(o=c.attributes)||void 0===o?void 0:o.call(c,p,{status:u,durationMs:d}));null===(a=e.metrics)||void 0===a||a.histogram(v,d,{unit:"ms",attributes:f})}catch(e){Bu.error("Failed to record network metric",e)}var l},Vu=()=>{},Wu=(e,t)=>R(null==a?void 0:a.fetch)?Nc(a,"fetch",i=>function(...s){const n=Uu(),r=i.apply(this,s);if(!t())return r;try{var o,a,l;const[i,c]=s,u=zu(null!==(o=null!==(a=null==c?void 0:c.method)&&void 0!==a?a:null==i?void 0:i.method)&&void 0!==o?o:"GET",null!==(l=null==i?void 0:i.url)&&void 0!==l?l:i);return r.then(i=>(qu(e,u,null==i?void 0:i.status,n,t),i),i=>{throw qu(e,u,void 0,n,t),i})}catch(e){return Bu.error("Failed to observe fetch",e),r}}):Vu,Gu=(e,t)=>{var i;const s=null==a||null===(i=a.XMLHttpRequest)||void 0===i?void 0:i.prototype;if(!s)return Vu;const n=new WeakMap,r=Nc(s,"open",e=>function(...t){try{(()=>hl.has(this))()||n.set(this,zu(t[0],t[1]))}catch(e){Bu.error("Failed to observe XHR open",e)}return e.apply(this,t)}),o=Nc(s,"send",i=>function(...s){let r;try{const i=n.get(this);if(i&&t()){const s=Uu();r=()=>{this.removeEventListener("loadend",r),qu(e,i,this.status,s,t)},ir(this,"loadend",r)}}catch(e){Bu.error("Failed to observe XHR send",e)}try{return i.apply(this,s)}catch(e){throw r&&this.removeEventListener("loadend",r),e}});return()=>{r(),o()}},Ku={featureFlags:class{constructor(e){this.name="featureFlags",this.Hc=!1,this.featureFlagEventHandlers=[],this.$=gu,this.zc={},this.Uc={},this.Wc=[],this.Vc=!1,this.Gc=!1,this.Zc=0,this.Qc=!1,this.Jc=!1,this.Kc=!1,this.Xc=!1,this.Yc=0,this.td=!1,this.sn=()=>{const e=this.ed();this.Yc=0,e&&this.reloadFeatureFlags()},this.nd=()=>{var e,t;const i=this.sd,s=null!==(e=this.rd)&&void 0!==e?e:i;D(i)||D(s)||this.Mr.remoteRequestsDisabled||!u||"hidden"===u.visibilityState||Date.now()-(null!==(t=this.od)&&void 0!==t?t:0)<s||(this.rd=this.td||!this.Mr.idleRefreshBackoff?i:Math.min(2*s,36e5),this.td=!1,this.reloadFeatureFlags(),this.ld())},this.ad=()=>{this.td&&this.rd===this.sd||this.ud()},this.an=()=>{"visible"===(null==u?void 0:u.visibilityState)&&this.ud()},"get"in e?this.yo=e:(this._instance=e,this.hd=new fu(e.config,e.Xl()),this.yo=this.hd)}updateConfig(e,t){var i;null===(i=this.hd)||void 0===i||i.update(e,t),this.po&&this.dd()}setup(e){return this.xh=e,this.$=e.logger.createLogger("[FeatureFlags]"),tu(e.kv.initialize(),()=>{this.xh===e&&(this.xh=void 0,this.po=e,this.vd(e))})}vd(e){var t;if(this.po===e)return a&&ir(a,"online",this.sn),this.dd(),this.fd=e.registerDynamicEventProperties(()=>this.pd()?this.zc:this.Uc),this.gd=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.onCrossTabFeatureFlagChange(()=>{this.md(),this.yd(),this.bd()}),this.yd(),this.initialize()}ud(){this.td=!0,this.rd=this.sd,this.nd()}dd(){const e=this.Mr.refreshIntervalMs,t=!this.Mr.remoteRequestsDisabled&&u&&!D(e)&&e>0?e:void 0;this.Mr.idleRefreshBackoff||(this.rd=t),t!==this.sd&&(this._d(),D(t)||(this.sd=t,this.rd=t,this.ld(),(null==u?void 0:u.addEventListener)&&(ir(u,Un,this.an),Gn(yu,e=>{ir(u,e,this.ad,{capture:!0})}))))}ld(){D(this.sd)||(D(this.wd)||clearInterval(this.wd),this.od=Date.now(),this.wd=setInterval(this.nd,this.sd))}_d(){var e;D(this.wd)||(clearInterval(this.wd),this.wd=void 0,null==u||null===(e=u.removeEventListener)||void 0===e||e.call(u,"visibilitychange",this.an),Gn(yu,e=>{var t;null==u||null===(t=u.removeEventListener)||void 0===t||t.call(u,e,this.ad,{capture:!0})})),this.sd=void 0,this.rd=void 0,this.td=!1,this.od=void 0}destroy(){this.kd()}dispose(){this.kd()}kd(){var e,t;this._d(),this.Zc++,this.Jc=!1,this.xh=void 0,this.po&&(this.Sd(),null===(e=this.fd)||void 0===e||e.dispose(),this.fd=void 0,null===(t=this.gd)||void 0===t||t.call(this),this.gd=void 0,this.Wc=[],null==a||a.removeEventListener("online",this.sn),this.po=void 0)}get Mr(){return this.yo.get()}xd(e){var t;return this.Cd&&e in this.Cd?this.Cd[e]:null===(t=this.po)||void 0===t?void 0:t.kv.get(e)}md(){return!!this.Cd&&(this.Cd=void 0,!0)}$d(){var e;return!D(null===(e=this.po)||void 0===e?void 0:e.kv.get("$enabled_feature_flags"))&&this.md()}At(e){this.Td(()=>{var t;return null===(t=this.po)||void 0===t?void 0:t.kv.set(e)})}Id(e,t,i){var s;if(!(null===(s=this._instance)||void 0===s?void 0:s.persistence)||!e.$enabled_feature_flags)return;const n=this.xd("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(([,e])=>!(null==e?void 0:e.failed)).map(([e])=>e):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,c=l?a:i&&!I(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),u=this.xd("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},h=l||i?c:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),p=!l&&!i,v=!!p||c,f=!!p||h,g={[zs]:v,[Hs]:v,[Ws]:f};e.$feature_flag_details&&(g[Vs]=v);for(const t of[Gs,gn,Ks])D(e[t])||(g[t]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}Lt(e){this.Td(()=>{var t;return null===(t=this.po)||void 0===t?void 0:t.kv.remove(e)})}Td(e){try{e()}catch(e){this.$.error("Failed to update feature flag persistence",e)}}yd(){const e={};for(const t of[zs,Ws,Gs,Ys]){const i=this.xd(t);D(i)||(e[t]=i)}this.zc=e;const t=Ot({},e),i=this.xd(Hs);if(i)for(const[e,s]of Object.entries(i))t[`$feature/${e}`]=s;this.Uc=t}pd(){const e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;const t=this.xd(gn);return"number"!=typeof t||Date.now()-t>e}Md(){return!!this.pd()&&(this.Xc||this.Gc||(this.Xc=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Ed(){const e=this.Mr.evaluationContexts;return(null==e?void 0:e.length)?e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this.$.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}Pd(){const e=this.Mr.flagKeys;if(!D(e))return e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this.$.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var e,t;const i=this.Mr,s=null!==(e=null===(t=i.bootstrap)||void 0===t?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var n,r;const e=null!==(n=null===(r=i.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},t=Object.keys(s).filter(e=>!D(s[e])).reduce((e,t)=>(e[t]=s[t],e),{}),o=Object.keys(e).filter(e=>t[e]).reduce((t,i)=>(t[i]=e[i],t),{});return this.Rd({featureFlags:t,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(e,t,i){var s,n;const r=(null==i?void 0:i.merge)&&null!==(s=this.xd("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==i?void 0:i.merge)&&null!==(n=this.xd("$feature_flag_payloads"))&&void 0!==n?n:{},a=Ot(Ot({},r),e),l=Ot(Ot({},o),t),c={};for(const[e,t]of Object.entries(a))c[e]={key:e,enabled:gi(t),variant:_i(t),reason:void 0,metadata:D(null==l?void 0:l[e])?void 0:{id:0,version:void 0,description:void 0,payload:l[e]}};this.Rd({flags:c})}get hasLoadedFlags(){return this.Vc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.xd(Vs),t=this.xd(Ys),i=this.xd(Js);if(!i&&!t)return e||{};const s=Yn({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(const e of n){var r;const n=s[e],a=null==t?void 0:t[e],l=D(a)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!a,c=D(a)?null==n?void 0:n.variant:"string"==typeof a?a:void 0,u=null==i?void 0:i[e],d=Ot(Ot({},n),{},{enabled:l,variant:l?null!=c?c:null==n?void 0:n.variant:void 0});var o;l!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),c!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),u&&(d.metadata=Ot(Ot({},null==n?void 0:n.metadata),{},{payload:u,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[e]=d}return this.Hc||(this.$.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this.Hc=!0),s}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{const s=e[i];return{key:i,enabled:gi(s),variant:_i(s),payload:fi(t[i])}})}getFlagVariants(){const e=this.xd(Hs),t=this.xd(Ys);if(!t)return e||{};const i=Yn({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this.Hc||(this.$.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.Hc=!0),i}getFlagPayloads(){const e=this.xd(Ws),t=this.xd(Js);if(!t)return e||{};const i=Yn({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this.Hc||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this.Hc=!0),i}reloadFeatureFlags(){this.Qc||this.Mr.featureFlagsDisabled||this.ed()||(this.Gc&&(this.Jc=!0),this.Ad||(this.Wc.slice().forEach(e=>{try{e()}catch(e){this.$.error("Error while running feature flags reloading callback",e)}}),this.Ad=setTimeout(()=>{this.Fd()},5)))}Sd(){clearTimeout(this.Ad),this.Ad=void 0}onReloading(e){return this.Wc.push(e),()=>{this.Wc=this.Wc.filter(t=>t!==e)}}ensureFlagsLoaded(){this.Vc||this.Gc||this.Ad||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Qc=e}resetFlagCallReported(){this.Lt(pn)}Fd(e){this.Sd();const t=this.po;if(!t||this.Mr.remoteRequestsDisabled||this.ed())return;if(this.Gc)return void(this.Jc=!0);const i={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:Ot(Ot(Ot({},t.initialPersonProperties),this.xd("$stored_person_properties")||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.xd(Xs),timezone:Qo()};D(t.deviceId)||(i.$device_id=t.deviceId),((null==e?void 0:e.disableFlags)||this.Mr.featureFlagsDisabled)&&(i.disable_flags=!0);const s=this.Ed();s.length&&(i.evaluation_contexts=s);const n=this.Pd();D(n)||(i.flag_keys=n);const r=this.Mr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),a=this.Zc;this.Gc=!0;const l=()=>{this.Jc&&(this.Jc=!1,this.Fd())},c=e=>{var t,s;const n=null!==(t=e.json)&&void 0!==t?t:{},o=200!==e.statusCode;if(this.Gc=!1,a!==this.Zc)return void l();if(this.Od(e.statusCode),o||this.Jc||(this.$anon_distinct_id=void 0),i.disable_flags&&!this.Jc)return;this.Kc=!o;const c=[];e.error?c.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?bu:"unknown_error"):200!==e.statusCode&&c.push(`api_error_${e.statusCode}`),n.errorsWhileComputingFlags&&c.push("errors_while_computing_flags");const u=!!(null===(s=n.quotaLimited)||void 0===s?void 0:s.includes("feature_flags"));u&&c.push("quota_limited"),this.At({[fn]:c}),u?this.$.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):i.disable_flags||this.Rd(n,o,{partialResponse:r}),l()},u=e=>{this.Gc=!1,a===this.Zc?(this.At({[fn]:[bu]}),this.$.error("Feature flag request failed",e),this.$d()&&this.bd(!0),l()):l()};try{t.sendRequest(o,{target:"flags",method:"POST",body:i,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(c).catch(u)}catch(e){u(e)}}ed(){return No(this.Yc,3)}Od(e){this.Yc=jo(e,this.Yc,3,()=>this.$.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var i;if(t.fresh&&!this.Kc)return;if(!(this.Vc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+e+mu);if(this.Md())return;const s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.Kc)return;if(!(this.Vc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+e+mu);if(this.Md())return;const i=this.getFlagVariants(),s=e in i,n=i[e],r=this.getFlagPayloads()[e],o=String(n),a=this.xd("$feature_flag_request_id")||void 0,l=this.xd("$feature_flag_evaluated_at")||void 0;let c,u=this.xd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var d;const e=null===(d=this.po)||void 0===d?void 0:d.session.sessionId,t=this.xd(vn);e&&e!==t&&(u={},c=e)}if(t.send_event||!("send_event"in t))if(e in u&&u[e].includes(o))c&&this.At({[pn]:u,[vn]:c});else{var h,p,v,f,g,_,m,y,b,w,x,E;I(u[e])?u[e].push(o):u[e]=[o],this.At(Ot({[pn]:u},c?{[vn]:c}:{}));const t=this.getFeatureFlagDetails(e),i=[...null!==(h=this.xd("$feature_flag_errors"))&&void 0!==h?h:[]];D(n)&&i.push("flag_missing");const s={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:null!==(p=null===(v=this.Mr.bootstrap)||void 0===v||null===(v=v.featureFlags)||void 0===v?void 0:v[e])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(f=null===(g=this.Mr.bootstrap)||void 0===g||null===(g=g.featureFlagPayloads)||void 0===g?void 0:g[e])&&void 0!==f?f:null,$used_bootstrap_value:!this.Kc};D(null==t||null===(_=t.metadata)||void 0===_?void 0:_.has_experiment)||(s.$feature_flag_has_experiment=t.metadata.has_experiment),D(null==t||null===(m=t.metadata)||void 0===m?void 0:m.version)||(s.$feature_flag_version=t.metadata.version);const d=null!==(y=null==t||null===(b=t.reason)||void 0===b?void 0:b.description)&&void 0!==y?y:null==t||null===(w=t.reason)||void 0===w?void 0:w.code;var $;d&&(s.$feature_flag_reason=d),(null==t||null===(x=t.metadata)||void 0===x?void 0:x.id)&&(s.$feature_flag_id=t.metadata.id),D(null==t?void 0:t.original_variant)&&D(null==t?void 0:t.original_enabled)||(s.$feature_flag_original_response=D(t.original_variant)?t.original_enabled:t.original_variant),(null==t||null===(E=t.metadata)||void 0===E?void 0:E.original_payload)&&(s.$feature_flag_original_payload=null==t||null===($=t.metadata)||void 0===$?void 0:$.original_payload),i.length&&(s.$feature_flag_error=i.join(",")),this.Dd(s)}else c&&this.At({[pn]:u,[vn]:c});return s?{key:e,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:fi(r)}:void 0}Dd(e){try{var t;null===(t=this.po)||void 0===t||t.capture("$feature_flag_called",e).catch(e=>{this.$.error("Failed to capture feature flag call",e)})}catch(e){this.$.error("Failed to capture feature flag call",e)}}getRemoteConfigPayload(e,t){this.Ld(e,t)}Ld(e,t){var i=this;return ie(function*(){const s=i.po;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=i.Ed();r.length&&(n.evaluation_contexts=r);const o=i.Pd();let a;D(o)||(n.flag_keys=o);try{var l;const t=null===(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i.Mr.compression,sentAt:"body",timeoutMs:i.Mr.requestTimeoutMs})).json)||void 0===l?void 0:l.featureFlagPayloads;a=(null==t?void 0:t[e])||void 0}catch(e){return void i.$.error("Remote config feature flag request failed",e)}try{t(a)}catch(e){i.$.error("Remote config feature flag callback failed",e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.Kc)return t.defaultValue;if(!(this.Vc||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+e+mu),t.defaultValue;const i=this.getFeatureFlag(e,t);return D(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this.Rd(e,t,i)}Rd(e,t,i){if(!this.po)return;this.Vc=!0;const s=((e,t={},i={},s={},n,r=gu)=>{const o=((e,t)=>{const i=e.flags;if(i){const t=Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),s=Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!D(null===(t=i[e].metadata)||void 0===t?void 0:t.payload)}).map(e=>{var t;return[e,null===(t=i[e].metadata)||void 0===t?void 0:t.payload]}));return Ot(Ot({},e),{},{featureFlags:t,featureFlagPayloads:s})}return e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e,r),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(!l)return;const u=e.requestId,d=e.evaluatedAt;if(I(l)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const e={};if(l)for(let t=0;l.length>t;t++)e[l[t]]=!0;return{[zs]:l,[Hs]:e,[Ks]:!1}}let h=l,p=c,v=a;if(null==n?void 0:n.partialResponse){const e=Object.keys(h),n=p||{};h=Ot(Ot({},t),h),p=Ot(Ot({},i),n),e.forEach(e=>{e in n||null==p||delete p[e]}),v=Ot(Ot({},s),v)}else if(e.errorsWhileComputingFlags)if(a){const e=new Set(Object.keys(a).filter(e=>{var t;return!(null===(t=a[e])||void 0===t?void 0:t.failed)}));h=Ot(Ot({},t),Object.fromEntries(Object.entries(h).filter(([t])=>e.has(t))));const n=Object.fromEntries(Object.entries(p||{}).filter(([t])=>e.has(t)));p=Ot(Ot({},i),n),e.forEach(e=>{e in n||null==p||delete p[e]}),v=Ot(Ot({},s),Object.fromEntries(Object.entries(v||{}).filter(([t])=>e.has(t))))}else h=Ot(Ot({},t),h),p=Ot(Ot({},i),p),v=Ot(Ot({},s),v);return Ot(Ot({[zs]:Object.keys(xu(h)),[Hs]:h||{},[Ws]:p||{},[Vs]:v||{},[Ks]:!0===e.minimalFlagCalledEvents},u?{[Gs]:u}:{}),d?{[gn]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this.$);if(s)if(!1===(null==i?void 0:i.persist)){const e=!D(this.po.kv.get(Hs));this.Cd=s,e||this.At(s)}else this.md(),this.Id(s,e,!!(null==i?void 0:i.partialResponse)),this.At(s);else t&&this.$d();t||(this.Xc=!1),this.bd(t)}override(e,t=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Nd(e)}Nd(e){if(this.po){if(!1===e)return this.Lt([Ys,Js]),this.bd(),void _u.info("All overrides cleared");if(I(e))return this.At({[Ys]:wu(e)}),this.bd(),void _u.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t;const i=e;this.Hc=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);const s={},n=i.flags,r=i.payloads;return n&&(s[Ys]=I(n)?wu(n):n),r&&(s[Js]=r),Object.keys(s).length&&this.At(s),!1===n&&!1===r?this.Lt([Ys,Js]):!1===n?this.Lt(Ys):!1===r&&this.Lt(Js),this.bd(),!1===n?_u.info("Flag overrides cleared"):n&&_u.info("Flag overrides set",{flags:n}),void(!1===r?_u.info("Payload overrides cleared"):r&&_u.info("Payload overrides set",{payloads:r}))}if(e&&"object"==typeof e)return this.At({[Ys]:e}),this.bd(),void _u.info("Flag overrides set",{flags:e});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Vc){const{flags:t,flagVariants:i}=this.qd();try{e(t,i)}catch(e){this.$.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;const n=(this.xd("$early_access_features")||[]).find(t=>t.flagKey===e),r={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:r};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i);const a=Ot(Ot({},this.getFlagVariants()),{},{[e]:t});null===(s=this._instance)||void 0===s||null===(s=s.persistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(r)}),this.At({[zs]:Object.keys(xu(a)),[Hs]:a,[Zs]:Ot(Ot({},this.xd("$stored_person_properties")||{}),r)}),this.bd();try{var l;null===(l=this.po)||void 0===l||l.capture("$feature_enrollment_update",o).catch(e=>{this.$.error("Failed to capture early access feature enrollment",e)})}catch(e){this.$.error("Failed to capture early access feature enrollment",e)}}getEarlyAccessFeatures(e,t=!1,i){const s=this.xd(qs);!s||t?this.jd(e,i):e(s)}jd(e,t){var i=this;return ie(function*(){const s=i.po;if(!s)return;const n=t?`&${t.map(e=>`stage=${e}`).join("&")}`:"";let r;try{const e=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!e.json)return;r=e.json.earlyAccessFeatures,i.At({[qs]:r})}catch(e){return void i.$.error("Early access feature request failed",e)}try{e(r)}catch(e){i.$.error("Early access feature callback failed",e)}})()}qd(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}bd(e){this.yd();const{flags:t,flagVariants:i}=this.qd();this.featureFlagEventHandlers.forEach(s=>{try{s(t,i,{errorsLoading:e})}catch(e){this.$.error("Error while running feature flags callback",e)}})}setPersonPropertiesForFlags(e,t=!0){this.Bd(e,t)}Bd(e,t=!0){const i=this.xd("$stored_person_properties")||{},s=(null==e?void 0:e.$set)||((null==e?void 0:e.$set_once)?{}:e),n=null==e?void 0:e.$set_once,r={};if(n)for(const e in n)({}).hasOwnProperty.call(n,e)&&(e in i||(r[e]=n[e]));this.At({[Zs]:Ot(Ot(Ot({},i),r),s)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const i=Ot({},this.xd("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this.At({[Zs]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(Zs),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const i=this.xd("$stored_group_properties")||{},s=Ot({},i);for(const t of Object.keys(e))s[t]=Ot(Ot({},i[t]),e[t]);this.At({[Xs]:s}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.xd("$stored_group_properties")||{};this.At({[Xs]:Ot(Ot({},t),{},{[e]:{}})})}else this.Lt(Xs)}reset(){this.Zc++,this.Jc=!1,this.zc={},this.Uc={},this.Cd=void 0,this.Vc=!1,this.Qc=!1,this.Kc=!1,this.$anon_distinct_id=void 0,this.Sd(),this.Hc=!1,this.Yc=0}}},Yu={sessionRecording:class{get Mr(){return this._instance.config}get xa(){return this._instance.persistence}get started(){var e;return!!(null===(e=this.Hd)||void 0===e?void 0:e.isStarted)}get status(){var e,t;return"awaiting_config"===this.zd||"missing_config"===this.zd?this.zd:null!==(e=null===(t=this.Hd)||void 0===t?void 0:t.status)&&void 0!==e?e:this.zd}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.zd=Vc,this.Ud=void 0,this.Wd=!1,this.Ke=(()=>{var e,t;if(!(null==u?void 0:u.visibilityState)||"visible"===u.visibilityState)return!0;const i=null==a||null===(e=a.performance)||void 0===e||null===(t=e.getEntriesByType)||void 0===t?void 0:t.call(e,"visibility-state");return!(null==i?void 0:i.length)||i.some(e=>"visible"===e.name)})(),this.an=()=>{var e,t;"visible"===(null==u?void 0:u.visibilityState)&&(this.Ke=!0,null===(e=this.Hd)||void 0===e||null===(t=e.setDocumentWasEverVisible)||void 0===t||t.call(e,!0))},!this._instance.sessionManager)throw Gc.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Mr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==u?void 0:u.addEventListener)&&ir(u,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.Wd=!0,null==u||null===(t=u.removeEventListener)||void 0===t||t.call(u,"visibilitychange",this.an),e?this.Vd(!0):this.stopRecording()}get Gd(){var e;const t=!!(null===(e=this._instance.get_property("$session_recording_remote_config"))||void 0===e?void 0:e.enabled),i=!this.Mr.disable_session_recording,s=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return a&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(this.Wd)return;if(this.Gd&&(null===(t=this.Hd)||void 0===t?void 0:t.isStarted))return;const i=!D(Object.assign)&&!D(Array.from);this.Gd&&i?(this.Zd(e),Gc.info("starting")):(this.zd=Vc,this.stopRecording())}Zd(e){var t,i;if(this.Gd)if("awaiting_config"!==this.zd&&"missing_config"!==this.zd&&(this.zd=Wc),(null==y||null===(t=y.__PosthogExtensions__)||void 0===t||null===(t=t.rrweb)||void 0===t?void 0:t.record)&&(null===(i=y.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))this.Qd(e);else{var s,n;const t=this._instance.sessionManager;null===(s=y.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this.Jd,i=>{if(!this.Wd&&this.Gd&&this._instance.sessionManager===t)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Gc.error("could not load recorder",i)):void this.Qd(e);this.zd="disabled"})}}stopRecording(){var e,t;null===(e=this.Ud)||void 0===e||e.call(this),this.Ud=void 0,null===(t=this.Hd)||void 0===t||t.stop()}Vd(e=!1){var t,i;null===(t=this.Ud)||void 0===t||t.call(this),this.Ud=void 0,null===(i=this.Hd)||void 0===i||i.discard({discardProducerEvents:e})}Kd(){var e,t;null===(e=this.xa)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this.xa)||void 0===t||t.unregister("$replay_sample_rate")}Xd(e,t){if(U(e))return null;const i=H(e)?e:parseFloat(e);return"number"!=typeof(s=i)||!Number.isFinite(s)||0>s||s>1?(Gc.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var s}Yd(e){if(this.xa){var t,i;const s=this.xa,n=()=>{var t;const i=!1===e.sessionRecording?void 0:e.sessionRecording,n=this.Xd(null===(t=this.Mr.session_recording)||void 0===t?void 0:t.sampleRate,"session_recording.sampleRate"),r=this.Xd(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=n?n:r;U(o)&&this.Kd();const a=null==i?void 0:i.minimumDurationMilliseconds;s.register({[Ms]:Ot(Ot({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:Ot({capturePerformance:e.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:D(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};n(),null===(t=this.Ud)||void 0===t||t.call(this),this.Ud=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.onSessionId(n)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this.Yd(t),void this.Vd()):(this.Yd(t),void this.startIfEnabledOrStop()):("awaiting_config"===this.zd&&(this.zd="missing_config",Gc.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;(null===(i=this.Hd)||void 0===i?void 0:i.log)?this.Hd.log(e,t):Gc.warn("log called before recorder was ready")}get Jd(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.get_property(Ms);return(null==i||null===(t=i.scriptConfig)||void 0===t?void 0:t.script)||"lazy-recorder"}tv(){const e=this._instance.get_property(Ms);if(!e)return!1;let t;try{t="object"==typeof e?e:JSON.parse(e)}catch(e){return Gc.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!U(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Qd(e){var t,i,s;if(!this.Wd&&this.Gd&&this._instance.sessionManager){if(!(null===(t=y.__PosthogExtensions__)||void 0===t?void 0:t.initSessionRecording))return Gc.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Mn]:!0});var n;if(this.Hd||(this.Hd=null===(n=y.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this.Ke),this.Hd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.tv()){if("missing_config"===this.zd||"awaiting_config"===this.zd)return;return this.zd="awaiting_config",Gc.info("persisted remote config is stale, requesting fresh config before starting"),void new Fa(this._instance).load()}this.zd=Wc,null===(i=(s=this.Hd).setDocumentWasEverVisible)||void 0===i||i.call(s,this.Ke),this.Hd.start(e)}else this.zd=Vc}onRRwebEmit(e){var t,i;null===(t=this.Hd)||void 0===t||null===(i=t.onRRwebEmit)||void 0===i||i.call(t,e)}overrideLinkedFlag(){var e,t;this.Hd||null===(t=this.xa)||void 0===t||t.register({$replay_override_linked_flag:!0}),null===(e=this.Hd)||void 0===e||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Hd||null===(t=this.xa)||void 0===t||t.register({$replay_override_sampling:!0}),null===(e=this.Hd)||void 0===e||e.overrideSampling()}overrideTrigger(e){var t,i;this.Hd||null===(i=this.xa)||void 0===i||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(t=this.Hd)||void 0===t||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null===(e=this.Hd)||void 0===e?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!!(null===(i=this.Hd)||void 0===i?void 0:i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;null===(e=this.Hd)||void 0===e||null===(t=e.flushBeforeIdentityReset)||void 0===t||t.call(e)}}},Ju={autocapture:class extends Ic{constructor(e){super(new Rc(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.ev=this.iv()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this.nv();return!!(e.path||e.search||this.sv(e))}startIfEnabled(){this.isEnabled&&(ts.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.ev=this.iv(),this.startIfEnabled()}stop(){this.rv&&this.rv(),this.rv=void 0,this.ov&&this.ov(),this.ov=void 0,ts.info("History API monitoring stopped")}monitorHistoryChanges(){a&&a.history&&(this.lv("pushState"),this.lv("replaceState"),this.av(),this.sv()&&this.uv())}lv(e){var t;if(!a||(null===(t=a.history[e])||void 0===t?void 0:t.__posthog_wrapped__))return;const i=this;Nc(a.history,e,t=>function(s,n,r){t.call(this,s,n,r),i.hv(e)})}iv(){const e=null==a?void 0:a.location;if(null==e?void 0:e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}nv(){const e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:A(e)?e:{}}sv(e=this.nv()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}dv(e){const t=this.nv(),i=this.ev;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this.sv(t)&&e.hash!==i.hash))}hv(e){try{const t=this.iv();if(!t)return;this.dv(t)&&this._instance.capture(zn,{navigation_type:e}),this.ev=t}catch(t){ts.error(`Error capturing ${e} pageview`,t)}}av(){if(this.rv)return;const e=()=>{this.hv("popstate")};ir(a,"popstate",e),this.rv=()=>{a&&a.removeEventListener("popstate",e)}}uv(){if(this.ov)return;const e=()=>{this.hv("hashchange")};ir(a,"hashchange",e),this.ov=()=>{a&&a.removeEventListener("hashchange",e)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(e){var t;this.vv=!1,this.bo=!1,this.fv=null,this.instance=e,this.vv=!!(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[ys]),this.rageclicks=new Pc(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return A(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Mr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return U(this.Mr.capture_heatmaps)?U(this.Mr.enable_heatmaps)?this.vv:this.Mr.enable_heatmaps:!1!==this.Mr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.bo)return;Kc.info("starting..."),this.pv(),this.an()}else{var e;clearInterval(null!==(e=this.fv)&&void 0!==e?e:void 0),this.gv(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ys]:i}),this.vv=i,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}mv(e){Yc(e.originalEvent)&&this.Cr(e.originalEvent,"deadclick")}an(){this.fv&&clearInterval(this.fv),this.fv="visible"===(null==u?void 0:u.visibilityState)?setInterval(this.fa.bind(this),this.flushIntervalMilliseconds):null}pv(){a&&u&&(this.yv=this.fa.bind(this),ir(a,Hn,this.yv),this.bv=e=>this.Cr(e||(null==a?void 0:a.event)),ir(u,"click",this.bv,{capture:!0}),this._v=e=>this.wv(e||(null==a?void 0:a.event)),ir(u,"mousemove",this._v,{capture:!0}),this.Sv=new xo(this.instance,bo,this.mv.bind(this)),this.Sv.startIfEnabledOrStop(),this.xv=this.an.bind(this),ir(u,Un,this.xv),this.bo=!0)}gv(){var e;a&&u&&(this.yv&&a.removeEventListener(Hn,this.yv),this.bv&&u.removeEventListener("click",this.bv,{capture:!0}),this._v&&u.removeEventListener("mousemove",this._v,{capture:!0}),this.xv&&u.removeEventListener(Un,this.xv),clearTimeout(this.Cv),null===(e=this.Sv)||void 0===e||e.stop(),this.bo=!1)}$v(e,t){const i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=(function(e,t,i){let s=e;for(;s&&Ar(s)&&!Lr(s,"body");){if(s===i)return!1;let e;try{var n,r,o;e=null===(n=null!==(r=null===(o=s.ownerDocument)||void 0===o?void 0:o.defaultView)&&void 0!==r?r:a)||void 0===n?void 0:n.getComputedStyle(s).position}catch(e){return!1}if(k(t,e))return!0;s=Kr(s)}return!1})(qr(e),["fixed","sticky"],n);return{x:e.clientX+(r?0:s),y:e.clientY+(r?0:i),target_fixed:r,type:t}}Cr(e,t="click"){var i;if(Rr(e.target)||!Yc(e))return;const s=this.$v(e,t);(null===(i=this.rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&to(qr(e),this.instance.config.rageclick)&&this.Zs(Ot(Ot({},s),{},{type:"rageclick"})),this.Zs(s)}wv(e){!Rr(e.target)&&Yc(e)&&(clearTimeout(this.Cv),this.Cv=setTimeout(()=>{this.Zs(this.$v(e,"mousemove"))},500))}Zs(e){if(!a)return;const t=this.Mr.disable_capture_url_hashes?_t(a.location.href):a.location.href,i=this.Mr.custom_personal_data_properties,s=this.Mr.mask_personal_data_properties?[...Bo,...i||[]]:[],n=Lo(t,s,Ho);this.Rt=this.Rt||{},this.Rt[n]||(this.Rt[n]=[]),this.Rt[n].push(e)}fa(){this.Rt&&!L(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:xo,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.vv=!1,this.bo=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Tv=()=>{clearTimeout(this.Iv),this.Iv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",Ot({$current_url:this.Rt.url},this.Rt.metrics.reduce((e,t)=>Ot(Ot({},e),{},{[`$web_vitals_${t.name}_event`]:Ot({},t),[`$web_vitals_${t.name}_value`]:t.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Mv=e=>{var t;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},U(null==e?void 0:e.name)||U(null==e?void 0:e.value))return void Bc.error("Invalid metric received",e);const i="string"==typeof e.navigationURL?e.navigationURL:void 0,s=this.Ev(i);if(D(s))return;const n=H(e.navigationId)||"string"==typeof e.navigationId?`navigation:${e.navigationId}`:`url:${s}`;if(this.Pv&&e.value>=this.Pv)return void Bc.error("Ignoring metric with value >= "+this.Pv,e);this.Rt.navigationKey!==n&&(this.Tv(),this.Iv=setTimeout(this.Tv,this.flushToCaptureTimeoutMs)),D(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=D(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const r=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0),o=Ot(Ot(Ot({},e),i?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,A(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){const t={};for(const i of qc){const s="url"===i&&"string"==typeof e.attribution[i]?this.Ev(e.attribution[i]):e.attribution[i];D(s)||(t[i]=s)}o.attribution=t}else delete o.attribution;D(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.Tv()},this.Rv=()=>{if(this.bo)return;let e,t,i,s,n=!1;const r=y.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,a=(null==o?void 0:o[this.Av])||("web-vitals"===this.Av&&D(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!D(a)){const r=a.withoutAttribution,o=this.attributionMetrics;n=!D(r),e=o.indexOf("LCP")>-1?a.onLCP:(null==r?void 0:r.onLCP)||a.onLCP,t=o.indexOf("CLS")>-1?a.onCLS:(null==r?void 0:r.onCLS)||a.onCLS,i=o.indexOf("FCP")>-1?a.onFCP:(null==r?void 0:r.onFCP)||a.onFCP,s=o.indexOf("INP")>-1?a.onINP:(null==r?void 0:r.onINP)||a.onINP}if(!(e&&t&&i&&s))return void Bc.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},c=n&&this.attributionMetrics.indexOf("INP")>-1?Ot(Ot({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&e(this.Mv.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&t(this.Mv.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this.Mv.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&s(this.Mv.bind(this),c),this.bo=!0},this.vv=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[Es]),this.startIfEnabled()}get Fv(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const i=A(this.Fv)?null===(e=this.Fv)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return U(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props.$web_vitals_allowed_metrics)||Hc:i}get flushToCaptureTimeoutMs(){return(A(this.Fv)?this.Fv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=A(this.Fv)?this.Fv.web_vitals_attribution:void 0;return q(e)?e?Hc:[]:I(e)?e:zc}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=A(this.Fv)?this.Fv.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get Pv(){const e=A(this.Fv)&&H(this.Fv.__web_vitals_max_value)?this.Fv.__web_vitals_max_value:Uc;return e>0&&6e4>=e?Uc:e}get isEnabled(){const e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return Bc.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=A(this.Fv)?this.Fv.web_vitals:q(this.Fv)?this.Fv:void 0;return q(t)?t:this.vv}startIfEnabled(){this.isEnabled&&!this.bo&&(Bc.info("enabled, starting..."),this.No(this.Rv))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const i=A(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=A(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Es]:i}),this._instance.persistence.register({[Ps]:s})),this.vv=i,this.startIfEnabled()}get Av(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}No(e){var t;const i=y.__PosthogExtensions__,s=this.Av,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&D(n)&&(null==i?void 0:i.postHogWebVitalsCallbacks)?e():null==i||null===(t=i.loadExternalDependency)||void 0===t||t.call(i,this._instance,s,t=>{t?Bc.error("failed to load script",t):e()})}Ev(e){const t=e||(null==a?void 0:a.location.href);if(!t)return void Bc.error("Could not determine current URL");const i=this._instance.config.disable_capture_url_hashes?_t(t):t,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Bo,...s||[]]:[];return Lo(i,n,Ho)}}},Zu={exceptionObserver:class{constructor(e){var t;this.Rv=()=>{var e;if(!a||!this.isEnabled||!(null===(e=y.__PosthogExtensions__)||void 0===e?void 0:e.errorWrappingFunctions))return;const t=y.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=y.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=y.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Ov&&this.Mr.capture_unhandled_errors&&(this.Ov=t(this.captureException.bind(this))),!this.Dv&&this.Mr.capture_unhandled_rejections&&(this.Dv=i(this.captureException.bind(this))),!this.Lv&&this.Mr.capture_console_errors&&(this.Lv=s(this.captureException.bind(this)))}catch(e){Ac.error("failed to start",e),this.Nv()}},this._instance=e,this.qv=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[bs]),this.wt=new oe(Ot(Ot({},(function(e={}){var t,i,s,n;return{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(s=null!==(n=e.exceptionRateLimiterBucketSize)&&void 0!==n?n:e.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:Ac})),this.Mr=this.jv(),this.startIfEnabledOrStop()}jv(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return A(e)?t=Ot(Ot({},t),e):(D(e)?this.qv:e)&&(t=Ot(Ot({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ac.info("enabled"),this.Nv(),this.No(this.Rv)):this.Nv()}No(e){var t,i,s;(null===(t=y.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions)?e():null===(i=y.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"exception-autocapture",t=>{if(t)return Ac.error("failed to load script",t);e()})}Nv(){var e,t,i;null===(e=this.Ov)||void 0===e||e.call(this),this.Ov=void 0,null===(t=this.Dv)||void 0===t||t.call(this),this.Dv=void 0,null===(i=this.Lv)||void 0===i||i.call(this),this.Lv=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this.qv=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[bs]:this.qv}),this.Mr=this.jv(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.jv()}captureException(e){try{var t,i,s;const n=null!==(t=null==e||null===(i=e.$exception_list)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.type)&&void 0!==t?t:"Exception";if(this.wt.consumeRateLimit(n))return void Ac.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this.Bv=[],this.Hv=new Tt([new Zt,new ai,new Qt,new Xt,new ri,new ni,new ti,new oi],(function(e,...t){return(i,s=0)=>{const n=[],r=i.split("\n"),o=Math.min(r.length,s+1e3),a=[];for(let i=s;o>i;i++){const s=r[i];if(s.length>1024)continue;const o=zt.test(s)?s.replace(zt,"$1"):s;if(!o.match(/\S*Error: /)){for(const i of t){const t=i(o,e);if(t){n.push(t);const e=Vt(n);if(e){for(let t=a.length-1;t>=0;t--){const i=a[t];if(e.start>=i.start+i.length)break;a.pop()}a.push(e)}break}}if(Yt(n,a)>=50)break}}const l=[...a].sort((e,t)=>t.start-e.start),c=l[l.length-1];if(c){const e=Gt(n,c);n.splice(c.start-e,e);for(const t of l)t.start-=e}for(const e of l)Wt(n,e);return a.some(e=>0===e.start&&n.length===e.length)&&(function(e){const t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`);let i=0;for(let e=1;t.length>e;e++)Jt(t,e,i)&&(i=e);e.push(...e.splice(0,i))})(n),(function(e){if(!e.length)return[];const t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return Ot(Ot({},e),{},{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})})(n)}})("web:javascript",jt,Ht)),this._instance=e,this.Bv=null!==(t=null===(i=this._instance.persistence)||void 0===i?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this.zv=hi(this.Uv()),this.Wv=new pi(this.zv)}onConfigChange(){this.zv=hi(this.Uv()),this.Wv.setConfig(this.zv)}onRemoteConfig(e){var t,i,s;if(!e.ok)return;const n=e.config;if(!("errorTracking"in n))return;const r=null!==(t=null===(i=n.errorTracking)||void 0===i?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this.Bv=r,this._instance.persistence&&this._instance.persistence.register({[ws]:this.Bv,[xs]:o})}get Vv(){var e;const t=!!this._instance.get_property(xs),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this.Hv.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this.zv.enabled)try{if(!N(e)||0===e.trim().length)return void $u.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:i,droppedKeys:s}=(function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};const t=[];return{sanitizedProperties:Object.keys(e).reduce((i,s)=>ui.has(s)?(t.push(s),i):(i[s]=e[s],i),{}),droppedKeys:t}})(this.Gv(t));s.length>0&&$u.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.Wv.add(Ot({[li]:e,[ci]:(new Date).toISOString()},i))}catch(e){$u.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this.Zv(t)){if(this.Qv(t))return this.Jv("Exception dropped: matched a suppression rule"),void $u.info("Skipping exception capture because a suppression rule matched");if(!this.Vv&&this.Kv(t))return this.Jv("Exception dropped: thrown by a browser extension"),void $u.info("Skipping exception capture because it was thrown by an extension");if(!this.Vv&&this.Xv(t))return this.Jv("Exception dropped: thrown by an injected browser script"),void $u.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Yv(t))return this.Jv("Exception dropped: thrown by the PostHog SDK"),void $u.info("Skipping exception capture because it was thrown by the PostHog SDK")}const i=this.zv.enabled&&U(e.$exception_steps)?this.tf(e):e,s=(function(){const e=globalThis._posthogReleaseId;return"string"==typeof e&&e.length>0?e:void 0})();s&&(i.$release_id=s);try{const e=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",eh:!0});return e&&this.Wv.clear(),e}catch(e){return Eu(e)||$u.error("Failed to capture exception event. Dropping this exception.",e),void this.Wv.clear()}}catch(e){return void(Eu(e)||$u.error("Failed to process exception event. Ignoring this exception.",e))}}tf(e){try{const t=this.Wv.getAttachable();return 0===t.length?e:Ot(Ot({},e),{},{$exception_steps:t})}catch(t){return $u.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}Jv(e){this.zv.enabled&&this.Wv.add({[li]:e,[ci]:(new Date).toISOString()})}Gv(e){return A(e)?Ot({},e):{}}Uv(){var e,t;return null!==(e=null===(t=this._instance.config.error_tracking)||void 0===t?void 0:t.exception_steps)&&void 0!==e?e:{}}Qv(e){if(0===e.length)return!1;try{const t=e.reduce((e,{type:t,value:i})=>(N(t)&&t.length>0&&e.$exception_types.push(t),N(i)&&i.length>0&&e.$exception_values.push(i),e),{$exception_types:[],$exception_values:[]});return this.Bv.some(e=>{const i=e.values.map(e=>{const i=ql[e.operator],s=t[e.key];if(!i||!s)return!1;const n=I(e.value)?e.value:[e.value];return n.length>0&&i(n,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return $u.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}Kv(e){const t=e.flatMap(e=>{var t,i;return null!==(t=null===(i=e.stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(({filename:e})=>!!e&&Pu.some(t=>e.startsWith(t)));return 0!==i.length&&(!i.every(({filename:e})=>!!e&&e.startsWith(Su))||e.some(({type:e,value:t})=>"NoResponse"===e||N(t)&&ku.some(({value:e,exact:i})=>i?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!(null==t?void 0:t.startsWith(Su))))}Xv(e){return e.some(({value:e})=>N(e)&&Mu.some(t=>e.includes(t)))}Yv(e){if(e.length>0){var t,i,s,n;const r=null!==(t=null===(i=e[0].stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}Zv(e){return!U(e)&&I(e)}}},Xu=Ot({productTours:class{get xa(){return this._instance.persistence}constructor(e){this.ef=null,this.if=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var i,s;if(this.xa&&this.xa.register({[Ss]:!!t.productTours}),!Zc(this._instance))return!this.ef&&U(null===(i=this.xa)||void 0===i?void 0:i.props.ph_product_tours)||Jc.info("product tours disabled; stopping and clearing cached tours"),null===(s=this.ef)||void 0===s||s.stop(),this.ef=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.ef&&Zc(this._instance)&&this.No(()=>this.nf())}No(e){var t,i,s;(null===(t=y.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)?e():null===(i=y.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"product-tours",t=>{t?Jc.error("Could not load product tours script",t):e()})}nf(){var e;!this.ef&&(null===(e=y.__PosthogExtensions__)||void 0===e?void 0:e.generateProductTours)&&(this.ef=y.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(I(this.if)&&!t)return void e(this.if,{isLoaded:!0});const i=this.xa;if(i){const s=i.props[on];if(I(s)&&!t)return this.if=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:t=>{if(!Zc(this._instance))return void e([],{isLoaded:!0});const s=t.statusCode;if(200!==s||!t.json){const i=`Product Tours API could not be loaded, status: ${s}`;return 0===s?t.error||Jc.warn(i):Jc.error(i),void e([],{isLoaded:!1,error:i})}const n=I(t.json.product_tours)?t.json.product_tours:[];this.if=n,i&&i.register({[on]:n}),e(n,{isLoaded:!0})}})}getActiveProductTours(e){U(this.ef)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.ef.getActiveProductTours(e)}showProductTour(e){var t;null===(t=this.ef)||void 0===t||t.showTourById(e)}previewTour(e){this.ef?this.ef.previewTour(e):this.No(()=>{var t;this.nf(),null===(t=this.ef)||void 0===t||t.previewTour(e)})}dismissProductTour(){var e;null===(e=this.ef)||void 0===e||e.dismissTour("user_clicked_skip")}nextStep(){var e;null===(e=this.ef)||void 0===e||e.nextStep()}previousStep(){var e;null===(e=this.ef)||void 0===e||e.previousStep()}clearCache(){var e;this.if=null,null===(e=this.xa)||void 0===e||e.unregister("ph_product_tours")}resetTour(e){var t;null===(t=this.ef)||void 0===t||t.resetTour(e)}resetAllTours(){var e;null===(e=this.ef)||void 0===e||e.resetAllTours()}cancelPendingTour(e){var t;null===(t=this.ef)||void 0===t||t.cancelPendingTour(e)}}},Ku),Qu={siteApps:class{constructor(e){this._instance=e,this.sf=0,this.rf=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}lf(e,t){if(!t)return;const i=this.globalsForEvent(t);this.rf.push(i),this.rf.length>1e3&&(this.rf=this.rf.slice(10))}get siteAppLoaders(){var e;return null===(e=y._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this.lf.bind(this));this.af=()=>{e(),this.rf=[],this.af=void 0}}}globalsForEvent(e){var t,i,s,n,r,o,a;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[e,t]of Object.entries(u))l[e]={id:c[e],type:e,properties:t};const{$set_once:d,$set:h}=e;return{event:Ot(Ot({},Ti(e,Xc)),{},{properties:Ot(Ot(Ot({},e.properties),h?{$set:Ot(Ot({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),h)}:{}),d?{$set_once:Ot(Ot({},null!==(s=null===(n=e.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}uf(e){var t;const i=null===(t=e.tagName)||void 0===t?void 0:t.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Qc.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(Qc.error("prepare_external_dependency_script returned null"),null):e}hf(){var e,t,i,s,n,r,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const l=null==u?void 0:u.defaultView,c=null==l||null===(e=l.Node)||void 0===e?void 0:e.prototype;if(!l||!c)return()=>{};if(this.sf++,this.cf)return this.df();const d=[],h=this,p=new WeakSet,v=(e,t,i)=>{if(!(null==e?void 0:e[t]))return;const s=e[t];e[t]=i(s),d.push(()=>{e[t]=s})},f=e=>{if(p.has(e))return e;const t=h.uf(e);return t&&p.add(t),t},g=e=>e.map(e=>"string"==typeof e?e:f(e)).filter(e=>!B(e));return v(c,"appendChild",e=>function(t){const i=f(t);return i?e.call(this,i):t}),v(c,"insertBefore",e=>function(t,i){const s=f(t);return s?e.call(this,s,i):t}),v(c,"replaceChild",e=>function(t,i){const s=f(t);return s?e.call(this,s,i):i}),[null===(t=l.Element)||void 0===t?void 0:t.prototype,null===(i=l.Document)||void 0===i?void 0:i.prototype,null===(s=l.DocumentFragment)||void 0===s?void 0:s.prototype].forEach(e=>{v(e,"append",e=>function(...t){return e.apply(this,g(t))}),v(e,"prepend",e=>function(...t){return e.apply(this,g(t))})}),[null===(n=l.Element)||void 0===n?void 0:n.prototype,null===(r=l.CharacterData)||void 0===r?void 0:r.prototype,null===(o=l.DocumentType)||void 0===o?void 0:o.prototype].forEach(e=>{v(e,"before",e=>function(...t){return e.apply(this,g(t))}),v(e,"after",e=>function(...t){return e.apply(this,g(t))}),v(e,"replaceWith",e=>function(...t){const i=g(t);return t.length&&!i.length?void 0:e.apply(this,i)})}),v(null===(a=l.Element)||void 0===a?void 0:a.prototype,"insertAdjacentElement",e=>function(t,i){const s=f(i);return s?e.call(this,t,s):null}),this.cf=()=>{d.forEach(e=>e()),this.cf=void 0},this.df()}df(){let e=!1;return()=>{var t;e||(e=!0,this.sf--,0===this.sf&&(null===(t=this.cf)||void 0===t||t.call(this)))}}vf(e,t=!0){const i=this.hf();try{const s=e(i);return t&&i(),s}catch(e){throw i(),e}}setupSiteApp(e){const t=this.apps[e.id],i=()=>{var i;!t.errored&&this.rf.length&&(Qc.info(`Processing ${this.rf.length} events for site app with id ${e.id}`),this.rf.forEach(e=>this.vf(()=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null===(i=this.af)||void 0===i||i.call(this))};let s=!1;const n=n=>{t.errored=!n,t.loaded=!0,Qc.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),s&&i()};try{const{processEvent:i}=this.vf(t=>e.init({posthog:this._instance,callback(e){t(),n(e)}}),!1);i&&(t.processEvent=i),s=!0}catch(t){Qc.error(eu+e.id,t),n(!1)}if(s&&t.loaded)try{i()}catch(i){Qc.error(`Error while processing buffered events PostHog app with config id ${e.id}`,i),t.errored=!0}}ff(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}pf(e){if(0===Object.keys(this.apps).length)return;const t=this.globalsForEvent(e);for(const i of Object.values(this.apps))try{this.vf(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})}catch(t){Qc.error(`Error while processing event ${e.event} for site app ${i.id}`,t)}}onRemoteConfig(e){var t,i,s;if(null===(t=this.siteAppLoaders)||void 0===t?void 0:t.length)return this.isEnabled?(this.ff(),void this._instance.on("eventCaptured",e=>this.pf(e))):void Qc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this.af)||void 0===i||i.call(this),!e.ok)return;const n=e.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:e,url:t}of n.siteApps){var r,o;y[`__$$ph_site_app_${e}`]=this._instance,null===(r=y.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,t,t=>{if(t)return Qc.error(eu+e,t)})}else Qc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ed={tracingHeaders:class{constructor(e){this._instance=e,this.gf=void 0,this.mf=void 0,this.yf=void 0,this.Rv=()=>{const e=this.bf();var t,i;e?(D(this.gf)&&(this.gf=null===(t=y.__PosthogExtensions__)||void 0===t||null===(t=t.tracingHeadersPatchFns)||void 0===t?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),D(this.mf)&&(this.mf=null===(i=y.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Nv()}}initialize(){this.startIfEnabledOrStop()}No(e){var t,i,s;(null===(t=y.__PosthogExtensions__)||void 0===t?void 0:t.tracingHeadersPatchFns)?e():null===(i=y.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"tracing-headers",t=>{if(t)return jc.error("failed to load script",t);e()})}_f(){var e,t;return null!==(e=null!==(t=this._instance.config.tracing_headers)&&void 0!==t?t:this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}bf(){const e=this._f();return I(e)?(I(this.yf)?this.yf.splice(0,this.yf.length,...e):this.yf=[...e],e.length>0?this.yf:void 0):(I(this.yf)&&this.yf.splice(0),this.yf=e||void 0,this.yf)}Nv(){var e,t;null===(e=this.gf)||void 0===e||e.call(this),null===(t=this.mf)||void 0===t||t.call(this),this.gf=void 0,this.mf=void 0}startIfEnabledOrStop(){this.bf()?this.No(this.Rv):this.Nv()}}},td=Ot({surveys:class extends nu{constructor(e){var t;super(new uu(e),(t=e,{get projectToken(){return t.config.token},kv:new cu(t)})),this._instance=e}Mh(e,t){const i=t.query?gl(e,t.query):e;return new Promise(e=>{var s;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor(null!==(s=t.target)&&void 0!==s?s:"api",i),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:e})})}}},Ku),id={toolbar:class{constructor(e){this.instance=e}wf(e){y.ph_toolbar_state=e}kf(){var e;return null!==(e=y.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,i=void 0){var s,n;if(sr(this.instance.config))return!1;if(!a||!u)return!1;e=null!==(s=e)&&void 0!==s?s:a.location,i=null!==(n=i)&&void 0!==n?n:a.history;try{if(!t){try{a.localStorage.setItem("test","test"),a.localStorage.removeItem("test")}catch(e){return!1}t=null==a?void 0:a.localStorage}const s=du||Do(e.hash,"__posthog")||Do(e.hash,"state");let n;const r=s?mt(()=>JSON.parse(atob(decodeURIComponent(s))))||mt(()=>JSON.parse(decodeURIComponent(s))):null;return r&&"ph_authorize"===r.action?(n=r,n.source="url",n&&Object.keys(n).length>0&&(r.desiredHash?e.hash=r.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):(n=JSON.parse(t.getItem(hu)||"{}"),n.source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(e){return!1}}Sf(e){const t=y.ph_load_toolbar||y.ph_load_editor;!U(t)&&R(t)?t(e,this.instance):pu.warn("No toolbar load function found")}loadToolbar(e){const t=!!(null==u?void 0:u.getElementById("__POSTHOG_TOOLBAR__"));if(!a||t)return!1;const i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=Ot(Ot({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(a.localStorage.setItem(hu,JSON.stringify(Ot(Ot({},s),{},{source:void 0}))),2===this.kf())this.Sf(s);else if(0===this.kf()){var n,r;this.wf(1),null===(n=y.__PosthogExtensions__)||void 0===n||null===(r=n.loadExternalDependency)||void 0===r||r.call(n,this.instance,"toolbar",e=>{if(e)return pu.error("[Toolbar] Failed to load",e),void this.wf(0);this.wf(2),this.Sf(s)}),ir(a,"turbolinks:load",()=>{this.wf(0),this.loadToolbar(s)})}return!0}xf(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},sd=Ot({experiments:class e{get Mr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{e.Cf("retrieved web experiments from the server"),this.$f=new Map,t.forEach(t=>{if(t.feature_flag_key){var i;this.$f&&(e.Cf("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(i=this.$f)||void 0===i||i.set(t.feature_flag_key,t));const s=this._instance.getFeatureFlag(t.feature_flag_key);N(s)&&t.variants[s]&&this.Tf(t.name,s,t.variants[s].transforms)}else if(t.variants)for(const i in t.variants){const s=t.variants[i];e.If(s,this._instance)&&this.Tf(t.name,i,s.transforms)}})},t)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Cf(Ou);else if(!this.Mr.disable_web_experiments){if(U(this.$f))return this.$f=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Cf("applying feature flags",t),t.forEach(e=>{var t;if(this.$f&&(null===(t=this.$f)||void 0===t?void 0:t.has(e))){var i;const t=this._instance.getFeatureFlag(e),s=null===(i=this.$f)||void 0===i?void 0:i.get(e);t&&(null==s?void 0:s.variants[t])&&this.Tf(s.name,t,s.variants[t].transforms)}})}}previewWebExperiment(){const t=e.getWindowLocation();if(null==t?void 0:t.search){const i=Ao(null==t?void 0:t.search,"__experiment_id"),s=Ao(null==t?void 0:t.search,"__experiment_variant");i&&s&&(e.Cf(`previewing web experiments ${i} && ${s}`),this.getWebExperiments(e=>{this.Mf(parseInt(i),s,e)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.Mr.disable_web_experiments&&!i)return e([]);const s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}Mf(t,i,s){const n=s.filter(e=>e.id===t);n&&n.length>0&&(e.Cf(`Previewing web experiment [${n[0].name}] with variant [${i}]`),this.Tf(n[0].name,i,n[0].variants[i].transforms))}static If(t,i){return!U(t.conditions)&&e.Ef(t,i)&&e.Pf(t)}static Ef(t,i){var s;if(U(t.conditions)||U(null===(s=t.conditions)||void 0===s?void 0:s.url))return!0;const n=e.getWindowLocation();if(n){var r,o,a;const e=Ir(i,n.href);return!(null===(r=t.conditions)||void 0===r?void 0:r.url)||Tu[null!==(o=null===(a=t.conditions)||void 0===a?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,e)}return!1}static getWindowLocation(){return null==a?void 0:a.location}static Pf(e){var t;if(U(e.conditions)||U(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=qo();if(i.utm_source){var s,n,r,o,a,l,c,u;const t=!(null===(s=e.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=e.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==i.utm_campaign,d=!(null===(r=e.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=e.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==i.utm_source,h=!(null===(a=e.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)||(null===(l=e.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)==i.utm_medium,p=!(null===(c=e.conditions)||void 0===c||null===(c=c.utm)||void 0===c?void 0:c.utm_term)||(null===(u=e.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==i.utm_term;return t&&h&&p&&d}return!1}static Cf(e,...t){ts.info(`[WebExperiments] ${e}`,t)}Tf(t,i,s){this._is_bot()?e.Cf(Ou):"control"!==i?s.forEach(s=>{if(s.selector){var n;e.Cf(`applying transform of variant ${i} for experiment ${t} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(e=>{const t=e;s.html&&(t.innerHTML=s.html),s.css&&t.setAttribute("style",s.css)})}}):e.Cf("Control variants leave the page unmodified.")}_is_bot(){return c&&this._instance?Nl(c,this.Mr.custom_blocked_useragents):void 0}}},Ku),nd={conversations:class{constructor(e){this._instance=e,this.Rf=void 0,this._conversationsManager=null,this.Af=!1,this.ne=null,this.Ff=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations)return;if(this.Of=e.ok,!e.ok)return;const t=e.config.conversations;U(t)||(q(t)?this.Rf=t:(this.Rf=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;null===(e=this._conversationsManager)||void 0===e||e.reset(),this._conversationsManager=null,this.Rf=void 0,this.ne=null,this.Of=void 0,this.Ff=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this.Af)return;if(this._instance.config.disable_conversations)return;if(sr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=null==y?void 0:y.__PosthogExtensions__;if(e&&!D(this.Rf)&&this.Rf)if(this.ne&&this.ne.token){this.Af=!0;try{const t=e.initConversations;if(t)return this.Df(t),void(this.Af=!1);const i=e.loadExternalDependency;if(!i)return void this.Lf(Dn);i(this._instance,"conversations",t=>{t||!e.initConversations?this.Lf("Could not load conversations script",t):this.Df(e.initConversations),this.Af=!1})}catch(e){this.Lf("Error initializing conversations",e),this.Af=!1}}else Fu.error("Conversations enabled but missing token in remote config.")}Df(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.Ff=!1,Fu.info("Conversations loaded successfully")}catch(e){this.Lf("Error completing conversations initialization",e)}else Fu.error("Cannot complete initialization: remote config is null")}Lf(e,t){Fu.error(e,t),this._conversationsManager=null,this.Af=!1,this.Ff=!0}show(){this._conversationsManager?this._conversationsManager.show():Fu.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Rf&&!B(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":sr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Of?"remote_config_failed":D(this.Rf)?this.Of?"disabled_in_project":"remote_config_pending":this.Rf?U(this.ne)||!this.ne.token?"missing_token":(null==y?void 0:y.__PosthogExtensions__)?this.Af?"initializing":this.Ff?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var s=this;return ie(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(Fu.warn(Cu),null)})()}getMessages(e,t){var i=this;return ie(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Fu.warn(Cu),null)})()}markAsRead(e){var t=this;return ie(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Fu.warn(Cu),null)})()}getTickets(e){var t=this;return ie(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Fu.warn(Cu),null)})()}requestRestoreLink(e){var t=this;return ie(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Fu.warn(Cu),null)})()}restoreFromToken(e){var t=this;return ie(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Fu.warn(Cu),null)})()}restoreFromUrlToken(){var e=this;return ie(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Fu.warn(Cu),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}dh(){var e;null===(e=this._conversationsManager)||void 0===e||e.setIdentity()}fh(){var e;null===(e=this._conversationsManager)||void 0===e||e.clearIdentity()}}},rd={logs:class{constructor(e){var t;this._instance=e,this.name="logs",this.Nf=!1,this.qf=!1,this.jf=!1,this.$=is("[logs]"),this.Bf=Ot(Ot({},this.$),{},{error:(...e)=>{e.some(ju)||this.$.error(...e)}}),this.ia=[],this.Hf=[],this.Yc=0,this.So=!1,this.zf=[],this.Uf=[],this.Wf=!1,this.Vf=!1,this.Gf=()=>{var e,t;this.So||(this.Yc=0,null===(e=this.Zf)||void 0===e||e.onReconnect(),null===(t=this.Qf)||void 0===t||t.onReconnect())},this._instance&&(null===(t=this._instance.config.logs)||void 0===t?void 0:t.captureConsoleLogs)&&(this.Nf=!0),a&&ir(a,"online",this.Gf)}Jf(e,t,i,s){var n;const r=Iu(null===(n=this._instance)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.logs,i);return[new Yi(this.Kf(e,t),r,this.Bf,()=>this.Xf(),e=>e(),void 0,s),r]}Yf(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs;var i;return this.Zf&&this.tp===t||(null===(i=this.Zf)||void 0===i||i.reset(),this.tp=t,[this.Zf,this.ep]=this.Jf(()=>this.ia,e=>{this.ia=e})),this.Zf}np(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs;var i;return this.Qf&&this.sp===t||(null===(i=this.Qf)||void 0===i||i.reset(),this.sp=t,[this.Qf,this.rp]=this.Jf(()=>this.Hf,e=>{this.Hf=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Lu)),this.Qf}setup(e){var t;if(this.So)return;this.po=e,(null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t||null===(t=t.logs)||void 0===t?void 0:t.captureConsoleLogs)&&(this.Nf=!0),(this.Nf||this.op()&&this.lp())&&this.ap();let i=!1;const s=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this.So?s.dispose():(this.$o=s,i||this.loadIfEnabled())}dispose(){var e,t,i,s;this.So||(this.So=!0,this.up(),null===(e=this.$o)||void 0===e||e.dispose(),this.$o=void 0,this.po=void 0,this.jf=!1,null==a||a.removeEventListener("online",this.Gf),null===(t=this.hp)||void 0===t||t.call(this),this.hp=void 0,null===(i=this.Zf)||void 0===i||i.reset(),null===(s=this.Qf)||void 0===s||s.reset())}onRemoteConfig(e){var t,i;if(this.So)return;const s=e.ok?null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs:void 0;U(s)?this.cp():(null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$logs_capture_enabled_server_side:!!s}),s?(this.Nf=!0,this.qf||this.ap(),this.loadIfEnabled()):this.cp())}reset(){var e,t,i,s;this.up(),null===(e=this.Zf)||void 0===e||e.clearQueue(),this.ia=[],null===(t=this.Zf)||void 0===t||t.reset(),null===(i=this.Qf)||void 0===i||i.clearQueue(),this.Hf=[],null===(s=this.Qf)||void 0===s||s.reset(),this.Yc=0}captureLog(e){this.So||this.Yf().captureLog(e)}captureConsoleLog(e){this.So||this.np().captureLog(e)}captureBufferedConsoleLog(e,t,i){this.So||this.np().captureLog(e,{context:t,occurredAtMs:i})}lp(){var e;return!!(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e[ks])}op(){var e,t,i;return!(null===(e=this._instance)||void 0===e||null===(t=e.Xl)||void 0===t?void 0:t.call(e))||!!(null===(i=y._POSTHOG_REMOTE_CONFIG)||void 0===i||null===(i=i[this._instance.config.token])||void 0===i?void 0:i.config)}gh(){var e;this.up(),null===(e=this.Qf)||void 0===e||e.clearQueue(),this.Hf=[]}cp(){this.Nf||this.up()}ap(){var e;if(this.Wf||!(null==y?void 0:y.console))return;const t=Iu(null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.logs).maxBufferSize;let i=!0;this.Uf.push(()=>{i=!1});for(const s of Ru){let n;try{n=Au(y.console[s])}catch(e){continue}n&&this.Uf.push(Nc(y.console,s,e=>{const r=(...n)=>{try{i&&this.dp(s,n,t)}catch(e){}return e.apply(y.console,n)};return r.__rrweb_original__=n,r}))}this.Wf=!0,this.vp=setTimeout(()=>{this.up()},3e4)}dp(e,t,i){var s;if(this.Wf&&!this.Vf&&0!==t.length)if(null===(s=this._instance)||void 0===s?void 0:s.is_capturing()){if(i>this.zf.length){this.Vf=!0;try{this.zf.push({level:e,args:t,occurredAtMs:Date.now(),context:this.Xf()})}finally{this.Vf=!1}}}else this.up()}up(){if(this.zf=[],this.Wf){this.Wf=!1,this.vp&&(clearTimeout(this.vp),this.vp=void 0);for(const e of this.Uf)e();this.Uf=[]}}fp(){const e=this.zf;return this.up(),e}get logger(){return this.pp||(this.pp={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this.pp}flushLogs(e){e?this.gp(e):(this.Zf&&this.Zf.flush().catch(e=>this.mp(e)),this.Qf&&this.Qf.flush().catch(e=>this.mp(e)))}mp(e){ju(e)||this.$.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.So||!this.Nf||this.qf||this.jf)return;const e=null==y?void 0:y.__PosthogExtensions__;if(!e)return this.$.error("PostHog Extensions not found."),void this.up();const t=e.loadExternalDependency;if(!t)return this.$.error(Dn),void this.up();this.jf=!0;try{t(this._instance,"logs",t=>{if(this.jf=!1,this.So||!this.Nf)return;const i=e.logs;if(t||!(null==i?void 0:i.initializeLogs))this.$.error("Could not load logs script",t),this.up();else{var s;const e=this.fp();var n,r;this.hp=i.initializeLogs(null!==(s=this.po)&&void 0!==s?s:this._instance),this.qf=!0,e.length>0&&(null===(n=i.replayConsoleBuffer)||void 0===n||n.call(i,null!==(r=this.po)&&void 0!==r?r:this._instance,e))}})}catch(e){throw this.jf=!1,e}}Kf(e,t){const i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:t=>t===x.LogsQueue?e():void 0,setPersistedProperty(e,i){var s;e===x.LogsQueue&&t(null!==(s=i)&&void 0!==s?s:[])},js:e=>this.js(e),getLibraryId:()=>ls.LIB_NAME,getLibraryVersion:()=>ls.LIB_VERSION}}js(e){return new Promise(t=>{if(No(this.Yc,3))return void t({kind:"fatal",error:Nu(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1;const s=e=>{i||(i=!0,clearTimeout(n),t(e))},n=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Nu(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.yp(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:e=>{const t=e.statusCode;if(this.bp(t),t>=200&&300>t)s({kind:"ok"});else if(413===t)s({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)s({kind:"fatal",error:new Error(`logs request failed with status ${t}`)});else{var i;0===t?(e.error||this.$.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Nu(e.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`logs request failed with status ${t}`)})}}})})}bp(e){(0!==e||this._instance.__loaded)&&(this.Yc=jo(e,this.Yc,3,()=>this.$.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}gp(e){this.ia.length>0&&this._p(e,this.ia,this.ep,ls.LIB_NAME,e=>{this.ia=e}),this.Hf.length>0&&this._p(e,this.Hf,this.rp,Lu,e=>{this.Hf=e})}_p(e,t,i,s,n){if(0===t.length)return;const r=t.map(e=>e.record);n([]);const o=Vi(r,qi(i,ls.LIB_NAME,ls.LIB_VERSION),s,ls.LIB_VERSION);this._instance._send_request({method:"POST",url:this.yp(),data:o,compression:"best-available",batchKey:"logs",transport:e})}yp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Xf(){var e;const t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:e,windowId:i,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=e,t.windowId=i,U(s)||(t.sessionStartTimestamp=s),U(n)||(t.lastActivityTimestamp=n)}if((null==y||null===(e=y.location)||void 0===e?void 0:e.href)&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?_t(y.location.href):y.location.href),this._instance.featureFlags){const e=this._instance.featureFlags.getFlags();e&&e.length>0&&(t.activeFeatureFlags=e)}return t}}},od={metrics:class{constructor(e){this._instance=e,this.$=is("[metrics]"),this.So=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this.So)return;const t=!!(null===(e=this._instance.config.metrics)||void 0===e?void 0:e.network);t&&!this.wp?this.wp=(e=>{let t=!0;const i=()=>t?(e=>{var t;const i=null===(t=e.config.metrics)||void 0===t?void 0:t.network;return!0===i?{}:i||void 0})(e):void 0,s=Wu(e,i),n=Gu(e,i);return()=>{t=!1,s(),n()}})(this._instance):!t&&this.wp&&(this.wp(),this.wp=void 0)}Yf(){var e;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.metrics;var i;return this.Zf&&this.tp===t||(null===(i=this.Zf)||void 0===i||i.reset(),this.tp=t,this.Zf=new Qi(this.Kf(),(function(e){var t,i,s,n,r;const o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(n=null==e?void 0:e.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==r?r:1e3}})(t),this.$)),this.Zf}count(e,t=1,i){this.Yf().count(e,t,i)}gauge(e,t,i){this.Yf().gauge(e,t,i)}histogram(e,t,i){this.Yf().histogram(e,t,i)}flush(e){if(!this.Zf)return Promise.resolve();if(e){const t=this.Zf.drainWindow();return t&&this.Ys(t,e),Promise.resolve()}return this.Zf.flush().catch(e=>this.$.error("PostHog metrics flush failed:",e))}reset(){var e;null===(e=this.Zf)||void 0===e||e.reset()}dispose(){var e,t;this.So=!0,null===(e=this.wp)||void 0===e||e.call(this),this.wp=void 0,null===(t=this.Zf)||void 0===t||t.reset()}Kf(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Ys:e=>t.Ys(e),getLibraryId:()=>ls.LIB_NAME,getLibraryVersion:()=>ls.LIB_VERSION}}Ys(e,t){return new Promise(i=>{let s=!1;const n=e=>{s||(s=!0,clearTimeout(r),i(e))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(Ot(Ot({method:"POST",url:this.kp(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){const t=e.statusCode;if(t>=200&&300>t)n({kind:"ok"});else if(413===t)n({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)n({kind:"fatal",error:new Error(`metrics request failed with status ${t}`)});else{var i;n({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`metrics request failed with status ${t}`)})}}}))})}kp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};kc.__defaultExtensionClasses=Ot({},Ot(Ot(Ot(Ot(Ot(Ot(Ot(Ot(Ot(Ot(Ot(Ot(Ot({},Ku),Yu),Ju),Zu),Xu),Qu),td),ed),id),sd),nd),rd),od));const ad=(function(){ls.SDK_DIST_CHANNEL="npm";const e=cc[yc]=new kc;return(function(){function e(){e.done||(e.done=!0,bc=!1,Kn(cc,function(e){e._dom_loaded()}))}(null==u?void 0:u.addEventListener)?"complete"===u.readyState?e():ir(u,"DOMContentLoaded",e,{capture:!1}):a&&ts.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();var ld=ad},4481,[]);
|
|
16241
|
-
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return v}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),c=r(d[4]);r(d[5]);var o,u=r(d[6]),l=(o=u)&&o.__esModule?o:{default:o};r(d[7]);var f=r(d[8]),S=r(d[9]),_=r(d[10]),b=r(d[11]),y=r(d[12]);const h=
|
|
16241
|
+
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return v}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),c=r(d[4]);r(d[5]);var o,u=r(d[6]),l=(o=u)&&o.__esModule?o:{default:o};r(d[7]);var f=r(d[8]),S=r(d[9]),_=r(d[10]),b=r(d[11]),y=r(d[12]);const h=24e3;function j(e){const t=S.useSessionStore.getState().sessions;for(const n of Object.keys(t))if(t[n]?.agents.has(e))return n;return null}function v(){const o=(0,n.c)(17),u=(0,s.useLocalSearchParams)(),l=Array.isArray(u.agentId)?u.agentId[0]:u.agentId,v=(0,s.usePathname)();let x;o[0]!==l?(x=()=>l?j(l):null,o[0]=l,o[1]=x):x=o[1];const[P,R]=(0,c.useState)(x),[A,O]=(0,c.useState)(!1),p=(0,c.useRef)(!1);let E,H,T,w,M;if(o[2]!==l||o[3]!==P?(E=()=>{if(!l||P)return;const e=()=>{const e=j(l);e&&R(e)};e();const t=S.useSessionStore.subscribe(e),n=setTimeout(()=>O(!0),h);return()=>{t(),clearTimeout(n)}},H=[l,P],o[2]=l,o[3]=P,o[4]=E,o[5]=H):(E=o[4],H=o[5]),(0,c.useEffect)(E,H),o[6]!==l||o[7]!==v||o[8]!==P?(T=()=>{!p.current&&l&&P&&(p.current=!0,(0,b.navigateToAgent)({serverId:P,agentId:l,currentPathname:v,pin:!0}))},w=[l,P,v],o[6]=l,o[7]=v,o[8]=P,o[9]=T,o[10]=w):(T=o[9],w=o[10]),(0,c.useEffect)(T,w),!l){let e;return o[11]===Symbol.for("react.memo_cache_sentinel")?(e=(0,y.jsx)(s.Redirect,{href:"/"}),o[11]=e):e=o[11],e}if(A&&!P){let e,t,n;if(o[12]===Symbol.for("react.memo_cache_sentinel")){const n=(0,f.getHostRuntimeStore)().getEarliestOnlineHostServerId();e=s.Redirect,t=n?(0,_.buildHostKanbanRoute)(n):"/welcome",o[12]=e,o[13]=t}else e=o[12],t=o[13];return o[14]!==t?(n=(0,y.jsx)(e,{href:t}),o[14]=t,o[15]=n):n=o[15],n}return o[16]===Symbol.for("react.memo_cache_sentinel")?(M=(0,y.jsx)(e.View,{style:I.container,children:(0,y.jsx)(t.ActivityIndicator,{})}),o[16]=M):M=o[16],M}const I=l.default.create({container:{alignItems:"center",flex:1,justifyContent:"center"}})},4482,[348,2477,350,379,36,654,59,146,3274,3427,3492,3499,279]);
|
|
16242
16242
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});var t=r(d[0]),s=r(d[1]),n=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),l=r(d[6]);const S={headerShown:!1,animation:"none"},f={gestureEnabled:!1};function k(){const s=(0,t.c)(1);let n;return s[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,l.jsx)(p,{}),s[0]=n):n=s[0],n}function p(){const k=(0,t.c)(10),p=(0,s.useLocalSearchParams)(),h=(0,u.useHosts)(),j=(0,u.useHostRegistryStatus)(),x=(0,n.useHostRuntimeBootstrapState)(),v="string"==typeof p.serverId?p.serverId:null;let _;k[0]!==x.startupBlocker||k[1]!==j||k[2]!==h||k[3]!==v?(_=(0,c.resolveStartupRoute)({route:{kind:"host",serverId:v},startupBlocker:x.startupBlocker,hostRegistryStatus:j,hosts:h}),k[0]=x.startupBlocker,k[1]=j,k[2]=h,k[3]=v,k[4]=_):_=k[4];const y=_;if("redirect"===y.kind){let t;return k[5]!==y.href?(t=(0,l.jsx)(s.Redirect,{href:y.href}),k[5]=y.href,k[6]=t):t=k[6],t}let b;k[7]===Symbol.for("react.memo_cache_sentinel")?(b=(0,l.jsxs)(s.Stack,{screenOptions:S,children:[(0,l.jsx)(s.Stack.Screen,{name:"index"}),(0,l.jsx)(s.Stack.Screen,{name:"workspace/[workspaceId]/index"}),(0,l.jsx)(s.Stack.Screen,{name:"agent/[agentId]",options:f}),(0,l.jsx)(s.Stack.Screen,{name:"sessions"}),(0,l.jsx)(s.Stack.Screen,{name:"open-project"}),(0,l.jsx)(s.Stack.Screen,{name:"settings"})]}),k[7]=b):b=k[7];const I=b;if(!v)return I;let R;return k[8]!==v?(R=(0,l.jsx)(o.HostRouteProvider,{serverId:v,children:I}),k[8]=v,k[9]=R):R=k[9],R}},4483,[350,379,2478,4484,4196,3274,279]);
|
|
16243
16243
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.HostRouteProvider=function(n){const s=(0,t.c)(3),{children:l,serverId:v}=n;let f;(0,o.useKanbanBoardSync)(v),s[0]!==l||s[1]!==v?(f=(0,u.jsx)(c.Provider,{value:v,children:l}),s[0]=l,s[1]=v,s[2]=f):f=s[2];return f},e.useHostRouteServerId=function(){return(0,n.useContext)(c)};var t=r(d[0]),n=r(d[1]),o=r(d[2]),u=r(d[3]);const c=(0,n.createContext)(null)},4484,[350,36,4485,279]);
|
|
16244
16244
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useKanbanBoardSync=function(s){const f=(0,u.useHostFeature)(s,"kanbanBoardConfig"),b=Boolean(s)&&f,{config:B,patchConfig:k}=(0,n.useDaemonConfig)(b?s:null),p=b?B?.kanbanBoard:void 0,v=(0,t.useRef)(!1),S=(0,t.useRef)(k);S.current=k,(0,t.useEffect)(()=>{v.current=!1},[s]),(0,t.useEffect)(()=>{if(!b||!B)return;if(void 0===p)return v.current=!0,void S.current({kanbanBoard:l((0,o.getKanbanBoardSnapshot)())});const t={buckets:(n=p).buckets.map(t=>Object.assign({id:t.id,label:t.label},"number"==typeof t.limit?{limit:t.limit}:{})),defaultBucketId:n.defaultBucketId};var n;v.current=!0,(0,o.isSameKanbanBoard)(t,(0,o.getKanbanBoardSnapshot)())||o.useKanbanBoardStore.getState().applyRemoteBoard(t)},[b,B,p]),(0,t.useEffect)(()=>{if(!b)return;let t=null,n=null;const u=()=>{t=null;const u=n;n=null,u&&S.current({kanbanBoard:l(u)})},s=(0,o.subscribeToLocalBoardChanges)(o=>{v.current&&(n=o,t&&clearTimeout(t),t=setTimeout(u,c))});return()=>{s(),t&&(clearTimeout(t),u())}},[b])};var t=r(d[0]),n=r(d[1]),u=r(d[2]),o=r(d[3]);const c=400;function l(t){return{buckets:t.buckets.map(t=>Object.assign({id:t.id,label:t.label},"number"==typeof t.limit?{limit:t.limit}:{})),defaultBucketId:t.defaultBucketId}}},4485,[36,3929,3609,4007]);
|
|
@@ -16540,7 +16540,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
16540
16540
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.InboxRow=function(s){const c=(0,t.c)(65),{row:y,isFirst:O,onAction:z}=s;let D;c[0]!==O?(D=O?[j.row,j.rowFirst]:j.row,c[0]=O,c[1]=D):D=c[1];const T=D;let L;c[2]!==y?(L=(0,x.openSessionFromRow)(y),c[2]=y,c[3]=L):L=c[3];const A=L,N=y.agentId;let E;c[4]!==N||c[5]!==y.serverId||c[6]!==y.workspaceId?(E=()=>{null!==N&&0!==N.trim().length&&(0,b.navigateToAgent)({serverId:y.serverId,agentId:N,workspaceId:y.workspaceId})},c[4]=N,c[5]=y.serverId,c[6]=y.workspaceId,c[7]=E):E=c[7];const M=E;let R;c[8]!==z||c[9]!==M||c[10]!==y?(R=n=>{n!==v&&(n!==_||"needs_information"!==y.wall)?z(y,n):M()},c[8]=z,c[9]=M,c[10]=y,c[11]=R):R=c[11];const V=R,[W,k]=(0,l.useState)(null),[q,F]=(0,l.useState)(!1);let P;c[12]!==N||c[13]!==y.informationOptions||c[14]!==y.informationRequest||c[15]!==y.serverId?(P=n=>{const o=y.informationRequest,s=y.informationOptions.find(o=>o.id===n);o&&s&&null!==N&&(k(null),F(!0),(0,p.answerNeedsInformation)({serverId:y.serverId,agentId:N,requestId:o.requestId,input:o.input,header:o.header,label:s.label}).catch(n=>{k((0,I.toErrorMessage)(n))}).finally(()=>F(!1)))},c[12]=N,c[13]=y.informationOptions,c[14]=y.informationRequest,c[15]=y.serverId,c[16]=P):P=c[16];const H=P;let B;c[17]!==A?(B=null===A?[v]:void 0,c[17]=A,c[18]=B):B=c[18];const $=B,C=`inbox-row-${y.runId}`,U=`inbox-row-body-${y.runId}`,G=null===A?null:M,J="failed"===y.wall?"error":"muted";let K,Q,X,Y,Z,ee,ne,oe,re,se,te,ie;c[19]!==y.wall||c[20]!==J?(K=(0,h.jsx)(n.View,{testID:"inbox-row-wall",children:(0,h.jsx)(w.StatusBadge,{label:y.wall,variant:J})}),c[19]=y.wall,c[20]=J,c[21]=K):K=c[21];c[22]!==y.sourceLabel?(Q=(0,h.jsx)(o.Text,{style:j.source,numberOfLines:1,children:y.sourceLabel}),c[22]=y.sourceLabel,c[23]=Q):Q=c[23];c[24]!==y.age?(X=(0,h.jsx)(o.Text,{style:j.age,children:y.age}),c[24]=y.age,c[25]=X):X=c[25];c[26]!==y.serverName||c[27]!==y.singleHost?(Y=y.singleHost?null:(0,h.jsx)(o.Text,{style:j.host,children:y.serverName}),c[26]=y.serverName,c[27]=y.singleHost,c[28]=Y):Y=c[28];c[29]!==K||c[30]!==Q||c[31]!==X||c[32]!==Y?(Z=(0,h.jsxs)(n.View,{style:j.header,children:[K,Q,X,Y]}),c[29]=K,c[30]=Q,c[31]=X,c[32]=Y,c[33]=Z):Z=c[33];c[34]!==y.reason?(ee=(0,h.jsx)(o.Text,{style:j.reason,testID:"inbox-row-reason",children:y.reason}),c[34]=y.reason,c[35]=ee):ee=c[35];c[36]!==A?(ne=null===A?(0,h.jsx)(o.Text,{style:j.unavailable,testID:"inbox-row-session-unavailable",children:x.SESSION_UNAVAILABLE_REASON}):null,c[36]=A,c[37]=ne):ne=c[37];c[38]!==y.runId||c[39]!==y.verificationLabel?(oe=null===y.verificationLabel?null:(0,h.jsx)(o.Text,{style:j.unavailable,testID:`filter-run-verification-${y.runId}`,children:y.verificationLabel}),c[38]=y.runId,c[39]=y.verificationLabel,c[40]=oe):oe=c[40];c[41]!==Z||c[42]!==ee||c[43]!==ne||c[44]!==oe||c[45]!==U||c[46]!==G?(re=(0,h.jsxs)(S,{testID:U,onPress:G,children:[Z,ee,ne,oe]}),c[41]=Z,c[42]=ee,c[43]=ne,c[44]=oe,c[45]=U,c[46]=G,c[47]=re):re=c[47];c[48]!==W||c[49]!==H||c[50]!==q||c[51]!==y.informationOptions||c[52]!==y.informationOverflow||c[53]!==y.wall?(se="needs_information"===y.wall?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u.NeedsInformationOptions,{options:y.informationOptions,overflow:y.informationOverflow,onChoose:H,disabled:q}),null===W?null:(0,h.jsx)(o.Text,{style:j.answerError,testID:"inbox-option-error",children:W})]}):null,c[48]=W,c[49]=H,c[50]=q,c[51]=y.informationOptions,c[52]=y.informationOverflow,c[53]=y.wall,c[54]=se):se=c[54];c[55]!==$||c[56]!==V||c[57]!==y.wall?(te=(0,h.jsx)(f.WallActionsBar,{wall:y.wall,onAction:V,disabledActionIds:$}),c[55]=$,c[56]=V,c[57]=y.wall,c[58]=te):te=c[58];c[59]!==T||c[60]!==re||c[61]!==se||c[62]!==te||c[63]!==C?(ie=(0,h.jsxs)(n.View,{style:T,testID:C,children:[re,se,te]}),c[59]=T,c[60]=re,c[61]=se,c[62]=te,c[63]=C,c[64]=ie):ie=c[64];return ie};var n=r(d[0]),o=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4]);r(d[5]),r(d[6]),r(d[7]);var c=r(d[8]),u=r(d[9]),f=r(d[10]),w=r(d[11]),p=r(d[12]),x=r(d[13]),I=r(d[14]),b=r(d[15]),h=r(d[16]);const v="session",_="answer";function S(o){const l=(0,t.c)(7),{testID:c,onPress:u,children:f}=o;if(null===u){let o;return l[0]!==f||l[1]!==c?(o=(0,h.jsx)(n.View,{style:j.body,testID:c,children:f}),l[0]=f,l[1]=c,l[2]=o):o=l[2],o}let w;return l[3]!==f||l[4]!==u||l[5]!==c?(w=(0,h.jsx)(s.Pressable,{style:j.body,testID:c,onPress:u,children:f}),l[3]=f,l[4]=u,l[5]=c,l[6]=w):w=l[6],w}const j=c.StyleSheet.create(n=>({row:{borderTopWidth:1,borderTopColor:n.colors.border,paddingVertical:n.spacing[3],paddingHorizontal:n.spacing[3],gap:n.spacing[2],uni__dependencies:[0]},rowFirst:{borderTopWidth:0},body:{gap:n.spacing[2],uni__dependencies:[0]},header:{flexDirection:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:n.spacing[2],uni__dependencies:[0]},source:{color:n.colors.foreground,fontSize:n.fontSize.sm,fontWeight:n.fontWeight.medium,flexShrink:1,uni__dependencies:[0]},age:{color:n.colors.foregroundMuted,fontSize:n.fontSize.xs,uni__dependencies:[0]},host:{color:n.colors.foregroundMuted,fontSize:n.fontSize.xs,uni__dependencies:[0]},reason:{color:n.colors.foregroundMuted,fontSize:n.fontSize.sm,uni__dependencies:[0]},unavailable:{color:n.colors.foregroundMuted,fontSize:n.fontSize.xs,uni__dependencies:[0]},answerError:{color:n.colors.palette.red[300],fontSize:n.fontSize.xs,uni__dependencies:[0]}}))},4781,[348,349,2476,350,36,546,234,146,56,4782,4783,3636,4784,4785,3996,3499,279]);
|
|
16541
16541
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NeedsInformationOptions=function(t){const c=(0,s.c)(11),{options:b,overflow:x,onChoose:_,disabled:h}=t,{t:w}=(0,l.useTranslation)(),v=b.length>0;let y,j,S;c[0]!==h||c[1]!==v||c[2]!==_||c[3]!==b?(y=v?(0,p.jsx)(o.View,{style:f.options,children:b.map(o=>(0,p.jsx)(u,{option:o,onChoose:_,disabled:h},o.id))}):null,c[0]=h,c[1]=v,c[2]=_,c[3]=b,c[4]=y):y=c[4];c[5]!==x||c[6]!==w?(j=x?(0,p.jsx)(n.Text,{style:f.overflow,testID:"inbox-option-overflow",children:w("inbox.needsInformation.overflow")}):null,c[5]=x,c[6]=w,c[7]=j):j=c[7];c[8]!==y||c[9]!==j?(S=(0,p.jsxs)(o.View,{style:f.container,children:[y,j]}),c[8]=y,c[9]=j,c[10]=S):S=c[10];return S};var o=r(d[0]),n=r(d[1]),t=r(d[2]),s=r(d[3]);r(d[4]),r(d[5]),r(d[6]),r(d[7]);var l=r(d[8]),c=r(d[9]),p=r(d[10]);function u(o){const l=(0,s.c)(10),{option:c,onChoose:u,disabled:b}=o;let x;l[0]!==u||l[1]!==c.id?(x=()=>u(c.id),l[0]=u,l[1]=c.id,l[2]=x):x=l[2];const _=x,h=`inbox-option-${c.id}`;let w,v;return l[3]!==c.label?(w=(0,p.jsx)(n.Text,{style:f.optionLabel,children:c.label}),l[3]=c.label,l[4]=w):w=l[4],l[5]!==b||l[6]!==_||l[7]!==h||l[8]!==w?(v=(0,p.jsx)(t.Pressable,{accessibilityRole:"button",onPress:_,disabled:b,style:f.option,testID:h,children:w}),l[5]=b,l[6]=_,l[7]=h,l[8]=w,l[9]=v):v=l[9],v}const f=c.StyleSheet.create(o=>({container:{gap:o.spacing[2],alignItems:"flex-start",uni__dependencies:[0]},options:{flexDirection:"row",flexWrap:"wrap",gap:o.spacing[2],uni__dependencies:[0]},option:{paddingVertical:o.spacing[1],paddingHorizontal:o.spacing[3],borderRadius:o.borderRadius.base,backgroundColor:o.colors.surface2,uni__dependencies:[0]},optionLabel:{color:o.colors.foreground,fontSize:o.fontSize.sm,uni__dependencies:[0]},overflow:{color:o.colors.foregroundMuted,fontSize:o.fontSize.xs,uni__dependencies:[0]}}))},4782,[348,349,2476,350,36,546,234,146,352,56,279]);
|
|
16542
16542
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.wallVariantToButtonVariant=A,e.WallActionsBar=function(s){const o=(0,n.c)(14),{wall:l,onAction:f,disabledActionIds:A,hiddenActionIds:v}=s;let _,x,y,h;if(o[0]!==A||o[1]!==v||o[2]!==f||o[3]!==l){const n=v?c.WALL_ACTIONS[l].filter(t=>!v.includes(t.id)):c.WALL_ACTIONS[l];let s;_=t.View,x=p.actions,o[7]!==A||o[8]!==f?(s=t=>(0,u.jsx)(b,{action:t,onAction:f,disabled:A?.includes(t.id)??!1},t.id),o[7]=A,o[8]=f,o[9]=s):s=o[9],y=n.map(s),o[0]=A,o[1]=v,o[2]=f,o[3]=l,o[4]=_,o[5]=x,o[6]=y}else _=o[4],x=o[5],y=o[6];o[10]!==_||o[11]!==x||o[12]!==y?(h=(0,u.jsx)(_,{style:x,children:y}),o[10]=_,o[11]=x,o[12]=y,o[13]=h):h=o[13];return h};var t=r(d[0]),n=r(d[1]);r(d[2]),r(d[3]);var s=r(d[4]),o=r(d[5]),c=r(d[6]),l=r(d[7]),u=r(d[8]);const f={primary:"default",ghost:"ghost",danger:"destructive"};function A(t){return f[t]}function b(t){const o=(0,n.c)(14),{action:c,onAction:f,disabled:b}=t,{t:p}=(0,s.useTranslation)();let v;o[0]!==c.id||o[1]!==f?(v=()=>f(c.id),o[0]=c.id,o[1]=f,o[2]=v):v=o[2];const _=v;let x;o[3]!==c.variant?(x=A(c.variant),o[3]=c.variant,o[4]=x):x=o[4];const y=`inbox-action-${c.id}`;let h,I;return o[5]!==c.labelKey||o[6]!==p?(h=p(c.labelKey),o[5]=c.labelKey,o[6]=p,o[7]=h):h=o[7],o[8]!==b||o[9]!==_||o[10]!==x||o[11]!==y||o[12]!==h?(I=(0,u.jsx)(l.Button,{size:"xs",variant:x,disabled:b,onPress:_,testID:y,children:h}),o[8]=b,o[9]=_,o[10]=x,o[11]=y,o[12]=h,o[13]=I):I=o[13],I}const p=o.StyleSheet.create(t=>({actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:t.spacing[2],uni__dependencies:[0]}}))},4783,[348,350,36,146,352,56,4669,2475,279]);
|
|
16543
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.answerNeedsInformation=async function({serverId:u,agentId:c,requestId:y,input:b,header:f,label:p}){const v=(0,s.getHostRuntimeStore)().getSnapshot(u)?.client;if(!v)throw new Error(t.i18n.t("common.errors.daemonClientUnavailable"));try{await v.respondToPermissionAndWait(c,y,{behavior:"allow",updatedInput:Object.assign({},b,{answers:{[f]:p}})},l)}finally{o.queryClient.invalidateQueries({queryKey:n.inboxQueryBaseKey})}};var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]);const l=
|
|
16543
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.answerNeedsInformation=async function({serverId:u,agentId:c,requestId:y,input:b,header:f,label:p}){const v=(0,s.getHostRuntimeStore)().getSnapshot(u)?.client;if(!v)throw new Error(t.i18n.t("common.errors.daemonClientUnavailable"));try{await v.respondToPermissionAndWait(c,y,{behavior:"allow",updatedInput:Object.assign({},b,{answers:{[f]:p}})},l)}finally{o.queryClient.invalidateQueries({queryKey:n.inboxQueryBaseKey})}};var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]);const l=3e4},4784,[4665,3549,3445,3274]);
|
|
16544
16544
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SESSION_UNAVAILABLE_REASON",{enumerable:!0,get:function(){return n}}),e.openSessionFromRow=function(n){const o=n.agentId;if(null===o||0===o.trim().length)return null;return(0,t.buildHostAgentDetailRoute)(n.serverId,o,n.workspaceId??void 0)};var t=r(d[0]);const n="No session was started"},4785,[3492]);
|
|
16545
16545
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});var t=r(d[0]);r(d[1]);var s=r(d[2]),o=r(d[3]),n=r(d[4]),u=r(d[5]),c=r(d[6]),l=r(d[7]),p=r(d[8]),k=r(d[9]),S=r(d[10]);const h=(0,k.shouldUseDesktopDaemon)();function v(){const k=(0,t.c)(15),v=(0,s.usePathname)(),H=(0,n.useHostRuntimeBootstrapState)(),f=(0,n.useEarliestOnlineHostServerId)(),W=(0,c.useHosts)(),y=(0,c.useHostRegistryStatus)(),x=(0,p.useLastWorkspaceSelection)(),B=(0,p.useIsLastWorkspaceSelectionHydrated)(),I=x?.serverId??null,R=x?.workspaceId??null,U=(0,l.useHasHydratedWorkspaces)(I),b=(0,l.useWorkspaceExists)(I,R);let j;k[0]!==f||k[1]!==H.hasGivenUpWaitingForHost||k[2]!==H.startupBlocker||k[3]!==U||k[4]!==y||k[5]!==W||k[6]!==B||k[7]!==v||k[8]!==x||k[9]!==b?(j=(0,u.resolveStartupRoute)({route:{kind:"index",pathname:v},startupBlocker:H.startupBlocker,hostRegistryStatus:y,hosts:W,anyOnlineHostServerId:f,workspaceSelection:x,workspaceSelectionStatus:(0,u.resolveWorkspaceSelectionStatus)({hasHydratedWorkspaces:U,workspaceExists:b}),isWorkspaceSelectionLoaded:B,hasGivenUpWaitingForHost:H.hasGivenUpWaitingForHost}),k[0]=f,k[1]=H.hasGivenUpWaitingForHost,k[2]=H.startupBlocker,k[3]=U,k[4]=y,k[5]=W,k[6]=B,k[7]=v,k[8]=x,k[9]=b,k[10]=j):j=k[10];const w=j;if("redirect"===w.kind){let t;return k[11]!==w.href?(t=(0,S.jsx)(s.Redirect,{href:w.href}),k[11]=w.href,k[12]=t):t=k[12],t}const F=h?H:void 0;let G;return k[13]!==F?(G=(0,S.jsx)(o.StartupSplashScreen,{bootstrapState:F}),k[13]=F,k[14]=G):G=k[14],G}},4786,[350,36,379,4488,2478,4196,3274,3540,3502,3416,279]);
|
|
16546
16546
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]),o=r(d[2]),c=r(d[3]);function u(){const u=(0,t.c)(1);let s;return u[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,c.jsx)(n.HostRouteBootstrapBoundary,{children:(0,c.jsx)(o.LoopsScreen,{})}),u[0]=s):s=u[0],s}},4787,[350,4487,4788,279]);
|
|
@@ -16632,7 +16632,7 @@ __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{
|
|
|
16632
16632
|
__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fetchAgentHistoryPage=p,e.fetchAgentHistoryBatch=I,e.useAgentHistory=function(l){const u=(0,t.c)(51),{t:h}=(0,a.useTranslation)(),f=(0,o.useHosts)();let p;u[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.getHostRuntimeStore)(),u[0]=p):p=u[0];const j=p;let L,M,H;u[1]===Symbol.for("react.memo_cache_sentinel")?(L=t=>j.subscribeAll(t),M=()=>j.getVersion(),H=()=>j.getVersion(),u[1]=L,u[2]=M,u[3]=H):(L=u[1],M=u[2],H=u[3]);(0,s.useSyncExternalStore)(L,M,H);const O=l.serverId;let _;u[4]!==O?(_="string"==typeof O&&O.trim().length>0?O.trim():null,u[4]=O,u[5]=_):_=u[5];const x=_,k=l.enabled??!0;let B;u[6]!==f?(B=new Map(f.map(S)),u[6]=f,u[7]=B):B=u[7];const E=B;let T;if(u[8]!==f||u[9]!==x||u[10]!==E){const t=x?[x]:f.map(P);T=[];for(const n of t){const t=j.getSnapshot(n),s=j.getClient(n);s&&(0,o.isHostRuntimeConnected)(t)&&T.push({serverId:n,serverLabel:E.get(n)??n,client:s})}u[8]=f,u[9]=x,u[10]=E,u[11]=T}else T=u[11];const C=T;let N;u[12]!==C?(N=C.map(w),u[12]=C,u[13]=N):N=u[13];const R=N;let q;u[14]!==x||u[15]!==R?(q=x?(0,c.agentHistoryQueryKey)(x):(0,c.allAgentHistoryQueryKey)(R),u[14]=x,u[15]=R,u[16]=q):q=u[16];const F=q;let K;u[17]!==f?(K=new Map(f.map(A)),u[17]=f,u[18]=K):K=u[18];const Q=K,D=Boolean(k&&C.length>0);let V,z;u[19]!==h||u[20]!==C?(V=async t=>{const{pageParam:n}=t;if(0===C.length)throw new Error(h("workspace.terminal.hostDisconnected"));return I({hosts:C,cursorByServerId:n})},u[19]=h,u[20]=C,u[21]=V):V=u[21];u[22]!==F||u[23]!==V||u[24]!==D?(z={queryKey:F,enabled:D,staleTime:3e4,initialPageParam:null,getNextPageParam:y,queryFn:V},u[22]=F,u[23]=V,u[24]=D,u[25]=z):z=u[25];const G=(0,n.useInfiniteQuery)(z),{data:J,fetchNextPage:U,hasNextPage:W,isError:X,isFetching:Y,isFetchingNextPage:Z,isLoading:$,refetch:ee}=G;let te;u[26]!==k||u[27]!==ee||u[28]!==C.length?(te=async()=>{k&&0!==C.length&&await ee()},u[26]=k,u[27]=ee,u[28]=C.length,u[29]=te):te=u[29];const re=te;let ne;u[30]!==k||u[31]!==U||u[32]!==W||u[33]!==Z||u[34]!==C.length?(ne=()=>{k&&0!==C.length&&W&&!Z&&U()},u[30]=k,u[31]=U,u[32]=W,u[33]=Z,u[34]=C.length,u[35]=ne):ne=u[35];const se=ne;let ae;if(u[36]!==J?.pages||u[37]!==Q){const t=(J?.pages??[]).flatMap(b);let n;u[39]!==Q?(n=t=>Object.assign({},t,{serverLabel:Q.get(t.serverId)??t.serverLabel}),u[39]=Q,u[40]=n):n=u[40];ae=v(t.map(n)),u[36]=J?.pages,u[37]=Q,u[38]=ae}else ae=u[38];const oe=ae,ie=$&&0===oe.length,le=Y&&!Z&&oe.length>0;let ce;u[41]!==oe||u[42]!==W||u[43]!==X||u[44]!==Z||u[45]!==ie||u[46]!==$||u[47]!==le||u[48]!==se||u[49]!==re?(ce={agents:oe,isLoading:$,isInitialLoad:ie,isRevalidating:le,isError:X,hasMore:W,isLoadingMore:Z,refreshAll:re,loadMore:se},u[41]=oe,u[42]=W,u[43]=X,u[44]=Z,u[45]=ie,u[46]=$,u[47]=le,u[48]=se,u[49]=re,u[50]=ce):ce=u[50];return ce};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),l=r(d[5]),c=r(d[6]);const u=200,h=[{key:"updated_at",direction:"desc"}],f="No connected hosts could load agent history";async function p(t){const n=await t.client.fetchAgentHistory({sort:h,page:t.cursor?{limit:u,cursor:t.cursor}:{limit:u}}),{agents:s}=(0,l.buildAgentDirectoryState)({serverId:t.serverId,entries:n.entries});return{agents:Array.from(s.values(),n=>({id:n.id,serverId:t.serverId,serverLabel:t.serverId,title:n.title??null,status:n.status,lastActivityAt:n.lastActivityAt,cwd:n.cwd,workspaceId:n.workspaceId,provider:n.provider,pendingPermissionCount:n.pendingPermissions.length,requiresAttention:n.requiresAttention,attentionReason:n.attentionReason,attentionTimestamp:n.attentionTimestamp??null,archivedAt:n.archivedAt??null,createdAt:n.createdAt,labels:n.labels,projectPlacement:n.projectPlacement})),pageInfo:n.pageInfo}}function v(t){return[...t].sort((t,n)=>n.lastActivityAt.getTime()-t.lastActivityAt.getTime())}function y(t){const n={};for(const[s,a]of Object.entries(t.pageInfoByServerId))a.hasMore&&a.nextCursor&&(n[s]=a.nextCursor);return Object.keys(n).length>0?n:null}async function I(t){const n=t.cursorByServerId??{},s=Object.keys(n).length>0?t.hosts.filter(t=>Object.hasOwn(n,t.serverId)):t.hosts,a=(await Promise.allSettled(s.map(async t=>({host:t,page:await p({client:t.client,serverId:t.serverId,cursor:n[t.serverId]??null})})))).flatMap(t=>"fulfilled"===t.status?[t.value]:[]);if(0===a.length)throw new Error(f);const o=a.flatMap(({host:t,page:n})=>n.agents.map(n=>Object.assign({},n,{serverLabel:t.serverLabel}))),l=Object.fromEntries(a.map(({host:t,page:n})=>[t.serverId,n.pageInfo]));return{agents:v(o),pageInfoByServerId:l}}function b(t){return t.agents}function A(t){return[t.serverId,t.label]}function w(t){return t.serverId}function P(t){return t.serverId}function S(t){return[t.serverId,t.label]}},4873,[350,3030,36,352,3274,3426,4015]);
|
|
16633
16633
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return l}});var e=r(d[0]),t=r(d[1]);r(d[2]);var n,o=r(d[3]),s=(n=o)&&n.__esModule?n:{default:n},c=r(d[4]),u=r(d[5]);function l(){const n=(0,e.c)(7),o=(0,t.useLocalSearchParams)(),l="string"==typeof o.section?o.section:"";let f;n[0]!==l?(f=(0,c.isSettingsSectionSlug)(l)?l:"general",n[0]=l,n[1]=f):f=n[1];const _=f,p="string"==typeof o.addHost?o.addHost:null;let v;n[2]!==_?(v={kind:"section",section:_},n[2]=_,n[3]=v):v=n[3];const y=v;let S;return n[4]!==p||n[5]!==y?(S=(0,u.jsx)(s.default,{view:y,openAddHostIntent:p}),n[4]=p,n[5]=y,n[6]=S):S=n[6],S}},4874,[350,379,36,4875,3492,279]);
|
|
16634
16634
|
__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return Ye}});var t=r(d[0]),s=r(d[1]),n=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=e(r(d[7]));r(d[8]),r(d[9]),r(d[10]),r(d[11]),r(d[12]);var h=r(d[13]),b=r(d[14]),S=r(d[15]),y=r(d[16]),x=r(d[17]),f=r(d[18]),j=r(d[19]),v=r(d[20]),w=r(d[21]),k=r(d[22]),T=r(d[23]),C=r(d[24]),V=r(d[25]),I=r(d[26]),H=r(d[27]),_=r(d[28]),L=r(d[29]),P=r(d[30]),z=r(d[31]),D=r(d[32]),A=r(d[33]),B=r(d[34]),M=r(d[35]),R=r(d[36]),O=r(d[37]),U=r(d[38]),K=r(d[39]),W=r(d[40]),F=r(d[41]),E=r(d[42]),G=r(d[43]),N=r(d[44]),q=r(d[45]),$=r(d[46]),Q=r(d[47]),J=r(d[48]),X=r(d[49]),Y=r(d[50]),Z=r(d[51]),ee=r(d[52]),te=r(d[53]),se=r(d[54]),ne=r(d[55]),ie=r(d[56]),oe=r(d[57]),le=r(d[58]),re=r(d[59]),ae=r(d[60]),ce=r(d[61]),de=r(d[62]),ue=r(d[63]),ge=e(r(d[64])),pe=e(r(d[65])),he=r(d[66]),be=r(d[67]),Se=r(d[68]),ye=r(d[69]),xe=r(d[70]),fe=r(d[71]),me=r(d[72]);const je=[{id:"general",labelKey:"settings.sections.general",icon:f.Settings},{id:"daemon",labelKey:"settings.sections.daemon",icon:f.Server,desktopOnly:!0},{id:"appearance",labelKey:"settings.sections.appearance",icon:f.Palette},{id:"voice-language",labelKey:"settings.sections.voiceLanguage",icon:f.Languages},{id:"shortcuts",labelKey:"settings.sections.shortcuts",icon:f.Keyboard,desktopOnly:!0},{id:"integrations",labelKey:"settings.sections.integrations",icon:f.Puzzle,desktopOnly:!0},{id:"permissions",labelKey:"settings.sections.permissions",icon:f.Shield,desktopOnly:!0},{id:"diagnostics",labelKey:"settings.sections.diagnostics",icon:f.Stethoscope},{id:"about",labelKey:"settings.sections.about",icon:f.Info}],ve=[{id:"connections",labelKey:"settings.hostSections.connections",icon:f.Network},{id:"agents",labelKey:"settings.hostSections.agents",icon:f.Bot},{id:"workspaces",labelKey:"settings.hostSections.workspaces",icon:f.FolderGit2},{id:"providers",labelKey:"settings.hostSections.providers",icon:f.Boxes},{id:"usage",labelKey:"settings.hostSections.usage",icon:f.Gauge},{id:"terminals",labelKey:"settings.hostSections.terminals",icon:f.SquareTerminal},{id:"host",labelKey:"settings.hostSections.host",icon:f.Server}];function we(e,t){switch(e.section){case"connections":return(0,me.jsx)(ue.HostConnectionsPage,{serverId:e.serverId});case"agents":return(0,me.jsx)(ue.HostAgentsPage,{serverId:e.serverId});case"workspaces":return(0,me.jsx)(ue.HostWorkspacesPage,{serverId:e.serverId});case"providers":return(0,me.jsx)(ue.HostProvidersPage,{serverId:e.serverId});case"usage":return(0,me.jsx)(ue.HostUsagePage,{serverId:e.serverId});case"terminals":return(0,me.jsx)(ue.HostTerminalsPage,{serverId:e.serverId});case"host":return(0,me.jsx)(ue.HostSettingsPage,{serverId:e.serverId,onHostRemoved:t})}}function ke({pressed:e}){return[Ze.themeTrigger,e&&{opacity:.85}]}function Te({hovered:e}){return[tt.item,Boolean(e)&&tt.itemHovered]}function Ce({hovered:e}){return[tt.item,Boolean(e)&&tt.itemHovered,tt.itemSelected]}const Ve=[re.settingsStyles.row,re.settingsStyles.rowBorder];function Ie(e){return[{value:"interrupt",label:e("settings.general.defaultSend.options.interrupt")},{value:"queue",label:e("settings.general.defaultSend.options.queue")}]}function He(e,t){return{ask:e("settings.general.serviceUrls.options.ask"),"in-app":e("settings.general.serviceUrls.options.inApp"),external:e("settings.general.serviceUrls.options.external")}[t]}function Le(e){const t=(0,de.parseAppLanguage)(e);return t&&"system"!==t?t:"en"}const Pe=["ask","in-app","external"];function ze(e){const t=(0,c.c)(7),{value:s,label:n,selected:o,onChange:l}=e;let u;t[0]!==l||t[1]!==s?(u=()=>{l(s)},t[0]=l,t[1]=s,t[2]=u):u=t[2];const p=u;let h;return t[3]!==p||t[4]!==n||t[5]!==o?(h=(0,me.jsx)(ee.DropdownMenuItem,{selected:o,onSelect:p,children:n}),t[3]=p,t[4]=n,t[5]=o,t[6]=h):h=t[6],h}function De(e){const t=(0,c.c)(13),{value:s,activeLocale:n,selected:o,onChange:l}=e,{t:u}=(0,y.useTranslation)();let p;t[0]!==l||t[1]!==s?(p=()=>{l(s)},t[0]=l,t[1]=s,t[2]=p):p=t[2];const h=p;let b;if(t[3]!==n||t[4]!==u||t[5]!==s){let e;t[7]!==s?(e=e=>e.value===s,t[7]=s,t[8]=e):e=t[8];const o=de.LANGUAGE_OPTIONS.find(e);b=o?(0,de.formatLanguageOptionLabel)(o,n,u(o.labelKey)):s,t[3]=n,t[4]=u,t[5]=s,t[6]=b}else b=t[6];const S=b;let x;return t[9]!==h||t[10]!==S||t[11]!==o?(x=(0,me.jsx)(ee.DropdownMenuItem,{selected:o,onSelect:h,children:S}),t[9]=h,t[10]=S,t[11]=o,t[12]=x):x=t[12],x}function Ae(e){const o=(0,c.c)(106),{settings:l,isDesktopApp:p,handleSendBehaviorChange:h,handleServiceUrlBehaviorChange:b,handleLanguageChange:S,handleTerminalScrollbackLinesChange:x,handleFastOfflineModeChange:f}=e,{t:v,i18n:w}=(0,y.useTranslation)();let k,T,C,V;if(o[0]!==w.language||o[1]!==l.language||o[2]!==l.sendBehavior||o[3]!==v){let e,t;k=Le(w.language),o[8]!==v?(e=Ie(v),o[8]=v,o[9]=e):e=o[9],C=e,T="interrupt"===l.sendBehavior?"settings.general.defaultSend.descriptions.interrupt":"settings.general.defaultSend.descriptions.queue",o[10]!==l.language?(t=e=>e.value===l.language,o[10]=l.language,o[11]=t):t=o[11];const s=de.LANGUAGE_OPTIONS.find(t);V=s?(0,de.formatLanguageOptionLabel)(s,k,v(s.labelKey)):l.language,o[0]=w.language,o[1]=l.language,o[2]=l.sendBehavior,o[3]=v,o[4]=k,o[5]=T,o[6]=C,o[7]=V}else k=o[4],T=o[5],C=o[6],V=o[7];const I=V,[H,L]=(0,u.useState)(String(l.terminalScrollbackLines));let P;o[12]===Symbol.for("react.memo_cache_sentinel")?(P=e=>{L(e.replace(/[^\d]/g,""))},o[12]=P):P=o[12];const D=P;let A;o[13]!==x||o[14]!==l.terminalScrollbackLines||o[15]!==H?(A=()=>{const e=(0,z.parseTerminalScrollbackLines)(H)??l.terminalScrollbackLines;L(String(e)),e!==l.terminalScrollbackLines&&x(e)},o[13]=x,o[14]=l.terminalScrollbackLines,o[15]=H,o[16]=A):A=o[16];const B=A;let O,U,K,W,F,E,G,N,q,$,Q,J,X,Y,te,se,ne,ie,oe,le,ae,ce,ue,ge,pe,he,be,Se,ye,xe,fe,je,ve;return o[17]!==l.terminalScrollbackLines?(O=()=>{L(String(l.terminalScrollbackLines))},U=[l.terminalScrollbackLines],o[17]=l.terminalScrollbackLines,o[18]=O,o[19]=U):(O=o[18],U=o[19]),(0,u.useEffect)(O,U),o[20]!==v?(K=v("settings.general.title"),o[20]=v,o[21]=K):K=o[21],o[22]!==v?(W=v("settings.general.defaultSend.label"),o[22]=v,o[23]=W):W=o[23],o[24]!==W?(F=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:W}),o[24]=W,o[25]=F):F=o[25],o[26]!==T||o[27]!==v?(E=v(T),o[26]=T,o[27]=v,o[28]=E):E=o[28],o[29]!==E?(G=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:E}),o[29]=E,o[30]=G):G=o[30],o[31]!==G||o[32]!==F?(N=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[F,G]}),o[31]=G,o[32]=F,o[33]=N):N=o[33],o[34]!==h||o[35]!==C||o[36]!==l.sendBehavior?(q=(0,me.jsx)(Z.SegmentedControl,{size:"sm",value:l.sendBehavior,onValueChange:h,options:C}),o[34]=h,o[35]=C,o[36]=l.sendBehavior,o[37]=q):q=o[37],o[38]!==N||o[39]!==q?($=(0,me.jsxs)(t.View,{style:re.settingsStyles.row,children:[N,q]}),o[38]=N,o[39]=q,o[40]=$):$=o[40],o[41]!==f||o[42]!==l.fastOfflineMode?(Q=R.isNative?(0,me.jsxs)(t.View,{style:Ve,children:[(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:"Fast offline mode"}),(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:"Voice replies and dictation use the on-device iOS engines instead of the daemon \u2014 lower latency, works without a voice connection"})]}),(0,me.jsx)(M.Switch,{value:l.fastOfflineMode,onValueChange:f,accessibilityLabel:"Toggle fast offline voice mode",testID:"settings-fast-offline-mode"})]}):null,o[41]=f,o[42]=l.fastOfflineMode,o[43]=Q):Q=o[43],o[44]!==v?(J=v("settings.general.language.label"),o[44]=v,o[45]=J):J=o[45],o[46]!==J?(X=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:J}),o[46]=J,o[47]=X):X=o[47],o[48]!==v?(Y=v("settings.general.language.description"),o[48]=v,o[49]=Y):Y=o[49],o[50]!==Y?(te=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:Y}),o[50]=Y,o[51]=te):te=o[51],o[52]!==X||o[53]!==te?(se=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[X,te]}),o[52]=X,o[53]=te,o[54]=se):se=o[54],o[55]!==I?(ne=(0,me.jsx)(n.Text,{style:Ze.themeTriggerText,children:I}),o[55]=I,o[56]=ne):ne=o[56],o[57]!==I||o[58]!==ne?(ie=(0,me.jsx)(j.DropdownTrigger,{accessibilityRole:"button",accessibilityLabel:I,style:ke,children:ne}),o[57]=I,o[58]=ne,o[59]=ie):ie=o[59],o[60]!==k||o[61]!==S||o[62]!==l.language?(oe=de.LANGUAGE_OPTIONS.map(e=>(0,me.jsx)(De,{value:e.value,activeLocale:k,selected:l.language===e.value,onChange:S},e.value)),o[60]=k,o[61]=S,o[62]=l.language,o[63]=oe):oe=o[63],o[64]!==oe?(le=(0,me.jsx)(ee.DropdownMenuContent,{side:"bottom",align:"end",width:300,children:oe}),o[64]=oe,o[65]=le):le=o[65],o[66]!==ie||o[67]!==le?(ae=(0,me.jsxs)(ee.DropdownMenu,{children:[ie,le]}),o[66]=ie,o[67]=le,o[68]=ae):ae=o[68],o[69]!==se||o[70]!==ae?(ce=(0,me.jsxs)(t.View,{style:Ve,children:[se,ae]}),o[69]=se,o[70]=ae,o[71]=ce):ce=o[71],o[72]!==b||o[73]!==p||o[74]!==l.serviceUrlBehavior||o[75]!==v?(ue=p?(0,me.jsxs)(t.View,{style:Ve,children:[(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:v("settings.general.serviceUrls.label")}),(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:v("settings.general.serviceUrls.description")})]}),(0,me.jsxs)(ee.DropdownMenu,{children:[(0,me.jsx)(j.DropdownTrigger,{style:ke,children:(0,me.jsx)(n.Text,{style:Ze.themeTriggerText,children:He(v,l.serviceUrlBehavior)})}),(0,me.jsx)(ee.DropdownMenuContent,{side:"bottom",align:"end",width:200,children:Pe.map(e=>(0,me.jsx)(ze,{value:e,label:He(v,e),selected:l.serviceUrlBehavior===e,onChange:b},e))})]})]}):null,o[72]=b,o[73]=p,o[74]=l.serviceUrlBehavior,o[75]=v,o[76]=ue):ue=o[76],o[77]!==v?(ge=v("settings.general.terminalScrollback.label"),o[77]=v,o[78]=ge):ge=o[78],o[79]!==ge?(pe=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:ge}),o[79]=ge,o[80]=pe):pe=o[80],o[81]!==v?(he=v("settings.general.terminalScrollback.description"),o[81]=v,o[82]=he):he=o[82],o[83]!==he?(be=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:he}),o[83]=he,o[84]=be):be=o[84],o[85]!==pe||o[86]!==be?(Se=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[pe,be]}),o[85]=pe,o[86]=be,o[87]=Se):Se=o[87],o[88]!==v?(ye=v("settings.general.terminalScrollback.accessibilityLabel"),o[88]=v,o[89]=ye):ye=o[89],o[90]!==B||o[91]!==ye||o[92]!==H?(xe=(0,me.jsx)(s.TextInput,{value:H,onChangeText:D,onBlur:B,onSubmitEditing:B,keyboardType:"number-pad",inputMode:"numeric",selectTextOnFocus:!0,style:Ze.terminalScrollbackInput,accessibilityLabel:ye}),o[90]=B,o[91]=ye,o[92]=H,o[93]=xe):xe=o[93],o[94]!==Se||o[95]!==xe?(fe=(0,me.jsxs)(t.View,{style:Ve,children:[Se,xe]}),o[94]=Se,o[95]=xe,o[96]=fe):fe=o[96],o[97]!==$||o[98]!==Q||o[99]!==ce||o[100]!==ue||o[101]!==fe?(je=(0,me.jsxs)(t.View,{style:re.settingsStyles.card,children:[$,Q,ce,ue,fe]}),o[97]=$,o[98]=Q,o[99]=ce,o[100]=ue,o[101]=fe,o[102]=je):je=o[102],o[103]!==je||o[104]!==K?(ve=(0,me.jsx)(_.SettingsSection,{title:K,children:je}),o[103]=je,o[104]=K,o[105]=ve):ve=o[105],ve}function Be(e){const s=(0,c.c)(54),{voiceAudioEngine:o,isPlaybackTestRunning:l,playbackTestResult:p,handlePlaybackTest:h,appVersion:b,isDesktopApp:S}=e,{t:x}=(0,y.useTranslation)(),[f,j]=(0,u.useState)(!1);let w;s[0]!==h?(w=()=>{h()},s[0]=h,s[1]=w):w=s[1];const k=w;let T;s[2]===Symbol.for("react.memo_cache_sentinel")?(T=()=>j(!0),s[2]=T):T=s[2];const C=T;let V;s[3]===Symbol.for("react.memo_cache_sentinel")?(V=()=>j(!1),s[3]=V):V=s[3];const I=V;let H,L,P,z,D,A,B,M,R,O,U,K,W;s[4]!==x?(H=x("settings.diagnostics.title"),s[4]=x,s[5]=H):H=s[5],s[6]!==x?(L=x("settings.diagnostics.app.rowTitle"),s[6]=x,s[7]=L):L=s[7],s[8]!==L?(P=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:L}),s[8]=L,s[9]=P):P=s[9],s[10]!==x?(z=x("settings.diagnostics.app.rowHint"),s[10]=x,s[11]=z):z=s[11],s[12]!==z?(D=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:z}),s[12]=z,s[13]=D):D=s[13],s[14]!==P||s[15]!==D?(A=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[P,D]}),s[14]=P,s[15]=D,s[16]=A):A=s[16],s[17]!==x?(B=x("settings.diagnostics.app.run"),s[17]=x,s[18]=B):B=s[18],s[19]!==B?(M=(0,me.jsx)(X.Button,{variant:"secondary",size:"sm",onPress:C,children:B}),s[19]=B,s[20]=M):M=s[20],s[21]!==M||s[22]!==A?(R=(0,me.jsxs)(t.View,{style:re.settingsStyles.row,testID:"app-diagnostic-row",children:[A,M]}),s[21]=M,s[22]=A,s[23]=R):R=s[23],s[24]!==x?(O=x("settings.diagnostics.testAudio"),s[24]=x,s[25]=O):O=s[25],s[26]!==O?(U=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:O}),s[26]=O,s[27]=U):U=s[27],s[28]!==p?(K=p?(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:p}):null,s[28]=p,s[29]=K):K=s[29],s[30]!==U||s[31]!==K?(W=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[U,K]}),s[30]=U,s[31]=K,s[32]=W):W=s[32];const F=!o||l;let E,G,N,q,$,Q;return s[33]!==l||s[34]!==x?(E=x(l?"settings.diagnostics.playing":"settings.diagnostics.playTest"),s[33]=l,s[34]=x,s[35]=E):E=s[35],s[36]!==k||s[37]!==F||s[38]!==E?(G=(0,me.jsx)(X.Button,{variant:"secondary",size:"sm",onPress:k,disabled:F,children:E}),s[36]=k,s[37]=F,s[38]=E,s[39]=G):G=s[39],s[40]!==W||s[41]!==G?(N=(0,me.jsxs)(t.View,{style:re.settingsStyles.row,children:[W,G]}),s[40]=W,s[41]=G,s[42]=N):N=s[42],s[43]!==R||s[44]!==N?(q=(0,me.jsxs)(t.View,{style:re.settingsStyles.card,children:[R,N]}),s[43]=R,s[44]=N,s[45]=q):q=s[45],s[46]!==b||s[47]!==f||s[48]!==S?($=(0,me.jsx)(v.AppDiagnosticSheet,{visible:f,onClose:I,appVersion:b,isDesktopApp:S}),s[46]=b,s[47]=f,s[48]=S,s[49]=$):$=s[49],s[50]!==q||s[51]!==$||s[52]!==H?(Q=(0,me.jsxs)(_.SettingsSection,{title:H,children:[q,$]}),s[50]=q,s[51]=$,s[52]=H,s[53]=Q):Q=s[53],Q}function Me(){const e=(0,c.c)(2),t=(0,Se.useActiveServerId)();let s;return e[0]!==t?(s=e=>t?e.sessions[t]?.serverInfo?.version??null:null,e[0]=t,e[1]=s):s=e[1],(0,U.useSessionStore)(s)}function Re(e){const s=(0,c.c)(42),{appVersion:o,appVersionText:l}=e,{t:u}=(0,y.useTranslation)(),p=Me();let h;s[0]!==p?(h=(0,oe.formatVersionWithPrefix)(p),s[0]=p,s[1]=h):h=s[1];const b=h;let S,x,f,j,v,w,k,T,C,V,I,H,L,P,z,D,A,B;return s[2]!==u?(S=u("settings.about.title"),s[2]=u,s[3]=S):S=s[3],s[4]!==u?(x=u("settings.about.appVersion"),s[4]=u,s[5]=x):x=s[5],s[6]!==x?(f=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:x}),s[6]=x,s[7]=f):f=s[7],s[8]!==u?(j=u("settings.about.thisDevice"),s[8]=u,s[9]=j):j=s[9],s[10]!==j?(v=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:j}),s[10]=j,s[11]=v):v=s[11],s[12]!==f||s[13]!==v?(w=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[f,v]}),s[12]=f,s[13]=v,s[14]=w):w=s[14],s[15]!==l?(k=(0,me.jsx)(n.Text,{style:Ze.aboutValue,testID:"settings-about-app-version",children:l}),s[15]=l,s[16]=k):k=s[16],s[17]!==w||s[18]!==k?(T=(0,me.jsxs)(t.View,{style:re.settingsStyles.row,children:[w,k]}),s[17]=w,s[18]=k,s[19]=T):T=s[19],s[20]!==u?(C=u("settings.about.daemonVersion"),s[20]=u,s[21]=C):C=s[21],s[22]!==C?(V=(0,me.jsx)(t.View,{style:re.settingsStyles.rowContent,children:(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:C})}),s[22]=C,s[23]=V):V=s[23],s[24]!==b?(I=(0,me.jsx)(n.Text,{style:Ze.aboutValue,testID:"settings-about-daemon-version",children:b}),s[24]=b,s[25]=I):I=s[25],s[26]!==V||s[27]!==I?(H=(0,me.jsxs)(t.View,{style:Ve,children:[V,I]}),s[26]=V,s[27]=I,s[28]=H):H=s[28],s[29]!==T||s[30]!==H?(L=(0,me.jsxs)(t.View,{style:re.settingsStyles.card,children:[T,H]}),s[29]=T,s[30]=H,s[31]=L):L=s[31],s[32]===Symbol.for("react.memo_cache_sentinel")?(P=(0,me.jsx)(Fe,{}),s[32]=P):P=s[32],s[33]!==L||s[34]!==S?(z=(0,me.jsxs)(_.SettingsSection,{title:S,children:[L,P]}),s[33]=L,s[34]=S,s[35]=z):z=s[35],s[36]!==o?(D=(0,me.jsx)(Ue,{clientVersion:o}),s[36]=o,s[37]=D):D=s[37],s[38]===Symbol.for("react.memo_cache_sentinel")?(A=(0,me.jsx)(t.View,{style:Ze.aboutCommunity,children:(0,me.jsx)(Y.CommunityLinks,{})}),s[38]=A):A=s[38],s[39]!==z||s[40]!==D?(B=(0,me.jsxs)(me.Fragment,{children:[z,D,A]}),s[39]=z,s[40]=D,s[41]=B):B=s[41],B}function Oe(e){const t=e?.trim();return t?t.replace(/^v/i,""):null}function Ue(e){const s=(0,c.c)(12),{clientVersion:n}=e,{t:o}=(0,y.useTranslation)(),l=(0,O.useHosts)();if(0===l.length)return null;let u,p,h,b;if(s[0]!==o?(u=o("settings.about.connectedHosts"),s[0]=o,s[1]=u):u=s[1],s[2]!==n||s[3]!==l){let e;s[5]!==n?(e=(e,t)=>(0,me.jsx)(Ke,{host:e,showBorder:t>0,clientVersion:n},e.serverId),s[5]=n,s[6]=e):e=s[6],p=l.map(e),s[2]=n,s[3]=l,s[4]=p}else p=s[4];return s[7]!==p?(h=(0,me.jsx)(t.View,{style:re.settingsStyles.card,children:p}),s[7]=p,s[8]=h):h=s[8],s[9]!==u||s[10]!==h?(b=(0,me.jsx)(_.SettingsSection,{title:u,children:h}),s[9]=u,s[10]=h,s[11]=b):b=s[11],b}function Ke(e){const s=(0,c.c)(31),{host:o,showBorder:l,clientVersion:u}=e,{t:p}=(0,y.useTranslation)(),h=(0,O.useHostRuntimeIsConnected)(o.serverId);let b;s[0]!==o.serverId?(b=e=>e.sessions[o.serverId]?.serverInfo?.version??null,s[0]=o.serverId,s[1]=b):b=s[1];const S=(0,U.useSessionStore)(b),x=l&&re.settingsStyles.rowBorder;let f;s[2]!==x?(f=[re.settingsStyles.row,x],s[2]=x,s[3]=f):f=s[3];const j=f;let v,w;if(s[4]!==u||s[5]!==S||s[6]!==h||s[7]!==p){const e=Oe(S);let t;s[10]!==u?(t=Oe(u),s[10]=u,s[11]=t):t=s[11];if(v=null!==e&&null!==t&&e!==t,h)w=e?(0,oe.formatVersionWithPrefix)(e):"\u2014";else{let e;s[12]!==p?(e=p("settings.about.offline"),s[12]=p,s[13]=e):e=s[13],w=e}s[4]=u,s[5]=S,s[6]=h,s[7]=p,s[8]=v,s[9]=w}else v=s[8],w=s[9];const k=v&&Ze.aboutVersionMismatch;let T;s[14]!==k?(T=[Ze.aboutValue,k],s[14]=k,s[15]=T):T=s[15];const C=T;let V,I,H,_,L;return s[16]!==o.label?(V=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,numberOfLines:1,children:o.label}),s[16]=o.label,s[17]=V):V=s[17],s[18]!==v||s[19]!==p?(I=v?(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:p("settings.about.versionDiffers")}):null,s[18]=v,s[19]=p,s[20]=I):I=s[20],s[21]!==V||s[22]!==I?(H=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[V,I]}),s[21]=V,s[22]=I,s[23]=H):H=s[23],s[24]!==C||s[25]!==w?(_=(0,me.jsx)(n.Text,{style:C,children:w}),s[24]=C,s[25]=w,s[26]=_):_=s[26],s[27]!==j||s[28]!==H||s[29]!==_?(L=(0,me.jsxs)(t.View,{style:j,children:[H,_]}),s[27]=j,s[28]=H,s[29]=_,s[30]=L):L=s[30],L}function We(e,t,s){return t?e("settings.about.updates.installing"):s?e("settings.about.updates.updateTo",{version:(0,oe.formatVersionWithPrefix)(s)}):e("settings.about.updates.update")}function Fe(){const e=(0,c.c)(81),{t:s}=(0,y.useTranslation)(),{settings:o,updateSettings:l}=(0,z.useSettings)(),{isDesktopApp:u,statusText:h,availableUpdate:b,errorMessage:S,isChecking:x,isInstalling:f,checkForUpdates:j,installUpdate:v}=(0,B.useDesktopAppUpdater)();let w,k;e[0]!==j||e[1]!==u?(w=()=>{u&&j({intent:"automatic",silent:!0})},e[0]=j,e[1]=u,e[2]=w):w=e[2],(0,D.useFocusEffect)(w),e[3]!==j||e[4]!==u?(k=()=>{u&&j()},e[3]=j,e[4]=u,e[5]=k):k=e[5];const T=k;let C;e[6]!==l?(C=e=>{l({releaseChannel:e})},e[6]=l,e[7]=C):C=e[7];const V=C;let I,H,_,L,P;e[8]!==s?(I=s("settings.about.releaseChannel.stable"),e[8]=s,e[9]=I):I=e[9],e[10]!==I?(H={value:"stable",label:I},e[10]=I,e[11]=H):H=e[11],e[12]!==s?(_=s("settings.about.releaseChannel.beta"),e[12]=s,e[13]=_):_=e[13],e[14]!==_?(L={value:"beta",label:_},e[14]=_,e[15]=L):L=e[15],e[16]!==H||e[17]!==L?(P=[H,L],e[16]=H,e[17]=L,e[18]=P):P=e[18];const M=P;let R;e[19]!==v||e[20]!==u||e[21]!==s?(R=()=>{u&&(0,A.confirmDialog)({title:s("settings.about.updates.installTitle"),message:s("settings.about.updates.installMessage"),confirmLabel:s("settings.about.updates.installConfirm"),cancelLabel:s("common.actions.cancel")}).then(e=>{e&&v()}).catch(e=>{console.error("[Settings] Failed to open app update confirmation",e),p.default.alert(s("settings.about.updates.alertTitle"),s("settings.about.updates.alertMessage"))})},e[19]=v,e[20]=u,e[21]=s,e[22]=R):R=e[22];const O=R,U=!0===b?.readyToInstall,K=U?b?.latestVersion:null;if(!u)return null;let W,F,E,G,N,q,$,Q,J,Y,ee,te,se;e[23]!==s?(W=s("settings.about.releaseChannel.label"),e[23]=s,e[24]=W):W=e[24],e[25]!==W?(F=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:W}),e[25]=W,e[26]=F):F=e[26],e[27]!==s?(E=s("settings.about.releaseChannel.description"),e[27]=s,e[28]=E):E=e[28],e[29]!==E?(G=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:E}),e[29]=E,e[30]=G):G=e[30],e[31]!==F||e[32]!==G?(N=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[F,G]}),e[31]=F,e[32]=G,e[33]=N):N=e[33],e[34]!==V||e[35]!==M||e[36]!==o.releaseChannel?(q=(0,me.jsx)(Z.SegmentedControl,{size:"sm",value:o.releaseChannel,onValueChange:V,options:M}),e[34]=V,e[35]=M,e[36]=o.releaseChannel,e[37]=q):q=e[37],e[38]!==N||e[39]!==q?($=(0,me.jsxs)(t.View,{style:Ve,children:[N,q]}),e[38]=N,e[39]=q,e[40]=$):$=e[40],e[41]!==s?(Q=s("settings.about.updates.label"),e[41]=s,e[42]=Q):Q=e[42],e[43]!==Q?(J=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowTitle,children:Q}),e[43]=Q,e[44]=J):J=e[44],e[45]!==h?(Y=(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:h}),e[45]=h,e[46]=Y):Y=e[46],e[47]!==K||e[48]!==s?(ee=K?(0,me.jsx)(n.Text,{style:re.settingsStyles.rowHint,children:s("settings.about.updates.readyToInstall",{version:(0,oe.formatVersionWithPrefix)(K)})}):null,e[47]=K,e[48]=s,e[49]=ee):ee=e[49],e[50]!==S?(te=S?(0,me.jsx)(n.Text,{style:Ze.aboutErrorText,children:S}):null,e[50]=S,e[51]=te):te=e[51],e[52]!==J||e[53]!==Y||e[54]!==ee||e[55]!==te?(se=(0,me.jsxs)(t.View,{style:re.settingsStyles.rowContent,children:[J,Y,ee,te]}),e[52]=J,e[53]=Y,e[54]=ee,e[55]=te,e[56]=se):se=e[56];const ne=x||f;let ie,le;e[57]!==x||e[58]!==s?(ie=s(x?"settings.about.updates.checking":"settings.about.updates.check"),e[57]=x,e[58]=s,e[59]=ie):ie=e[59],e[60]!==T||e[61]!==ne||e[62]!==ie?(le=(0,me.jsx)(X.Button,{variant:"outline",size:"sm",onPress:T,disabled:ne,children:ie}),e[60]=T,e[61]=ne,e[62]=ie,e[63]=le):le=e[63];const ae=x||f||!U;let ce,de,ue,ge,pe;return e[64]!==f||e[65]!==K||e[66]!==s?(ce=We(s,f,K),e[64]=f,e[65]=K,e[66]=s,e[67]=ce):ce=e[67],e[68]!==O||e[69]!==ae||e[70]!==ce?(de=(0,me.jsx)(X.Button,{variant:"default",size:"sm",onPress:O,disabled:ae,children:ce}),e[68]=O,e[69]=ae,e[70]=ce,e[71]=de):de=e[71],e[72]!==le||e[73]!==de?(ue=(0,me.jsxs)(t.View,{style:Ze.aboutUpdateActions,children:[le,de]}),e[72]=le,e[73]=de,e[74]=ue):ue=e[74],e[75]!==se||e[76]!==ue?(ge=(0,me.jsxs)(t.View,{style:Ve,children:[se,ue]}),e[75]=se,e[76]=ue,e[77]=ge):ge=e[77],e[78]!==$||e[79]!==ge?(pe=(0,me.jsxs)(me.Fragment,{children:[$,ge]}),e[78]=$,e[79]=ge,e[80]=pe):pe=e[80],pe}function Ee(e,t){const s=(0,c.c)(3);let n;return s[0]!==e||s[1]!==t?(n=(0,K.orderHostsLocalFirst)(e,t),s[0]=e,s[1]=t,s[2]=n):n=s[2],n}function Ge(e){const t=(0,c.c)(23),{itemId:s,label:o,icon:u,isSelected:p,onSelect:h}=e,{theme:b}=(0,S.useUnistyles)();let y;t[0]!==s||t[1]!==h?(y=()=>{h(s)},t[0]=s,t[1]=h,t[2]=y):y=t[2];const x=y;let f;t[3]!==p?(f={selected:p},t[3]=p,t[4]=f):f=t[4];const j=f;let v,w;t[5]!==p||t[6]!==b.colors.foreground?(v=p&&{color:b.colors.foreground},t[5]=p,t[6]=b.colors.foreground,t[7]=v):v=t[7],t[8]!==v?(w=[tt.label,v],t[8]=v,t[9]=w):w=t[9];const k=w,T=p?Ce:Te,C=p?b.colors.foreground:b.colors.foregroundMuted;let V,I,H;return t[10]!==u||t[11]!==C||t[12]!==b.iconSize.md?(V=(0,me.jsx)(u,{size:b.iconSize.md,color:C}),t[10]=u,t[11]=C,t[12]=b.iconSize.md,t[13]=V):V=t[13],t[14]!==o||t[15]!==k?(I=(0,me.jsx)(n.Text,{style:k,numberOfLines:1,children:o}),t[14]=o,t[15]=k,t[16]=I):I=t[16],t[17]!==j||t[18]!==x||t[19]!==T||t[20]!==V||t[21]!==I?(H=(0,me.jsxs)(l.Pressable,{accessibilityRole:"button",accessibilityState:j,onPress:x,style:T,children:[V,I]}),t[17]=j,t[18]=x,t[19]=T,t[20]=V,t[21]=I,t[22]=H):H=t[22],H}function Ne(e){const t=(0,c.c)(24),{itemId:s,label:o,icon:u,isSelected:p,onSelect:h}=e,{theme:b}=(0,S.useUnistyles)();let y;t[0]!==s||t[1]!==h?(y=()=>{h(s)},t[0]=s,t[1]=h,t[2]=y):y=t[2];const x=y;let f;t[3]!==p?(f={selected:p},t[3]=p,t[4]=f):f=t[4];const j=f;let v,w;t[5]!==p||t[6]!==b.colors.foreground?(v=p&&{color:b.colors.foreground},t[5]=p,t[6]=b.colors.foreground,t[7]=v):v=t[7],t[8]!==v?(w=[tt.label,v],t[8]=v,t[9]=w):w=t[9];const k=w,T=`settings-host-section-${s}`,C=p?Ce:Te,V=p?b.colors.foreground:b.colors.foregroundMuted;let I,H,_;return t[10]!==u||t[11]!==V||t[12]!==b.iconSize.md?(I=(0,me.jsx)(u,{size:b.iconSize.md,color:V}),t[10]=u,t[11]=V,t[12]=b.iconSize.md,t[13]=I):I=t[13],t[14]!==o||t[15]!==k?(H=(0,me.jsx)(n.Text,{style:k,numberOfLines:1,children:o}),t[14]=o,t[15]=k,t[16]=H):H=t[16],t[17]!==j||t[18]!==x||t[19]!==T||t[20]!==C||t[21]!==I||t[22]!==H?(_=(0,me.jsxs)(l.Pressable,{accessibilityRole:"button",accessibilityState:j,onPress:x,testID:T,style:C,children:[I,H]}),t[17]=j,t[18]=x,t[19]=T,t[20]=C,t[21]=I,t[22]=H,t[23]=_):_=t[23],_}function qe(e){const t=(0,c.c)(21),{isSelected:s,onSelect:o}=e,{theme:u}=(0,S.useUnistyles)(),{t:p}=(0,y.useTranslation)();let h;t[0]!==s?(h={selected:s},t[0]=s,t[1]=h):h=t[1];const b=h;let x,j;t[2]!==s||t[3]!==u.colors.foreground?(x=s&&{color:u.colors.foreground},t[2]=s,t[3]=u.colors.foreground,t[4]=x):x=t[4],t[5]!==x?(j=[tt.label,x],t[5]=x,t[6]=j):j=t[6];const v=j,w=s?Ce:Te,k=s?u.colors.foreground:u.colors.foregroundMuted;let T,C,V,I;return t[7]!==k||t[8]!==u.iconSize.md?(T=(0,me.jsx)(f.FolderGit2,{size:u.iconSize.md,color:k}),t[7]=k,t[8]=u.iconSize.md,t[9]=T):T=t[9],t[10]!==p?(C=p("settings.projects"),t[10]=p,t[11]=C):C=t[11],t[12]!==v||t[13]!==C?(V=(0,me.jsx)(n.Text,{style:v,numberOfLines:1,children:C}),t[12]=v,t[13]=C,t[14]=V):V=t[14],t[15]!==b||t[16]!==o||t[17]!==w||t[18]!==T||t[19]!==V?(I=(0,me.jsxs)(l.Pressable,{accessibilityRole:"button",accessibilityState:b,onPress:o,testID:"settings-projects",style:w,children:[T,V]}),t[15]=b,t[16]=o,t[17]=w,t[18]=T,t[19]=V,t[20]=I):I=t[20],I}function $e(e){const s=(0,c.c)(27),{activeServerId:o,sortedHosts:l,onSelectHost:p,onAddHost:h}=e,{t:b}=(0,y.useTranslation)(),[S,x]=(0,u.useState)(!1),f=(0,u.useRef)(null);let j;s[0]!==o||s[1]!==l?(j=l.find(e=>e.serverId===o)??l[0]??null,s[0]=o,s[1]=l,s[2]=j):j=s[2];const v=j;let k;s[3]===Symbol.for("react.memo_cache_sentinel")?(k=()=>x(!0),s[3]=k):k=s[3];const T=k,I=Je,H=Qe,_=o??"";let L,P,z,D,A,B,M;return s[4]!==b?(L=b("settings.hostPicker.switchHost"),s[4]=b,s[5]=L):L=s[5],s[6]!==b?(P=b("settings.hostPicker.switchHost"),s[6]=b,s[7]=P):P=s[7],s[8]!==v?(z=v?(0,me.jsx)(t.View,{style:tt.pickerTriggerDot,children:(0,me.jsx)(V.HostStatusDot,{serverId:v.serverId})}):null,s[8]=v,s[9]=z):z=s[9],s[10]!==v?.label||s[11]!==b?(D=v?.label??b("settings.groups.host"),s[10]=v?.label,s[11]=b,s[12]=D):D=s[12],s[13]!==D?(A=(0,me.jsx)(n.Text,{style:tt.pickerTriggerLabel,numberOfLines:1,children:D}),s[13]=D,s[14]=A):A=s[14],s[15]!==P||s[16]!==z||s[17]!==A?(B=(0,me.jsxs)(w.ComboboxTrigger,{ref:f,block:!0,style:H,onPress:T,accessibilityRole:"button",accessibilityLabel:P,testID:"settings-host-picker",children:[z,A]}),s[15]=P,s[16]=z,s[17]=A,s[18]=B):B=s[18],s[19]!==S||s[20]!==h||s[21]!==p||s[22]!==l||s[23]!==_||s[24]!==L||s[25]!==B?(M=(0,me.jsx)(C.HostPicker,{hosts:l,value:_,onSelect:p,open:S,onOpenChange:x,anchorRef:f,includeAddHost:!0,onAddHost:h,showActiveConnection:!0,searchable:!1,title:L,desktopMinWidth:240,addHostTestID:"settings-add-host",hostOptionTestID:I,children:B}),s[19]=S,s[20]=h,s[21]=p,s[22]=l,s[23]=_,s[24]=L,s[25]=B,s[26]=M):M=s[26],M}function Qe(e){const{hovered:t}=e,s=void 0!==t&&t;return[tt.pickerTrigger,s&&tt.pickerTriggerHovered]}function Je(e){return`settings-host-picker-item-${e}`}function Xe(e){const s=(0,c.c)(50),{view:p,onSelectSection:h,onSelectHostSection:x,onSelectHost:j,onSelectProjects:v,onAddHost:w,onBackToWorkspace:C,activeHostServerId:V,layout:I}=e,{theme:H}=(0,S.useUnistyles)(),{t:_}=(0,y.useTranslation)(),L=Ee((0,O.useHosts)(),(0,be.useLocalDaemonServerId)()),P=L.length>0,z=(0,ie.isElectronRuntime)(),D=je.filter(e=>!e.desktopOnly||z),A=(0,b.useSafeAreaInsets)(),B=(0,F.useWindowControlsPadding)("sidebar"),M="desktop"===I,R=M?tt.desktopContainer:tt.mobileContainer;let U;s[0]!==R?(U=[R],s[0]=R,s[1]=U):U=s[1];const K=U;let E,G,N;s[2]===Symbol.for("react.memo_cache_sentinel")?(E={flex:1},s[2]=E):E=s[2],s[3]!==A.top||s[4]!==M?(G=M?{paddingTop:A.top}:null,s[3]=A.top,s[4]=M,s[5]=G):G=s[5],s[6]!==G?(N=[E,G],s[6]=G,s[7]=N):N=s[7];const q=N,$="section"===p.kind?p.section:null,Q="host"===p.kind?p.section:null,J="projects"===p.kind||"project"===p.kind;let X;s[8]!==B.top?(X={height:B.top},s[8]=B.top,s[9]=X):X=s[9];const Y=X,Z=t.View,ee=tt;let te,se,ne;s[10]!==_?(te=_("settings.groups.app"),s[10]=_,s[11]=te):te=s[11],s[12]!==te?(se=(0,me.jsx)(n.Text,{style:tt.groupLabel,children:te}),s[12]=te,s[13]=se):se=s[13],s[14]!==J||s[15]!==v||s[16]!==h||s[17]!==$||s[18]!==_?(ne=e=>(0,me.jsxs)(u.Fragment,{children:[(0,me.jsx)(Ge,{itemId:e.id,label:_(e.labelKey),icon:e.icon,isSelected:$===e.id,onSelect:h}),"general"===e.id?(0,me.jsx)(qe,{isSelected:J,onSelect:v}):null]},e.id),s[14]=J,s[15]=v,s[16]=h,s[17]=$,s[18]=_,s[19]=ne):ne=s[19];const oe=D.map(ne);let le,re,ae,ce;s[20]!==Z||s[21]!==oe||s[22]!==ee.list||s[23]!==se?(le=(0,me.jsxs)(Z,{style:ee.list,children:[se,oe]}),s[20]=Z,s[21]=oe,s[22]=ee.list,s[23]=se,s[24]=le):le=s[24],s[25]===Symbol.for("react.memo_cache_sentinel")?(re=(0,me.jsx)(T.SidebarSeparator,{}),s[25]=re):re=s[25],s[26]!==V||s[27]!==P||s[28]!==w||s[29]!==j||s[30]!==x||s[31]!==Q||s[32]!==L||s[33]!==_||s[34]!==H?(ae=P?(0,me.jsxs)(t.View,{style:tt.list,children:[(0,me.jsx)(n.Text,{style:tt.groupLabel,children:_("settings.groups.host")}),(0,me.jsx)($e,{activeServerId:V,sortedHosts:L,onSelectHost:j,onAddHost:w}),ve.map(e=>(0,me.jsx)(Ne,{itemId:e.id,label:_(e.labelKey),icon:e.icon,isSelected:Q===e.id,onSelect:x},e.id))]}):(0,me.jsx)(t.View,{style:tt.list,children:(0,me.jsxs)(l.Pressable,{accessibilityRole:"button",accessibilityLabel:_("settings.addHost"),onPress:w,testID:"settings-add-host",style:Te,children:[(0,me.jsx)(f.Plus,{size:H.iconSize.md,color:H.colors.foregroundMuted}),(0,me.jsx)(n.Text,{style:tt.label,numberOfLines:1,children:_("settings.addHost")})]})}),s[26]=V,s[27]=P,s[28]=w,s[29]=j,s[30]=x,s[31]=Q,s[32]=L,s[33]=_,s[34]=H,s[35]=ae):ae=s[35],s[36]!==le||s[37]!==ae?(ce=(0,me.jsxs)(me.Fragment,{children:[le,re,ae]}),s[36]=le,s[37]=ae,s[38]=ce):ce=s[38];const de=ce;let ue,ge;return s[39]!==q||s[40]!==M||s[41]!==C||s[42]!==B.top||s[43]!==Y||s[44]!==de||s[45]!==_?(ue=M?(0,me.jsxs)(t.View,{style:q,children:[(0,me.jsxs)(t.View,{style:tt.sidebarDragArea,children:[(0,me.jsx)(W.TitlebarDragRegion,{}),B.top>0?(0,me.jsx)(t.View,{style:Y}):null,(0,me.jsx)(k.SidebarHeaderRow,{icon:f.ArrowLeft,label:_("settings.backToWorkspace"),onPress:C,testID:"settings-back-to-workspace"})]}),(0,me.jsx)(o.ScrollView,{style:tt.scrollBody,showsVerticalScrollIndicator:!1,children:de})]}):de,s[39]=q,s[40]=M,s[41]=C,s[42]=B.top,s[43]=Y,s[44]=de,s[45]=_,s[46]=ue):ue=s[46],s[47]!==K||s[48]!==ue?(ge=(0,me.jsx)(t.View,{style:K,testID:"settings-sidebar",children:ue}),s[47]=K,s[48]=ue,s[49]=ge):ge=s[49],ge}function Ye({view:e,openAddHostIntent:s=null}){const l=(0,h.useRouter)(),{theme:c}=(0,S.useUnistyles)(),{t:p}=(0,y.useTranslation)(),j=(0,ce.useVoiceAudioEngineOptional)(),{settings:v,isLoading:w,updateSettings:k}=(0,z.useAppSettings)(),[T,C]=(0,u.useState)(!1),[V,_]=(0,u.useState)(!1),[D,A]=(0,u.useState)(!1),[B,M]=(0,u.useState)(!1),[R,U]=(0,u.useState)(null),K=(0,u.useRef)(null),W=(0,ie.isElectronRuntime)(),F=(0,le.resolveAppVersion)(),X=(0,oe.formatVersionWithPrefix)(F),Y=(0,he.useIsCompactFormFactor)(),Z=(0,b.useSafeAreaInsets)(),ee=(0,u.useMemo)(()=>({paddingBottom:Z.bottom}),[Z.bottom]),re=(0,ye.useWebScrollbarStyle)(),de=(0,u.useMemo)(()=>[Ze.scrollView,re],[re]),ue=(0,O.useHosts)(),Se=(0,be.useLocalDaemonServerId)(),ke=Ee(ue,Se),[Te,Ce]=(0,u.useState)("host"===e.kind?e.serverId:null),Ve=(0,u.useMemo)(()=>Te&&ue.some(e=>e.serverId===Te)?Te:null,[ue,Te]);(0,u.useEffect)(()=>{"host"===e.kind&&Ce(e.serverId)},[e]);const Ie=(0,u.useMemo)(()=>"host"===e.kind?e.serverId:Ve??Se??ke[0]?.serverId??null,[e,Ve,Se,ke]),He=(0,u.useCallback)(e=>{k({sendBehavior:e})},[k]),Le=(0,u.useCallback)(e=>{k({fastOfflineMode:e})},[k]),Pe=(0,u.useCallback)(e=>{k({serviceUrlBehavior:e})},[k]),ze=(0,u.useCallback)(e=>{k({language:e})},[k]),De=(0,u.useCallback)(e=>{k({terminalScrollbackLines:e})},[k]),Me=(0,u.useCallback)(async()=>{if(j&&!B){M(!0),U(null);try{const e=x.Buffer.from(ae.THINKING_TONE_NATIVE_PCM_BASE64,"base64");await j.initialize(),j.stop(),await j.play({type:"audio/pcm;rate=16000;bits=16",size:e.byteLength,arrayBuffer:async()=>Uint8Array.from(e).buffer}),U(null)}catch(e){const t=e instanceof Error?e.message:String(e);console.error("[Settings] Playback test failed",e),U(p("settings.diagnostics.playbackFailed",{message:t}))}finally{M(!1)}}},[B,p,j]),Oe=(0,u.useCallback)(()=>{C(!1),_(!1),A(!1)},[]),Ue=(0,u.useCallback)(()=>{_(!1),A(!1),C(!0)},[]),Ke=(0,u.useCallback)(()=>{C(!0)},[]);(0,u.useEffect)(()=>{s&&K.current!==s&&(K.current=s,Ke())},[Ke,s]);const We=(0,u.useCallback)(()=>{C(!1),_(!0)},[]),Fe=(0,u.useCallback)(()=>{C(!1),A(!0)},[]),Ge=(0,u.useCallback)(({serverId:e})=>{const t=(0,xe.buildSettingsHostSectionRoute)(e,"connections");Y?l.push(t):l.replace(t)},[Y,l]),Ne=(0,u.useCallback)(e=>{const t=(0,xe.buildSettingsSectionRoute)(e);Y?l.push(t):l.replace(t)},[Y,l]),qe=(0,u.useCallback)(t=>{if(Ce(t),"host"!==e.kind)return;const s=e.section,n=(0,xe.buildSettingsHostSectionRoute)(t,s);Y?l.push(n):l.replace(n)},[Y,l,e]),$e=(0,u.useCallback)(e=>{if(!Ie)return void Ke();const t=(0,xe.buildSettingsHostSectionRoute)(Ie,e);Y?l.push(t):l.replace(t)},[Ie,Ke,Y,l]),Qe=(0,u.useCallback)(()=>{const e=(0,xe.buildProjectsSettingsRoute)();Y?l.push(e):l.replace(e)},[Y,l]),Je=(0,u.useCallback)(()=>{Oe(),l.push({pathname:"/pair-scan",params:{source:"settings"}})},[Oe,l]),Ye=(0,u.useCallback)(()=>{const e=(0,xe.buildSettingsSectionRoute)("general");Y?l.replace("/settings"):l.replace(e)},[Y,l]),tt=(0,u.useCallback)(()=>{l.canGoBack()?l.back():l.replace("/settings")},[l]),st=(0,u.useCallback)(()=>{(0,fe.navigateToLastWorkspace)()||l.replace((0,xe.buildOpenProjectRoute)())},[l]),nt=(()=>{if("host"===e.kind){const t=ve.find(t=>t.id===e.section);return t?{title:p(t.labelKey),Icon:t.icon}:null}if("section"===e.kind){const t=je.find(t=>t.id===e.section);return t?{title:p(t.labelKey),Icon:t.icon}:null}return"project"===e.kind||"projects"===e.kind?{title:p("settings.projects"),Icon:f.FolderGit2}:null})(),it=(()=>{if("host"===e.kind)return we(e,Ye);if("projects"===e.kind)return(0,me.jsx)(ge.default,{view:e});if("project"===e.kind)return(0,me.jsx)(pe.default,{projectKey:e.projectKey});if("section"===e.kind)switch(e.section){case"general":return(0,me.jsx)(Ae,{settings:v,isDesktopApp:W,handleSendBehaviorChange:He,handleServiceUrlBehaviorChange:Pe,handleLanguageChange:ze,handleTerminalScrollbackLinesChange:De,handleFastOfflineModeChange:Le});case"daemon":return(0,me.jsx)(ne.LocalDaemonSection,{});case"appearance":return(0,me.jsx)(P.AppearanceSection,{serverId:Ie});case"voice-language":return(0,me.jsx)(L.VoiceLanguageSection,{});case"shortcuts":return W?(0,me.jsx)(Q.KeyboardShortcutsSection,{}):(0,me.jsx)(J.SectionUnavailable,{icon:f.Keyboard,sectionTitle:p("settings.sections.shortcuts"),description:p("settings.unavailable.shortcuts"),testID:"settings-shortcuts-unavailable"});case"integrations":return W?(0,me.jsx)(se.IntegrationsSection,{}):(0,me.jsx)(J.SectionUnavailable,{icon:f.Puzzle,sectionTitle:p("settings.sections.integrations"),description:p("settings.unavailable.integrations"),testID:"settings-integrations-unavailable"});case"permissions":return W?(0,me.jsx)(te.DesktopPermissionsSection,{}):(0,me.jsx)(J.SectionUnavailable,{icon:f.Shield,sectionTitle:p("settings.sections.permissions"),description:p("settings.unavailable.permissions"),testID:"settings-permissions-unavailable"});case"diagnostics":return(0,me.jsx)(Be,{voiceAudioEngine:j,isPlaybackTestRunning:B,playbackTestResult:R,handlePlaybackTest:Me,appVersion:F,isDesktopApp:W});case"about":return(0,me.jsx)(Re,{appVersion:F,appVersionText:X,isDesktopApp:W})}return null})();if(w)return(0,me.jsx)(t.View,{style:Ze.loadingContainer,children:(0,me.jsx)(n.Text,{style:Ze.loadingText,children:p("settings.loading")})});const ot=(0,me.jsxs)(me.Fragment,{children:[(0,me.jsx)(N.AddHostMethodModal,{visible:T,onClose:Oe,onDirectConnection:We,onPasteLink:Fe,onScanQr:Je}),(0,me.jsx)(q.AddHostModal,{visible:V,onClose:Oe,onCancel:Ue,onSaved:Ge}),(0,me.jsx)($.PairLinkModal,{visible:D,onClose:Oe,onCancel:Ue,onSaved:Ge})]});if(Y&&"root"===e.kind)return(0,me.jsxs)(t.View,{style:Ze.container,children:[(0,me.jsx)(E.BackHeader,{title:p("settings.title"),onBack:st}),(0,me.jsx)(o.ScrollView,{style:de,contentContainerStyle:ee,children:(0,me.jsx)(Xe,{view:e,onSelectSection:Ne,onSelectHostSection:$e,onSelectHost:qe,onSelectProjects:Qe,onAddHost:Ke,onBackToWorkspace:st,activeHostServerId:Ie,layout:"mobile"})}),ot]});const lt="project"===e.kind?st:tt;return Y?(0,me.jsxs)(t.View,{style:Ze.container,children:[(0,me.jsx)(E.BackHeader,{title:nt?.title,titleAccessory:nt?.titleAccessory,onBack:lt}),(0,me.jsx)(o.ScrollView,{style:de,contentContainerStyle:ee,children:(0,me.jsx)(t.View,{style:Ze.content,children:it})}),ot]}):(0,me.jsxs)(t.View,{style:Ze.container,children:[(0,me.jsxs)(t.View,{style:et.row,children:[(0,me.jsx)(Xe,{view:e,onSelectSection:Ne,onSelectHostSection:$e,onSelectHost:qe,onSelectProjects:Qe,onAddHost:Ke,onBackToWorkspace:st,activeHostServerId:Ie,layout:"desktop"}),(0,me.jsxs)(t.View,{style:et.contentPane,children:[(0,me.jsx)(G.ScreenHeader,{borderless:!nt,windowControlsPaddingRole:"detailHeader",left:nt?(0,me.jsxs)(me.Fragment,{children:[(0,me.jsx)(H.HeaderIconBadge,{children:(0,me.jsx)(nt.Icon,{size:c.iconSize.md,color:c.colors.foregroundMuted})}),(0,me.jsx)(I.ScreenTitle,{testID:"settings-detail-header-title",children:nt.title}),nt.titleAccessory]}):null,leftStyle:et.detailLeft}),(0,me.jsx)(o.ScrollView,{style:de,contentContainerStyle:ee,children:(0,me.jsx)(t.View,{style:Ze.content,children:it})})]})]}),ot]})}const Ze=S.StyleSheet.create(e=>({loadingContainer:{flex:1,backgroundColor:e.colors.surface0,alignItems:"center",justifyContent:"center",uni__dependencies:[0]},loadingText:{color:e.colors.foreground,fontSize:e.fontSize.lg,uni__dependencies:[0]},container:{flex:1,backgroundColor:e.colors.surface0,uni__dependencies:[0]},scrollView:{flex:1},content:{padding:e.spacing[4],paddingTop:e.spacing[6],width:"100%",maxWidth:720,alignSelf:"center",uni__dependencies:[0]},aboutValue:{color:e.colors.foregroundMuted,fontSize:e.fontSize.sm,uni__dependencies:[0]},aboutVersionMismatch:{color:e.colors.palette.amber[500],uni__dependencies:[0]},aboutErrorText:{color:e.colors.palette.red[300],fontSize:e.fontSize.xs,marginTop:e.spacing[1],uni__dependencies:[0]},aboutCommunity:{marginTop:e.spacing[4],uni__dependencies:[0]},aboutUpdateActions:{flexDirection:"row",alignItems:"center",gap:e.spacing[2],uni__dependencies:[0]},themeTrigger:{flexDirection:"row",alignItems:"center",gap:e.spacing[1],paddingVertical:e.spacing[1],paddingHorizontal:e.spacing[2],borderRadius:e.borderRadius.md,borderWidth:1,borderColor:e.colors.border,uni__dependencies:[0]},themeTriggerText:{color:e.colors.foreground,fontSize:e.fontSize.sm,uni__dependencies:[0]},terminalScrollbackInput:{width:112,minHeight:36,paddingVertical:e.spacing[2],paddingHorizontal:e.spacing[3],borderRadius:e.borderRadius.md,borderWidth:1,borderColor:e.colors.border,backgroundColor:e.colors.surface2,color:e.colors.foreground,fontSize:e.fontSize.sm,textAlign:"right",uni__dependencies:[0]},placeholder:{flex:1,alignItems:"center",justifyContent:"center",paddingVertical:e.spacing[8],uni__dependencies:[0]},placeholderText:{color:e.colors.foregroundMuted,fontSize:e.fontSize.sm,uni__dependencies:[0]}})),et=S.StyleSheet.create(e=>({row:{flex:1,flexDirection:"row"},contentPane:{flex:1},detailLeft:{gap:e.spacing[2],uni__dependencies:[0]}})),tt=S.StyleSheet.create(e=>({desktopContainer:{width:320,borderRightWidth:1,borderRightColor:e.colors.border,backgroundColor:e.colors.surfaceSidebar,uni__dependencies:[0]},scrollBody:{flex:1},sidebarDragArea:{position:"relative"},mobileContainer:{paddingVertical:e.spacing[2],paddingHorizontal:e.spacing[2],uni__dependencies:[0]},list:{paddingVertical:e.spacing[2],paddingHorizontal:e.spacing[2],gap:e.spacing[1],uni__dependencies:[0]},groupLabel:{fontSize:e.fontSize.sm,fontWeight:e.fontWeight.medium,color:e.colors.foregroundMuted,paddingHorizontal:e.spacing[2],paddingVertical:e.spacing[1],uni__dependencies:[0]},item:{flexDirection:"row",alignItems:"center",gap:e.spacing[2],minHeight:36,paddingVertical:e.spacing[2],paddingHorizontal:e.spacing[2],borderRadius:e.borderRadius.lg,uni__dependencies:[0]},itemHovered:{backgroundColor:e.colors.surfaceSidebarHover,uni__dependencies:[0]},itemSelected:{backgroundColor:e.colors.surfaceSidebarHover,uni__dependencies:[0]},label:{fontSize:e.fontSize.base,color:e.colors.foregroundMuted,fontWeight:e.fontWeight.normal,flex:1,uni__dependencies:[0]},pickerTrigger:{flexDirection:"row",alignItems:"center",gap:e.spacing[2],minHeight:36,paddingVertical:e.spacing[2],paddingHorizontal:e.spacing[2],borderRadius:e.borderRadius.lg,uni__dependencies:[0]},pickerTriggerHovered:{backgroundColor:e.colors.surfaceSidebarHover,uni__dependencies:[0]},pickerTriggerLabel:{flex:1,minWidth:0,fontSize:e.fontSize.base,color:e.colors.foreground,fontWeight:e.fontWeight.normal,uni__dependencies:[0]},pickerTriggerDot:{width:e.iconSize.md,height:e.iconSize.md,alignItems:"center",justifyContent:"center",uni__dependencies:[0]}}))},4875,[348,2838,349,2815,2476,350,36,639,546,182,234,571,146,379,558,56,352,52,811,3953,4876,3954,3584,4878,3469,3470,4496,4879,4880,4881,4882,3590,384,3696,4215,4887,3420,3274,3427,3410,3583,3626,4863,4495,4888,4889,4890,4891,4892,2475,4817,4504,3587,4893,4897,4899,3417,4212,3414,3933,4067,4060,3594,4904,4917,4918,3472,3490,3512,3589,3492,3502,279]);
|
|
16635
|
-
__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppDiagnosticSheet=function({visible:l,onClose:c,appVersion:p,isDesktopApp:f}){const{t:R}=(0,u.useTranslation)(),H=(0,b.useToast)(),E=(0,S.useHosts)(),[O,B]=(0,o.useState)(null),[M,T]=(0,o.useState)(!1),[$,z]=(0,o.useState)([]),L=(0,o.useRef)(0),V=(0,o.useCallback)((e,s,t)=>{z(n=>n.find(s=>s.id===e)?n.map(n=>n.id===e?Object.assign({},n,{label:s,status:t}):n):[...n,{id:e,label:s,status:t}])},[]),N=(0,o.useCallback)(async()=>{const e=L.current+1;L.current=e;const s=()=>L.current===e,t=(e,t,n)=>{s()&&V(e,t,n)};T(!0),B(null),z([]);const n=[];try{if(t("client",R("settings.diagnostics.app.progress.client"),"running"),n.push((0,y.formatAppDiagnosticHeader)({appVersion:p,platform:"web",isDesktopApp:f,hostCount:E.length})),t("client",R("settings.diagnostics.app.progress.client"),"done"),f){const e=R("settings.diagnostics.app.progress.desktop");t("desktop",e,"running");const s=await C();n.push(...s.sections),t("desktop",e,s.status)}const e=(0,S.getHostRuntimeStore)();for(const s of E){const o=`host:${s.serverId}`;t(o,s.label,"running");const l=e.getSnapshot(s.serverId),c=await I(s,l);n.push(...c.sections),t(o,s.label,c.status)}s()&&B((0,y.redactAppDiagnosticReport)(n.join("\n\n"),E))}finally{s()&&T(!1)}},[p,E,f,R,V]);(0,o.useEffect)(()=>{l?N():(L.current+=1,T(!1),B(null),z([]))},[l,N]);const Z=(0,o.useCallback)(()=>{N()},[N]),F=(0,o.useCallback)(()=>{O&&n.setStringAsync(O).then(()=>H.copied(R("settings.diagnostics.app.copyLabel"))).catch(()=>H.error(R("settings.diagnostics.app.copyFailed")))},[O,R,H]),U=(0,o.useCallback)(({hovered:e,pressed:s})=>[A.iconButton,(Boolean(e)||s)&&A.iconButtonHovered],[]),q=(0,o.useCallback)(({hovered:e,pressed:s})=>[A.iconButton,(Boolean(e)||s)&&Boolean(O)&&A.iconButtonHovered,O?null:A.disabled],[O]),G=(0,o.useMemo)(()=>({title:R("settings.diagnostics.app.title"),actions:(0,D.jsxs)(e.View,{style:A.headerActions,children:[(0,D.jsx)(t.Pressable,{onPress:F,disabled:!O,hitSlop:8,style:q,accessibilityRole:"button",accessibilityLabel:R("settings.diagnostics.app.copyAccessibility"),children:(0,D.jsx)(_,{size:v.ICON_SIZE.sm,uniProps:k})}),(0,D.jsx)(t.Pressable,{onPress:Z,disabled:M,hitSlop:8,style:U,accessibilityRole:"button",accessibilityLabel:R(M?"settings.diagnostics.app.refreshingAccessibility":"settings.diagnostics.app.refreshAccessibility"),children:M?(0,D.jsx)(x,{size:v.ICON_SIZE.sm,uniProps:k}):(0,D.jsx)(j,{size:v.ICON_SIZE.sm,uniProps:k})})]})}),[O,q,F,Z,U,M,R]);return(0,D.jsx)(d.AdaptiveModalSheet,{header:G,visible:l,onClose:c,snapPoints:w,scrollable:!1,testID:"app-diagnostic-sheet",children:O?(0,D.jsx)(h.ScrollableCodeSurface,{maxHeight:520,children:O},l?"visible":"hidden"):(0,D.jsx)(h.SurfaceCard,{children:(0,D.jsx)(e.View,{style:A.progressContent,children:0===$.length?(0,D.jsxs)(e.View,{style:A.progressRow,children:[(0,D.jsx)(x,{size:v.ICON_SIZE.sm,uniProps:k}),(0,D.jsx)(s.Text,{style:A.mutedText,children:R("settings.diagnostics.app.running")})]}):$.map(t=>(0,D.jsxs)(e.View,{style:A.progressRow,children:["running"===t.status||"pending"===t.status?(0,D.jsx)(x,{size:v.ICON_SIZE.sm,uniProps:k}):(0,D.jsx)(e.View,{style:"failed"===t.status?A.statusDotFailed:A.statusDot}),(0,D.jsx)(s.Text,{style:A.mutedText,children:`${t.label}: ${P(t.status)}`})]},t.id))})},l?"visible":"hidden")})};var e=r(_d[0]),s=r(_d[1]),t=r(_d[2]),n=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),s.default=e,s})(r(_d[3])),o=r(_d[4]);r(_d[5]),r(_d[6]),r(_d[7]),r(_d[8]);var l=r(_d[9]),c=r(_d[10]),u=r(_d[11]),d=r(_d[12]),p=r(_d[13]),h=r(_d[14]),b=r(_d[15]),f=r(_d[16]),y=r(_d[17]),S=r(_d[18]),v=r(_d[19]),D=r(_d[20]);const w=["55%","88%"],_=(0,c.withUnistyles)(l.Copy),j=(0,c.withUnistyles)(l.RotateCw),x=(0,c.withUnistyles)(p.LoadingSpinner),k=e=>({color:e.colors.foregroundMuted});async function C(){try{const[s,t]=await Promise.all([(0,f.getDesktopDaemonStatus)(),(0,f.getDesktopDaemonLogs)()]);return{status:"done",sections:[(0,y.formatDiagnosticSection)("Desktop",[{label:"Daemon status",value:s.status},{label:"Desktop managed",value:String(s.desktopManaged)},{label:"Daemon PID",value:null===s.pid?"none":String(s.pid)},{label:"Daemon version",value:s.version??"unknown"},{label:"Daemon home",value:s.home||"unknown"},{label:"Log path",value:t.logPath||"unknown"},{label:"Error",value:s.error??"none"}]),["Desktop daemon log tail",t.contents?(e=t.contents,e.split("\n").filter(Boolean).map(e=>` ${e}`).join("\n")):" No log lines found"].join("\n")]}}catch(e){return{status:"failed",sections:[(0,y.formatDiagnosticSection)("Desktop",[{label:"Error",value:R(e)}])]}}var e}async function I(e,s){const t=[(0,y.formatHostRuntimeSection)({host:e,snapshot:s})],n=s?.client??null;if("online"!==s?.connectionStatus||!n)return t.push((0,y.formatDiagnosticSection)(`Host diagnostics: ${e.label}`,[{label:"Status",value:"host is not connected"}])),{sections:t,status:"done"};try{const s=n.getLastServerInfoMessage();t.push((0,y.formatServerInfoSection)(s));const o=await n.measureLatency({timeoutMs:
|
|
16635
|
+
__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppDiagnosticSheet=function({visible:l,onClose:c,appVersion:p,isDesktopApp:f}){const{t:R}=(0,u.useTranslation)(),H=(0,b.useToast)(),E=(0,S.useHosts)(),[O,B]=(0,o.useState)(null),[M,T]=(0,o.useState)(!1),[$,z]=(0,o.useState)([]),L=(0,o.useRef)(0),V=(0,o.useCallback)((e,s,t)=>{z(n=>n.find(s=>s.id===e)?n.map(n=>n.id===e?Object.assign({},n,{label:s,status:t}):n):[...n,{id:e,label:s,status:t}])},[]),N=(0,o.useCallback)(async()=>{const e=L.current+1;L.current=e;const s=()=>L.current===e,t=(e,t,n)=>{s()&&V(e,t,n)};T(!0),B(null),z([]);const n=[];try{if(t("client",R("settings.diagnostics.app.progress.client"),"running"),n.push((0,y.formatAppDiagnosticHeader)({appVersion:p,platform:"web",isDesktopApp:f,hostCount:E.length})),t("client",R("settings.diagnostics.app.progress.client"),"done"),f){const e=R("settings.diagnostics.app.progress.desktop");t("desktop",e,"running");const s=await C();n.push(...s.sections),t("desktop",e,s.status)}const e=(0,S.getHostRuntimeStore)();for(const s of E){const o=`host:${s.serverId}`;t(o,s.label,"running");const l=e.getSnapshot(s.serverId),c=await I(s,l);n.push(...c.sections),t(o,s.label,c.status)}s()&&B((0,y.redactAppDiagnosticReport)(n.join("\n\n"),E))}finally{s()&&T(!1)}},[p,E,f,R,V]);(0,o.useEffect)(()=>{l?N():(L.current+=1,T(!1),B(null),z([]))},[l,N]);const Z=(0,o.useCallback)(()=>{N()},[N]),F=(0,o.useCallback)(()=>{O&&n.setStringAsync(O).then(()=>H.copied(R("settings.diagnostics.app.copyLabel"))).catch(()=>H.error(R("settings.diagnostics.app.copyFailed")))},[O,R,H]),U=(0,o.useCallback)(({hovered:e,pressed:s})=>[A.iconButton,(Boolean(e)||s)&&A.iconButtonHovered],[]),q=(0,o.useCallback)(({hovered:e,pressed:s})=>[A.iconButton,(Boolean(e)||s)&&Boolean(O)&&A.iconButtonHovered,O?null:A.disabled],[O]),G=(0,o.useMemo)(()=>({title:R("settings.diagnostics.app.title"),actions:(0,D.jsxs)(e.View,{style:A.headerActions,children:[(0,D.jsx)(t.Pressable,{onPress:F,disabled:!O,hitSlop:8,style:q,accessibilityRole:"button",accessibilityLabel:R("settings.diagnostics.app.copyAccessibility"),children:(0,D.jsx)(_,{size:v.ICON_SIZE.sm,uniProps:k})}),(0,D.jsx)(t.Pressable,{onPress:Z,disabled:M,hitSlop:8,style:U,accessibilityRole:"button",accessibilityLabel:R(M?"settings.diagnostics.app.refreshingAccessibility":"settings.diagnostics.app.refreshAccessibility"),children:M?(0,D.jsx)(x,{size:v.ICON_SIZE.sm,uniProps:k}):(0,D.jsx)(j,{size:v.ICON_SIZE.sm,uniProps:k})})]})}),[O,q,F,Z,U,M,R]);return(0,D.jsx)(d.AdaptiveModalSheet,{header:G,visible:l,onClose:c,snapPoints:w,scrollable:!1,testID:"app-diagnostic-sheet",children:O?(0,D.jsx)(h.ScrollableCodeSurface,{maxHeight:520,children:O},l?"visible":"hidden"):(0,D.jsx)(h.SurfaceCard,{children:(0,D.jsx)(e.View,{style:A.progressContent,children:0===$.length?(0,D.jsxs)(e.View,{style:A.progressRow,children:[(0,D.jsx)(x,{size:v.ICON_SIZE.sm,uniProps:k}),(0,D.jsx)(s.Text,{style:A.mutedText,children:R("settings.diagnostics.app.running")})]}):$.map(t=>(0,D.jsxs)(e.View,{style:A.progressRow,children:["running"===t.status||"pending"===t.status?(0,D.jsx)(x,{size:v.ICON_SIZE.sm,uniProps:k}):(0,D.jsx)(e.View,{style:"failed"===t.status?A.statusDotFailed:A.statusDot}),(0,D.jsx)(s.Text,{style:A.mutedText,children:`${t.label}: ${P(t.status)}`})]},t.id))})},l?"visible":"hidden")})};var e=r(_d[0]),s=r(_d[1]),t=r(_d[2]),n=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),s.default=e,s})(r(_d[3])),o=r(_d[4]);r(_d[5]),r(_d[6]),r(_d[7]),r(_d[8]);var l=r(_d[9]),c=r(_d[10]),u=r(_d[11]),d=r(_d[12]),p=r(_d[13]),h=r(_d[14]),b=r(_d[15]),f=r(_d[16]),y=r(_d[17]),S=r(_d[18]),v=r(_d[19]),D=r(_d[20]);const w=["55%","88%"],_=(0,c.withUnistyles)(l.Copy),j=(0,c.withUnistyles)(l.RotateCw),x=(0,c.withUnistyles)(p.LoadingSpinner),k=e=>({color:e.colors.foregroundMuted});async function C(){try{const[s,t]=await Promise.all([(0,f.getDesktopDaemonStatus)(),(0,f.getDesktopDaemonLogs)()]);return{status:"done",sections:[(0,y.formatDiagnosticSection)("Desktop",[{label:"Daemon status",value:s.status},{label:"Desktop managed",value:String(s.desktopManaged)},{label:"Daemon PID",value:null===s.pid?"none":String(s.pid)},{label:"Daemon version",value:s.version??"unknown"},{label:"Daemon home",value:s.home||"unknown"},{label:"Log path",value:t.logPath||"unknown"},{label:"Error",value:s.error??"none"}]),["Desktop daemon log tail",t.contents?(e=t.contents,e.split("\n").filter(Boolean).map(e=>` ${e}`).join("\n")):" No log lines found"].join("\n")]}}catch(e){return{status:"failed",sections:[(0,y.formatDiagnosticSection)("Desktop",[{label:"Error",value:R(e)}])]}}var e}async function I(e,s){const t=[(0,y.formatHostRuntimeSection)({host:e,snapshot:s})],n=s?.client??null;if("online"!==s?.connectionStatus||!n)return t.push((0,y.formatDiagnosticSection)(`Host diagnostics: ${e.label}`,[{label:"Status",value:"host is not connected"}])),{sections:t,status:"done"};try{const s=n.getLastServerInfoMessage();t.push((0,y.formatServerInfoSection)(s));const o=await n.measureLatency({timeoutMs:1e4});if(t.push((0,y.formatDiagnosticSection)(`Host latency: ${e.label}`,[{label:"Active RTT",value:`${Math.round(o)}ms`}])),!0===s?.features?.daemonDiagnostics){const e=await n.collectDiagnostics();t.push(e.diagnostic)}else t.push((0,y.formatDiagnosticSection)(`Daemon diagnostics: ${e.label}`,[{label:"Status",value:"unsupported by this daemon"}]));return{sections:t,status:"done"}}catch(s){return t.push((0,y.formatDiagnosticSection)(`Host diagnostics: ${e.label}`,[{label:"Error",value:R(s)}])),{sections:t,status:"failed"}}}function R(e){return e instanceof Error?e.message:String(e)}function P(e){switch(e){case"done":return"done";case"failed":return"failed";case"running":case"pending":return"running"}}const A=c.StyleSheet.create(e=>({progressContent:{paddingVertical:e.spacing[4],paddingHorizontal:e.spacing[4],gap:e.spacing[3],uni__dependencies:[0]},progressRow:{flexDirection:"row",alignItems:"center",gap:e.spacing[2],minHeight:24,uni__dependencies:[0]},mutedText:{flex:1,fontSize:e.fontSize.sm,color:e.colors.foregroundMuted,uni__dependencies:[0]},headerActions:{flexDirection:"row",alignItems:"center",gap:e.spacing[1],uni__dependencies:[0]},iconButton:{width:28,height:28,borderRadius:e.borderRadius.full,alignItems:"center",justifyContent:"center",uni__dependencies:[0]},iconButtonHovered:{backgroundColor:e.colors.surface2,uni__dependencies:[0]},disabled:{opacity:.5},statusDot:{width:8,height:8,borderRadius:e.borderRadius.full,backgroundColor:e.colors.success,uni__dependencies:[0]},statusDotFailed:{width:8,height:8,borderRadius:e.borderRadius.full,backgroundColor:e.colors.destructive,uni__dependencies:[0]}}))},4876,[348,349,2476,3646,36,25,546,234,146,811,56,352,3481,3579,3928,3514,3416,4877,3274,305,279]);
|
|
16636
16636
|
__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n){return[t,...n.map(t=>` ${t.label}: ${t.value}`)].join("\n")}function n(t){switch(t){case"directTcp":return"direct TCP";case"directSocket":return"local socket";case"directPipe":return"local pipe";case"relay":return"relay";default:return"unknown"}}function o(t){const n=new Set;for(const o of t)for(const t of o.connections)n.add(t.id),"directTcp"===t.type?(n.add(t.endpoint),t.password&&n.add(t.password)):"relay"===t.type?(n.add(t.relayEndpoint),n.add(t.daemonPublicKeyB64)):"directSocket"!==t.type&&"directPipe"!==t.type||n.add(t.path);return[...n].filter(t=>t.trim().length>0)}Object.defineProperty(e,'__esModule',{value:!0}),e.formatDiagnosticSection=t,e.formatAppDiagnosticHeader=function(n){return t("Paseo app diagnostics",[{label:"Collected at",value:(new Date).toISOString()},{label:"App version",value:n.appVersion??"unknown"},{label:"Platform",value:n.platform},{label:"Desktop app",value:String(n.isDesktopApp)},{label:"Saved hosts",value:String(n.hostCount)}])},e.formatHostRuntimeSection=function(o){const{host:l,snapshot:c}=o,s=[{label:"Server ID",value:l.serverId},{label:"Status",value:c?.connectionStatus??"not started"},{label:"Active connection",value:c?.activeConnection?n(c.activeConnection.type):"none"},{label:"Last online",value:c?.lastOnlineAt??"never"},{label:"Last error",value:c?.lastError??"none"},{label:"Agent directory",value:c?.agentDirectoryStatus??"unknown"}],u=l.connections.map((t,o)=>{const l=c?.probeByConnectionId.get(t.id)??null,s=c?.activeConnectionId===t.id;return{label:`Connection ${o+1}`,value:[n(t.type),s?"active":"inactive",l?`probe=${l.status}`:"probe=unknown","available"===l?.status?`latency=${Math.round(l.latencyMs)}ms`:null].filter(Boolean).join(", ")}});return t(`Host: ${l.label}`,[...s,...u])},e.formatServerInfoSection=function(n){if(!n)return t("Server info",[{label:"Status",value:"not received"}]);const o=n.features?Object.keys(n.features).sort():[];return t("Server info",[{label:"Server ID",value:n.serverId},{label:"Hostname",value:n.hostname??"unknown"},{label:"Version",value:n.version??"unknown"},{label:"Features",value:o.length>0?o.join(", "):"none"}])},e.describeConnectionKind=n,e.redactAppDiagnosticReport=function(t,n){let l=t;for(const t of o(n))l=l.split(t).join("[redacted]");return l.replace(/paseo:\/\/\S+/gi,"paseo://[redacted]").replace(/([?&](?:password|token|secret|key|publicKey|daemonPublicKeyB64)=)[^&\s"']+/gi,"$1[redacted]").replace(/((?:password|token|secret|authorization|api[_-]?key|daemonPublicKeyB64|relayKey)\s*[:=]\s*)("[^"]+"|'[^']+'|[^\s,}]+)/gi,"$1[redacted]")}},4877,[]);
|
|
16637
16637
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SidebarSeparator=function(){const n=(0,o.c)(1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,c.jsx)(t.View,{style:l.line}),n[0]=s):s=n[0];return s};var t=r(d[0]),o=r(d[1]);r(d[2]);var n=r(d[3]),c=r(d[4]);const l=n.StyleSheet.create(t=>({line:{borderBottomWidth:1,borderBottomColor:t.colors.border,uni__dependencies:[0]}}))},4878,[348,350,146,56,279]);
|
|
16638
16638
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.HeaderIconBadge=function(o){const s=(0,n.c)(2),{children:u}=o;let _;s[0]!==u?(_=(0,l.jsx)(t.View,{style:c.headerIconSlotStyle.slot,children:u}),s[0]=u,s[1]=_):_=s[1];return _};var t=r(d[0]),n=r(d[1]);r(d[2]);var c=r(d[3]),l=r(d[4])},4879,[348,350,146,4497,279]);
|
|
@@ -16708,5 +16708,5 @@ __d(function(g,r,_i,a,_m,_e,d){"use strict";var e,t=r(d[0]),n=this&&this.__creat
|
|
|
16708
16708
|
__r(694);
|
|
16709
16709
|
__r(341);
|
|
16710
16710
|
__r(0);
|
|
16711
|
-
//# sourceMappingURL=/_expo/static/js/web/index-
|
|
16712
|
-
//# debugId=
|
|
16711
|
+
//# sourceMappingURL=/_expo/static/js/web/index-81ee92214133211579a50ef5c84491cf.js.map
|
|
16712
|
+
//# debugId=4c56fba4-e656-42c0-840b-b64c6b46b956
|