getborg 0.0.117 → 0.0.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/bin.mjs +251 -79
  2. package/dist/client/.vite/manifest.json +171 -171
  3. package/dist/client/assets/{ChatMarkdown-BGNgYyxf.js → ChatMarkdown-6kh9qKYW.js} +2 -2
  4. package/dist/client/assets/{DesignWorkspace-Ddz8UJXt.js → DesignWorkspace-DPuyt5mw.js} +2 -2
  5. package/dist/client/assets/{DiffPanel-mzb-LNBg.js → DiffPanel-DzRhendL.js} +2 -2
  6. package/dist/client/assets/{DiffWorkerPoolProvider-iCAF4Ogc.js → DiffWorkerPoolProvider-BU7l1oGv.js} +2 -2
  7. package/dist/client/assets/{DocxPreview-BKhbQZ7C.js → DocxPreview-B7-febv_.js} +4 -4
  8. package/dist/client/assets/{FilePreviewPanel-DuxNlIRO.js → FilePreviewPanel-B3x43muL.js} +4 -4
  9. package/dist/client/assets/{HtmlPreview-DaZHfcMP.js → HtmlPreview-DY3PT2FT.js} +2 -2
  10. package/dist/client/assets/{PdfPreview-BoUaG-ol.js → PdfPreview-W5mTp32l.js} +3 -3
  11. package/dist/client/assets/{PptxPreview-BQU4yUZZ.js → PptxPreview-B02U0OAE.js} +3 -3
  12. package/dist/client/assets/{PreviewPanel-CnjyoM26.js → PreviewPanel-DhzZlEWJ.js} +2 -2
  13. package/dist/client/assets/{PullRequestCodeTab-DM_H15J2.js → PullRequestCodeTab-CoB5ByAD.js} +2 -2
  14. package/dist/client/assets/{PullRequestReactions-CHoFc7lq.js → PullRequestReactions-DVg6Hz1F.js} +2 -2
  15. package/dist/client/assets/{VirtualizedFile-CZoHsBen.js → VirtualizedFile-Bz5fGbNr.js} +2 -2
  16. package/dist/client/assets/{XlsxPreview-DjwlT8cY.js → XlsxPreview-8ACeuCsx.js} +3 -3
  17. package/dist/client/assets/{assetUrls-CrfozqHH.js → assetUrls-CbeTQh3H.js} +2 -2
  18. package/dist/client/assets/{browserHistoryStore-7Le_ew5p.js → browserHistoryStore-DLbnuO9R.js} +2 -2
  19. package/dist/client/assets/{browserRecording-CSyywxgr.js → browserRecording-DpmNgRt_.js} +2 -2
  20. package/dist/client/assets/{combobox-CiD-v9Ce.js → combobox-CByZwSML.js} +2 -2
  21. package/dist/client/assets/{composerMentionDrag-DqJ92Sd8.js → composerMentionDrag-1fGsNlV_.js} +2 -2
  22. package/dist/client/assets/{designCanvas.logic-HpJw8lAO.js → designCanvas.logic-BaQE_ItM.js} +2 -2
  23. package/dist/client/assets/{designOpenFileContext-BP2f7uoG.js → designOpenFileContext-CCL9VKvQ.js} +2 -2
  24. package/dist/client/assets/{diffFileContents-CpXvVerb.js → diffFileContents-CgDa-z2d.js} +2 -2
  25. package/dist/client/assets/{empty-BoorOwgr.js → empty-CLS3rXBc.js} +2 -2
  26. package/dist/client/assets/{entities-CYOkudic.js → entities-DPi_gbtI.js} +2 -2
  27. package/dist/client/assets/{index-xOiIIEJO.js → index-DnoL7z0M.js} +3 -3
  28. package/dist/client/assets/{input-Dm20FTNt.js → input-BbliVf4z.js} +2 -2
  29. package/dist/client/assets/{lib-CP-ex6Vc.js → lib-CySB76JU.js} +2 -2
  30. package/dist/client/assets/{main-SyzcWFeO.js → main-Ck7oK5At.js} +5 -5
  31. package/dist/client/assets/{pdf-DcYZLBb4.js → pdf-CdULDwXT.js} +2 -2
  32. package/dist/client/assets/{popover-ivgAAZ7Z.js → popover-CFDsW-_z.js} +2 -2
  33. package/dist/client/assets/{pptxDocument-DtL8fmW3.js → pptxDocument-Dh-M0DL5.js} +2 -2
  34. package/dist/client/assets/{projectFilesQueryState-BwZ_KRI1.js → projectFilesQueryState-CmtzaSrb.js} +2 -2
  35. package/dist/client/assets/{queries-DIo5yBTp.js → queries-DRotn4pk.js} +2 -2
  36. package/dist/client/assets/{scroll-area-DKsvPvOo.js → scroll-area-BW5o0Izf.js} +2 -2
  37. package/dist/client/assets/{session-CgVsO0DD.js → session-D3Szkrpk.js} +2 -2
  38. package/dist/client/assets/{textarea-DprGKUyt.js → textarea-5SMJbr7K.js} +2 -2
  39. package/dist/client/assets/{xlsxDocument-iqdkqQBZ.js → xlsxDocument-BMNJtufK.js} +2 -2
  40. package/dist/client/index.html +1 -1
  41. package/dist/service-launcher.mjs +1 -1
  42. package/package.json +1 -1
@@ -63,5 +63,5 @@ import{o as e,t}from"./rolldown-runtime-DAXXjFlN.js";import{$a as n,$c as r,$d a
63
63
 
64
64
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=qy,s=!Ny.jitless,c=s&&Jy.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?pS([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function gS(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!lb(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>pb(e,r,Py())))}),t)}var _S=Z(`$ZodUnion`,(e,t)=>{Ax.init(e,t),Q(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Q(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Q(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Q(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>zy(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>gS(t,r,e,i)):gS(o,r,e,i)}}),vS=Z(`$ZodIntersection`,(e,t)=>{Ax.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>bS(e,t,n)):bS(e,i,a)}});function yS(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Yy(e)&&Yy(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=yS(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=yS(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function bS(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),lb(e))return e;let o=yS(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var xS=Z(`$ZodEnum`,(e,t)=>{Ax.init(e,t);let n=Fy(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Zy.has(typeof e)).map(e=>typeof e==`string`?Qy(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),SS=Z(`$ZodTransform`,(e,t)=>{Ax.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new My(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new jy;return n.value=i,n.fallback=!0,n}});function CS(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var wS=Z(`$ZodOptional`,(e,t)=>{Ax.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Q(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Q(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${zy(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>CS(e,r)):CS(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),TS=Z(`$ZodExactOptional`,(e,t)=>{wS.init(e,t),Q(e._zod,`values`,()=>t.innerType._zod.values),Q(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ES=Z(`$ZodNullable`,(e,t)=>{Ax.init(e,t),Q(e._zod,`optin`,()=>t.innerType._zod.optin),Q(e._zod,`optout`,()=>t.innerType._zod.optout),Q(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${zy(e.source)}|null)$`):void 0}),Q(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),DS=Z(`$ZodDefault`,(e,t)=>{Ax.init(e,t),e._zod.optin=`optional`,Q(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>OS(e,t)):OS(r,t)}});function OS(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var kS=Z(`$ZodPrefault`,(e,t)=>{Ax.init(e,t),e._zod.optin=`optional`,Q(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),AS=Z(`$ZodNonOptional`,(e,t)=>{Ax.init(e,t),Q(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>jS(t,e)):jS(i,e)}});function jS(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var MS=Z(`$ZodCatch`,(e,t)=>{Ax.init(e,t),e._zod.optin=`optional`,Q(e._zod,`optout`,()=>t.innerType._zod.optout),Q(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>pb(e,n,Py()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>pb(e,n,Py()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),NS=Z(`$ZodPipe`,(e,t)=>{Ax.init(e,t),Q(e._zod,`values`,()=>t.in._zod.values),Q(e._zod,`optin`,()=>t.in._zod.optin),Q(e._zod,`optout`,()=>t.out._zod.optout),Q(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>PS(e,t.in,n)):PS(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>PS(e,t.out,n)):PS(r,t.out,n)}});function PS(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var FS=Z(`$ZodReadonly`,(e,t)=>{Ax.init(e,t),Q(e._zod,`propValues`,()=>t.innerType._zod.propValues),Q(e._zod,`values`,()=>t.innerType._zod.values),Q(e._zod,`optin`,()=>t.innerType?._zod?.optin),Q(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(IS):IS(r)}});function IS(e){return e.value=Object.freeze(e.value),e}var LS=Z(`$ZodCustom`,(e,t)=>{dx.init(e,t),Ax.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>RS(t,n,r,e));RS(i,n,r,e)}});function RS(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(hb(e))}}var zS,BS=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function VS(){return new BS}(zS=globalThis).__zod_globalRegistry??(zS.__zod_globalRegistry=VS());var HS=globalThis.__zod_globalRegistry;function US(e,t){return new e({type:`string`,...$(t)})}function WS(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...$(t)})}function GS(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...$(t)})}function KS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...$(t)})}function qS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...$(t)})}function JS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...$(t)})}function YS(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...$(t)})}function XS(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...$(t)})}function ZS(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...$(t)})}function QS(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...$(t)})}function $S(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...$(t)})}function eC(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...$(t)})}function tC(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...$(t)})}function nC(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...$(t)})}function rC(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...$(t)})}function iC(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...$(t)})}function aC(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...$(t)})}function oC(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...$(t)})}function sC(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...$(t)})}function cC(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...$(t)})}function lC(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...$(t)})}function uC(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...$(t)})}function dC(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...$(t)})}function fC(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...$(t)})}function pC(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...$(t)})}function mC(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...$(t)})}function hC(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...$(t)})}function gC(e,t){return new e({type:`number`,checks:[],...$(t)})}function _C(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...$(t)})}function vC(e){return new e({type:`unknown`})}function yC(e,t){return new e({type:`never`,...$(t)})}function bC(e,t){return new px({check:`less_than`,...$(t),value:e,inclusive:!1})}function xC(e,t){return new px({check:`less_than`,...$(t),value:e,inclusive:!0})}function SC(e,t){return new mx({check:`greater_than`,...$(t),value:e,inclusive:!1})}function CC(e,t){return new mx({check:`greater_than`,...$(t),value:e,inclusive:!0})}function wC(e,t){return new hx({check:`multiple_of`,...$(t),value:e})}function TC(e,t){return new _x({check:`max_length`,...$(t),maximum:e})}function EC(e,t){return new vx({check:`min_length`,...$(t),minimum:e})}function DC(e,t){return new yx({check:`length_equals`,...$(t),length:e})}function OC(e,t){return new xx({check:`string_format`,format:`regex`,...$(t),pattern:e})}function kC(e){return new Sx({check:`string_format`,format:`lowercase`,...$(e)})}function AC(e){return new Cx({check:`string_format`,format:`uppercase`,...$(e)})}function jC(e,t){return new wx({check:`string_format`,format:`includes`,...$(t),includes:e})}function MC(e,t){return new Tx({check:`string_format`,format:`starts_with`,...$(t),prefix:e})}function NC(e,t){return new Ex({check:`string_format`,format:`ends_with`,...$(t),suffix:e})}function PC(e){return new Dx({check:`overwrite`,tx:e})}function FC(e){return PC(t=>t.normalize(e))}function IC(){return PC(e=>e.trim())}function LC(){return PC(e=>e.toLowerCase())}function RC(){return PC(e=>e.toUpperCase())}function zC(){return PC(e=>Gy(e))}function BC(e,t,n){return new e({type:`array`,element:t,...$(n)})}function VC(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...$(n)})}function HC(e,t){let n=UC(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(hb(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(hb(r))}},e(t.value,t)),t);return n}function UC(e,t){let n=new dx({check:`custom`,...$(t)});return n._zod.check=e,n}function WC(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??HS,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function GC(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,GC(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&JC(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function KC(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
65
65
 
66
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function qC(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:XC(t,`input`,e.processors),output:XC(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function JC(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return JC(r.element,n);if(r.type===`set`)return JC(r.valueType,n);if(r.type===`lazy`)return JC(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return JC(r.innerType,n);if(r.type===`intersection`)return JC(r.left,n)||JC(r.right,n);if(r.type===`record`||r.type===`map`)return JC(r.keyType,n)||JC(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:JC(r.in,n)||JC(r.out,n);if(r.type===`object`){for(let e in r.shape)if(JC(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(JC(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(JC(e,n))return!0;return!!(r.rest&&JC(r.rest,n))}return!1}var YC=(e,t={})=>n=>{let r=WC({...n,processors:t});return GC(e,r),KC(r,e),qC(r,e)},XC=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=WC({...i??{},target:a,io:t,processors:n});return GC(e,o),KC(o,e),qC(o,e)},ZC={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},QC=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ZC[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},$C=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ew=(e,t,n,r)=>{n.not={}},tw=(e,t,n,r)=>{let i=e._zod.def,a=Fy(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},nw=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},rw=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},iw=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=GC(a.element,t,{...r,path:[...r.path,`items`]})},aw=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=GC(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=GC(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ow=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>GC(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},sw=(e,t,n,r)=>{let i=e._zod.def,a=GC(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=GC(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},cw=(e,t,n,r)=>{let i=e._zod.def,a=GC(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},lw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},uw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},dw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},pw=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;GC(o,t,r);let s=t.seen.get(e);s.ref=o},mw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gw=Z(`ZodISODateTime`,(e,t)=>{Wx.init(e,t),Uw.init(e,t)});function _w(e){return fC(gw,e)}var vw=Z(`ZodISODate`,(e,t)=>{Gx.init(e,t),Uw.init(e,t)});function yw(e){return pC(vw,e)}var bw=Z(`ZodISOTime`,(e,t)=>{Kx.init(e,t),Uw.init(e,t)});function xw(e){return mC(bw,e)}var Sw=Z(`ZodISODuration`,(e,t)=>{qx.init(e,t),Uw.init(e,t)});function Cw(e){return hC(Sw,e)}var ww=Z(`ZodError`,(e,t)=>{_b.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>bb(e,t)},flatten:{value:t=>yb(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Iy,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Iy,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Tw=xb(ww),Ew=Sb(ww),Dw=Cb(ww),Ow=Tb(ww),kw=Db(ww),Aw=Ob(ww),jw=kb(ww),Mw=Ab(ww),Nw=jb(ww),Pw=Mb(ww),Fw=Nb(ww),Iw=Pb(ww),Lw=new WeakMap;function Rw(e,t,n){let r=Object.getPrototypeOf(e),i=Lw.get(r);if(i||(i=new Set,Lw.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zw=Z(`ZodType`,(e,t)=>(Ax.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:XC(e,`input`),output:XC(e,`output`)}}),e.toJSONSchema=YC(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Tw(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Dw(e,t,n),e.parseAsync=async(t,n)=>Ew(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ow(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>kw(e,t,n),e.decode=(t,n)=>Aw(e,t,n),e.encodeAsync=async(t,n)=>jw(e,t,n),e.decodeAsync=async(t,n)=>Mw(e,t,n),e.safeEncode=(t,n)=>Nw(e,t,n),e.safeDecode=(t,n)=>Pw(e,t,n),e.safeEncodeAsync=async(t,n)=>Fw(e,t,n),e.safeDecodeAsync=async(t,n)=>Iw(e,t,n),Rw(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Uy(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return $y(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(JT(e,t))},superRefine(e,t){return this.check(YT(e,t))},overwrite(e){return this.check(PC(e))},optional(){return AT(this)},exactOptional(){return MT(this)},nullable(){return PT(this)},nullish(){return AT(PT(this))},nonoptional(e){return BT(this,e)},array(){return vT(this)},or(e){return ST([this,e])},and(e){return wT(this,e)},transform(e){return WT(this,OT(e))},default(e){return IT(this,e)},prefault(e){return RT(this,e)},catch(e){return HT(this,e)},pipe(e){return WT(this,e)},readonly(){return KT(this)},describe(e){let t=this.clone();return HS.add(t,{description:e}),t},meta(...e){if(e.length===0)return HS.get(this);let t=this.clone();return HS.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return HS.get(e)?.description},configurable:!0}),e)),Bw=Z(`_ZodString`,(e,t)=>{jx.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QC(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rw(e,`_ZodString`,{regex(...e){return this.check(OC(...e))},includes(...e){return this.check(jC(...e))},startsWith(...e){return this.check(MC(...e))},endsWith(...e){return this.check(NC(...e))},min(...e){return this.check(EC(...e))},max(...e){return this.check(TC(...e))},length(...e){return this.check(DC(...e))},nonempty(...e){return this.check(EC(1,...e))},lowercase(e){return this.check(kC(e))},uppercase(e){return this.check(AC(e))},trim(){return this.check(IC())},normalize(...e){return this.check(FC(...e))},toLowerCase(){return this.check(LC())},toUpperCase(){return this.check(RC())},slugify(){return this.check(zC())}})}),Vw=Z(`ZodString`,(e,t)=>{jx.init(e,t),Bw.init(e,t),e.email=t=>e.check(WS(Ww,t)),e.url=t=>e.check(XS(qw,t)),e.jwt=t=>e.check(dC(cT,t)),e.emoji=t=>e.check(ZS(Jw,t)),e.guid=t=>e.check(GS(Gw,t)),e.uuid=t=>e.check(KS(Kw,t)),e.uuidv4=t=>e.check(qS(Kw,t)),e.uuidv6=t=>e.check(JS(Kw,t)),e.uuidv7=t=>e.check(YS(Kw,t)),e.nanoid=t=>e.check(QS(Yw,t)),e.guid=t=>e.check(GS(Gw,t)),e.cuid=t=>e.check($S(Xw,t)),e.cuid2=t=>e.check(eC(Zw,t)),e.ulid=t=>e.check(tC(Qw,t)),e.base64=t=>e.check(cC(aT,t)),e.base64url=t=>e.check(lC(oT,t)),e.xid=t=>e.check(nC($w,t)),e.ksuid=t=>e.check(rC(eT,t)),e.ipv4=t=>e.check(iC(tT,t)),e.ipv6=t=>e.check(aC(nT,t)),e.cidrv4=t=>e.check(oC(rT,t)),e.cidrv6=t=>e.check(sC(iT,t)),e.e164=t=>e.check(uC(sT,t)),e.datetime=t=>e.check(_w(t)),e.date=t=>e.check(yw(t)),e.time=t=>e.check(xw(t)),e.duration=t=>e.check(Cw(t))});function Hw(e){return US(Vw,e)}var Uw=Z(`ZodStringFormat`,(e,t)=>{Mx.init(e,t),Bw.init(e,t)}),Ww=Z(`ZodEmail`,(e,t)=>{Fx.init(e,t),Uw.init(e,t)}),Gw=Z(`ZodGUID`,(e,t)=>{Nx.init(e,t),Uw.init(e,t)}),Kw=Z(`ZodUUID`,(e,t)=>{Px.init(e,t),Uw.init(e,t)}),qw=Z(`ZodURL`,(e,t)=>{Ix.init(e,t),Uw.init(e,t)}),Jw=Z(`ZodEmoji`,(e,t)=>{Lx.init(e,t),Uw.init(e,t)}),Yw=Z(`ZodNanoID`,(e,t)=>{Rx.init(e,t),Uw.init(e,t)}),Xw=Z(`ZodCUID`,(e,t)=>{zx.init(e,t),Uw.init(e,t)}),Zw=Z(`ZodCUID2`,(e,t)=>{Bx.init(e,t),Uw.init(e,t)}),Qw=Z(`ZodULID`,(e,t)=>{Vx.init(e,t),Uw.init(e,t)}),$w=Z(`ZodXID`,(e,t)=>{Hx.init(e,t),Uw.init(e,t)}),eT=Z(`ZodKSUID`,(e,t)=>{Ux.init(e,t),Uw.init(e,t)}),tT=Z(`ZodIPv4`,(e,t)=>{Jx.init(e,t),Uw.init(e,t)}),nT=Z(`ZodIPv6`,(e,t)=>{Yx.init(e,t),Uw.init(e,t)}),rT=Z(`ZodCIDRv4`,(e,t)=>{Xx.init(e,t),Uw.init(e,t)}),iT=Z(`ZodCIDRv6`,(e,t)=>{Zx.init(e,t),Uw.init(e,t)}),aT=Z(`ZodBase64`,(e,t)=>{$x.init(e,t),Uw.init(e,t)}),oT=Z(`ZodBase64URL`,(e,t)=>{tS.init(e,t),Uw.init(e,t)}),sT=Z(`ZodE164`,(e,t)=>{nS.init(e,t),Uw.init(e,t)}),cT=Z(`ZodJWT`,(e,t)=>{iS.init(e,t),Uw.init(e,t)}),lT=Z(`ZodNumber`,(e,t)=>{aS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$C(e,t,n,r),Rw(e,`ZodNumber`,{gt(e,t){return this.check(SC(e,t))},gte(e,t){return this.check(CC(e,t))},min(e,t){return this.check(CC(e,t))},lt(e,t){return this.check(bC(e,t))},lte(e,t){return this.check(xC(e,t))},max(e,t){return this.check(xC(e,t))},int(e){return this.check(fT(e))},safe(e){return this.check(fT(e))},positive(e){return this.check(SC(0,e))},nonnegative(e){return this.check(CC(0,e))},negative(e){return this.check(bC(0,e))},nonpositive(e){return this.check(xC(0,e))},multipleOf(e,t){return this.check(wC(e,t))},step(e,t){return this.check(wC(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function uT(e){return gC(lT,e)}var dT=Z(`ZodNumberFormat`,(e,t)=>{oS.init(e,t),lT.init(e,t)});function fT(e){return _C(dT,e)}var pT=Z(`ZodUnknown`,(e,t)=>{sS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mT(){return vC(pT)}var hT=Z(`ZodNever`,(e,t)=>{cS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ew(e,t,n,r)});function gT(e){return yC(hT,e)}var _T=Z(`ZodArray`,(e,t)=>{uS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iw(e,t,n,r),e.element=t.element,Rw(e,`ZodArray`,{min(e,t){return this.check(EC(e,t))},nonempty(e){return this.check(EC(1,e))},max(e,t){return this.check(TC(e,t))},length(e,t){return this.check(DC(e,t))},unwrap(){return this.element}})});function vT(e,t){return BC(_T,e,t)}var yT=Z(`ZodObject`,(e,t)=>{hS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aw(e,t,n,r),Q(e,`shape`,()=>t.shape),Rw(e,`ZodObject`,{keyof(){return ET(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mT()})},loose(){return this.clone({...this._zod.def,catchall:mT()})},strict(){return this.clone({...this._zod.def,catchall:gT()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ib(this,e)},safeExtend(e){return ab(this,e)},merge(e){return ob(this,e)},pick(e){return nb(this,e)},omit(e){return rb(this,e)},partial(...e){return sb(kT,this,e[0])},required(...e){return cb(zT,this,e[0])}})});function bT(e,t){return new yT({type:`object`,shape:e??{},...$(t)})}var xT=Z(`ZodUnion`,(e,t)=>{_S.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ow(e,t,n,r),e.options=t.options});function ST(e,t){return new xT({type:`union`,options:e,...$(t)})}var CT=Z(`ZodIntersection`,(e,t)=>{vS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sw(e,t,n,r)});function wT(e,t){return new CT({type:`intersection`,left:e,right:t})}var TT=Z(`ZodEnum`,(e,t)=>{xS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tw(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new TT({...t,checks:[],...$(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new TT({...t,checks:[],...$(r),entries:i})}});function ET(e,t){return new TT({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...$(t)})}var DT=Z(`ZodTransform`,(e,t)=>{SS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rw(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new My(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(hb(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(hb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function OT(e){return new DT({type:`transform`,transform:e})}var kT=Z(`ZodOptional`,(e,t)=>{wS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function AT(e){return new kT({type:`optional`,innerType:e})}var jT=Z(`ZodExactOptional`,(e,t)=>{TS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function MT(e){return new jT({type:`optional`,innerType:e})}var NT=Z(`ZodNullable`,(e,t)=>{ES.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function PT(e){return new NT({type:`nullable`,innerType:e})}var FT=Z(`ZodDefault`,(e,t)=>{DS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function IT(e,t){return new FT({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Xy(t)}})}var LT=Z(`ZodPrefault`,(e,t)=>{kS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RT(e,t){return new LT({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Xy(t)}})}var zT=Z(`ZodNonOptional`,(e,t)=>{AS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function BT(e,t){return new zT({type:`nonoptional`,innerType:e,...$(t)})}var VT=Z(`ZodCatch`,(e,t)=>{MS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function HT(e,t){return new VT({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var UT=Z(`ZodPipe`,(e,t)=>{NS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pw(e,t,n,r),e.in=t.in,e.out=t.out});function WT(e,t){return new UT({type:`pipe`,in:e,out:t})}var GT=Z(`ZodReadonly`,(e,t)=>{FS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function KT(e){return new GT({type:`readonly`,innerType:e})}var qT=Z(`ZodCustom`,(e,t)=>{LS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nw(e,t,n,r)});function JT(e,t={}){return VC(qT,e,t)}function YT(e,t){return HC(e,t)}var XT=bT({accessToken:Hw().min(1),refreshToken:Hw().min(1).optional(),expiresAt:uT().int().positive().optional(),tokenType:Hw().default(`Bearer`),scope:Hw().optional()}),ZT=bT({access_token:Hw().min(1),refresh_token:Hw().min(1).optional(),expires_in:uT().int().positive().optional(),token_type:Hw().optional(),scope:Hw().optional()}),QT=(e,t=Date.now())=>e.expiresAt!==void 0&&e.expiresAt-6e4<=t;function $T(e,t=Date.now()){let n=ZT.parse(e);return{accessToken:n.access_token,...n.refresh_token?{refreshToken:n.refresh_token}:{},...n.expires_in?{expiresAt:t+n.expires_in*1e3}:{},tokenType:n.token_type??`Bearer`,...n.scope?{scope:n.scope}:{}}}var eE=`relay`,tE=class extends Error{refusal;constructor(e){super(`Search Atlas refused the request (${e.status})`),this.name=`EmailAuthRefusedError`,this.refusal=e}},nE=(e,t)=>new URL(t,e).toString(),rE=`/api/customer/account/register/v2/`,iE=`/api/token/`,aE=`/api/customer/account/check-email/`,oE=`/oauth/approve/`,sE=`/account/google/oauth/start`;function cE(e){let t=JSON.stringify({a:e.api,c:e.clientId,r:e.redirectUri,s:e.scope,t:e.state,x:e.challenge});return btoa(t).replace(/\+/gu,`-`).replace(/\//gu,`_`).replace(/=+$/u,``)}function lE(e){let t=e.name?.trim();return{email:e.email.trim(),password:e.password,...t?{contact_name:t}:{},registration_source:eE,...uE(e.captcha)}}var uE=e=>e.version===`v2`?{captcha_v2:e.token}:{captcha:e.token};function dE(e){return{username:e.email.trim(),password:e.password,...uE(e.captcha)}}var fE={email:`email`,password:`password`,contact_name:`name`},pE=e=>{let t=Array.isArray(e)?e[0]:e;return typeof t==`string`&&t.trim().length>0?t.trim():null},mE=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:null;function hE(e,t){let n=mE(t);if(e===201||e===200){let e=n?.jwt_token;if(typeof e==`string`&&e.length>0)return e;if(n?.verification_required===!0)throw new tE({status:`verification-required`});return null}if(e===409)throw new tE({status:`email-registered`});if(e===406)throw new tE({status:`invalid`,field:`email`,message:`Search Atlas doesn't accept this email provider. Use a different email.`});if(e!==400||!n)return null;if(gE(n))throw new tE({status:`captcha-required`});for(let[e,t]of Object.entries(fE)){let r=pE(n[e]);if(r)throw new tE({status:`invalid`,field:t,message:r})}return null}function gE(e){if(`recaptcha_fallback`in e||`captcha`in e||`captcha_v2`in e)return!0;let t=pE(e.non_field_errors);return t!==null&&/recaptcha/iu.test(t)}function _E(e,t){let n=mE(t);if(e===200){let e=n?.token;return typeof e==`string`&&e.length>0?e:null}if(e===400&&n&&gE(n))throw new tE({status:`captcha-required`});if(e===403&&n?.kind===`email_verification_required`)throw new tE({status:`verification-required`});if(e===401)throw new tE({status:`invalid`,field:`password`,message:`The email or password is incorrect.`});return null}function vE(e){let t=mE(e)?.redirect_url;return typeof t==`string`&&t.length>0?t:null}var yE=class extends Error{code;status;constructor(e,t,n){super(t),this.code=e,this.status=n,this.name=`AuthError`}},bE=e=>e instanceof yE&&e.status!==void 0&&e.status>=400&&e.status<500&&e.status!==408&&e.status!==429,xE=2e4;async function SE(e){let t=new AbortController,n,r=new Promise((e,r)=>{n=setTimeout(()=>{let e=Error(`Search Atlas authentication timed out. Try again.`);e.name=`TimeoutError`,r(e),t.abort(e)},xE)});try{return await Promise.race([e(t.signal),r])}finally{clearTimeout(n)}}function CE(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;return typeof t.sub!=`string`||typeof t.name!=`string`?null:{subject:t.sub,email:typeof t.email==`string`?t.email:``,name:t.name.trim()}}var wE=`borg.tokens`;function TE(e,t){let n=new URL(e),r=n.searchParams.get(`error`);if(r)throw new yE(r,n.searchParams.get(`error_description`)??r);if(n.searchParams.get(`state`)!==t)throw new yE(`state_mismatch`,`Authorization state did not match`);let i=n.searchParams.get(`code`);if(!i)throw new yE(`missing_code`,`Callback carried no authorization code`);return i}var EE=class{#e;#t;#n=Promise.resolve();#r=new Map;#i=Promise.resolve();#a=0;#o;#s;#c=new Set;constructor(e,t){this.#o=e,this.#s=t}subscribe(e){return this.#c.add(e),()=>{this.#c.delete(e)}}#l(e){for(let t of this.#c)try{t(e)}catch{}}async beginAuthorization(e=this.#o.redirectUri){let{state:t,challenge:n,method:r}=await this.#u(e),i=new URL(this.#o.authorizationEndpoint);return i.searchParams.set(`response_type`,`code`),i.searchParams.set(`client_id`,this.#o.clientId),i.searchParams.set(`redirect_uri`,e),i.searchParams.set(`code_challenge`,n),i.searchParams.set(`code_challenge_method`,r),i.searchParams.set(`state`,t),this.#o.scopes?.length&&i.searchParams.set(`scope`,this.#o.scopes.join(` `)),i.toString()}async#u(e){let t=await this.#d(e);return this.#e=t,t}async#d(e){let{verifier:t,challenge:n,method:r}=await ky(this.#s.pkceCrypto);return{state:await Oy(16,this.#s.pkceCrypto),verifier:t,challenge:n,method:r,redirectUri:e}}async isEmailRegistered(e){let t=nE(this.#o.tokenEndpoint,aE);return SE(async n=>{let r=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e.trim()}),signal:n}),i=await r.json().catch(()=>null);if(!r.ok)throw new yE(`http_${r.status}`,`Email check returned ${r.status}`,r.status);return i?.exists===!0})}async signUp(e){let t=await this.#f(rE,lE(e),hE);return this.authorizeWithAccountToken(t)}async signIn(e){let t=await this.#f(iE,dE(e),_E);return this.authorizeWithAccountToken(t)}#f(e,t,n){return SE(async r=>{let i=await fetch(nE(this.#o.tokenEndpoint,e),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t),signal:r}),a=await i.json().catch(()=>null),o=n(i.status,a);if(o===null)throw new yE(`http_${i.status}`,`Search Atlas returned ${i.status}`,i.status);return o})}async authorizeWithGoogle(e){let t=new URL(e);if(t.protocol!==`https:`)throw new yE(`invalid_request`,`Google sign-in must return to an https page`);return this.#p(async()=>{let e=await this.#s.listenForOAuthCallback(),{state:n,challenge:r}=await this.#u(e.redirectUri),i=cE({api:new URL(this.#o.tokenEndpoint).origin,clientId:this.#o.clientId,redirectUri:e.redirectUri,scope:this.#o.scopes?.join(` `)??``,state:n,challenge:r}),a=new URL(sE,this.#o.tokenEndpoint);return a.searchParams.set(`from_domain`,`${t.host}${t.pathname}#${i}`),a.searchParams.set(`registration_source`,eE),a.toString()})}async authorizeWithAccountToken(e){let t=await this.#d(this.#o.redirectUri),n=await SE(async n=>{let r=await fetch(nE(this.#o.tokenEndpoint,oE),{method:`POST`,headers:{authorization:`Bearer ${e}`,"content-type":`application/json`},body:JSON.stringify({client_id:this.#o.clientId,scope:this.#o.scopes?.join(` `)??``,state:t.state,redirect_uri:t.redirectUri,code_challenge:t.challenge,code_challenge_method:t.method,nonce:``,response_type:`code`,action:`approve`}),signal:n}),i=await r.json().catch(()=>null),a=r.ok?vE(i):null;if(a===null){let e=i;throw new yE(e?.error??`http_${r.status}`,e?.error_description??`Approval returned ${r.status}`,r.status)}return a});return this.#m(TE(n,t.state),t)}cancelAuthorization(){this.#e=void 0,this.#t?.(),this.#s.cancelOAuthCallback?.()}async authorizeNative(){return this.#p(async()=>{let e=await this.#s.listenForOAuthCallback();return this.beginAuthorization(e.redirectUri)})}async#p(e){this.#t&&this.cancelAuthorization();let t=()=>{},n=new Promise((e,n)=>{t=()=>n(new yE(`cancelled`,`Sign-in was cancelled.`))});n.catch(()=>void 0),this.#t=t;let r=e();r.catch(()=>void 0);try{let e=await Promise.race([r,n]),t=this.#s.waitForOAuthCallback();return t.catch(()=>void 0),await Promise.race([this.#s.openExternal(e),n]),await this.completeAuthorization(await Promise.race([t,n]))}catch(e){throw e instanceof yE&&e.code===`cancelled`&&(await r.catch(()=>void 0),this.#t===t&&this.#s.cancelOAuthCallback?.()),e}finally{this.#t===t&&(this.#t=void 0)}}async completeAuthorization(e){let t=this.#e;if(!t)throw new yE(`no_pending_authorization`,`No authorization in progress`);let n=TE(e,t.state);return this.#e=void 0,this.#m(n,t)}async#m(e,t){let n=this.#a,r=await this.#g({grant_type:`authorization_code`,code:e,redirect_uri:t.redirectUri,client_id:this.#o.clientId,code_verifier:t.verifier});if(n!==this.#a||!await this.#v(r,++this.#a))throw new yE(`session_changed`,`This sign-in was cancelled. Start sign-in again.`);return r}getAccessToken(e){let t=this.#a,n=this.#r.get(e);if(n?.version===t)return n.promise;let r=this.#n.then(()=>this.#h(t,e)).finally(()=>{this.#r.get(e)?.promise===r&&this.#r.delete(e)});return this.#r.set(e,{version:t,promise:r}),this.#n=r.catch(()=>void 0),r}async#h(e,t){if(await this.#i,e!==this.#a)return null;let n=await this.loadTokens();if(e!==this.#a||!n)return null;if(!QT(n)&&n.accessToken!==t)return n.accessToken;if(!n.refreshToken)return await this.signOut(),null;try{let t=await this.refresh(n.refreshToken);return e===this.#a?t.accessToken:null}catch(t){if(e!==this.#a)return null;throw bE(t)&&await this.signOut(),t}}async getUserProfile(){if(!this.#o.userinfoEndpoint)return null;let e=await this.getAccessToken();if(!e)return null;let t=this.#o.userinfoEndpoint,n=e=>SE(async n=>{let r=await fetch(t,{headers:{authorization:`Bearer ${e}`},signal:n});return{response:r,payload:await r.json().catch(()=>null)}}),r=await n(e);if(r.response.status===401){if(e=await this.getAccessToken(e),!e)return null;r=await n(e)}if(!r.response.ok)throw new yE(`http_${r.response.status}`,`Userinfo endpoint returned ${r.response.status}`,r.response.status);let i=CE(r.payload);if(!i)throw new yE(`invalid_userinfo`,`Userinfo endpoint returned an invalid profile`);return i}async refresh(e){let t=this.#a,n=await this.#g({grant_type:`refresh_token`,refresh_token:e,client_id:this.#o.clientId}),r=n.refreshToken?n:{...n,refreshToken:e};return await this.#v(r,t),r}async#g(e){return SE(async t=>{let n=await fetch(this.#o.tokenEndpoint,{method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded`},body:new URLSearchParams(e).toString(),signal:t}),r=await n.json().catch(()=>null);if(!n.ok){let e=r;throw new yE(e?.error??`http_${n.status}`,e?.error_description??`Token endpoint returned ${n.status}`,n.status)}return $T(r)})}async storeTokens(e){await this.#v(e,++this.#a)}#_(e){let t=this.#i.then(e);return this.#i=t.catch(()=>void 0),t}#v(e,t){return this.#_(async()=>t!==this.#a||(await this.#s.setSecureCredential(wE,JSON.stringify(e)),t!==this.#a)?!1:(this.#l(e.accessToken),!0))}async loadTokens(){let e=await this.#s.getSecureCredential(wE);if(!e)return null;try{let t=XT.safeParse(JSON.parse(e));return t.success?t.data:null}catch(e){if(e instanceof SyntaxError)return null;throw e}}async signOut(){this.#e=void 0;let e=++this.#a,t=await this.#_(async()=>{let t=await this.loadTokens().catch(()=>null);return await this.#s.deleteSecureCredential(wE),e===this.#a&&this.#l(null),t});if(t?.refreshToken&&this.#o.revocationEndpoint){let e=this.#o.revocationEndpoint,n=t.refreshToken;SE(t=>fetch(e,{method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:n,client_id:this.#o.clientId}).toString(),signal:t})).catch(()=>{})}}};function DE(){if(typeof window>`u`||!window.location)return null;let e=`mcp:tools:read mcp:tools:execute profile`.split(/\s+/u);return{authorizationEndpoint:`https://dashboard.searchatlas.com/oauth/authorize`,tokenEndpoint:`https://api.searchatlas.com/oauth/token/`,userinfoEndpoint:`https://api.searchatlas.com/oauth/userinfo/`,clientId:`C735iQetqz7GyPSU1N7rCoQunxZuwtq8WR5z-hCp8VA`,redirectUri:`${window.location.origin}/oauth-callback.html`,scopes:e,revocationEndpoint:`https://api.searchatlas.com/oauth/revoke/`}}var OE=`borg.search-atlas.oauth-callback`,kE=`borg-search-atlas-auth`,AE=`borg-search-atlas-oauth-callback`;function jE(e){if(typeof e!=`object`||!e)return null;let t=e;return t.type===AE&&typeof t.url==`string`?t.url:null}function ME(){let e=DE();if(!e)return null;let t=new Map,n=e=>{try{return window.sessionStorage.getItem(e)??t.get(e)??null}catch{return t.get(e)??null}},r=(e,n)=>{t.set(e,n);try{window.sessionStorage.setItem(e,n)}catch{}},i=e=>{t.delete(e);try{window.sessionStorage.removeItem(e)}catch{}},a=null,o=null,s=null;return new EE(e,{getSecureCredential:async e=>n(e),setSecureCredential:async(e,t)=>{r(e,t)},deleteSecureCredential:async e=>{i(e)},listenForOAuthCallback:async()=>({redirectUri:e.redirectUri}),waitForOAuthCallback:()=>(o??=new Promise((e,t)=>{let n=window.setTimeout(()=>{d(),t(Error(`Search Atlas authentication timed out.`))},12e4),r=typeof BroadcastChannel>`u`?null:new BroadcastChannel(kE),i=t=>{d(),e(t)},c=e=>{let t=jE(e.data);t&&i(t)},l=e=>{if(e.origin!==window.location.origin||e.source!==a)return;let t=jE(e.data);t&&i(t)},u=e=>{if(!(e.key!==OE||!e.newValue))try{let t=jE(JSON.parse(e.newValue));t&&i(t)}catch{}};s=()=>{d(),t(new yE(`cancelled`,`Sign-in was cancelled.`))};let d=()=>{s=null,window.clearTimeout(n),window.removeEventListener(`message`,l),window.removeEventListener(`storage`,u),r?.removeEventListener(`message`,c),r?.close(),o=null};window.addEventListener(`message`,l),window.addEventListener(`storage`,u),r?.addEventListener(`message`,c)}),o),cancelOAuthCallback:()=>{s?.(),a?.close()},openExternal:async e=>{if(a=window.open(e,`borg-search-atlas-auth`,`popup,width=520,height=720`),!a)throw Error(`The authentication window was blocked.`)}})}var NE;function PE(){return NE??=ME(),NE}async function FE(e){if(!e.apiUrl)throw Error(`Borg Cloud is not configured.`);let t=Ri(e.token);if(t===void 0)throw Error(`This Search Atlas session names no customer.`);return t.customerId}var IE=/-nightly\.\d{8}\.\d+$/;function LE(e){return e.stageLabel.trim().toLowerCase()===`latest`?e.baseName:`${e.baseName} (${e.stageLabel})`}function RE(e){return e.primaryServerVersion&&IE.test(e.primaryServerVersion)?`Nightly`:e.fallbackStageLabel}function zE(e){let t=RE({primaryServerVersion:e.primaryServerVersion,fallbackStageLabel:e.fallbackStageLabel});return t===e.fallbackStageLabel?e.fallbackDisplayName:LE({baseName:e.baseName,stageLabel:t})}var BE={local:`Development`,staging:`Preview`,production:``};function VE(e){return[BE[e.environment.trim().toLowerCase()]??`Development`,/^[0-9a-f]{7,40}$/i.test(e.commit.trim())?e.commit.trim().slice(0,7):``].filter(Boolean).join(` · `)}function HE(){return typeof window>`u`?null:window.desktopBridge?.getAppBranding?.()??null}var UE=HE(),WE=``,GE=WE===`latest`||WE===`nightly`?WE:null,KE=GE===`nightly`?`Nightly`:GE===`latest`?`Latest`:null,qE=UE?.baseName??`Borg`,JE=UE?.stageLabel??KE??`Alpha`,YE=UE?.displayName??LE({baseName:qE,stageLabel:JE}),XE=`0.0.117`,ZE=VE({environment:`production`,commit:`a1c46473f388eb6cb184700d5b1caca3d9c8763d`});[`${qE} ${XE}`,ZE].filter(Boolean).join(` · `);function QE(){return`https://app.getborg.com`}function $E(){return``}function eD(){return null}function tD(e){try{return new URL(e).origin}catch{return null}}function nD(){return typeof window<`u`&&window.desktopBridge!==void 0}function rD(e=new URL(window.location.href)){if($E()||nD())return!1;if(eD())return!0;let t=tD(QE());return t!==null&&e.origin===t}function iD(e=new URL(window.location.href)){let t=e.searchParams.get(`host`)?.trim()??``,n=Lm(e)?.trim()??``,r=e.searchParams.get(`label`)?.trim()??``;return!t||!n?null:{host:t,token:n,label:r}}function aD(e=new URL(window.location.href)){return iD(e)!==null}function oD(e){let t=new URL(`/pair`,QE());t.searchParams.set(`host`,e.host);let n=e.label?.trim();return n&&t.searchParams.set(`label`,n),zm(t,e.token).toString()}function sD(e){let t=new URL(`/__borgcode/channel`,QE());return t.searchParams.set(`channel`,e.channel),t.toString()}var cD=Ss();function lD({children:e}){return(0,Mc.createElement)(Fc.Provider,{value:cD},e)}var uD=15e3,dD=12e4,fD=uD,pD=new Map,mD=new Set([k.previewAutomationConnect,k.shellCaptureLoopbackRedirect]),hD=new Set([k.serverUpdateProvider,k.serverRefreshProviders,k.serverUpdateServer]),gD=R([]).pipe(vc,B(`slow-rpc-ack-requests`));function _D(e){cD.set(gD,[...e])}function vD(){return cD.get(gD)}function yD(e){return!e.includes(`subscribe`)&&!e.startsWith(`pullRequests.`)&&!mD.has(e)}function bD(e){return hD.has(e)?Math.max(fD,dD):fD}function xD(e,t,n=t){if(!yD(t))return;CD(e),TD();let r=Date.now(),i=bD(t),a={requestId:e,startedAt:new Date(r).toISOString(),startedAtMs:r,tag:n,thresholdMs:i},o=setTimeout(()=>{pD.delete(e),wD(a)},i);pD.set(e,{request:a,timeoutId:o})}function SD(e){CD(e);let t=vD();t.some(t=>t.requestId===e)&&_D(t.filter(t=>t.requestId!==e))}function CD(e){let t=pD.get(e);t&&(clearTimeout(t.timeoutId),pD.delete(e))}function wD(e){let t=[...vD(),e];if(t.length<=256){_D(t);return}_D(t.slice(-256))}function TD(){for(;pD.size>=256;){let e=pD.keys().next().value;if(e===void 0)return;CD(e)}}function ED(){return zc(gD)}var DD=Promise.resolve(),OD=e=>{DD=e},kD=()=>DD,AD=4,jD=`catalog`,MD=`shell`,ND=`thread`,PD=`server-config`,FD=`vcs-refs`,ID=`document`,LD=`5 seconds`,RD=1,zD=tn($i({schemaVersion:On(RD),environmentId:xe,snapshot:Hn})),BD=tn($i({schemaVersion:On(3),environmentId:xe,threadId:It,snapshot:s})),VD=tn($i({schemaVersion:On(1),environmentId:xe,config:un})),HD=tn($i({schemaVersion:On(1),environmentId:xe,cwd:P,refs:m})),UD=tn(py),WD=Ja(UD),GD=qt(UD),KD=Ja(zD),qD=qt(zD),JD=Ja(BD),YD=qt(BD),XD=Ja(VD),ZD=qt(VD),QD=Ja(HD),$D=qt(HD);function eO(e,t){return new ed({reason:`remote-unavailable`,detail:`Could not ${e} the local connection catalog: ${String(t)}`})}function tO(e,t){return new wd({operation:e,message:`Could not ${e.replaceAll(`-`,` `)}: ${String(t)}`})}var nO=x(`web.connectionStorage.openDatabase`)(function*(){yield*Ga(kD);let e=yield*y(e=>{if(typeof indexedDB>`u`){e(S(eO(`open`,`IndexedDB is unavailable in this browser context.`)));return}let t=!1,n=indexedDB.open(Yr(oa),AD);return n.addEventListener(`upgradeneeded`,()=>{n.result.objectStoreNames.contains(jD)||n.result.createObjectStore(jD),n.result.objectStoreNames.contains(MD)||n.result.createObjectStore(MD),n.result.objectStoreNames.contains(ND)||n.result.createObjectStore(ND),n.result.objectStoreNames.contains(PD)||n.result.createObjectStore(PD),n.result.objectStoreNames.contains(FD)||n.result.createObjectStore(FD)}),n.addEventListener(`error`,()=>{e(S(eO(`open`,n.error??`Unknown IndexedDB error`)))}),n.addEventListener(`success`,()=>{let r=n.result;if(t){r.close();return}r.addEventListener(`versionchange`,()=>r.close()),e(b(r))}),M(()=>{t=!0})}).pipe(r({duration:LD,orElse:()=>S(new ed({reason:`timeout`,detail:`Another Borg tab is holding Borg's saved data. Close your other Borg tabs, then reload this one.`}))}));return yield*rO(e),e});function rO(e){return kr(()=>ur(Zn(),di(),vr)).pipe(I(t=>t===void 0?j:E(function*(){t.document!==void 0&&(yield*iO(e,jD,ID))===void 0&&(yield*aO(e,jD,ID,t.document)),yield*kr(t.release)})),Vn)}function iO(e,t,n){return y(r=>{let i=e.transaction(t,`readonly`).objectStore(t).get(n);i.addEventListener(`error`,()=>{r(S(eO(`read`,i.error??`Unknown IndexedDB read error`)))}),i.addEventListener(`success`,()=>{r(b(i.result))})}).pipe(F(`web.connectionStorage.readDatabaseValue`))}function aO(e,t,n,r){return y(i=>{let a=e.transaction(t,`readwrite`);a.addEventListener(`error`,()=>{i(S(eO(`write`,a.error??`Unknown IndexedDB write error`)))}),a.addEventListener(`complete`,()=>{i(j)}),a.objectStore(t).put(r,n)}).pipe(F(`web.connectionStorage.writeDatabaseValue`))}function oO(e,t,n){return y(r=>{let i=e.transaction(t,`readwrite`);i.addEventListener(`error`,()=>{r(S(eO(`remove`,i.error??`Unknown IndexedDB remove error`)))}),i.addEventListener(`complete`,()=>{r(j)}),i.objectStore(t).delete(n)}).pipe(F(`web.connectionStorage.removeDatabaseValue`))}function sO(e,t,n){return y(r=>{let i=e.transaction(t,`readwrite`);i.addEventListener(`error`,()=>{r(S(eO(`remove`,i.error??`Unknown IndexedDB cursor error`)))}),i.addEventListener(`complete`,()=>{r(j)});let a=i.objectStore(t).openCursor(n);a.addEventListener(`error`,()=>{r(S(eO(`remove`,a.error??`Unknown IndexedDB cursor error`)))}),a.addEventListener(`success`,()=>{let e=a.result;e!==null&&(e.delete(),e.continue())})}).pipe(F(`web.connectionStorage.removeDatabaseValuesInRange`))}function cO(e,t){return`${e}:${t}`}function lO(e,t){return`${e}:${t}`}var uO=x(`web.connectionStorage.decodeCatalog`)(function*(e){return yield*WD(e).pipe(N(e=>eO(`decode`,e)))}),dO=x(`web.connectionStorage.encodeCatalog`)(function*(e){return yield*GD(e).pipe(N(e=>eO(`encode`,e)))});function fO(e){return t=>typeof navigator>`u`||!navigator.locks?t:kr({try:()=>navigator.locks.request(e,()=>gt(t)),catch:e=>eO(`lock`,e)}).pipe(I(e=>e))}function pO(e){let t=window.desktopBridge;return t?.getConnectionCatalog!==void 0&&t.setConnectionCatalog!==void 0?{read:kr({try:()=>t.getConnectionCatalog(),catch:e=>eO(`load`,e)}),write:e=>kr({try:()=>t.setConnectionCatalog(e),catch:e=>eO(`save`,e)}).pipe(I(e=>e?j:S(eO(`save`,`Desktop secure storage is unavailable in this system context.`))))}:{read:iO(e,jD,ID).pipe(O(e=>typeof e==`string`?e:null)),write:t=>aO(e,jD,ID,t),quarantine:t=>aO(e,jD,`${ID}:corrupt:${Date.now()}`,t),exclusive:fO(`${e.name}:catalog`)}}var mO=x(`web.connectionStorage.makeCatalogStore`)(function*(e){let t=yield*bo(C()),n=yield*sa(1),r=x(`web.connectionStorage.loadCatalog`)(function*(){let n=yield*yo(t);if(u(n))return n.value;let r=yield*e.read,i=my;return r!==null&&r.trim()!==``&&(i=yield*uO(r).pipe(li(t=>E(function*(){yield*Qi(`Discarding a corrupt web connection catalog.`,{error:t.message}),e.quarantine!==void 0&&(yield*e.quarantine(r).pipe(li(e=>Qi(`Could not quarantine the corrupt web connection catalog.`,{error:e.message}))));let n=yield*dO(my);return yield*e.write(n).pipe(li(e=>Qi(`Could not persist the recovered web connection catalog.`,{error:e.message}))),my})))),yield*to(t,w(i)),i}),i=n.withPermits(1)(r()),a=e.exclusive??(e=>e);return{read:i,update:x(`web.connectionStorage.updateCatalog`)(function*(i){yield*n.withPermits(1)(a(E(function*(){yield*to(t,C());let n=i(yield*r());yield*e.write(yield*dO(n)),yield*to(t,w(n))})))})}}),hO=Dn(E(function*(){let e=yield*Wi(nO(),e=>M(()=>e.close())),t=yield*mO(pO(e)),n=Td.of({list:t.read.pipe(O(e=>e.targets),N(e=>tO(`list-targets`,e)))}),r=Ed.of({register:e=>t.update(t=>yy(t,e)).pipe(N(e=>tO(`register-connection`,e))),remove:e=>t.update(t=>by(t,e)).pipe(N(e=>tO(`remove-connection`,e)))}),i=bd({get:e=>t.read.pipe(O(t=>ie(t.profiles.find(t=>t.connectionId===e)))),put:e=>t.update(t=>({...t,profiles:hy(t.profiles,e=>e.connectionId,e)})),remove:e=>t.update(t=>({...t,profiles:gy(t.profiles,e=>e.connectionId,e)}))}),a=vd({get:e=>t.read.pipe(O(t=>ie(t.credentials.find(t=>t.connectionId===e)?.credential))),put:(e,n)=>t.update(t=>({...t,credentials:hy(t.credentials,e=>e.connectionId,{connectionId:e,credential:n})})),remove:e=>t.update(t=>({...t,credentials:gy(t.credentials,e=>e.connectionId,e)}))}),o=of({get:e=>t.read.pipe(O(t=>ie(t.remoteDpopTokens.find(t=>t.environmentId===e)))),put:e=>t.update(t=>({...t,remoteDpopTokens:hy(t.remoteDpopTokens,e=>e.environmentId,e)})),remove:e=>t.update(t=>({...t,remoteDpopTokens:gy(t.remoteDpopTokens,e=>e.environmentId,e)}))}),s=Dd.of({loadShell:t=>iO(e,MD,t).pipe(I(e=>typeof e==`string`?KD(e).pipe(N(e=>tO(`load-shell`,e)),O(e=>e.environmentId===t?w(e.snapshot):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-shell`,e))),saveShell:(t,n)=>E(function*(){let r=yield*qD({schemaVersion:RD,environmentId:t,snapshot:n}).pipe(N(e=>tO(`save-shell`,e)));yield*aO(e,MD,t,r)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-shell`,e))),loadServerConfig:t=>iO(e,PD,t).pipe(I(e=>typeof e==`string`?XD(e).pipe(N(e=>tO(`load-server-config`,e)),O(e=>e.environmentId===t?w(e.config):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-server-config`,e))),saveServerConfig:(t,n)=>E(function*(){let r=yield*ZD({schemaVersion:1,environmentId:t,config:n}).pipe(N(e=>tO(`save-server-config`,e)));yield*aO(e,PD,t,r)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-server-config`,e))),loadThread:(t,n)=>iO(e,ND,cO(t,n)).pipe(I(e=>typeof e==`string`?JD(e).pipe(N(e=>tO(`load-thread`,e)),O(e=>e.environmentId===t&&e.threadId===n?w(e.snapshot):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-thread`,e))),saveThread:(t,n)=>E(function*(){let r=yield*YD({schemaVersion:3,environmentId:t,threadId:n.thread.id,snapshot:n}).pipe(N(e=>tO(`save-thread`,e)));yield*aO(e,ND,cO(t,n.thread.id),r)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-thread`,e))),loadVcsRefs:(t,n)=>iO(e,FD,lO(t,n)).pipe(I(e=>typeof e==`string`?QD(e).pipe(N(e=>tO(`load-vcs-refs`,e)),O(e=>e.environmentId===t&&e.cwd===n?w(e.refs):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-vcs-refs`,e))),saveVcsRefs:(t,n,r)=>E(function*(){let i=yield*$D({schemaVersion:1,environmentId:t,cwd:n,refs:r}).pipe(N(e=>tO(`save-vcs-refs`,e)));yield*aO(e,FD,lO(t,n),i)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-vcs-refs`,e))),removeVcsRefs:(t,n)=>oO(e,FD,lO(t,n)).pipe(N(e=>tO(`remove-vcs-refs`,e))),clearVcsRefs:t=>sO(e,FD,IDBKeyRange.bound(`${t}:`,`${t}:\uffff`)).pipe(N(e=>tO(`clear-vcs-refs`,e))),removeThread:(t,n)=>oO(e,ND,cO(t,n)).pipe(N(e=>tO(`remove-thread`,e))),clear:t=>Br([oO(e,MD,t),sO(e,ND,IDBKeyRange.bound(`${t}:`,`${t}:\uffff`)),oO(e,PD,t),sO(e,FD,IDBKeyRange.bound(`${t}:`,`${t}:\uffff`))],{concurrency:`unbounded`,discard:!0}).pipe(N(e=>tO(`clear-environment`,e)))});return xi(Td,n).pipe(ma(Ed,r),ma(yd,i),ma(_d,a),ma(af,o),ma(Dd,s))}));function gO(e){switch(e){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`linux`:return`Linux`;default:return e?`other`:`unknown`}}function _O(e){return/macintosh/i.test(e.userAgent)&&/mac/i.test(e.platform)&&e.maxTouchPoints>1}function vO(e){let t=e.userAgent;return t.trim()===``?`unknown`:/iphone|ipad|ipod/i.test(t)||_O(e)?`iOS`:/android/i.test(t)?`Android`:/cros/i.test(t)?`ChromeOS`:/windows/i.test(t)?`Windows`:/macintosh|mac os x/i.test(t)?`macOS`:/linux|x11/i.test(t)?`Linux`:`other`}function yO(e){return e.trim()===``?`unknown`:/edg(?:e|a|ios)?\//i.test(e)?`Edge`:/opr\/|opios\//i.test(e)?`Opera`:/samsungbrowser\//i.test(e)?`Samsung Internet`:/firefox\/|fxios\//i.test(e)?`Firefox`:/chrome\/|crios\//i.test(e)?`Chrome`:/safari\//i.test(e)?`Safari`:`other`}function bO(e){let t=e.userAgent;return t.trim()===``?`unknown`:/ipad|tablet|kindle|silk/i.test(t)||/android/i.test(t)&&!/mobile/i.test(t)||_O(e)?`tablet`:/iphone|ipod|android.+mobile|mobile/i.test(t)?`mobile`:`desktop`}function xO(e){return e.desktopBridge===void 0?{label:`Borg Web`,deviceType:bO(e.identity),os:vO(e.identity),surface:`web`,webDeployment:e.hosted?`hosted`:`server`,browser:yO(e.identity.userAgent),...e.appVersion===`0.0.0`?{}:{appVersion:e.appVersion}}:{label:`Borg Desktop`,deviceType:`desktop`,os:gO(e.desktopBridge.getClientPlatform?.()),surface:`desktop`,...e.appVersion===`0.0.0`?{}:{appVersion:e.appVersion}}}var SO=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`]),CO=new Set([101,103,204,205,304]),wO=e=>SO.has(e);function TO(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=()=>r(t.reason);t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var EO=async(e,t)=>{let n=typeof window>`u`?void 0:window.desktopBridge?.requestBorgCloud;if(!n)return globalThis.fetch(e,t);let r=new Request(e,t),i=r.method.toUpperCase();if(!wO(i))throw TypeError(`Borg Cloud does not take ${i} requests from the desktop app.`);let a=i===`GET`?``:await r.text(),o=await TO(n({url:r.url,method:i,headers:Object.fromEntries(r.headers),body:a.length===0?null:a}).catch(e=>{throw TypeError(`Borg Cloud could not be reached.`,{cause:e})}),r.signal);return new Response(CO.has(o.status)?null:o.body,{status:o.status,headers:o.headers})},DO=0;function OO(){return typeof navigator>`u`?`unknown`:navigator.onLine?`online`:`offline`}var kO=Cd({status:M(OO),changes:Pi(e=>Wi(M(()=>{let t=()=>fa(e,`online`),n=()=>fa(e,`offline`);return window.addEventListener(`online`,t),window.addEventListener(`offline`,n),{online:t,offline:n}}),({online:e,offline:t})=>M(()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)})).pipe(Jt))}),AO=Cp({changes:Pi(e=>Wi(M(()=>{let t=()=>{document.visibilityState===`visible`&&fa(e,`application-active`)};return document.addEventListener(`visibilitychange`,t),{visibility:t,detachCredentials:_p(()=>{fa(e,`credentials-changed`)})}}),e=>M(()=>{document.removeEventListener(`visibilitychange`,e.visibility),e.detachCredentials()})).pipe(Jt))});function jO(){return xO({appVersion:XE,hosted:rD(),identity:{userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints},desktopBridge:window.desktopBridge})}function MO(e){let t=e instanceof Error?e.message:String(e);return t.toLowerCase().includes(`cancel`)?new Y({reason:`authentication`,detail:t}):new ed({reason:`remote-unavailable`,detail:`Could not prepare the SSH environment: ${t}`})}function NO(e){return new ed({reason:`borg-unavailable`,detail:`Borg is unavailable: ${String(e)}`})}var PO=x(`web.connectionPlatform.borgTunnelCredentials`)(function*(){let e=window.desktopBridge;if(e?.getSearchAtlasAccessToken||e?.getSearchAtlasTunnelCredentials){let t=yield*kr({try:async()=>e.getSearchAtlasAccessToken?e.getSearchAtlasAccessToken():(await e.getSearchAtlasTunnelCredentials?.())?.accessToken??null,catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not load the desktop Borg credentials: ${String(e)}`})});return t===null?yield*new Y({reason:`authentication`,detail:`Sign in to Search Atlas to reach this device through Borg.`}):{getAccessToken:async()=>t}}let t=PE();return t?{getAccessToken:()=>t.getAccessToken()}:yield*new Y({reason:`configuration`,detail:`Borg is not configured for this client.`})}),FO=x(`web.connectionPlatform.borgTunnelClient`)(function*(){let e=hv();if(!e)return yield*new Y({reason:`configuration`,detail:`Borg is not configured for this client.`});let t=yield*PO(),n=yield*kr({try:async()=>{let n=await t.getAccessToken();if(!n)throw Error(`Search Atlas authentication is required.`);return FE({apiUrl:e,token:n})},catch:e=>new Y({reason:`configuration`,detail:`Borg customer could not be resolved: ${String(e)}`})});return yield*ua({try:()=>Cy({apiUrl:e,customerId:n,getAccessToken:t.getAccessToken,fetch:EO}),catch:e=>new Y({reason:`configuration`,detail:`Borg is not configured for this client: ${String(e)}`})})}),IO=x(`web.connectionPlatform.ssh.provisionDesktop`)(function*(e,t){let n=yield*kr({try:()=>e.ensureSshEnvironment(t,{issuePairingToken:!0}),catch:MO}),r=n.pairingToken;if(r===null)return yield*new Y({reason:`authentication`,detail:`The SSH environment did not issue a pairing credential.`});let i=yield*kr({try:()=>e.fetchSshEnvironmentDescriptor(n.httpBaseUrl),catch:MO}),a=yield*kr({try:()=>e.bootstrapSshBearerSession(n.httpBaseUrl,r),catch:MO});return{environmentId:i.environmentId,label:i.label,bootstrap:n,bearerToken:a.access_token}}),LO=Dn(M(()=>{let e=Vu.of({metadata:jO(),scopes:Pn}),t=Bu.of({deviceId:Ze(()=>{let e=window.desktopBridge?.getSearchAtlasTunnelCredentials;return e?kr({try:()=>e(),catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not load the desktop device identity: ${String(e)}`})}).pipe(O(e=>Wt(e?.deviceId))):b(C())})}),n=Hu.of({bearerToken:kr({try:Lv,catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not load the desktop primary credential: ${String(e)}`})}).pipe(O(Wt))}),r=Uu.of({provision:x(`web.connectionPlatform.ssh.provision`)(function*(e){let t=window.desktopBridge;return t===void 0?yield*new Y({reason:`unsupported`,detail:`SSH environments are only available in the desktop app.`}):yield*IO(t,e)}),prepare:x(`web.connectionPlatform.ssh.prepare`)(function*(e){let t=window.desktopBridge;if(t===void 0)return yield*new Y({reason:`unsupported`,detail:`SSH environments are only available in the desktop app.`});let n=yield*kr({try:()=>t.ensureSshEnvironment(e.target,{issuePairingToken:!0}),catch:MO});return n.pairingToken===null?yield*new Y({reason:`authentication`,detail:`The SSH environment did not issue a pairing credential.`}):{bootstrap:n,bearerToken:(yield*kr({try:()=>t.bootstrapSshBearerSession(n.httpBaseUrl,n.pairingToken),catch:MO})).access_token}}),disconnect:x(`web.connectionPlatform.ssh.disconnect`)(function*(e){let t=window.desktopBridge;t!==void 0&&(yield*kr({try:()=>t.disconnectSshEnvironment(e),catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not disconnect the SSH environment: ${String(e)}`})}))})}),i=Wu.of({openTunnel:x(`web.connectionPlatform.borgTunnel.openTunnel`)(function*(){let e=yield*FO();return{ticket:yield*kr({try:()=>e.requestTicket(),catch:NO}),tunnelId:Sy()}}),isDeviceOnline:x(`web.connectionPlatform.borgTunnel.isDeviceOnline`)(function*(e){let t=yield*FO();return(yield*kr({try:()=>t.status(e),catch:NO})).online})});return xi(Bu,t).pipe(ma(Hu,n),ma(Vu,e),ma(Uu,r),ma(Wu,i))})),RO=x(`web.connectionPlatform.loadPrimaryConnectionRegistration`)(function*(e){let t=yield*go({httpBaseUrl:e.target.httpBaseUrl}).pipe(ir(Vv),N(Qd));return new dd({target:new Ku({environmentId:t.environmentId,label:t.label,httpBaseUrl:e.target.httpBaseUrl,wsBaseUrl:e.target.wsBaseUrl})})}),zO=x(`web.connectionPlatform.loadSecondaryConnectionRegistration`)(function*(e){if(e.httpBaseUrl===null||e.wsBaseUrl===null||e.bootstrapToken===void 0)return yield*new ed({reason:`endpoint-unavailable`,detail:`Desktop-local backend ${e.id} is not ready yet.`});let t=e.httpBaseUrl,n=e.wsBaseUrl,r=yield*go({httpBaseUrl:t}).pipe(N(Qd)),i=yield*en,a=yield*zd({httpBaseUrl:t,credential:e.bootstrapToken,scopes:Pn,clientMetadata:jO()}).pipe(N(Qd)),o=Co(e.id),s=e.label||r.label;return{registration:new fd({target:new qu({environmentId:r.environmentId,label:s,connectionId:o}),profile:new id({connectionId:o,environmentId:r.environmentId,label:s,httpBaseUrl:t,wsBaseUrl:n}),credential:new ld({token:a.access_token})}),expiresAtEpochMs:HO(i,a.expires_in),refreshAtEpochMs:UO(i,a.expires_in)}}),BO=`3 seconds`,VO=5e3;function HO(e,t){return e+Math.max(0,t*1e3)}function UO(e,t){return Math.max(e,HO(e,t)-VO)}function WO(e=Nv){try{return{_tag:`Success`,target:e()}}catch(e){return{_tag:`Failure`,cause:e}}}function GO(e,t){return t._tag===`Failure`?e.get(Ea):void 0}function KO(e,t,n){return e.signature===t&&(e.refreshAtEpochMs===void 0||n<e.refreshAtEpochMs)}function qO(e,t,n){return e.signature===t&&e.expiresAtEpochMs!==void 0&&n<e.expiresAtEpochMs}function JO(e,t,n){return t._tag===`Success`?new Map:new Map([...e].filter(([,e])=>e.expiresAtEpochMs!==void 0&&n<e.expiresAtEpochMs))}var YO=Ar(hO,kO,AO,LO,Mn(ih,E(function*(){if(rD())return ih.of({registrations:Si});let e=yield*bo(new Map),t=E(function*(){let t=yield*yo(e),n=yield*en,r=new Map,i=[],a=WO(),o=GO(t,a);if(o!==void 0&&(r.set(Ea,o),i.push(o.registration)),a._tag===`Failure`)yield*Qi(`Could not read the primary environment topology.`,{cause:a.cause});else if(a.target!==null){let e=a.target,o=`primary|${e.target.httpBaseUrl}|${e.target.wsBaseUrl}`,s=t.get(Ea);if(s!==void 0&&KO(s,o,n))r.set(Ea,s),i.push(s.registration);else{let t=yield*RO(e).pipe(wn(e=>Qi(`Could not discover the primary environment.`,{error:e})),Ir);if(u(t)){let e={signature:o,registration:t.value};r.set(Ea,e),i.push(t.value)}}}let s=Eo();for(let[e,a]of JO(t,s,n))r.set(e,a),i.push(a.registration);if(s._tag===`Failure`)yield*Qi(`Could not read the desktop-local backend topology.`,{cause:s.cause});else for(let e of s.bootstraps){let a=`${e.httpBaseUrl}|${e.wsBaseUrl}|${e.bootstrapToken??``}`,o=t.get(e.id);if(o!==void 0&&KO(o,a,n)){r.set(e.id,o),i.push(o.registration);continue}let s=yield*zO(e).pipe(wn(t=>Qi(`Could not connect a desktop-local backend.`,{id:e.id,error:t})),Ir);if(u(s)){let t={signature:a,...s.value};r.set(e.id,t),i.push(s.value.registration)}else o!==void 0&&qO(o,a,n)&&(r.set(e.id,o),i.push(o.registration))}return yield*to(e,r),i}).pipe(ir(lo));return ih.of({registrations:pn(BO).pipe(Ct(()=>t))})})),ea(Od,Od.of({clear:(e,t)=>M(()=>{ho(e,t)})})),ea(Wp,Wp.of({observe:({environmentId:e,method:t})=>M(()=>{DO+=1;let n=`${e}:${DO}`;return xD(n,t,`${t} · ${e}`),M(()=>{SD(n)})})}))),XO=`borg.searchatlas.api-key`,ZO=`borg.searchatlas.api-customer-id`,QO=`borg-search-atlas-credential-changed`,$O=e=>/^\d+$/u.test(e)&&Number(e)>0,ek=()=>{try{let e=window.sessionStorage.getItem(XO)?.trim(),t=window.sessionStorage.getItem(ZO)?.trim();return e&&t&&$O(t)?{kind:`apiKey`,key:e,customerId:t}:void 0}catch{return}};function tk(e,t){try{e.trim()&&$O(t.trim())?(window.sessionStorage.setItem(XO,e.trim()),window.sessionStorage.setItem(ZO,t.trim())):(window.sessionStorage.removeItem(XO),window.sessionStorage.removeItem(ZO)),window.dispatchEvent(new Event(QO))}catch{}}function nk(){tk(``,``)}var rk=e=>e===null||e.trim().length===0?C():w({kind:`jwt`,token:e}),ik=e=>{let t=rk(e);return u(t)?t:ie(ek())},ak=Mn(Jf,E(function*(){let e=typeof window>`u`?void 0:window.desktopBridge,t=e?null:PE(),n=yield*yi(),r=async()=>{let n=null;try{n=e?e.getSearchAtlasAccessToken?await e.getSearchAtlasAccessToken():(await e.getSearchAtlasTunnelCredentials?.())?.accessToken??null:t?await t.getAccessToken():null}catch{n=null}return e?rk(n):ik(n)};t!==null&&(yield*Wi(M(()=>t.subscribe(e=>fa(n,ik(e)))),e=>M(e)));let i=e?.onSearchAtlasCredentialChanged;return i&&(yield*Wi(M(()=>i(()=>{r().then(e=>fa(n,e))})),e=>M(e))),typeof window<`u`&&(yield*Wi(M(()=>{let e=()=>{r().then(e=>fa(n,e))};window.addEventListener(QO,e);let t=_p(e);return()=>{window.removeEventListener(QO,e),t()}}),e=>M(e))),Jf.of({current:Ga(r),changes:ae(n)})}));function ok(){try{return{key:window.sessionStorage.getItem(XO)??``,customerId:window.sessionStorage.getItem(ZO)??``}}catch{return{key:``,customerId:``}}}var sk=YO.pipe(da(qv)),ck=Ar(ng,_h,uv),lk=a(oh({environmentThemes:!0}),ck).pipe(Ai(Ar(qv,sk,uy,ak))),uk=cc(Ar(dy,Qh,Yh(hv)).pipe(Ai(lk)));function dk(e){return e.pipe(O(w),li(e=>Qi(`Could not load the initial environment configuration.`).pipe(Ya({...hp(e)}),cr(C()))))}var fk=6e3,pk=x(`clientRuntime.state.fetchEnvironmentSessionState`)(function*(e){let t=uo(e.prepared.httpBaseUrl,`/api/auth/session`),n=yield*fo(e.prepared.httpBaseUrl),r=yield*ph(e.prepared.httpAuthorization,`GET`,t,e.signer);return yield*ro(t,e.timeoutMs??fk,fh(e.prepared.httpAuthorization,n.auth.session({headers:r})))});function mk(e){let t=z(t=>e.atom(hm(t,ke(Ip.pipe(O(e=>Zo(e.session).pipe(Ct(dt({onNone:()=>b(C()),onSome:e=>dk(e.initialConfig)}))))))),{initialValue:C()})),n=z(e=>R(n=>Qt(ja(gs(n(t(e))),()=>C()))).pipe(B(`environment-config-value:${e}`))),r=z(t=>e.atom(hm(t,ke(Ip.pipe(O(e=>Zo(e.prepared))))),{initialValue:C()})),i=z(e=>R(t=>ja(gs(t(r(e))),()=>C())).pipe(B(`environment-prepared-connection:${e}`))),a=z(t=>e.atom(e=>{let n=Qt(e(i(t)));return n===null?Nr:E(function*(){let e=yield*an(ef);return yield*pk({prepared:n,signer:e})})}).pipe(Cc({staleTime:3e4,revalidateOnMount:!0}),Gs(5*6e4),B(`environment-session-state:${t}`)));return{initialConfigAtom:t,initialConfigValueAtom:n,preparedConnectionAtom:r,preparedConnectionValueAtom:i,sessionStateAtom:a,sessionStateValueAtom:z(e=>R(t=>Qt(gs(t(a(e))))??null).pipe(B(`environment-session-state-value:${e}`)))}}var hk=mk(uk),gk=R(C()).pipe(B(`web-prepared-connection:empty`));function _k(e){let t=(0,Gc.c)(2),n;return t[0]===e?n=t[1]:(n=e===null?gk:hk.preparedConnectionValueAtom(e),t[0]=e,t[1]=n),zc(n)}function vk(e){return Qt(cD.get(hk.preparedConnectionValueAtom(e)))}export{u_ as $,Jp as $t,PE as A,gs as An,uh as At,mv as B,_m as Bt,XE as C,Cs as Cn,Ch as Ct,zE as D,ls as Dn,dh as Dt,KE as E,os as En,xh as Et,Dv as F,Lo as Fn,$p as Ft,J_ as G,nm as Gt,ov as H,sm as Ht,Mv as I,vm as It,U_ as J,em as Jt,H_ as K,tm as Kt,hv as L,xm as Lt,Kv as M,L as Mn,Lm as Mt,Vv as N,Xo as Nn,zm as Nt,RE as O,ss as On,ch as Ot,Pv as P,$o as Pn,Rm as Pt,m_ as Q,Kp as Qt,gv as R,ym as Rt,JE as S,B as Sn,Nh as St,GE as T,_s as Tn,yh as Tt,tv as U,hm as Ut,pv as V,cm as Vt,Y_ as W,rm as Wt,p_ as X,um as Xt,B_ as Y,am as Yt,h_ as Z,im as Zt,aD as _,z as _n,Bh as _t,QO as a,_p as an,Jg as at,qE as b,Gs as bn,Ph as bt,tk as c,Yf as cn,Pg as ct,ED as d,td as dn,dg as dt,Yp as en,o_ as et,lD as f,Wc as fn,sg as ft,QE as g,jc as gn,Lh as gt,oD as h,Fc as hn,zh as ht,uk as i,vp as in,qg as it,tE as j,Zo as jn,Wm as jt,FE as k,cs as kn,lh as kt,EO as l,Dd as ln,gg as lt,sD as m,zc as mn,cg as mt,vk as n,Vp as nn,Rg as nt,nk as o,hp as on,Bg as ot,cD as p,Uc as pn,mg as pt,V_ as q,mm as qt,_k as r,Ip as rn,zg as rt,ok as s,Xf as sn,Ng as st,hk as t,Zp as tn,Zg as tt,OD as u,nd as un,lg as ut,rD as v,vc as vn,Wh as vt,ZE as w,us as wn,Sh as wt,YE as x,Cc as xn,Fh as xt,iD as y,R as yn,Ih as yt,fv as z,bm as zt};
67
- //# sourceMappingURL=session-CgVsO0DD.js.map
66
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function qC(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:XC(t,`input`,e.processors),output:XC(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function JC(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return JC(r.element,n);if(r.type===`set`)return JC(r.valueType,n);if(r.type===`lazy`)return JC(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return JC(r.innerType,n);if(r.type===`intersection`)return JC(r.left,n)||JC(r.right,n);if(r.type===`record`||r.type===`map`)return JC(r.keyType,n)||JC(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:JC(r.in,n)||JC(r.out,n);if(r.type===`object`){for(let e in r.shape)if(JC(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(JC(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(JC(e,n))return!0;return!!(r.rest&&JC(r.rest,n))}return!1}var YC=(e,t={})=>n=>{let r=WC({...n,processors:t});return GC(e,r),KC(r,e),qC(r,e)},XC=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=WC({...i??{},target:a,io:t,processors:n});return GC(e,o),KC(o,e),qC(o,e)},ZC={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},QC=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ZC[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},$C=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ew=(e,t,n,r)=>{n.not={}},tw=(e,t,n,r)=>{let i=e._zod.def,a=Fy(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},nw=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},rw=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},iw=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=GC(a.element,t,{...r,path:[...r.path,`items`]})},aw=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=GC(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=GC(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ow=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>GC(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},sw=(e,t,n,r)=>{let i=e._zod.def,a=GC(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=GC(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},cw=(e,t,n,r)=>{let i=e._zod.def,a=GC(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},lw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},uw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},dw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},pw=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;GC(o,t,r);let s=t.seen.get(e);s.ref=o},mw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hw=(e,t,n,r)=>{let i=e._zod.def;GC(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gw=Z(`ZodISODateTime`,(e,t)=>{Wx.init(e,t),Uw.init(e,t)});function _w(e){return fC(gw,e)}var vw=Z(`ZodISODate`,(e,t)=>{Gx.init(e,t),Uw.init(e,t)});function yw(e){return pC(vw,e)}var bw=Z(`ZodISOTime`,(e,t)=>{Kx.init(e,t),Uw.init(e,t)});function xw(e){return mC(bw,e)}var Sw=Z(`ZodISODuration`,(e,t)=>{qx.init(e,t),Uw.init(e,t)});function Cw(e){return hC(Sw,e)}var ww=Z(`ZodError`,(e,t)=>{_b.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>bb(e,t)},flatten:{value:t=>yb(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Iy,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Iy,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Tw=xb(ww),Ew=Sb(ww),Dw=Cb(ww),Ow=Tb(ww),kw=Db(ww),Aw=Ob(ww),jw=kb(ww),Mw=Ab(ww),Nw=jb(ww),Pw=Mb(ww),Fw=Nb(ww),Iw=Pb(ww),Lw=new WeakMap;function Rw(e,t,n){let r=Object.getPrototypeOf(e),i=Lw.get(r);if(i||(i=new Set,Lw.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zw=Z(`ZodType`,(e,t)=>(Ax.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:XC(e,`input`),output:XC(e,`output`)}}),e.toJSONSchema=YC(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Tw(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Dw(e,t,n),e.parseAsync=async(t,n)=>Ew(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ow(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>kw(e,t,n),e.decode=(t,n)=>Aw(e,t,n),e.encodeAsync=async(t,n)=>jw(e,t,n),e.decodeAsync=async(t,n)=>Mw(e,t,n),e.safeEncode=(t,n)=>Nw(e,t,n),e.safeDecode=(t,n)=>Pw(e,t,n),e.safeEncodeAsync=async(t,n)=>Fw(e,t,n),e.safeDecodeAsync=async(t,n)=>Iw(e,t,n),Rw(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Uy(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return $y(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(JT(e,t))},superRefine(e,t){return this.check(YT(e,t))},overwrite(e){return this.check(PC(e))},optional(){return AT(this)},exactOptional(){return MT(this)},nullable(){return PT(this)},nullish(){return AT(PT(this))},nonoptional(e){return BT(this,e)},array(){return vT(this)},or(e){return ST([this,e])},and(e){return wT(this,e)},transform(e){return WT(this,OT(e))},default(e){return IT(this,e)},prefault(e){return RT(this,e)},catch(e){return HT(this,e)},pipe(e){return WT(this,e)},readonly(){return KT(this)},describe(e){let t=this.clone();return HS.add(t,{description:e}),t},meta(...e){if(e.length===0)return HS.get(this);let t=this.clone();return HS.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return HS.get(e)?.description},configurable:!0}),e)),Bw=Z(`_ZodString`,(e,t)=>{jx.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QC(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rw(e,`_ZodString`,{regex(...e){return this.check(OC(...e))},includes(...e){return this.check(jC(...e))},startsWith(...e){return this.check(MC(...e))},endsWith(...e){return this.check(NC(...e))},min(...e){return this.check(EC(...e))},max(...e){return this.check(TC(...e))},length(...e){return this.check(DC(...e))},nonempty(...e){return this.check(EC(1,...e))},lowercase(e){return this.check(kC(e))},uppercase(e){return this.check(AC(e))},trim(){return this.check(IC())},normalize(...e){return this.check(FC(...e))},toLowerCase(){return this.check(LC())},toUpperCase(){return this.check(RC())},slugify(){return this.check(zC())}})}),Vw=Z(`ZodString`,(e,t)=>{jx.init(e,t),Bw.init(e,t),e.email=t=>e.check(WS(Ww,t)),e.url=t=>e.check(XS(qw,t)),e.jwt=t=>e.check(dC(cT,t)),e.emoji=t=>e.check(ZS(Jw,t)),e.guid=t=>e.check(GS(Gw,t)),e.uuid=t=>e.check(KS(Kw,t)),e.uuidv4=t=>e.check(qS(Kw,t)),e.uuidv6=t=>e.check(JS(Kw,t)),e.uuidv7=t=>e.check(YS(Kw,t)),e.nanoid=t=>e.check(QS(Yw,t)),e.guid=t=>e.check(GS(Gw,t)),e.cuid=t=>e.check($S(Xw,t)),e.cuid2=t=>e.check(eC(Zw,t)),e.ulid=t=>e.check(tC(Qw,t)),e.base64=t=>e.check(cC(aT,t)),e.base64url=t=>e.check(lC(oT,t)),e.xid=t=>e.check(nC($w,t)),e.ksuid=t=>e.check(rC(eT,t)),e.ipv4=t=>e.check(iC(tT,t)),e.ipv6=t=>e.check(aC(nT,t)),e.cidrv4=t=>e.check(oC(rT,t)),e.cidrv6=t=>e.check(sC(iT,t)),e.e164=t=>e.check(uC(sT,t)),e.datetime=t=>e.check(_w(t)),e.date=t=>e.check(yw(t)),e.time=t=>e.check(xw(t)),e.duration=t=>e.check(Cw(t))});function Hw(e){return US(Vw,e)}var Uw=Z(`ZodStringFormat`,(e,t)=>{Mx.init(e,t),Bw.init(e,t)}),Ww=Z(`ZodEmail`,(e,t)=>{Fx.init(e,t),Uw.init(e,t)}),Gw=Z(`ZodGUID`,(e,t)=>{Nx.init(e,t),Uw.init(e,t)}),Kw=Z(`ZodUUID`,(e,t)=>{Px.init(e,t),Uw.init(e,t)}),qw=Z(`ZodURL`,(e,t)=>{Ix.init(e,t),Uw.init(e,t)}),Jw=Z(`ZodEmoji`,(e,t)=>{Lx.init(e,t),Uw.init(e,t)}),Yw=Z(`ZodNanoID`,(e,t)=>{Rx.init(e,t),Uw.init(e,t)}),Xw=Z(`ZodCUID`,(e,t)=>{zx.init(e,t),Uw.init(e,t)}),Zw=Z(`ZodCUID2`,(e,t)=>{Bx.init(e,t),Uw.init(e,t)}),Qw=Z(`ZodULID`,(e,t)=>{Vx.init(e,t),Uw.init(e,t)}),$w=Z(`ZodXID`,(e,t)=>{Hx.init(e,t),Uw.init(e,t)}),eT=Z(`ZodKSUID`,(e,t)=>{Ux.init(e,t),Uw.init(e,t)}),tT=Z(`ZodIPv4`,(e,t)=>{Jx.init(e,t),Uw.init(e,t)}),nT=Z(`ZodIPv6`,(e,t)=>{Yx.init(e,t),Uw.init(e,t)}),rT=Z(`ZodCIDRv4`,(e,t)=>{Xx.init(e,t),Uw.init(e,t)}),iT=Z(`ZodCIDRv6`,(e,t)=>{Zx.init(e,t),Uw.init(e,t)}),aT=Z(`ZodBase64`,(e,t)=>{$x.init(e,t),Uw.init(e,t)}),oT=Z(`ZodBase64URL`,(e,t)=>{tS.init(e,t),Uw.init(e,t)}),sT=Z(`ZodE164`,(e,t)=>{nS.init(e,t),Uw.init(e,t)}),cT=Z(`ZodJWT`,(e,t)=>{iS.init(e,t),Uw.init(e,t)}),lT=Z(`ZodNumber`,(e,t)=>{aS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$C(e,t,n,r),Rw(e,`ZodNumber`,{gt(e,t){return this.check(SC(e,t))},gte(e,t){return this.check(CC(e,t))},min(e,t){return this.check(CC(e,t))},lt(e,t){return this.check(bC(e,t))},lte(e,t){return this.check(xC(e,t))},max(e,t){return this.check(xC(e,t))},int(e){return this.check(fT(e))},safe(e){return this.check(fT(e))},positive(e){return this.check(SC(0,e))},nonnegative(e){return this.check(CC(0,e))},negative(e){return this.check(bC(0,e))},nonpositive(e){return this.check(xC(0,e))},multipleOf(e,t){return this.check(wC(e,t))},step(e,t){return this.check(wC(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function uT(e){return gC(lT,e)}var dT=Z(`ZodNumberFormat`,(e,t)=>{oS.init(e,t),lT.init(e,t)});function fT(e){return _C(dT,e)}var pT=Z(`ZodUnknown`,(e,t)=>{sS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function mT(){return vC(pT)}var hT=Z(`ZodNever`,(e,t)=>{cS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ew(e,t,n,r)});function gT(e){return yC(hT,e)}var _T=Z(`ZodArray`,(e,t)=>{uS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iw(e,t,n,r),e.element=t.element,Rw(e,`ZodArray`,{min(e,t){return this.check(EC(e,t))},nonempty(e){return this.check(EC(1,e))},max(e,t){return this.check(TC(e,t))},length(e,t){return this.check(DC(e,t))},unwrap(){return this.element}})});function vT(e,t){return BC(_T,e,t)}var yT=Z(`ZodObject`,(e,t)=>{hS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aw(e,t,n,r),Q(e,`shape`,()=>t.shape),Rw(e,`ZodObject`,{keyof(){return ET(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:mT()})},loose(){return this.clone({...this._zod.def,catchall:mT()})},strict(){return this.clone({...this._zod.def,catchall:gT()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ib(this,e)},safeExtend(e){return ab(this,e)},merge(e){return ob(this,e)},pick(e){return nb(this,e)},omit(e){return rb(this,e)},partial(...e){return sb(kT,this,e[0])},required(...e){return cb(zT,this,e[0])}})});function bT(e,t){return new yT({type:`object`,shape:e??{},...$(t)})}var xT=Z(`ZodUnion`,(e,t)=>{_S.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ow(e,t,n,r),e.options=t.options});function ST(e,t){return new xT({type:`union`,options:e,...$(t)})}var CT=Z(`ZodIntersection`,(e,t)=>{vS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sw(e,t,n,r)});function wT(e,t){return new CT({type:`intersection`,left:e,right:t})}var TT=Z(`ZodEnum`,(e,t)=>{xS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tw(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new TT({...t,checks:[],...$(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new TT({...t,checks:[],...$(r),entries:i})}});function ET(e,t){return new TT({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...$(t)})}var DT=Z(`ZodTransform`,(e,t)=>{SS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rw(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new My(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(hb(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(hb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function OT(e){return new DT({type:`transform`,transform:e})}var kT=Z(`ZodOptional`,(e,t)=>{wS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function AT(e){return new kT({type:`optional`,innerType:e})}var jT=Z(`ZodExactOptional`,(e,t)=>{TS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function MT(e){return new jT({type:`optional`,innerType:e})}var NT=Z(`ZodNullable`,(e,t)=>{ES.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function PT(e){return new NT({type:`nullable`,innerType:e})}var FT=Z(`ZodDefault`,(e,t)=>{DS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function IT(e,t){return new FT({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Xy(t)}})}var LT=Z(`ZodPrefault`,(e,t)=>{kS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RT(e,t){return new LT({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Xy(t)}})}var zT=Z(`ZodNonOptional`,(e,t)=>{AS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function BT(e,t){return new zT({type:`nonoptional`,innerType:e,...$(t)})}var VT=Z(`ZodCatch`,(e,t)=>{MS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function HT(e,t){return new VT({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var UT=Z(`ZodPipe`,(e,t)=>{NS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pw(e,t,n,r),e.in=t.in,e.out=t.out});function WT(e,t){return new UT({type:`pipe`,in:e,out:t})}var GT=Z(`ZodReadonly`,(e,t)=>{FS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mw(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function KT(e){return new GT({type:`readonly`,innerType:e})}var qT=Z(`ZodCustom`,(e,t)=>{LS.init(e,t),zw.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nw(e,t,n,r)});function JT(e,t={}){return VC(qT,e,t)}function YT(e,t){return HC(e,t)}var XT=bT({accessToken:Hw().min(1),refreshToken:Hw().min(1).optional(),expiresAt:uT().int().positive().optional(),tokenType:Hw().default(`Bearer`),scope:Hw().optional()}),ZT=bT({access_token:Hw().min(1),refresh_token:Hw().min(1).optional(),expires_in:uT().int().positive().optional(),token_type:Hw().optional(),scope:Hw().optional()}),QT=(e,t=Date.now())=>e.expiresAt!==void 0&&e.expiresAt-6e4<=t;function $T(e,t=Date.now()){let n=ZT.parse(e);return{accessToken:n.access_token,...n.refresh_token?{refreshToken:n.refresh_token}:{},...n.expires_in?{expiresAt:t+n.expires_in*1e3}:{},tokenType:n.token_type??`Bearer`,...n.scope?{scope:n.scope}:{}}}var eE=`relay`,tE=class extends Error{refusal;constructor(e){super(`Search Atlas refused the request (${e.status})`),this.name=`EmailAuthRefusedError`,this.refusal=e}},nE=(e,t)=>new URL(t,e).toString(),rE=`/api/customer/account/register/v2/`,iE=`/api/token/`,aE=`/api/customer/account/check-email/`,oE=`/oauth/approve/`,sE=`/account/google/oauth/start`;function cE(e){let t=JSON.stringify({a:e.api,c:e.clientId,r:e.redirectUri,s:e.scope,t:e.state,x:e.challenge});return btoa(t).replace(/\+/gu,`-`).replace(/\//gu,`_`).replace(/=+$/u,``)}function lE(e){let t=e.name?.trim();return{email:e.email.trim(),password:e.password,...t?{contact_name:t}:{},registration_source:eE,...uE(e.captcha)}}var uE=e=>e.version===`v2`?{captcha_v2:e.token}:{captcha:e.token};function dE(e){return{username:e.email.trim(),password:e.password,...uE(e.captcha)}}var fE={email:`email`,password:`password`,contact_name:`name`},pE=e=>{let t=Array.isArray(e)?e[0]:e;return typeof t==`string`&&t.trim().length>0?t.trim():null},mE=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:null;function hE(e,t){let n=mE(t);if(e===201||e===200){let e=n?.jwt_token;if(typeof e==`string`&&e.length>0)return e;if(n?.verification_required===!0)throw new tE({status:`verification-required`});return null}if(e===409)throw new tE({status:`email-registered`});if(e===406)throw new tE({status:`invalid`,field:`email`,message:`Search Atlas doesn't accept this email provider. Use a different email.`});if(e!==400||!n)return null;if(gE(n))throw new tE({status:`captcha-required`});for(let[e,t]of Object.entries(fE)){let r=pE(n[e]);if(r)throw new tE({status:`invalid`,field:t,message:r})}return null}function gE(e){if(`recaptcha_fallback`in e||`captcha`in e||`captcha_v2`in e)return!0;let t=pE(e.non_field_errors);return t!==null&&/recaptcha/iu.test(t)}function _E(e,t){let n=mE(t);if(e===200){let e=n?.token;return typeof e==`string`&&e.length>0?e:null}if(e===400&&n&&gE(n))throw new tE({status:`captcha-required`});if(e===403&&n?.kind===`email_verification_required`)throw new tE({status:`verification-required`});if(e===401)throw new tE({status:`invalid`,field:`password`,message:`The email or password is incorrect.`});return null}function vE(e){let t=mE(e)?.redirect_url;return typeof t==`string`&&t.length>0?t:null}var yE=class extends Error{code;status;constructor(e,t,n){super(t),this.code=e,this.status=n,this.name=`AuthError`}},bE=e=>e instanceof yE&&e.status!==void 0&&e.status>=400&&e.status<500&&e.status!==408&&e.status!==429,xE=2e4;async function SE(e){let t=new AbortController,n,r=new Promise((e,r)=>{n=setTimeout(()=>{let e=Error(`Search Atlas authentication timed out. Try again.`);e.name=`TimeoutError`,r(e),t.abort(e)},xE)});try{return await Promise.race([e(t.signal),r])}finally{clearTimeout(n)}}function CE(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;return typeof t.sub!=`string`||typeof t.name!=`string`?null:{subject:t.sub,email:typeof t.email==`string`?t.email:``,name:t.name.trim()}}var wE=`borg.tokens`;function TE(e,t){let n=new URL(e),r=n.searchParams.get(`error`);if(r)throw new yE(r,n.searchParams.get(`error_description`)??r);if(n.searchParams.get(`state`)!==t)throw new yE(`state_mismatch`,`Authorization state did not match`);let i=n.searchParams.get(`code`);if(!i)throw new yE(`missing_code`,`Callback carried no authorization code`);return i}var EE=class{#e;#t;#n=Promise.resolve();#r=new Map;#i=Promise.resolve();#a=0;#o;#s;#c=new Set;constructor(e,t){this.#o=e,this.#s=t}subscribe(e){return this.#c.add(e),()=>{this.#c.delete(e)}}#l(e){for(let t of this.#c)try{t(e)}catch{}}async beginAuthorization(e=this.#o.redirectUri){let{state:t,challenge:n,method:r}=await this.#u(e),i=new URL(this.#o.authorizationEndpoint);return i.searchParams.set(`response_type`,`code`),i.searchParams.set(`client_id`,this.#o.clientId),i.searchParams.set(`redirect_uri`,e),i.searchParams.set(`code_challenge`,n),i.searchParams.set(`code_challenge_method`,r),i.searchParams.set(`state`,t),this.#o.scopes?.length&&i.searchParams.set(`scope`,this.#o.scopes.join(` `)),i.toString()}async#u(e){let t=await this.#d(e);return this.#e=t,t}async#d(e){let{verifier:t,challenge:n,method:r}=await ky(this.#s.pkceCrypto);return{state:await Oy(16,this.#s.pkceCrypto),verifier:t,challenge:n,method:r,redirectUri:e}}async isEmailRegistered(e){let t=nE(this.#o.tokenEndpoint,aE);return SE(async n=>{let r=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({email:e.trim()}),signal:n}),i=await r.json().catch(()=>null);if(!r.ok)throw new yE(`http_${r.status}`,`Email check returned ${r.status}`,r.status);return i?.exists===!0})}async signUp(e){let t=await this.#f(rE,lE(e),hE);return this.authorizeWithAccountToken(t)}async signIn(e){let t=await this.#f(iE,dE(e),_E);return this.authorizeWithAccountToken(t)}#f(e,t,n){return SE(async r=>{let i=await fetch(nE(this.#o.tokenEndpoint,e),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t),signal:r}),a=await i.json().catch(()=>null),o=n(i.status,a);if(o===null)throw new yE(`http_${i.status}`,`Search Atlas returned ${i.status}`,i.status);return o})}async authorizeWithGoogle(e){let t=new URL(e);if(t.protocol!==`https:`)throw new yE(`invalid_request`,`Google sign-in must return to an https page`);return this.#p(async()=>{let e=await this.#s.listenForOAuthCallback(),{state:n,challenge:r}=await this.#u(e.redirectUri),i=cE({api:new URL(this.#o.tokenEndpoint).origin,clientId:this.#o.clientId,redirectUri:e.redirectUri,scope:this.#o.scopes?.join(` `)??``,state:n,challenge:r}),a=new URL(sE,this.#o.tokenEndpoint);return a.searchParams.set(`from_domain`,`${t.host}${t.pathname}#${i}`),a.searchParams.set(`registration_source`,eE),a.toString()})}async authorizeWithAccountToken(e){let t=await this.#d(this.#o.redirectUri),n=await SE(async n=>{let r=await fetch(nE(this.#o.tokenEndpoint,oE),{method:`POST`,headers:{authorization:`Bearer ${e}`,"content-type":`application/json`},body:JSON.stringify({client_id:this.#o.clientId,scope:this.#o.scopes?.join(` `)??``,state:t.state,redirect_uri:t.redirectUri,code_challenge:t.challenge,code_challenge_method:t.method,nonce:``,response_type:`code`,action:`approve`}),signal:n}),i=await r.json().catch(()=>null),a=r.ok?vE(i):null;if(a===null){let e=i;throw new yE(e?.error??`http_${r.status}`,e?.error_description??`Approval returned ${r.status}`,r.status)}return a});return this.#m(TE(n,t.state),t)}cancelAuthorization(){this.#e=void 0,this.#t?.(),this.#s.cancelOAuthCallback?.()}async authorizeNative(){return this.#p(async()=>{let e=await this.#s.listenForOAuthCallback();return this.beginAuthorization(e.redirectUri)})}async#p(e){this.#t&&this.cancelAuthorization();let t=()=>{},n=new Promise((e,n)=>{t=()=>n(new yE(`cancelled`,`Sign-in was cancelled.`))});n.catch(()=>void 0),this.#t=t;let r=e();r.catch(()=>void 0);try{let e=await Promise.race([r,n]),t=this.#s.waitForOAuthCallback();return t.catch(()=>void 0),await Promise.race([this.#s.openExternal(e),n]),await this.completeAuthorization(await Promise.race([t,n]))}catch(e){throw e instanceof yE&&e.code===`cancelled`&&(await r.catch(()=>void 0),this.#t===t&&this.#s.cancelOAuthCallback?.()),e}finally{this.#t===t&&(this.#t=void 0)}}async completeAuthorization(e){let t=this.#e;if(!t)throw new yE(`no_pending_authorization`,`No authorization in progress`);let n=TE(e,t.state);return this.#e=void 0,this.#m(n,t)}async#m(e,t){let n=this.#a,r=await this.#g({grant_type:`authorization_code`,code:e,redirect_uri:t.redirectUri,client_id:this.#o.clientId,code_verifier:t.verifier});if(n!==this.#a||!await this.#v(r,++this.#a))throw new yE(`session_changed`,`This sign-in was cancelled. Start sign-in again.`);return r}getAccessToken(e){let t=this.#a,n=this.#r.get(e);if(n?.version===t)return n.promise;let r=this.#n.then(()=>this.#h(t,e)).finally(()=>{this.#r.get(e)?.promise===r&&this.#r.delete(e)});return this.#r.set(e,{version:t,promise:r}),this.#n=r.catch(()=>void 0),r}async#h(e,t){if(await this.#i,e!==this.#a)return null;let n=await this.loadTokens();if(e!==this.#a||!n)return null;if(!QT(n)&&n.accessToken!==t)return n.accessToken;if(!n.refreshToken)return await this.signOut(),null;try{let t=await this.refresh(n.refreshToken);return e===this.#a?t.accessToken:null}catch(t){if(e!==this.#a)return null;throw bE(t)&&await this.signOut(),t}}async getUserProfile(){if(!this.#o.userinfoEndpoint)return null;let e=await this.getAccessToken();if(!e)return null;let t=this.#o.userinfoEndpoint,n=e=>SE(async n=>{let r=await fetch(t,{headers:{authorization:`Bearer ${e}`},signal:n});return{response:r,payload:await r.json().catch(()=>null)}}),r=await n(e);if(r.response.status===401){if(e=await this.getAccessToken(e),!e)return null;r=await n(e)}if(!r.response.ok)throw new yE(`http_${r.response.status}`,`Userinfo endpoint returned ${r.response.status}`,r.response.status);let i=CE(r.payload);if(!i)throw new yE(`invalid_userinfo`,`Userinfo endpoint returned an invalid profile`);return i}async refresh(e){let t=this.#a,n=await this.#g({grant_type:`refresh_token`,refresh_token:e,client_id:this.#o.clientId}),r=n.refreshToken?n:{...n,refreshToken:e};return await this.#v(r,t),r}async#g(e){return SE(async t=>{let n=await fetch(this.#o.tokenEndpoint,{method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded`},body:new URLSearchParams(e).toString(),signal:t}),r=await n.json().catch(()=>null);if(!n.ok){let e=r;throw new yE(e?.error??`http_${n.status}`,e?.error_description??`Token endpoint returned ${n.status}`,n.status)}return $T(r)})}async storeTokens(e){await this.#v(e,++this.#a)}#_(e){let t=this.#i.then(e);return this.#i=t.catch(()=>void 0),t}#v(e,t){return this.#_(async()=>t!==this.#a||(await this.#s.setSecureCredential(wE,JSON.stringify(e)),t!==this.#a)?!1:(this.#l(e.accessToken),!0))}async loadTokens(){let e=await this.#s.getSecureCredential(wE);if(!e)return null;try{let t=XT.safeParse(JSON.parse(e));return t.success?t.data:null}catch(e){if(e instanceof SyntaxError)return null;throw e}}async signOut(){this.#e=void 0;let e=++this.#a,t=await this.#_(async()=>{let t=await this.loadTokens().catch(()=>null);return await this.#s.deleteSecureCredential(wE),e===this.#a&&this.#l(null),t});if(t?.refreshToken&&this.#o.revocationEndpoint){let e=this.#o.revocationEndpoint,n=t.refreshToken;SE(t=>fetch(e,{method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:n,client_id:this.#o.clientId}).toString(),signal:t})).catch(()=>{})}}};function DE(){if(typeof window>`u`||!window.location)return null;let e=`mcp:tools:read mcp:tools:execute profile`.split(/\s+/u);return{authorizationEndpoint:`https://dashboard.searchatlas.com/oauth/authorize`,tokenEndpoint:`https://api.searchatlas.com/oauth/token/`,userinfoEndpoint:`https://api.searchatlas.com/oauth/userinfo/`,clientId:`C735iQetqz7GyPSU1N7rCoQunxZuwtq8WR5z-hCp8VA`,redirectUri:`${window.location.origin}/oauth-callback.html`,scopes:e,revocationEndpoint:`https://api.searchatlas.com/oauth/revoke/`}}var OE=`borg.search-atlas.oauth-callback`,kE=`borg-search-atlas-auth`,AE=`borg-search-atlas-oauth-callback`;function jE(e){if(typeof e!=`object`||!e)return null;let t=e;return t.type===AE&&typeof t.url==`string`?t.url:null}function ME(){let e=DE();if(!e)return null;let t=new Map,n=e=>{try{return window.sessionStorage.getItem(e)??t.get(e)??null}catch{return t.get(e)??null}},r=(e,n)=>{t.set(e,n);try{window.sessionStorage.setItem(e,n)}catch{}},i=e=>{t.delete(e);try{window.sessionStorage.removeItem(e)}catch{}},a=null,o=null,s=null;return new EE(e,{getSecureCredential:async e=>n(e),setSecureCredential:async(e,t)=>{r(e,t)},deleteSecureCredential:async e=>{i(e)},listenForOAuthCallback:async()=>({redirectUri:e.redirectUri}),waitForOAuthCallback:()=>(o??=new Promise((e,t)=>{let n=window.setTimeout(()=>{d(),t(Error(`Search Atlas authentication timed out.`))},12e4),r=typeof BroadcastChannel>`u`?null:new BroadcastChannel(kE),i=t=>{d(),e(t)},c=e=>{let t=jE(e.data);t&&i(t)},l=e=>{if(e.origin!==window.location.origin||e.source!==a)return;let t=jE(e.data);t&&i(t)},u=e=>{if(!(e.key!==OE||!e.newValue))try{let t=jE(JSON.parse(e.newValue));t&&i(t)}catch{}};s=()=>{d(),t(new yE(`cancelled`,`Sign-in was cancelled.`))};let d=()=>{s=null,window.clearTimeout(n),window.removeEventListener(`message`,l),window.removeEventListener(`storage`,u),r?.removeEventListener(`message`,c),r?.close(),o=null};window.addEventListener(`message`,l),window.addEventListener(`storage`,u),r?.addEventListener(`message`,c)}),o),cancelOAuthCallback:()=>{s?.(),a?.close()},openExternal:async e=>{if(a=window.open(e,`borg-search-atlas-auth`,`popup,width=520,height=720`),!a)throw Error(`The authentication window was blocked.`)}})}var NE;function PE(){return NE??=ME(),NE}async function FE(e){if(!e.apiUrl)throw Error(`Borg Cloud is not configured.`);let t=Ri(e.token);if(t===void 0)throw Error(`This Search Atlas session names no customer.`);return t.customerId}var IE=/-nightly\.\d{8}\.\d+$/;function LE(e){return e.stageLabel.trim().toLowerCase()===`latest`?e.baseName:`${e.baseName} (${e.stageLabel})`}function RE(e){return e.primaryServerVersion&&IE.test(e.primaryServerVersion)?`Nightly`:e.fallbackStageLabel}function zE(e){let t=RE({primaryServerVersion:e.primaryServerVersion,fallbackStageLabel:e.fallbackStageLabel});return t===e.fallbackStageLabel?e.fallbackDisplayName:LE({baseName:e.baseName,stageLabel:t})}var BE={local:`Development`,staging:`Preview`,production:``};function VE(e){return[BE[e.environment.trim().toLowerCase()]??`Development`,/^[0-9a-f]{7,40}$/i.test(e.commit.trim())?e.commit.trim().slice(0,7):``].filter(Boolean).join(` · `)}function HE(){return typeof window>`u`?null:window.desktopBridge?.getAppBranding?.()??null}var UE=HE(),WE=``,GE=WE===`latest`||WE===`nightly`?WE:null,KE=GE===`nightly`?`Nightly`:GE===`latest`?`Latest`:null,qE=UE?.baseName??`Borg`,JE=UE?.stageLabel??KE??`Alpha`,YE=UE?.displayName??LE({baseName:qE,stageLabel:JE}),XE=`0.0.119`,ZE=VE({environment:`production`,commit:`529849f3c01e48a9f1553d6c3dadb5449ee13b2d`});[`${qE} ${XE}`,ZE].filter(Boolean).join(` · `);function QE(){return`https://app.getborg.com`}function $E(){return``}function eD(){return null}function tD(e){try{return new URL(e).origin}catch{return null}}function nD(){return typeof window<`u`&&window.desktopBridge!==void 0}function rD(e=new URL(window.location.href)){if($E()||nD())return!1;if(eD())return!0;let t=tD(QE());return t!==null&&e.origin===t}function iD(e=new URL(window.location.href)){let t=e.searchParams.get(`host`)?.trim()??``,n=Lm(e)?.trim()??``,r=e.searchParams.get(`label`)?.trim()??``;return!t||!n?null:{host:t,token:n,label:r}}function aD(e=new URL(window.location.href)){return iD(e)!==null}function oD(e){let t=new URL(`/pair`,QE());t.searchParams.set(`host`,e.host);let n=e.label?.trim();return n&&t.searchParams.set(`label`,n),zm(t,e.token).toString()}function sD(e){let t=new URL(`/__borgcode/channel`,QE());return t.searchParams.set(`channel`,e.channel),t.toString()}var cD=Ss();function lD({children:e}){return(0,Mc.createElement)(Fc.Provider,{value:cD},e)}var uD=15e3,dD=12e4,fD=uD,pD=new Map,mD=new Set([k.previewAutomationConnect,k.shellCaptureLoopbackRedirect]),hD=new Set([k.serverUpdateProvider,k.serverRefreshProviders,k.serverUpdateServer]),gD=R([]).pipe(vc,B(`slow-rpc-ack-requests`));function _D(e){cD.set(gD,[...e])}function vD(){return cD.get(gD)}function yD(e){return!e.includes(`subscribe`)&&!e.startsWith(`pullRequests.`)&&!mD.has(e)}function bD(e){return hD.has(e)?Math.max(fD,dD):fD}function xD(e,t,n=t){if(!yD(t))return;CD(e),TD();let r=Date.now(),i=bD(t),a={requestId:e,startedAt:new Date(r).toISOString(),startedAtMs:r,tag:n,thresholdMs:i},o=setTimeout(()=>{pD.delete(e),wD(a)},i);pD.set(e,{request:a,timeoutId:o})}function SD(e){CD(e);let t=vD();t.some(t=>t.requestId===e)&&_D(t.filter(t=>t.requestId!==e))}function CD(e){let t=pD.get(e);t&&(clearTimeout(t.timeoutId),pD.delete(e))}function wD(e){let t=[...vD(),e];if(t.length<=256){_D(t);return}_D(t.slice(-256))}function TD(){for(;pD.size>=256;){let e=pD.keys().next().value;if(e===void 0)return;CD(e)}}function ED(){return zc(gD)}var DD=Promise.resolve(),OD=e=>{DD=e},kD=()=>DD,AD=4,jD=`catalog`,MD=`shell`,ND=`thread`,PD=`server-config`,FD=`vcs-refs`,ID=`document`,LD=`5 seconds`,RD=1,zD=tn($i({schemaVersion:On(RD),environmentId:xe,snapshot:Hn})),BD=tn($i({schemaVersion:On(3),environmentId:xe,threadId:It,snapshot:s})),VD=tn($i({schemaVersion:On(1),environmentId:xe,config:un})),HD=tn($i({schemaVersion:On(1),environmentId:xe,cwd:P,refs:m})),UD=tn(py),WD=Ja(UD),GD=qt(UD),KD=Ja(zD),qD=qt(zD),JD=Ja(BD),YD=qt(BD),XD=Ja(VD),ZD=qt(VD),QD=Ja(HD),$D=qt(HD);function eO(e,t){return new ed({reason:`remote-unavailable`,detail:`Could not ${e} the local connection catalog: ${String(t)}`})}function tO(e,t){return new wd({operation:e,message:`Could not ${e.replaceAll(`-`,` `)}: ${String(t)}`})}var nO=x(`web.connectionStorage.openDatabase`)(function*(){yield*Ga(kD);let e=yield*y(e=>{if(typeof indexedDB>`u`){e(S(eO(`open`,`IndexedDB is unavailable in this browser context.`)));return}let t=!1,n=indexedDB.open(Yr(oa),AD);return n.addEventListener(`upgradeneeded`,()=>{n.result.objectStoreNames.contains(jD)||n.result.createObjectStore(jD),n.result.objectStoreNames.contains(MD)||n.result.createObjectStore(MD),n.result.objectStoreNames.contains(ND)||n.result.createObjectStore(ND),n.result.objectStoreNames.contains(PD)||n.result.createObjectStore(PD),n.result.objectStoreNames.contains(FD)||n.result.createObjectStore(FD)}),n.addEventListener(`error`,()=>{e(S(eO(`open`,n.error??`Unknown IndexedDB error`)))}),n.addEventListener(`success`,()=>{let r=n.result;if(t){r.close();return}r.addEventListener(`versionchange`,()=>r.close()),e(b(r))}),M(()=>{t=!0})}).pipe(r({duration:LD,orElse:()=>S(new ed({reason:`timeout`,detail:`Another Borg tab is holding Borg's saved data. Close your other Borg tabs, then reload this one.`}))}));return yield*rO(e),e});function rO(e){return kr(()=>ur(Zn(),di(),vr)).pipe(I(t=>t===void 0?j:E(function*(){t.document!==void 0&&(yield*iO(e,jD,ID))===void 0&&(yield*aO(e,jD,ID,t.document)),yield*kr(t.release)})),Vn)}function iO(e,t,n){return y(r=>{let i=e.transaction(t,`readonly`).objectStore(t).get(n);i.addEventListener(`error`,()=>{r(S(eO(`read`,i.error??`Unknown IndexedDB read error`)))}),i.addEventListener(`success`,()=>{r(b(i.result))})}).pipe(F(`web.connectionStorage.readDatabaseValue`))}function aO(e,t,n,r){return y(i=>{let a=e.transaction(t,`readwrite`);a.addEventListener(`error`,()=>{i(S(eO(`write`,a.error??`Unknown IndexedDB write error`)))}),a.addEventListener(`complete`,()=>{i(j)}),a.objectStore(t).put(r,n)}).pipe(F(`web.connectionStorage.writeDatabaseValue`))}function oO(e,t,n){return y(r=>{let i=e.transaction(t,`readwrite`);i.addEventListener(`error`,()=>{r(S(eO(`remove`,i.error??`Unknown IndexedDB remove error`)))}),i.addEventListener(`complete`,()=>{r(j)}),i.objectStore(t).delete(n)}).pipe(F(`web.connectionStorage.removeDatabaseValue`))}function sO(e,t,n){return y(r=>{let i=e.transaction(t,`readwrite`);i.addEventListener(`error`,()=>{r(S(eO(`remove`,i.error??`Unknown IndexedDB cursor error`)))}),i.addEventListener(`complete`,()=>{r(j)});let a=i.objectStore(t).openCursor(n);a.addEventListener(`error`,()=>{r(S(eO(`remove`,a.error??`Unknown IndexedDB cursor error`)))}),a.addEventListener(`success`,()=>{let e=a.result;e!==null&&(e.delete(),e.continue())})}).pipe(F(`web.connectionStorage.removeDatabaseValuesInRange`))}function cO(e,t){return`${e}:${t}`}function lO(e,t){return`${e}:${t}`}var uO=x(`web.connectionStorage.decodeCatalog`)(function*(e){return yield*WD(e).pipe(N(e=>eO(`decode`,e)))}),dO=x(`web.connectionStorage.encodeCatalog`)(function*(e){return yield*GD(e).pipe(N(e=>eO(`encode`,e)))});function fO(e){return t=>typeof navigator>`u`||!navigator.locks?t:kr({try:()=>navigator.locks.request(e,()=>gt(t)),catch:e=>eO(`lock`,e)}).pipe(I(e=>e))}function pO(e){let t=window.desktopBridge;return t?.getConnectionCatalog!==void 0&&t.setConnectionCatalog!==void 0?{read:kr({try:()=>t.getConnectionCatalog(),catch:e=>eO(`load`,e)}),write:e=>kr({try:()=>t.setConnectionCatalog(e),catch:e=>eO(`save`,e)}).pipe(I(e=>e?j:S(eO(`save`,`Desktop secure storage is unavailable in this system context.`))))}:{read:iO(e,jD,ID).pipe(O(e=>typeof e==`string`?e:null)),write:t=>aO(e,jD,ID,t),quarantine:t=>aO(e,jD,`${ID}:corrupt:${Date.now()}`,t),exclusive:fO(`${e.name}:catalog`)}}var mO=x(`web.connectionStorage.makeCatalogStore`)(function*(e){let t=yield*bo(C()),n=yield*sa(1),r=x(`web.connectionStorage.loadCatalog`)(function*(){let n=yield*yo(t);if(u(n))return n.value;let r=yield*e.read,i=my;return r!==null&&r.trim()!==``&&(i=yield*uO(r).pipe(li(t=>E(function*(){yield*Qi(`Discarding a corrupt web connection catalog.`,{error:t.message}),e.quarantine!==void 0&&(yield*e.quarantine(r).pipe(li(e=>Qi(`Could not quarantine the corrupt web connection catalog.`,{error:e.message}))));let n=yield*dO(my);return yield*e.write(n).pipe(li(e=>Qi(`Could not persist the recovered web connection catalog.`,{error:e.message}))),my})))),yield*to(t,w(i)),i}),i=n.withPermits(1)(r()),a=e.exclusive??(e=>e);return{read:i,update:x(`web.connectionStorage.updateCatalog`)(function*(i){yield*n.withPermits(1)(a(E(function*(){yield*to(t,C());let n=i(yield*r());yield*e.write(yield*dO(n)),yield*to(t,w(n))})))})}}),hO=Dn(E(function*(){let e=yield*Wi(nO(),e=>M(()=>e.close())),t=yield*mO(pO(e)),n=Td.of({list:t.read.pipe(O(e=>e.targets),N(e=>tO(`list-targets`,e)))}),r=Ed.of({register:e=>t.update(t=>yy(t,e)).pipe(N(e=>tO(`register-connection`,e))),remove:e=>t.update(t=>by(t,e)).pipe(N(e=>tO(`remove-connection`,e)))}),i=bd({get:e=>t.read.pipe(O(t=>ie(t.profiles.find(t=>t.connectionId===e)))),put:e=>t.update(t=>({...t,profiles:hy(t.profiles,e=>e.connectionId,e)})),remove:e=>t.update(t=>({...t,profiles:gy(t.profiles,e=>e.connectionId,e)}))}),a=vd({get:e=>t.read.pipe(O(t=>ie(t.credentials.find(t=>t.connectionId===e)?.credential))),put:(e,n)=>t.update(t=>({...t,credentials:hy(t.credentials,e=>e.connectionId,{connectionId:e,credential:n})})),remove:e=>t.update(t=>({...t,credentials:gy(t.credentials,e=>e.connectionId,e)}))}),o=of({get:e=>t.read.pipe(O(t=>ie(t.remoteDpopTokens.find(t=>t.environmentId===e)))),put:e=>t.update(t=>({...t,remoteDpopTokens:hy(t.remoteDpopTokens,e=>e.environmentId,e)})),remove:e=>t.update(t=>({...t,remoteDpopTokens:gy(t.remoteDpopTokens,e=>e.environmentId,e)}))}),s=Dd.of({loadShell:t=>iO(e,MD,t).pipe(I(e=>typeof e==`string`?KD(e).pipe(N(e=>tO(`load-shell`,e)),O(e=>e.environmentId===t?w(e.snapshot):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-shell`,e))),saveShell:(t,n)=>E(function*(){let r=yield*qD({schemaVersion:RD,environmentId:t,snapshot:n}).pipe(N(e=>tO(`save-shell`,e)));yield*aO(e,MD,t,r)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-shell`,e))),loadServerConfig:t=>iO(e,PD,t).pipe(I(e=>typeof e==`string`?XD(e).pipe(N(e=>tO(`load-server-config`,e)),O(e=>e.environmentId===t?w(e.config):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-server-config`,e))),saveServerConfig:(t,n)=>E(function*(){let r=yield*ZD({schemaVersion:1,environmentId:t,config:n}).pipe(N(e=>tO(`save-server-config`,e)));yield*aO(e,PD,t,r)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-server-config`,e))),loadThread:(t,n)=>iO(e,ND,cO(t,n)).pipe(I(e=>typeof e==`string`?JD(e).pipe(N(e=>tO(`load-thread`,e)),O(e=>e.environmentId===t&&e.threadId===n?w(e.snapshot):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-thread`,e))),saveThread:(t,n)=>E(function*(){let r=yield*YD({schemaVersion:3,environmentId:t,threadId:n.thread.id,snapshot:n}).pipe(N(e=>tO(`save-thread`,e)));yield*aO(e,ND,cO(t,n.thread.id),r)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-thread`,e))),loadVcsRefs:(t,n)=>iO(e,FD,lO(t,n)).pipe(I(e=>typeof e==`string`?QD(e).pipe(N(e=>tO(`load-vcs-refs`,e)),O(e=>e.environmentId===t&&e.cwd===n?w(e.refs):C())):b(C())),N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`load-vcs-refs`,e))),saveVcsRefs:(t,n,r)=>E(function*(){let i=yield*$D({schemaVersion:1,environmentId:t,cwd:n,refs:r}).pipe(N(e=>tO(`save-vcs-refs`,e)));yield*aO(e,FD,lO(t,n),i)}).pipe(N(e=>e._tag===`ConnectionPersistenceError`?e:tO(`save-vcs-refs`,e))),removeVcsRefs:(t,n)=>oO(e,FD,lO(t,n)).pipe(N(e=>tO(`remove-vcs-refs`,e))),clearVcsRefs:t=>sO(e,FD,IDBKeyRange.bound(`${t}:`,`${t}:\uffff`)).pipe(N(e=>tO(`clear-vcs-refs`,e))),removeThread:(t,n)=>oO(e,ND,cO(t,n)).pipe(N(e=>tO(`remove-thread`,e))),clear:t=>Br([oO(e,MD,t),sO(e,ND,IDBKeyRange.bound(`${t}:`,`${t}:\uffff`)),oO(e,PD,t),sO(e,FD,IDBKeyRange.bound(`${t}:`,`${t}:\uffff`))],{concurrency:`unbounded`,discard:!0}).pipe(N(e=>tO(`clear-environment`,e)))});return xi(Td,n).pipe(ma(Ed,r),ma(yd,i),ma(_d,a),ma(af,o),ma(Dd,s))}));function gO(e){switch(e){case`darwin`:return`macOS`;case`win32`:return`Windows`;case`linux`:return`Linux`;default:return e?`other`:`unknown`}}function _O(e){return/macintosh/i.test(e.userAgent)&&/mac/i.test(e.platform)&&e.maxTouchPoints>1}function vO(e){let t=e.userAgent;return t.trim()===``?`unknown`:/iphone|ipad|ipod/i.test(t)||_O(e)?`iOS`:/android/i.test(t)?`Android`:/cros/i.test(t)?`ChromeOS`:/windows/i.test(t)?`Windows`:/macintosh|mac os x/i.test(t)?`macOS`:/linux|x11/i.test(t)?`Linux`:`other`}function yO(e){return e.trim()===``?`unknown`:/edg(?:e|a|ios)?\//i.test(e)?`Edge`:/opr\/|opios\//i.test(e)?`Opera`:/samsungbrowser\//i.test(e)?`Samsung Internet`:/firefox\/|fxios\//i.test(e)?`Firefox`:/chrome\/|crios\//i.test(e)?`Chrome`:/safari\//i.test(e)?`Safari`:`other`}function bO(e){let t=e.userAgent;return t.trim()===``?`unknown`:/ipad|tablet|kindle|silk/i.test(t)||/android/i.test(t)&&!/mobile/i.test(t)||_O(e)?`tablet`:/iphone|ipod|android.+mobile|mobile/i.test(t)?`mobile`:`desktop`}function xO(e){return e.desktopBridge===void 0?{label:`Borg Web`,deviceType:bO(e.identity),os:vO(e.identity),surface:`web`,webDeployment:e.hosted?`hosted`:`server`,browser:yO(e.identity.userAgent),...e.appVersion===`0.0.0`?{}:{appVersion:e.appVersion}}:{label:`Borg Desktop`,deviceType:`desktop`,os:gO(e.desktopBridge.getClientPlatform?.()),surface:`desktop`,...e.appVersion===`0.0.0`?{}:{appVersion:e.appVersion}}}var SO=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`]),CO=new Set([101,103,204,205,304]),wO=e=>SO.has(e);function TO(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=()=>r(t.reason);t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var EO=async(e,t)=>{let n=typeof window>`u`?void 0:window.desktopBridge?.requestBorgCloud;if(!n)return globalThis.fetch(e,t);let r=new Request(e,t),i=r.method.toUpperCase();if(!wO(i))throw TypeError(`Borg Cloud does not take ${i} requests from the desktop app.`);let a=i===`GET`?``:await r.text(),o=await TO(n({url:r.url,method:i,headers:Object.fromEntries(r.headers),body:a.length===0?null:a}).catch(e=>{throw TypeError(`Borg Cloud could not be reached.`,{cause:e})}),r.signal);return new Response(CO.has(o.status)?null:o.body,{status:o.status,headers:o.headers})},DO=0;function OO(){return typeof navigator>`u`?`unknown`:navigator.onLine?`online`:`offline`}var kO=Cd({status:M(OO),changes:Pi(e=>Wi(M(()=>{let t=()=>fa(e,`online`),n=()=>fa(e,`offline`);return window.addEventListener(`online`,t),window.addEventListener(`offline`,n),{online:t,offline:n}}),({online:e,offline:t})=>M(()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,t)})).pipe(Jt))}),AO=Cp({changes:Pi(e=>Wi(M(()=>{let t=()=>{document.visibilityState===`visible`&&fa(e,`application-active`)};return document.addEventListener(`visibilitychange`,t),{visibility:t,detachCredentials:_p(()=>{fa(e,`credentials-changed`)})}}),e=>M(()=>{document.removeEventListener(`visibilitychange`,e.visibility),e.detachCredentials()})).pipe(Jt))});function jO(){return xO({appVersion:XE,hosted:rD(),identity:{userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints},desktopBridge:window.desktopBridge})}function MO(e){let t=e instanceof Error?e.message:String(e);return t.toLowerCase().includes(`cancel`)?new Y({reason:`authentication`,detail:t}):new ed({reason:`remote-unavailable`,detail:`Could not prepare the SSH environment: ${t}`})}function NO(e){return new ed({reason:`borg-unavailable`,detail:`Borg is unavailable: ${String(e)}`})}var PO=x(`web.connectionPlatform.borgTunnelCredentials`)(function*(){let e=window.desktopBridge;if(e?.getSearchAtlasAccessToken||e?.getSearchAtlasTunnelCredentials){let t=yield*kr({try:async()=>e.getSearchAtlasAccessToken?e.getSearchAtlasAccessToken():(await e.getSearchAtlasTunnelCredentials?.())?.accessToken??null,catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not load the desktop Borg credentials: ${String(e)}`})});return t===null?yield*new Y({reason:`authentication`,detail:`Sign in to Search Atlas to reach this device through Borg.`}):{getAccessToken:async()=>t}}let t=PE();return t?{getAccessToken:()=>t.getAccessToken()}:yield*new Y({reason:`configuration`,detail:`Borg is not configured for this client.`})}),FO=x(`web.connectionPlatform.borgTunnelClient`)(function*(){let e=hv();if(!e)return yield*new Y({reason:`configuration`,detail:`Borg is not configured for this client.`});let t=yield*PO(),n=yield*kr({try:async()=>{let n=await t.getAccessToken();if(!n)throw Error(`Search Atlas authentication is required.`);return FE({apiUrl:e,token:n})},catch:e=>new Y({reason:`configuration`,detail:`Borg customer could not be resolved: ${String(e)}`})});return yield*ua({try:()=>Cy({apiUrl:e,customerId:n,getAccessToken:t.getAccessToken,fetch:EO}),catch:e=>new Y({reason:`configuration`,detail:`Borg is not configured for this client: ${String(e)}`})})}),IO=x(`web.connectionPlatform.ssh.provisionDesktop`)(function*(e,t){let n=yield*kr({try:()=>e.ensureSshEnvironment(t,{issuePairingToken:!0}),catch:MO}),r=n.pairingToken;if(r===null)return yield*new Y({reason:`authentication`,detail:`The SSH environment did not issue a pairing credential.`});let i=yield*kr({try:()=>e.fetchSshEnvironmentDescriptor(n.httpBaseUrl),catch:MO}),a=yield*kr({try:()=>e.bootstrapSshBearerSession(n.httpBaseUrl,r),catch:MO});return{environmentId:i.environmentId,label:i.label,bootstrap:n,bearerToken:a.access_token}}),LO=Dn(M(()=>{let e=Vu.of({metadata:jO(),scopes:Pn}),t=Bu.of({deviceId:Ze(()=>{let e=window.desktopBridge?.getSearchAtlasTunnelCredentials;return e?kr({try:()=>e(),catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not load the desktop device identity: ${String(e)}`})}).pipe(O(e=>Wt(e?.deviceId))):b(C())})}),n=Hu.of({bearerToken:kr({try:Lv,catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not load the desktop primary credential: ${String(e)}`})}).pipe(O(Wt))}),r=Uu.of({provision:x(`web.connectionPlatform.ssh.provision`)(function*(e){let t=window.desktopBridge;return t===void 0?yield*new Y({reason:`unsupported`,detail:`SSH environments are only available in the desktop app.`}):yield*IO(t,e)}),prepare:x(`web.connectionPlatform.ssh.prepare`)(function*(e){let t=window.desktopBridge;if(t===void 0)return yield*new Y({reason:`unsupported`,detail:`SSH environments are only available in the desktop app.`});let n=yield*kr({try:()=>t.ensureSshEnvironment(e.target,{issuePairingToken:!0}),catch:MO});return n.pairingToken===null?yield*new Y({reason:`authentication`,detail:`The SSH environment did not issue a pairing credential.`}):{bootstrap:n,bearerToken:(yield*kr({try:()=>t.bootstrapSshBearerSession(n.httpBaseUrl,n.pairingToken),catch:MO})).access_token}}),disconnect:x(`web.connectionPlatform.ssh.disconnect`)(function*(e){let t=window.desktopBridge;t!==void 0&&(yield*kr({try:()=>t.disconnectSshEnvironment(e),catch:e=>new ed({reason:`remote-unavailable`,detail:`Could not disconnect the SSH environment: ${String(e)}`})}))})}),i=Wu.of({openTunnel:x(`web.connectionPlatform.borgTunnel.openTunnel`)(function*(){let e=yield*FO();return{ticket:yield*kr({try:()=>e.requestTicket(),catch:NO}),tunnelId:Sy()}}),isDeviceOnline:x(`web.connectionPlatform.borgTunnel.isDeviceOnline`)(function*(e){let t=yield*FO();return(yield*kr({try:()=>t.status(e),catch:NO})).online})});return xi(Bu,t).pipe(ma(Hu,n),ma(Vu,e),ma(Uu,r),ma(Wu,i))})),RO=x(`web.connectionPlatform.loadPrimaryConnectionRegistration`)(function*(e){let t=yield*go({httpBaseUrl:e.target.httpBaseUrl}).pipe(ir(Vv),N(Qd));return new dd({target:new Ku({environmentId:t.environmentId,label:t.label,httpBaseUrl:e.target.httpBaseUrl,wsBaseUrl:e.target.wsBaseUrl})})}),zO=x(`web.connectionPlatform.loadSecondaryConnectionRegistration`)(function*(e){if(e.httpBaseUrl===null||e.wsBaseUrl===null||e.bootstrapToken===void 0)return yield*new ed({reason:`endpoint-unavailable`,detail:`Desktop-local backend ${e.id} is not ready yet.`});let t=e.httpBaseUrl,n=e.wsBaseUrl,r=yield*go({httpBaseUrl:t}).pipe(N(Qd)),i=yield*en,a=yield*zd({httpBaseUrl:t,credential:e.bootstrapToken,scopes:Pn,clientMetadata:jO()}).pipe(N(Qd)),o=Co(e.id),s=e.label||r.label;return{registration:new fd({target:new qu({environmentId:r.environmentId,label:s,connectionId:o}),profile:new id({connectionId:o,environmentId:r.environmentId,label:s,httpBaseUrl:t,wsBaseUrl:n}),credential:new ld({token:a.access_token})}),expiresAtEpochMs:HO(i,a.expires_in),refreshAtEpochMs:UO(i,a.expires_in)}}),BO=`3 seconds`,VO=5e3;function HO(e,t){return e+Math.max(0,t*1e3)}function UO(e,t){return Math.max(e,HO(e,t)-VO)}function WO(e=Nv){try{return{_tag:`Success`,target:e()}}catch(e){return{_tag:`Failure`,cause:e}}}function GO(e,t){return t._tag===`Failure`?e.get(Ea):void 0}function KO(e,t,n){return e.signature===t&&(e.refreshAtEpochMs===void 0||n<e.refreshAtEpochMs)}function qO(e,t,n){return e.signature===t&&e.expiresAtEpochMs!==void 0&&n<e.expiresAtEpochMs}function JO(e,t,n){return t._tag===`Success`?new Map:new Map([...e].filter(([,e])=>e.expiresAtEpochMs!==void 0&&n<e.expiresAtEpochMs))}var YO=Ar(hO,kO,AO,LO,Mn(ih,E(function*(){if(rD())return ih.of({registrations:Si});let e=yield*bo(new Map),t=E(function*(){let t=yield*yo(e),n=yield*en,r=new Map,i=[],a=WO(),o=GO(t,a);if(o!==void 0&&(r.set(Ea,o),i.push(o.registration)),a._tag===`Failure`)yield*Qi(`Could not read the primary environment topology.`,{cause:a.cause});else if(a.target!==null){let e=a.target,o=`primary|${e.target.httpBaseUrl}|${e.target.wsBaseUrl}`,s=t.get(Ea);if(s!==void 0&&KO(s,o,n))r.set(Ea,s),i.push(s.registration);else{let t=yield*RO(e).pipe(wn(e=>Qi(`Could not discover the primary environment.`,{error:e})),Ir);if(u(t)){let e={signature:o,registration:t.value};r.set(Ea,e),i.push(t.value)}}}let s=Eo();for(let[e,a]of JO(t,s,n))r.set(e,a),i.push(a.registration);if(s._tag===`Failure`)yield*Qi(`Could not read the desktop-local backend topology.`,{cause:s.cause});else for(let e of s.bootstraps){let a=`${e.httpBaseUrl}|${e.wsBaseUrl}|${e.bootstrapToken??``}`,o=t.get(e.id);if(o!==void 0&&KO(o,a,n)){r.set(e.id,o),i.push(o.registration);continue}let s=yield*zO(e).pipe(wn(t=>Qi(`Could not connect a desktop-local backend.`,{id:e.id,error:t})),Ir);if(u(s)){let t={signature:a,...s.value};r.set(e.id,t),i.push(s.value.registration)}else o!==void 0&&qO(o,a,n)&&(r.set(e.id,o),i.push(o.registration))}return yield*to(e,r),i}).pipe(ir(lo));return ih.of({registrations:pn(BO).pipe(Ct(()=>t))})})),ea(Od,Od.of({clear:(e,t)=>M(()=>{ho(e,t)})})),ea(Wp,Wp.of({observe:({environmentId:e,method:t})=>M(()=>{DO+=1;let n=`${e}:${DO}`;return xD(n,t,`${t} · ${e}`),M(()=>{SD(n)})})}))),XO=`borg.searchatlas.api-key`,ZO=`borg.searchatlas.api-customer-id`,QO=`borg-search-atlas-credential-changed`,$O=e=>/^\d+$/u.test(e)&&Number(e)>0,ek=()=>{try{let e=window.sessionStorage.getItem(XO)?.trim(),t=window.sessionStorage.getItem(ZO)?.trim();return e&&t&&$O(t)?{kind:`apiKey`,key:e,customerId:t}:void 0}catch{return}};function tk(e,t){try{e.trim()&&$O(t.trim())?(window.sessionStorage.setItem(XO,e.trim()),window.sessionStorage.setItem(ZO,t.trim())):(window.sessionStorage.removeItem(XO),window.sessionStorage.removeItem(ZO)),window.dispatchEvent(new Event(QO))}catch{}}function nk(){tk(``,``)}var rk=e=>e===null||e.trim().length===0?C():w({kind:`jwt`,token:e}),ik=e=>{let t=rk(e);return u(t)?t:ie(ek())},ak=Mn(Jf,E(function*(){let e=typeof window>`u`?void 0:window.desktopBridge,t=e?null:PE(),n=yield*yi(),r=async()=>{let n=null;try{n=e?e.getSearchAtlasAccessToken?await e.getSearchAtlasAccessToken():(await e.getSearchAtlasTunnelCredentials?.())?.accessToken??null:t?await t.getAccessToken():null}catch{n=null}return e?rk(n):ik(n)};t!==null&&(yield*Wi(M(()=>t.subscribe(e=>fa(n,ik(e)))),e=>M(e)));let i=e?.onSearchAtlasCredentialChanged;return i&&(yield*Wi(M(()=>i(()=>{r().then(e=>fa(n,e))})),e=>M(e))),typeof window<`u`&&(yield*Wi(M(()=>{let e=()=>{r().then(e=>fa(n,e))};window.addEventListener(QO,e);let t=_p(e);return()=>{window.removeEventListener(QO,e),t()}}),e=>M(e))),Jf.of({current:Ga(r),changes:ae(n)})}));function ok(){try{return{key:window.sessionStorage.getItem(XO)??``,customerId:window.sessionStorage.getItem(ZO)??``}}catch{return{key:``,customerId:``}}}var sk=YO.pipe(da(qv)),ck=Ar(ng,_h,uv),lk=a(oh({environmentThemes:!0}),ck).pipe(Ai(Ar(qv,sk,uy,ak))),uk=cc(Ar(dy,Qh,Yh(hv)).pipe(Ai(lk)));function dk(e){return e.pipe(O(w),li(e=>Qi(`Could not load the initial environment configuration.`).pipe(Ya({...hp(e)}),cr(C()))))}var fk=6e3,pk=x(`clientRuntime.state.fetchEnvironmentSessionState`)(function*(e){let t=uo(e.prepared.httpBaseUrl,`/api/auth/session`),n=yield*fo(e.prepared.httpBaseUrl),r=yield*ph(e.prepared.httpAuthorization,`GET`,t,e.signer);return yield*ro(t,e.timeoutMs??fk,fh(e.prepared.httpAuthorization,n.auth.session({headers:r})))});function mk(e){let t=z(t=>e.atom(hm(t,ke(Ip.pipe(O(e=>Zo(e.session).pipe(Ct(dt({onNone:()=>b(C()),onSome:e=>dk(e.initialConfig)}))))))),{initialValue:C()})),n=z(e=>R(n=>Qt(ja(gs(n(t(e))),()=>C()))).pipe(B(`environment-config-value:${e}`))),r=z(t=>e.atom(hm(t,ke(Ip.pipe(O(e=>Zo(e.prepared))))),{initialValue:C()})),i=z(e=>R(t=>ja(gs(t(r(e))),()=>C())).pipe(B(`environment-prepared-connection:${e}`))),a=z(t=>e.atom(e=>{let n=Qt(e(i(t)));return n===null?Nr:E(function*(){let e=yield*an(ef);return yield*pk({prepared:n,signer:e})})}).pipe(Cc({staleTime:3e4,revalidateOnMount:!0}),Gs(5*6e4),B(`environment-session-state:${t}`)));return{initialConfigAtom:t,initialConfigValueAtom:n,preparedConnectionAtom:r,preparedConnectionValueAtom:i,sessionStateAtom:a,sessionStateValueAtom:z(e=>R(t=>Qt(gs(t(a(e))))??null).pipe(B(`environment-session-state-value:${e}`)))}}var hk=mk(uk),gk=R(C()).pipe(B(`web-prepared-connection:empty`));function _k(e){let t=(0,Gc.c)(2),n;return t[0]===e?n=t[1]:(n=e===null?gk:hk.preparedConnectionValueAtom(e),t[0]=e,t[1]=n),zc(n)}function vk(e){return Qt(cD.get(hk.preparedConnectionValueAtom(e)))}export{u_ as $,Jp as $t,PE as A,gs as An,uh as At,mv as B,_m as Bt,XE as C,Cs as Cn,Ch as Ct,zE as D,ls as Dn,dh as Dt,KE as E,os as En,xh as Et,Dv as F,Lo as Fn,$p as Ft,J_ as G,nm as Gt,ov as H,sm as Ht,Mv as I,vm as It,U_ as J,em as Jt,H_ as K,tm as Kt,hv as L,xm as Lt,Kv as M,L as Mn,Lm as Mt,Vv as N,Xo as Nn,zm as Nt,RE as O,ss as On,ch as Ot,Pv as P,$o as Pn,Rm as Pt,m_ as Q,Kp as Qt,gv as R,ym as Rt,JE as S,B as Sn,Nh as St,GE as T,_s as Tn,yh as Tt,tv as U,hm as Ut,pv as V,cm as Vt,Y_ as W,rm as Wt,p_ as X,um as Xt,B_ as Y,am as Yt,h_ as Z,im as Zt,aD as _,z as _n,Bh as _t,QO as a,_p as an,Jg as at,qE as b,Gs as bn,Ph as bt,tk as c,Yf as cn,Pg as ct,ED as d,td as dn,dg as dt,Yp as en,o_ as et,lD as f,Wc as fn,sg as ft,QE as g,jc as gn,Lh as gt,oD as h,Fc as hn,zh as ht,uk as i,vp as in,qg as it,tE as j,Zo as jn,Wm as jt,FE as k,cs as kn,lh as kt,EO as l,Dd as ln,gg as lt,sD as m,zc as mn,cg as mt,vk as n,Vp as nn,Rg as nt,nk as o,hp as on,Bg as ot,cD as p,Uc as pn,mg as pt,V_ as q,mm as qt,_k as r,Ip as rn,zg as rt,ok as s,Xf as sn,Ng as st,hk as t,Zp as tn,Zg as tt,OD as u,nd as un,lg as ut,rD as v,vc as vn,Wh as vt,ZE as w,us as wn,Sh as wt,YE as x,Cc as xn,Fh as xt,iD as y,R as yn,Ih as yt,fv as z,bm as zt};
67
+ //# sourceMappingURL=session-D3Szkrpk.js.map