sliccy 6.0.3 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/ui/assets/account-store-Bj2PFEoD.js +44 -0
- package/dist/ui/assets/{account-store-mSLjXjrv.js → account-store-BnUIIjUC.js} +2 -2
- package/dist/ui/assets/{adobe-D73M32uk.js → adobe-Czr7m_TT.js} +1 -1
- package/dist/ui/assets/{adobe-Dxvx0Rfy.js → adobe-JmXV9kQp.js} +1 -1
- package/dist/ui/assets/{agent-message-to-chat-DH5qVsNo.js → agent-message-to-chat-DUYzcUYs.js} +1 -1
- package/dist/ui/assets/{apps-Dn7AtzKf.js → apps-eLp3JMi9.js} +1 -1
- package/dist/ui/assets/{azure-openai-BXN_MFIP.js → azure-openai-DmUBjHKn.js} +1 -1
- package/dist/ui/assets/{azure-openai-Dqra1Kjo.js → azure-openai-WQPrzmzl.js} +1 -1
- package/dist/ui/assets/base64-Ba7QB87Z.js +1 -0
- package/dist/ui/assets/{cerebras-C9Xh0EKF.js → cerebras-B6OFJhQY.js} +1 -1
- package/dist/ui/assets/{cerebras-C80fyItL.js → cerebras-Bzd0OB3R.js} +1 -1
- package/dist/ui/assets/{client-BxYB_ioq.js → client-BXN2qRve.js} +1 -1
- package/dist/ui/assets/{connect-surface-D1O9MWXX.js → connect-surface-C79IWXLS.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-DGq5bX3t.js → ensure-speech-assets-CzwTkGxm.js} +1 -1
- package/dist/ui/assets/{fs-nfluZNwf.js → fs-BKwOXUGY.js} +1 -1
- package/dist/ui/assets/{fs-BAn01XlF.js → fs-CPzDCGWj.js} +2 -2
- package/dist/ui/assets/{github-6Q8JEqFQ.js → github-CDT9ErFJ.js} +2 -2
- package/dist/ui/assets/{github-gRr2tmu1.js → github-XkSGCSpp.js} +1 -1
- package/dist/ui/assets/{github-copilot-ZgR3WmB4.js → github-copilot-BLsTiukB.js} +1 -1
- package/dist/ui/assets/{github-copilot-C-tsrjxi.js → github-copilot-BZDUFdt5.js} +1 -1
- package/dist/ui/assets/{hear-v5qXSZw8.js → hear-eesTGUNb.js} +1 -1
- package/dist/ui/assets/{kernel-worker-lNLs7P4h.js → kernel-worker-B4A3VjuZ.js} +247 -247
- package/dist/ui/assets/{kokoro-engine-CogHLlSk.js → kokoro-engine-BNfHBl2r.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-CFKIh9aE.js → lick-ws-bridge-eytKxVOP.js} +1 -1
- package/dist/ui/assets/{local-llm-C3h7XiuI.js → local-llm-6IajVSOQ.js} +1 -1
- package/dist/ui/assets/{local-llm-CA8ERuBC.js → local-llm-BknCmmbt.js} +1 -1
- package/dist/ui/assets/{main-DrN-Ucq0.js → main-5mEHTbp1.js} +3 -3
- package/dist/ui/assets/mount-B6vXbOCk.js +1 -0
- package/dist/ui/assets/{mount-CPQ4A01R.js → mount-DbCOeMHV.js} +2 -2
- package/dist/ui/assets/{mount-recovery-CcyBfuPs.js → mount-recovery-DFVBuWuW.js} +1 -1
- package/dist/ui/assets/{new-session-D2PFQwOI.js → new-session-Cu_fMVmN.js} +2 -2
- package/dist/ui/assets/oauth-bootstrap-9zGNab0F.js +2 -0
- package/dist/ui/assets/{oauth-service-BuEH8BXq.js → oauth-service-bKcyWLK0.js} +1 -1
- package/dist/ui/assets/{openai-codex-BeP1JtAL.js → openai-codex-CBAEHdaT.js} +1 -1
- package/dist/ui/assets/{openai-codex--NDvhrIR.js → openai-codex-DhP3Bc4o.js} +1 -1
- package/dist/ui/assets/{openrouter-DsJwhKIb.js → openrouter-C6LzaTJh.js} +1 -1
- package/dist/ui/assets/{openrouter-Df8qlpQb.js → openrouter-D2M_Nolr.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-D_VHwbW4.js → openrouter-oauth-CLIQCCLY.js} +1 -1
- package/dist/ui/assets/{openrouter-oauth-C5w2fvfX.js → openrouter-oauth-DIXeQ6QT.js} +1 -1
- package/dist/ui/assets/{panel-rpc-handlers-B1xXUNiw.js → panel-rpc-handlers-Dyt8XcM7.js} +2 -2
- package/dist/ui/assets/{port-bridge-client-f_6YKEkm.js → port-bridge-client-DXYvHFiB.js} +1 -1
- package/dist/ui/assets/{provider-DEiD4VSp.js → provider-BxyjRM0f.js} +1 -1
- package/dist/ui/assets/{provider-B64jwCth.js → provider-DW9RLF-a.js} +2 -2
- package/dist/ui/assets/{provider-settings-_y7Xt8Fz.js → provider-settings-BXwbB8RF.js} +1 -1
- package/dist/ui/assets/{provider-settings-D3dmj6k9.js → provider-settings-CzM2hHtV.js} +1 -1
- package/dist/ui/assets/provider-store-access-0M5vSpmv.js +1 -0
- package/dist/ui/assets/{provider-store-access-DZOn6rwQ.js → provider-store-access-M-631pba.js} +2 -2
- package/dist/ui/assets/providers-BU_CYZEQ.js +2 -0
- package/dist/ui/assets/{providers-DKrOwkrW.js → providers-DQpYSqlR.js} +1 -1
- package/dist/ui/assets/proxied-fetch-GabK83LB.js +1 -0
- package/dist/ui/assets/{quick-llm-D4gjL6VE.js → quick-llm-BmxcWrG9.js} +1 -1
- package/dist/ui/assets/{runtime-mode-B8Tqab3Z.js → runtime-mode-BT9Lswtn.js} +1 -1
- package/dist/ui/assets/{session-freezer-BS9l7-hg.js → session-freezer-C9bwD5or.js} +2 -2
- package/dist/ui/assets/{setup-standalone-prelude-xotJamVu.js → setup-standalone-prelude-DmP6XzHq.js} +1 -1
- package/dist/ui/assets/setup-sudo-Disgv7TU.js +2 -0
- package/dist/ui/assets/{skills-CshSJb62.js → skills-JWBWz93Y.js} +1 -1
- package/dist/ui/assets/{speak-DZhfxcQp.js → speak-FgPyHiBQ.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-BlrAt5ae.js → sprinkle-manager-DwLCgrU9.js} +1 -1
- package/dist/ui/assets/{store-BtitBSBp.js → store-W4scCsQ2.js} +1 -1
- package/dist/ui/assets/{sudo-9hh6SLgr.js → sudo-DlJO76Iy.js} +1 -1
- package/dist/ui/assets/{telemetry-Dxrv_mDE.js → telemetry-C8rZr13D.js} +1 -1
- package/dist/ui/assets/tool-result-images-AGln5sut.js +1 -0
- package/dist/ui/assets/tool-result-images-BFdAnBEq.js +1 -0
- package/dist/ui/assets/transcript-limits-HrXqL2T0.js +1 -0
- package/dist/ui/assets/{transformers-env-Cr03eE3X.js → transformers-env-fPn9uCat.js} +1 -1
- package/dist/ui/assets/{tray-runtime-config-GgP0BHji.js → tray-runtime-config-C9Kq7Hrh.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-RV8zL8s_.js → upgrade-detection-I9bwQZ3A.js} +1 -1
- package/dist/ui/assets/{wc-extension-W-0gowTx.js → wc-extension-C8rP0TQ5.js} +2 -2
- package/dist/ui/assets/wc-follower-BZbGw9cM.js +17 -0
- package/dist/ui/assets/{wc-live-BlVDyGBn.js → wc-live-z1Woib4_.js} +3 -3
- package/dist/ui/assets/wc-nav-CeMp5ghF.js +2 -0
- package/dist/ui/assets/{wc-onboarding-ZfVS_oUh.js → wc-onboarding-BW3KMsBt.js} +2 -2
- package/dist/ui/assets/{wc-placeholder-Co__klym.js → wc-placeholder-CvsaP7X6.js} +2 -2
- package/dist/ui/assets/{wc-settings-BeN5ysM5.js → wc-settings-nRxDO_kn.js} +2 -2
- package/dist/ui/assets/wc-shell-DGg7WImK.js +117 -0
- package/dist/ui/assets/{wc-sprinkles-DHJ0qcR8.js → wc-sprinkles-DiBOBknV.js} +2 -2
- package/dist/ui/assets/wc-tray-HHHE6vhN.js +2 -0
- package/dist/ui/assets/{whisper-engine-CHKYCaAu.js → whisper-engine-Bddvms5V.js} +1 -1
- package/dist/ui/assets/{xai-grok-8GYXs2ON.js → xai-grok-9vAl224Q.js} +1 -1
- package/dist/ui/assets/{xai-grok-Fnx5dY_b.js → xai-grok-Dw-lxH04.js} +1 -1
- package/dist/ui/index.html +8 -7
- package/dist/ui/packages/webapp/index.html +8 -7
- package/package.json +1 -1
- package/dist/ui/assets/account-store-DAs0V_cx.js +0 -44
- package/dist/ui/assets/mount-DQ3_bAfC.js +0 -1
- package/dist/ui/assets/oauth-bootstrap-C9iVVC0o.js +0 -2
- package/dist/ui/assets/provider-store-access-CmRz291S.js +0 -1
- package/dist/ui/assets/providers-GiPhGfKE.js +0 -2
- package/dist/ui/assets/proxied-fetch-D8ebvbVd.js +0 -1
- package/dist/ui/assets/setup-sudo-Bc6YyiyD.js +0 -2
- package/dist/ui/assets/src-C9oNvq2b2.js +0 -2
- package/dist/ui/assets/transcript-limits-D0M7bLr9.js +0 -1
- package/dist/ui/assets/wc-follower-DbN1wRKK.js +0 -17
- package/dist/ui/assets/wc-nav-BbDSc4Rp.js +0 -2
- package/dist/ui/assets/wc-shell-DURtAq9k.js +0 -117
- package/dist/ui/assets/wc-tray-CWg-ZdV_.js +0 -2
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ SLICC is for you if:
|
|
|
64
64
|
- **Automate repetitive workflows in authenticated web apps.** Use browser automation, page inspection, screenshots, storage access, and scripted tab control where your logged-in browser session already has the context.
|
|
65
65
|
- **Hand work off from another coding agent into your live browser session.** Open any URL whose response carries an RFC 8288 `Link` header with a SLICC handoff or upskill rel (the tray-hub `/handoff?handoff=...` / `?upskill=...` endpoint is a convenience) and SLICC prompts you to approve the action inside the Chat tab.
|
|
66
66
|
- **Solve technical tasks with practical tools.** Reach for `bash`, `git`, `grep`, `node`, `python`, previews, and browser automation when the job is bigger than text generation.
|
|
67
|
+
- **See image-producing tool results directly in chat.** Supported `<img:data:image/...;base64,...>` markers from commands such as `open --view` and `screencapture` render as bounded, lazy-loaded inline images in chat tool rows. Each tool body displays at most four images and shows an explicit overflow indication when more are present.
|
|
67
68
|
- **Serve driveable previews.** `serve --bridge <dir>` mints a URL whose every visitor tab becomes a live, leader-driveable synthetic-CDP target — the agent can navigate/click/evaluate/screenshot and weave in webhook licks. **Security: opt-in only; cross-subdomain cookie risk accepted and documented (host-only cookies isolated per preview; `Domain=.sliccy.now` cookies readable across all previews).**
|
|
68
69
|
- **Add visual and file context directly in chat.** Drop images or files onto the workspace, or use the paperclip button. Dropped `.skill` archives still install into `/workspace/skills`.
|
|
69
70
|
- **Steer a running turn instead of waiting for it.** In the chat composer, `Enter` sends (queueing behind whatever the cone is already doing) and `Shift+Enter` inserts a newline. `Ctrl+Enter` (`Cmd+Enter` on macOS) steers: the message is injected as soon as the current step finishes, so you can redirect the agent mid-turn.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import{n as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./logger-LESFN7Hj.js";import{n as r,r as i}from"./panel-rpc-CjFVE0nK.js";import{n as a,o,t as s}from"./providers-DQpYSqlR.js";import"./src-BcePBv4G.js";import{r as c,s as l,t as u}from"./proxied-fetch-GabK83LB.js";import{t as d}from"./runtime-env-byAg9ij-.js";import{i as f,r as p}from"./tool-ui-t6ocn6AG.js";import{t as m}from"./port-bridge-client-DXYvHFiB.js";import{n as h,r as g,t as ee}from"./tool-result-images-AGln5sut.js";import{i as _,n as te,r as ne}from"./compat-BHfpuQ4D.js";import"./context-compaction-DDE4L-Sj.js";import{c as re,r as ie,t as ae}from"./bedrock-camp-CvcU-31w.js";const oe=`slicc_oauth_extra_domains`;function se(e){try{let t=e.getItem(oe);if(!t)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){if(typeof e!=`string`||!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`&&e.length>0);n.length>0&&(r[e]=n)}return r}catch{return{}}}function ce(e,t){try{e.setItem(oe,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}function le(){return d()?`extension-direct`:c()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function ue(){return le()===`node-rest`}const de={assign:0,create:0,clone:0,discard:0,update:0};function v(e,t){return de.assign+=1,{...e,...t}}function fe(e,t,n){return e>=t&&e<=n}function pe(e){return fe(e,127462,127487)}function me(e){return fe(e,65024,65039)}function he(e){return fe(e,768,879)||fe(e,6832,6911)||fe(e,7616,7679)||fe(e,65056,65071)}function ge(e){return e>65535?2:1}function _e(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(he(n)||me(n))t+=ge(n);else break}return t}function ve(e,t){let n=e.codePointAt(t),r=t+ge(n);for(r=_e(e,r);r<e.length-1&&e[r]===``;){let t=e.codePointAt(r+1);r+=1+ge(t),r=_e(e,r)}return pe(n)&&r<e.length&&pe(e.codePointAt(r))&&(r+=ge(e.codePointAt(r))),r}function ye(e){return fe(e,55296,56319)||fe(e,768,879)||e===8205}function be(e){let t=0,n=0;for(;n<e.length;)n=ve(e,n),t++;return t}function xe(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=ve(e,r),n++,n>=t)return!0;return!1}function Se(e,t){let n=0,r=0;for(;r<e.length;)if(r=ve(e,r),n++,n>t)return!1;return!0}function Ce(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(ye(e.charCodeAt(n)))return xe(e,t);if(n++,n>=t)return!0}return!1}function we(e,t){let n=0;for(;n<e.length;){if(ye(e.charCodeAt(n)))return Se(e,t);if(n++,n>t)return!1}return!0}var Te=e({Entries:()=>$e,EntriesRegExp:()=>Qe,Every:()=>Ye,EveryAll:()=>Xe,GraphemeCount:()=>Ke,HasPropertyKey:()=>C,IsArray:()=>Ee,IsAsyncIterator:()=>De,IsBigInt:()=>Oe,IsBoolean:()=>ke,IsClassInstance:()=>We,IsConstructor:()=>Ae,IsDeepEqual:()=>it,IsEqual:()=>x,IsFunction:()=>je,IsGreaterEqualThan:()=>He,IsGreaterThan:()=>ze,IsInteger:()=>Me,IsIterator:()=>Ne,IsLessEqualThan:()=>Ve,IsLessThan:()=>Be,IsMaxLength:()=>qe,IsMinLength:()=>Je,IsMultipleOf:()=>Ue,IsNull:()=>Pe,IsNumber:()=>Fe,IsObject:()=>y,IsObjectNotArray:()=>Ie,IsString:()=>b,IsSymbol:()=>Le,IsUndefined:()=>Re,IsUnsafePropertyKey:()=>Ze,IsValueLike:()=>Ge,Keys:()=>w,Symbols:()=>et,TakeLeft:()=>S,Values:()=>tt});function Ee(e){return Array.isArray(e)}function De(e){return y(e)&&Symbol.asyncIterator in e}function Oe(e){return x(typeof e,`bigint`)}function ke(e){return x(typeof e,`boolean`)}function Ae(e){if(Re(e)||!je(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function je(e){return x(typeof e,`function`)}function Me(e){return Number.isInteger(e)}function Ne(e){return y(e)&&Symbol.iterator in e}function Pe(e){return x(e,null)}function Fe(e){return Number.isFinite(e)}function Ie(e){return y(e)&&!Ee(e)}function y(e){return x(typeof e,`object`)&&!Pe(e)}function b(e){return x(typeof e,`string`)}function Le(e){return x(typeof e,`symbol`)}function Re(e){return x(e,void 0)}function x(e,t){return e===t}function ze(e,t){return e>t}function Be(e,t){return e<t}function Ve(e,t){return e<=t}function He(e,t){return e>=t}function Ue(e,t){if(Oe(e)||Oe(t))return BigInt(e)%BigInt(t)===0n;if(!Fe(e)||Me(e)&&1/t%1==0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t))<1e-10}function We(e){if(!y(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return!Pe(t)&&x(typeof t.constructor,`function`)&&!(x(t.constructor,globalThis.Object)||x(t.constructor.name,`Object`))}function Ge(e){return Oe(e)||ke(e)||Pe(e)||Fe(e)||b(e)||Re(e)}function Ke(e){return be(e)}function qe(e,t){return we(e,t)}function Je(e,t){return Ce(e,t)}function Ye(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function Xe(e,t,n){let r=!0;for(let i=t;i<e.length;i++)n(e[i],i)||(r=!1);return r}function S(e,t,n){return x(e.length,0)?n():t(e[0],e.slice(1))}function Ze(e){return x(e,`__proto__`)||x(e,`constructor`)||x(e,`prototype`)}function C(e,t){return Ze(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Qe(e){return w(e).map(t=>[RegExp(`^${t}$`),e[t]])}function $e(e){return Object.entries(e)}function w(e){return Object.getOwnPropertyNames(e)}function et(e){return Object.getOwnPropertySymbols(e)}function tt(e){return Object.values(e)}function nt(e,t){if(!y(t))return!1;let n=w(e);return x(n.length,w(t).length)&&n.every(n=>it(e[n],t[n]))}function rt(e,t){return Ee(t)&&x(e.length,t.length)&&e.every((n,r)=>it(e[r],t[r]))}function it(e,t){return Ee(e)?rt(e,t):y(e)?nt(e,t):x(e,t)}function at(e){return e instanceof Boolean}function ot(e){return e instanceof Number}function st(e){return e instanceof String}function ct(e){return globalThis.ArrayBuffer.isView(e)}function lt(e){return e instanceof globalThis.RegExp}function ut(e){return e instanceof globalThis.Date}function dt(e){return e instanceof globalThis.Set}function ft(e){return e instanceof globalThis.Map}function pt(e){return y(e)&&C(e,`~guard`)}function mt(e){return e}function ht(e){return e.map(e=>yt(e))}function gt(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let e of Object.keys(n)){let r=n[e];C(r,`value`)&&Object.defineProperty(t,e,{...r,value:yt(r.value)})}return t}function _t(e){return new RegExp(e.source,e.flags)}function vt(e){return e}function yt(e){return e instanceof RegExp?_t(e):pt(e)?mt(e):Ee(e)?ht(e):y(e)?gt(e):vt(e)}function bt(e){return de.clone+=1,yt(e)}const xt={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1};function St(){return xt}function Ct(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function wt(e,t){return{...e,...t}}function T(e,t,n={}){de.create+=1;let r=St(),i=wt(t,n),a=r.enumerableKind?wt(i,e):Ct(i,e);return r.immutableTypes?Object.freeze(a):a}function Tt(e,t){de.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(bt(e)),i=new Set(t);for(let e of Object.keys(r))i.has(e)||Object.defineProperty(n,e,r[e]);return n}function E(e,t,n){de.update+=1;let r=St(),i=bt(e);for(let e of Object.keys(t))Object.defineProperty(i,e,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[e]});for(let e of Object.keys(n))Object.defineProperty(i,e,{configurable:!0,enumerable:!0,writable:!0,value:n[e]});return i}function D(e,t){return y(e)&&C(e,`~kind`)&&x(e[`~kind`],t)}function Et(e){return y(e)}function Dt(e){return y(e)&&C(e,`~kind`)&&C(e,`type`)&&x(e[`~kind`],`OptionalAddAction`)&&Et(e.type)}function Ot(e){return y(e)&&C(e,`~kind`)&&C(e,`type`)&&x(e[`~kind`],`OptionalRemoveAction`)&&Et(e.type)}function kt(e){return y(e)&&C(e,`~kind`)&&C(e,`type`)&&x(e[`~kind`],`ReadonlyAddAction`)&&Et(e.type)}function At(e){return y(e)&&C(e,`~kind`)&&C(e,`type`)&&x(e[`~kind`],`ReadonlyRemoveAction`)&&Et(e.type)}function O(e,t,n){return T({"~kind":`Deferred`},{action:e,parameters:t,options:n},{})}function jt(e){return D(e,`Deferred`)}function Mt(e,t){return T({"~kind":`Promise`},{type:`promise`,item:e},t)}function Nt(e){return D(e,`Promise`)}function Pt(e){return Tt(e,[`~kind`,`type`,`item`])}function Ft(e){return E(e,{"~immutable":!0},{})}function It(e){return Ft(e)}function Lt(e){return Et(e)&&C(e,`~immutable`)}function Rt(e){return Tt(e,[`~optional`])}function zt(e){return E(e,{"~optional":!0},{})}function Bt(e){return zt(e)}function Vt(e){return Et(e)&&C(e,`~optional`)}function Ht(e){return Tt(e,[`~readonly`])}function Ut(e){return E(e,{"~readonly":!0},{})}function Wt(e){return Ut(e)}function Gt(e){return Et(e)&&C(e,`~readonly`)}function Kt(e){return{enumerable:St().enumerableKind,writable:!1,configurable:!1,value:e}}var qt=class{constructor(){globalThis.Object.defineProperty(this,`~kind`,Kt(`Base`)),globalThis.Object.defineProperty(this,`~guard`,Kt({check:e=>this.Check(e),errors:e=>this.Errors(e)}))}Check(e){return!0}Errors(e){return[]}Convert(e){return e}Clean(e){return e}Default(e){return e}Create(){throw Error(`Create not implemented`)}Clone(){throw Error(`Clone not implemented`)}};function Jt(e){return D(e,`Base`)}function Yt(e,t){return T({"~kind":`Array`},{type:`array`,items:e},t)}function Xt(e){return D(e,`Array`)}function Zt(e){return Tt(e,[`~kind`,`type`,`items`])}function Qt(e,t){return T({"~kind":`AsyncIterator`},{type:`asyncIterator`,iteratorItems:e},t)}function $t(e){return D(e,`AsyncIterator`)}function en(e){return Tt(e,[`~kind`,`type`,`iteratorItems`])}function tn(e,t,n={}){return T({"~kind":`Constructor`},{type:`constructor`,parameters:e,instanceType:t},n)}function nn(e){return D(e,`Constructor`)}function rn(e){return Tt(e,[`~kind`,`type`,`parameters`,`instanceType`])}function an(e,t,n={}){return T({"~kind":`Function`},{type:`function`,parameters:e,returnType:t},n)}function on(e){return D(e,`Function`)}function sn(e){return Tt(e,[`~kind`,`type`,`parameters`,`returnType`])}function cn(e,t){return T({"~kind":`Ref`},{$ref:e},t)}function ln(e){return D(e,`Ref`)}function un(e,t){return T({"~kind":`Generic`},{type:`generic`,parameters:e,expression:t})}function dn(e){return D(e,`Generic`)}function fn(e){return T({"~kind":`Any`},{},e)}function pn(e){return D(e,`Any`)}function k(e){return T({"~kind":`Never`},{not:{}},e)}function mn(e){return D(e,`Never`)}function hn(e){return w(e).filter(t=>!Vt(e[t]))}function gn(e){return w(e)}function _n(e){return tt(e)}function A(e,t={}){let n=hn(e);return T({"~kind":`Object`},{type:`object`,...n.length>0?{required:n}:{},properties:e},t)}function j(e){return D(e,`Object`)}function vn(e){return Tt(e,[`~kind`,`type`,`properties`,`required`])}function M(e,t={}){return T({"~kind":`Union`},{anyOf:e},t)}function N(e){return D(e,`Union`)}function yn(e){return Tt(e,[`~kind`,`anyOf`])}function bn(e){return T({"~kind":`Unknown`},{},e)}function xn(e){return D(e,`Unknown`)}function Sn(e,t,n){return T({"~kind":`Cyclic`},{$defs:w(e).reduce((t,n)=>({...t,[n]:E(e[n],{},{$id:n})}),{}),$ref:t},n)}function Cn(e){return D(e,`Cyclic`)}function wn(e){return Ie(e)&&C(e,`~unsafe`)&&Pe(e[`~unsafe`])}function Tn(e){return D(e,`Infer`)}function En(e){return D(e,`Enum`)}function Dn(e,t={}){return T({"~kind":`Intersect`},{allOf:e},t)}function P(e){return D(e,`Intersect`)}function On(e){return Tt(e,[`~kind`,`allOf`])}function kn(){throw Error(`Unreachable`)}var An=e({Hash:()=>rr,HashCode:()=>nr});function jn(e){let t=new Set,n=e;for(;n&&n!==Object.prototype;){for(let e of Reflect.ownKeys(n))e!==`constructor`&&typeof e!=`symbol`&&t.add(e);n=Object.getPrototypeOf(n)}return[...t]}function Mn(e){return typeof e==`number`}var F;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(F||={});let Nn=BigInt(`14695981039346656037`);const[Pn,Fn]=[BigInt(`1099511628211`),BigInt(`18446744073709551616`)],In=Array.from({length:256}).map((e,t)=>BigInt(t)),Ln=new Float64Array(1),Rn=new DataView(Ln.buffer),zn=new Uint8Array(Ln.buffer);function I(e){Nn^=In[e],Nn=Nn*Pn%Fn}function Bn(e){I(F.Array);for(let t of e)tr(t)}function Vn(e){I(F.BigInt),Rn.setBigInt64(0,e);for(let e of zn)I(e)}function Hn(e){I(F.Boolean),I(+!!e)}function Un(e){I(F.Constructor),tr(e.toString())}function Wn(e){I(F.Date),tr(e.getTime())}function Gn(e){I(F.Function),tr(e.toString())}function Kn(e){I(F.Null)}function qn(e){I(F.Number),Rn.setFloat64(0,e,!0);for(let e of zn)I(e)}function Jn(e){I(F.Object);for(let t of jn(e).sort())tr(t),tr(e[t])}function Yn(e){I(F.RegExp),Zn(e.toString())}const Xn=new TextEncoder;function Zn(e){I(F.String);for(let t of Xn.encode(e))I(t)}function Qn(e){I(F.Symbol),tr(e.toString())}function $n(e){I(F.TypeArray);let t=new Uint8Array(e.buffer);for(let e=0;e<t.length;e++)I(t[e])}function er(e){return I(F.Undefined)}function tr(e){return ct(e)?$n(e):ut(e)?Wn(e):lt(e)?Yn(e):at(e)?Hn(e.valueOf()):st(e)?Zn(e.valueOf()):ot(e)?qn(e.valueOf()):Mn(e)?qn(e):Ee(e)?Bn(e):ke(e)?Hn(e):Oe(e)?Vn(e):Ae(e)?Un(e):Pe(e)?Kn(e):y(e)?Jn(e):b(e)?Zn(e):Le(e)?Qn(e):Re(e)?er(e):je(e)?Gn(e):kn()}function nr(e){return Nn=BigInt(`14695981039346656037`),tr(e),Nn}function rr(e){return nr(e).toString(16).padStart(16,`0`)}function ir(e){return Et(e)&&C(e,`~codec`)&&y(e[`~codec`])&&C(e[`~codec`],`encode`)&&C(e[`~codec`],`decode`)}function ar(e){return T({"~kind":`BigInt`},{type:`bigint`},e)}function or(e){return D(e,`BigInt`)}function sr(e){return D(e,`Boolean`)}const cr=`-?(?:0|[1-9][0-9]*)`;function lr(e){return T({"~kind":`Integer`},{type:`integer`},e)}function ur(e){return D(e,`Integer`)}function dr(e,t){return T({"~kind":`Iterator`},{type:`iterator`,iteratorItems:e},t)}function fr(e){return D(e,`Iterator`)}function pr(e){return Tt(e,[`~kind`,`type`,`iteratorItems`])}var mr=class extends Error{constructor(e){super(`Invalid Literal value`),Object.defineProperty(this,"cause",{value:{value:e},writable:!1,configurable:!1,enumerable:!1})}};function hr(e){return Oe(e)?`bigint`:ke(e)?`boolean`:Fe(e)?`number`:b(e)?`string`:(()=>{throw new mr(e)})()}function L(e,t){return T({"~kind":`Literal`},{type:hr(e),const:e},t)}function gr(e){return Oe(e)||ke(e)||Fe(e)||b(e)}function _r(e){return R(e)&&Oe(e.const)}function vr(e){return R(e)&&ke(e.const)}function yr(e){return R(e)&&Fe(e.const)}function br(e){return R(e)&&b(e.const)}function R(e){return D(e,`Literal`)}function xr(e){return T({"~kind":`Null`},{type:`null`},e)}function Sr(e){return D(e,`Null`)}const Cr=`-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?`;function wr(e){return T({"~kind":`Number`},{type:`number`},e)}function Tr(e){return D(e,`Number`)}function Er(e){return T({"~kind":`Symbol`},{type:`symbol`},e)}function Dr(e){return D(e,`Symbol`)}function Or(e){return T({"~kind":`String`},{type:`string`},e)}function kr(e){return D(e,`String`)}function Ar(e){let t=Ha(e);return x(t.length,2)?t[0]:[]}function jr(e){return!0}function Mr(e){return S(e,(e,t)=>Pr(e)?Mr(t):!1,()=>!0)}function Nr(e){return!x(e.length,0)&&Mr(e)}function Pr(e){return N(e)?Nr(e.anyOf):R(e)?jr(e.const):!1}function Fr(e){return Nr(e)}function Ir(e){return T({"~kind":`TemplateLiteral`},{type:`string`,pattern:e},{})}function Lr(e,t,n=[]){return S(e,(e,r)=>Lr(r,t,[...n,`${e}${t}`]),()=>n)}function Rr(e,t){return x(e.length,0)?[`${t}`]:Lr(e,t)}function zr(e,t,n=[]){return S(t,(t,r)=>zr(e,r,[...n,...Br(e,t)]),()=>n)}function Br(e,t){return N(t)?zr(e,t.anyOf):R(t)?Rr(e,t.const):kn()}function Vr(e,t){return S(t,(t,n)=>Vr(Br(e,t),n),()=>e)}function Hr(e){return e.map(e=>L(e))}function Ur(e){return M(Hr(Vr([],e)))}function Wr(e){return x(e.length,0)?kn():x(e.length,1)&&R(e[0])?e[0]:Ur(e)}function Gr(e){let t=Ar(e);return x(t.length,0)?Or():Fr(t)?Wr(t):Ir(e)}function Kr(e){let t=Gr(e);return lo(t)?Or():t}function qr(e,t){return T({"~kind":`Record`},{type:`object`,patternProperties:{[e]:t}})}function Jr(e){return qr(Vi,e)}function Yr(e){return A({true:e,false:e})}function Xr(e){return b(e)||Fe(e)?L(e):Pe(e)?xr():k()}function Zr(e){return e.map(e=>Xr(e))}function Qr(e){return M(Zr(e))}function $r(e){return Qr(e.enum)}function ei(e,t){return Ii(Qr(e),t)}function ti(e,t){return qr(zi,t)}function ni(e,t={}){let[n,r,i]=[e,e.length,!1];return T({"~kind":`Tuple`},{type:`array`,additionalItems:i,items:n,minItems:r},t)}function z(e){return D(e,`Tuple`)}function ri(e){return Tt(e,[`~kind`,`type`,`items`,`minItems`,`additionalItems`])}function ii(e){return e.reduceRight((e,t,n)=>({[n]:t,...e}),{})}function ai(e){return A(ii(e.items))}function oi(e,t){return Gt(e)?!!Gt(t):!1}function si(e,t){return Vt(e)?!!Vt(t):!1}function ci(e,t){let n=oi(e,t),r=si(e,t),i=Ht(Rt(bi([e,t])));return n&&r?Ut(zt(i)):n&&!r?Ut(i):!n&&r?zt(i):i}function li(e,t,n){return n in e?n in t?ci(e[n],t[n]):e[n]:n in t?t[n]:k()}function ui(e,t){return[...new Set([...w(t),...w(e)])].reduce((n,r)=>({...n,[r]:li(e,t,r)}),{})}function di(e){return j(e)?e.properties:z(e)?ii(e.items):kn()}function fi(e,t){return A(ui(di(e),di(t)))}function pi(e,t){let n=ac(e,t);return x(n,`left-inside`)?e:x(n,`right-inside`)||x(n,`equal`)?t:k()}function mi(e){return j(e)||z(e)}function hi(e,t){let n=N(e),r=N(t);return n||r}function gi(e,t){let n=Si(e),r=Si(t),i=hi(n,r),a=mi(n),o=mi(r);return i?bi([n,r]):a&&o?fi(n,r):a&&!o?n:!a&&o?r:pi(n,r)}function _i(e,t,n=[]){return S(t,(t,r)=>_i(e,r,[...n,gi(e,t)]),()=>x(n.length,0)?[e]:n)}function vi(e,t,n=[]){return S(e,(e,r)=>vi(r,t,[...n,...yi([e],t)]),()=>n)}function yi(e,t=[]){return S(e,(e,n)=>N(e)?yi(n,vi(e.anyOf,t)):yi(n,_i(e,t)),()=>t)}function bi(e){return uc(yi(e))}function xi(e){return uc(e)}function Si(e){return P(e)?bi(e.allOf):N(e)?xi(e.anyOf):e}function Ci(e){return x(e.length,1)?e[0]:x(e.length,0)?k():M(e)}function wi(e,t){return Ii(bi(e),t)}function Ti(e,t){return b(e)||Fe(e)?A({[e]:t}):x(e,!1)?A({false:t}):x(e,!0)?A({true:t}):A({})}function Ei(e,t){return qr(Bi,t)}function Di(e,t){return C(e,`pattern`)&&(b(e.pattern)||e.pattern instanceof RegExp)?qr(e.pattern.toString(),t):qr(Vi,t)}function Oi(e,t){return Fr(Ar(e))?Ii(Kr(e),t):qr(e,t)}function ki(e){return N(e)?Ai(e.anyOf):[e]}function Ai(e){return e.reduce((e,t)=>[...e,...ki(t)],[])}function ji(e){return e.some(e=>kr(e)||Tr(e)||ur(e))}function Mi(e,t){return x(ji(e),!0)?qr(Vi,t):void 0}function Ni(e,t){return e.reduce((e,n)=>R(n)&&(b(n.const)||Fe(n.const))?{...e,[n.const]:t}:e,{})}function Pi(e,t){return A(Ni(e,t))}function Fi(e,t){let n=Ai(e),r=Mi(n,t);return Et(r)?r:Pi(n,t)}function Ii(e,t){return pn(e)?Jr(t):sr(e)?Yr(t):En(e)?ei(e.enum,t):ur(e)?ti(e,t):P(e)?wi(e.allOf,t):R(e)?Ti(e.const,t):Tr(e)?Ei(e,t):N(e)?Fi(e.anyOf,t):kr(e)?Di(e,t):lo(e)?Oi(e.pattern,t):A({})}function Li(e,t,n){return G([e])?E(Ii(e,t),{},n):Hi(e,t,n)}function Ri(e,t,n,r,i){return Li(K(e,t,n),K(e,t,r),i)}const zi=`^${cr}$`,Bi=`^${Cr}$`,Vi=`^.*$`;function Hi(e,t,n={}){return O(`Record`,[e,t],n)}function Ui(e,t,n={}){return Li(e,t,n)}function Wi(e,t){return qr(e,t)}function Gi(e){return w(e.patternProperties)[0]}function Ki(e){let t=Gi(e);return x(t,Vi)?Or():x(t,zi)?lr():x(t,Bi)?wr():Gr(t)}function qi(e){return e.patternProperties[Gi(e)]}function Ji(e){return D(e,`Record`)}function Yi(e){return T({"~kind":`Rest`},{type:`rest`,items:e},{})}function Xi(e){return D(e,`Rest`)}function Zi(e){return D(e,`This`)}function Qi(e){return T({"~kind":`Undefined`},{type:`undefined`},e)}function $i(e){return D(e,`Undefined`)}function ea(e){return D(e,`Void`)}function ta(e){return ar()}function na(e){return Or()}function ra(e){return wr()}function ia(e){return lr()}function aa(e){return k()}function oa(e){return L(e)}function sa(e){return e}function ca(e){return M(e[1])}function la(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function ua(e){return[e[0],...e[1]]}function da(e){return e}function fa(e){return e[1]}function pa(e){return x(e.length,2)}function ma(e,t,n){return pa(e)?t(e[0],e[1]):n()}function ha(e,t){return x(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function ga(e,t){for(let n=0;n<e.length;n++){let r=ha(e[n],t);if(pa(r))return r}return[]}function _a(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}const va=[..._a(97,122),..._a(65,90)],ya=[`0`,..._a(49,57)];function ba(e){let t=e.indexOf(`*/`);return x(t,-1)?``:e.slice(t+2)}function xa(e){let t=e.indexOf(`
|
|
2
|
+
`);return x(t,-1)?``:e.slice(t)}function Sa(e){return e.replace(/^[ \t\r\f\v]+/,``)}function Ca(e){let t=Sa(e);return t.startsWith(`/*`)?Ca(ba(t.slice(2))):t.startsWith(`//`)?Ca(xa(t.slice(2))):t}function wa(e){let t=e.trimStart();return t.startsWith(`/*`)?wa(ba(t.slice(2))):t.startsWith(`//`)?wa(xa(t.slice(2))):t}[...ya];function Ta(e,t){return ga([e],t)}function Ea(e,t){return x(e,``)?[``,t]:e.startsWith(`
|
|
3
|
+
`)?Ta(e,Ca(t)):e.startsWith(` `)?Ta(e,t):Ta(e,wa(t))}[...va,...ya],[...ya];function Da(e){return x(e,``)?[]:[e.slice(0,1),e.slice(1)]}function Oa(e,t){return S(e,(e,n)=>t.startsWith(e)?!0:Oa(n,t),()=>!1)}function ka(e,t,n=``){return ma(Da(t),(r,i)=>Oa(e,t)?[n,t]:ka(e,i,`${n}${r}`),()=>[])}function Aa(e,t){return ma(ka(e,t),(e,t)=>x(e,``)?[]:[e,t],()=>[])}const B=(e,t,n=()=>[])=>e.length===2?t(e):n(),ja=e=>B(Ea(`-?(?:0|[1-9][0-9]*)n`,e),([e,t])=>[ta(e),t]),Ma=e=>B(Ea(`.*`,e),([e,t])=>[na(e),t]),Na=e=>B(Ea(`-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?`,e),([e,t])=>[ra(e),t]),Pa=e=>B(Ea(`-?(?:0|[1-9][0-9]*)`,e),([e,t])=>[ia(e),t]),Fa=e=>B(Ea(`(?!)`,e),([e,t])=>[aa(e),t]),Ia=e=>B(Aa([`-?(?:0|[1-9][0-9]*)n`,`.*`,`-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?`,`-?(?:0|[1-9][0-9]*)`,`(?!)`,`(`,`)`,`$`,`|`],e),([e,t])=>[oa(e),t]),La=e=>B(B(ja(e),([e,t])=>[e,t],()=>B(Ma(e),([e,t])=>[e,t],()=>B(Na(e),([e,t])=>[e,t],()=>B(Pa(e),([e,t])=>[e,t],()=>B(Fa(e),([e,t])=>[e,t],()=>B(Ra(e),([e,t])=>[e,t],()=>B(Ia(e),([e,t])=>[e,t],()=>[]))))))),([e,t])=>[sa(e),t]),Ra=e=>B(B(Ea(`(`,e),([e,t])=>B(Va(t),([t,n])=>B(Ea(`)`,n),([n,r])=>[[e,t,n],r]))),([e,t])=>[ca(e),t]),za=e=>B(B(B(Ba(e),([e,t])=>B(Ea(`|`,t),([t,n])=>B(za(n),([n,r])=>[[e,t,n],r]))),([e,t])=>[e,t],()=>B(B(Ba(e),([e,t])=>[[e],t]),([e,t])=>[e,t],()=>B([[],e],([e,t])=>[e,t],()=>[]))),([e,t])=>[la(e),t]),Ba=e=>B(B(La(e),([e,t])=>B(Va(t),([t,n])=>[[e,t],n])),([e,t])=>[ua(e),t]),Va=e=>B(B(za(e),([e,t])=>[e,t],()=>B(Ba(e),([e,t])=>[e,t],()=>[])),([e,t])=>[da(e),t]),Ha=e=>B(B(Ea(`^`,e),([e,t])=>B(Va(t),([t,n])=>B(Ea(`$`,n),([n,r])=>[[e,t,n],r]))),([e,t])=>[fa(e),t]);function Ua(e){return e.join(`|`)}function Wa(e){return e.slice(1,e.length-1)}function Ga(e,t,n){return no(t,`${n}${e}`)}function Ka(e,t){return no(e,`${t}-?(?:0|[1-9][0-9]*)n`)}function qa(e,t){return no(e,`${t}${cr}`)}function Ja(e,t){return no(e,`${t}${Cr}`)}function Ya(e,t){return to(M([L(`false`),L(`true`)]),e,t)}function Xa(e,t){return no(e,`${t}.*`)}function Za(e,t,n){return no(t,`${n}${Wa(e)}`)}function Qa(e,t,n){return to(ao(e,{}),t,n)}function $a(e,t,n){return eo(Zr(e),t,n)}function eo(e,t,n,r=[]){return S(e,(e,i)=>eo(i,t,n,[...r,to(e,[],``)]),()=>no(t,`${n}(${Ua(r)})`))}function to(e,t,n){return En(e)?$a(e.enum,t,n):ur(e)?qa(t,n):R(e)?Ga(e.const,t,n):or(e)?Ka(t,n):sr(e)?Ya(t,n):Tr(e)?Ja(t,n):kr(e)?Xa(t,n):lo(e)?Za(e.pattern,t,n):co(e)?Qa(e.parameters[0],t,n):N(e)?eo(e.anyOf,t,n):`(?!)`}function no(e,t){return S(e,(e,n)=>to(e,n,t),()=>t)}function ro(e){return`^${no(e,``)}$`}function io(e){return Ir(ro(e))}function ao(e,t){return G(e)?E(io(e),{},t):so(e,t)}function oo(e,t,n,r){return ao(af(e,t,n),r)}function so(e,t={}){return O(`TemplateLiteral`,[e],t)}function co(e){return Et(e)&&C(e,`action`)&&x(e.action,`TemplateLiteral`)}function lo(e){return D(e,`TemplateLiteral`)}function uo(e){return T({"~kind":`ExtendsUnion`},{inferred:e})}function fo(e){return y(e)&&C(e,`~kind`)&&C(e,`inferred`)&&x(e[`~kind`],`ExtendsUnion`)&&y(e.inferred)}function V(e){return T({"~kind":`ExtendsTrue`},{inferred:e})}function po(e){return y(e)&&C(e,`~kind`)&&C(e,`inferred`)&&x(e[`~kind`],`ExtendsTrue`)&&y(e.inferred)}function H(){return T({"~kind":`ExtendsFalse`},{})}function mo(e){return y(e)&&C(e,`~kind`)&&x(e[`~kind`],`ExtendsFalse`)}function ho(e){return fo(e)||po(e)}function go(e,t,n){return ho(e)?t(e.inferred):n()}function _o(e,t,n,r){return go(W(e,n,r),r=>V(v(v(e,r),{[t]:n})),()=>H())}function vo(e,t){return V(e)}function yo(e,t,n){return W(e,t,Qr(n))}function bo(e,t,n){return S(n,(n,r)=>go(W(e,t,n),e=>bo(e,t,r),()=>H()),()=>V(e))}function xo(e,t,n){return W(e,t,Kr(n))}function So(e,t,n){return S(n,(n,r)=>go(W(e,t,n),e=>V(e),()=>So(e,t,r)),()=>H())}function U(e,t,n){return pn(n)?vo(e,t):En(n)?yo(e,t,n.enum):Tn(n)?_o(e,n.name,t,n.extends):P(n)?bo(e,t,n.allOf):lo(n)?xo(e,t,n.pattern):N(n)?So(e,t,n.anyOf):xn(n)?V(e):H()}function Co(e,t,n){return Tn(n)?U(e,t,n):pn(n)||xn(n)?V(e):uo(e)}function wo(e,t){let n=Lt(e),r=Lt(t);return n&&r||!n&&r?!0:!(n&&!r)}function To(e,t,n,r){return Xt(r)?wo(t,r)?W(e,n,r.items):H():U(e,t,r)}function Eo(e,t,n){return $t(n)?W(e,t,n.iteratorItems):U(e,Qt(t),n)}function Do(e,t,n){return or(n)?V(e):U(e,t,n)}function Oo(e,t,n){return sr(n)?V(e):U(e,t,n)}function ko(e,t,n,r,i){let a=Tn(r)?t:r,o=Tn(r)?r:t,s=Vt(t),c=Vt(r);return!s&&c?H():go(W(e,a,o),e=>Mo(e,n,i),()=>H())}function Ao(e,t,n,r){return S(r,(r,i)=>ko(e,t,n,r,i),()=>Vt(t)?V(e):H())}function jo(e,t,n){return S(t,(t,r)=>Ao(e,t,r,n),()=>V(e))}function Mo(e,t,n){return jo(e,t,n)}function No(e,t,n){return ea(n)?V(e):W(e,t,n)}function Po(e,t,n,r){return pn(r)||xn(r)?V(e):nn(r)?go(Mo(e,t,r.parameters),e=>No(e,n,r.instanceType),()=>H()):H()}function Fo(e,t,n){return W(e,$r(t),n)}function Io(e,t,n,r){return pn(r)||xn(r)?V(e):on(r)?go(Mo(e,t,r.parameters),e=>No(e,n,r.returnType),()=>H()):H()}function Lo(e,t,n){return ur(n)||Tr(n)?V(e):U(e,t,n)}function Ro(e,t,n){return W(e,bi(t),n)}function zo(e,t,n){return fr(n)?W(e,t,n.iteratorItems):U(e,dr(t),n)}function Bo(e,t,n){return t===n?V(e):H()}function Vo(e,t,n){return R(n)?Bo(e,t,n.const):or(n)?V(e):U(e,L(t),n)}function Ho(e,t,n){return R(n)?Bo(e,t,n.const):sr(n)?V(e):U(e,L(t),n)}function Uo(e,t,n){return R(n)?Bo(e,t,n.const):Tr(n)?V(e):U(e,L(t),n)}function Wo(e,t,n){return R(n)?Bo(e,t,n.const):kr(n)?V(e):U(e,L(t),n)}function Go(e,t,n){return Oe(t.const)?Vo(e,t.const,n):ke(t.const)?Ho(e,t.const,n):Fe(t.const)?Uo(e,t.const,n):b(t.const)?Wo(e,t.const,n):kn()}function Ko(e,t,n){return Tn(n)?U(e,t,n):V(e)}function qo(e,t,n){return Sr(n)?V(e):U(e,t,n)}function Jo(e,t,n){return Tr(n)?V(e):U(e,t,n)}function Yo(e,t,n){return Vt(t)?Vt(n)?V(e):H():V(e)}function Xo(e,t,n){return Tn(n)&&mn(n.extends)?H():go(W(e,t,n),e=>Yo(e,t,n),()=>H())}function Zo(e,t){return e.reduce((e,n)=>n in t&&ho(t[n])?{...e,...t[n].inferred}:kn(),{})}function Qo(e,t,n){let r={};for(let i of w(n))r[i]=i in t?Xo({},t[i],n[i]):Vt(n[i])?Tn(n[i])?V(v(e,{[n[i].name]:n[i].extends})):V(e):H();let i=tt(r).every(e=>ho(e)),a=i?Zo(w(r),r):{};return i?V(a):H()}function $o(e,t,n){let r=Qo(e,t,n);return ho(r)?V(v(e,r.inferred)):H()}function es(e,t,n){return $o(e,t,n)}function ts(e,t,n){return j(n)?es(e,t,n.properties):U(e,A(t),n)}function ns(e,t,n){return Nt(n)?W(e,t,n.item):U(e,Mt(t),n)}function rs(e,t,n){return kr(n)?V(e):U(e,t,n)}function is(e,t,n){return Dr(n)?V(e):U(e,t,n)}function as(e,t,n){return W(e,Kr(t),n)}function os(e,t){return T({"~kind":`Inferrable`},{name:e,type:t},{})}function ss(e){return y(e)&&C(e,`~kind`)&&C(e,`name`)&&C(e,`type`)&&x(e[`~kind`],`Inferrable`)&&b(e.name)&&y(e.type)}function cs(e){return Xi(e)?Tn(e.items)?Xt(e.items.extends)?os(e.items.name,e.items.extends.items):xn(e.items.extends)?os(e.items.name,e.items.extends):void 0:kn():void 0}function ls(e){return Tn(e)?os(e.name,e.extends):void 0}function us(e,t,n=[]){return S(e,(e,r)=>go(W({},e,t),()=>us(r,t,[...n,e]),()=>void 0),()=>n)}function ds(e,t,n,r){let i=us(n,r);return Ee(i)?V(v(e,{[t]:ni(i)})):H()}function fs(e,t,n,r){let i=us(n,r);return Ee(i)?V(v(e,{[t]:M(i)})):H()}function ps(e){return[...e].reverse()}function ms(e,t){return t?ps(e):e}function hs(e){let t=e.length>0?e[0]:void 0;return Et(Et(t)?cs(t):void 0)}function gs(e,t,n,r,i,a){return go(W(e,n,i),e=>ys(e,t,r,a),()=>H())}function _s(e,t,n,r,i){let a=cs(r);return ss(a)?ds(e,a.name,ms(n,t),a.type):S(n,(n,a)=>gs(e,t,n,a,r,i),()=>H())}function vs(e,t,n,r){return S(r,(r,i)=>_s(e,t,n,r,i),()=>x(n.length,0)?V(e):H())}function ys(e,t,n,r){return vs(e,t,n,r)}function bs(e,t,n){let r=rf(e,{callstack:[]},n),i=hs(r);return ys(e,i,ms(t,i),ms(r,i))}function xs(e,t,n){let r=ls(n);return ss(r)?fs(e,r.name,t,r.type):S(t,(t,r)=>go(W(e,t,n),e=>xs(e,r,n),()=>H()),()=>V(e))}function Ss(e,t,n){let r=rf(e,{callstack:[]},t);return z(n)?bs(e,r,n.items):Xt(n)?xs(e,r,n.items):U(e,ni(r),n)}function Cs(e,t,n){return ea(n)||$i(n)?V(e):U(e,t,n)}function ws(e,t,n){return S(n,(n,r)=>go(W(e,t,n),e=>V(e),()=>ws(e,t,r)),()=>H())}function Ts(e,t,n){return S(t,(t,r)=>go(ws(e,t,n),e=>Ts(e,r,n),()=>H()),()=>V(e))}function Es(e,t,n){let r=ls(n);return ss(r)?fs(e,r.name,t,r.type):N(n)?Ts(e,t,n.anyOf):Ts(e,t,[n])}function Ds(e,t,n){return Tn(n)?U(e,t,n):pn(n)||xn(n)?V(e):H()}function Os(e,t,n){return ea(n)?V(e):U(e,t,n)}function W(e,t,n){return pn(t)?Co(e,t,n):Xt(t)?To(e,t,t.items,n):$t(t)?Eo(e,t.iteratorItems,n):or(t)?Do(e,t,n):sr(t)?Oo(e,t,n):nn(t)?Po(e,t.parameters,t.instanceType,n):En(t)?Fo(e,t,n):on(t)?Io(e,t.parameters,t.returnType,n):ur(t)?Lo(e,t,n):P(t)?Ro(e,t.allOf,n):fr(t)?zo(e,t.iteratorItems,n):R(t)?Go(e,t,n):mn(t)?Ko(e,t,n):Sr(t)?qo(e,t,n):Tr(t)?Jo(e,t,n):j(t)?ts(e,t.properties,n):Nt(t)?ns(e,t.item,n):kr(t)?rs(e,t,n):Dr(t)?is(e,t,n):lo(t)?as(e,t.pattern,n):z(t)?Ss(e,t.items,n):$i(t)?Cs(e,t,n):N(t)?Es(e,t.anyOf,n):xn(t)?Ds(e,t,n):ea(t)?Os(e,t,n):H()}function ks(e,t){return bi([...e,A(t)])}function As(e,t,n){return G(e)?E(ks(e,t),{},n):Ms(e,t,n)}function js(e,t,n,r,i){return As(af(e,t,n),nf(e,t,r),i)}function Ms(e,t,n={}){return O(`Interface`,[e,t],n)}function Ns(e){return Et(e)&&C(e,`action`)&&x(e.action,`Interface`)}function Ps(e,t,n){return e.includes(n)?!0:Ls([...e,n],t,t[n])}function Fs(e,t,n){return Is(e,t,_n(n))}function Is(e,t,n){return S(n,(n,r)=>Ls(e,t,n)?!0:Is(e,t,r),()=>!1)}function Ls(e,t,n){return ln(n)?Ps(e,t,n.$ref):Xt(n)?Ls(e,t,n.items):$t(n)?Ls(e,t,n.iteratorItems):nn(n)?Is(e,t,[...n.parameters,n.instanceType]):on(n)?Is(e,t,[...n.parameters,n.returnType]):Ns(n)?Fs(e,t,n.parameters[1]):P(n)?Is(e,t,n.allOf):fr(n)?Ls(e,t,n.iteratorItems):j(n)?Fs(e,t,n.properties):Nt(n)?Ls(e,t,n.item):N(n)?Is(e,t,n.anyOf):z(n)?Is(e,t,n.items):Ji(n)?Ls(e,t,qi(n)):!1}function Rs(e,t,n){return Ls(e,t,n)}function zs(e,t){return t.reduce((t,n)=>n in e?Rs([n],e,e[n])?[...t,n]:t:kn(),[])}function Bs(e){return zs(e,gn(e))}function Vs(e,t,n){return n.includes(t)?n:t in e?Ws(e,e[t],[...n,t]):kn()}function Hs(e,t,n){return Us(e,_n(t),n)}function Us(e,t,n){return t.reduce((t,n)=>Ws(e,n,t),n)}function Ws(e,t,n){return ln(t)?Vs(e,t.$ref,n):Xt(t)?Ws(e,t.items,n):$t(t)?Ws(e,t.iteratorItems,n):nn(t)?Us(e,[...t.parameters,t.instanceType],n):on(t)?Us(e,[...t.parameters,t.returnType],n):Ns(t)?Hs(e,t.parameters[1],n):P(t)?Us(e,t.allOf,n):fr(t)?Ws(e,t.iteratorItems,n):j(t)?Hs(e,t.properties,n):Nt(t)?Ws(e,t.item,n):N(t)?Us(e,t.anyOf,n):z(t)?Us(e,t.items,n):Ji(t)?Ws(e,qi(t),n):n}function Gs(e,t,n){return Ws(e,n,[t])}function Ks(e){return fn()}function qs(e){return w(e).reduce((t,n)=>({...t,[n]:Ys(e[n])}),{})}function Js(e){return e.reduce((e,t)=>[...e,Ys(t)],[])}function Ys(e){return ln(e)?Ks(e.$ref):Xt(e)?Yt(Ys(e.items),Zt(e)):$t(e)?Qt(Ys(e.iteratorItems)):nn(e)?tn(Js(e.parameters),Ys(e.instanceType)):on(e)?an(Js(e.parameters),Ys(e.returnType)):P(e)?Dn(Js(e.allOf)):fr(e)?dr(Ys(e.iteratorItems)):j(e)?A(qs(e.properties)):Nt(e)?Mt(Ys(e.item)):Ji(e)?Ui(Ki(e),Ys(qi(e))):N(e)?M(Js(e.anyOf)):z(e)?ni(Js(e.items)):e}function Xs(e,t){return t in e?Ys(e[t]):bn()}function Zs(e){return Xs(e.$defs,e.$ref)}function Qs(e,t,n){let r=af(e,{callstack:[]},t),i=nf({},{callstack:[]},n);return bi([...r,A(i)])}function $s(e,t){return w(e).filter(e=>t.includes(e)).reduce((t,n)=>{let r=e[n],i=Ns(r)?Qs(e,r.parameters[0],r.parameters[1]):r;return{...t,[n]:i}},{})}function ec(e,t,n){return Sn($s(e,Gs(e,t,n)),t)}function tc(e,t){return t in e?ln(e[t])?tc(e,e[t].$ref):e[t]:k()}function nc(e,t){return tc(e,t)}function rc(e){return Cn(e)?Zs(e):wn(e)?bn():e}function ic(e,t,n){return W(e,rc(t),rc(n))}function ac(e,t){let n=[xn(e)?H():ic({},e,t),xn(e)?V({}):ic({},t,e)];return ho(n[0])&&ho(n[1])?`equal`:ho(n[0])&&mo(n[1])?`left-inside`:mo(n[0])&&ho(n[1])?`right-inside`:`disjoint`}function oc(e,t){return t.filter(t=>ac(e,t)!==`right-inside`)}function sc(e,t){return x(t.some(t=>{let n=ac(e,t);return x(n,`left-inside`)||x(n,`equal`)}),!1)}function cc(e,t){let n=Si(e);return pn(n)?[n]:sc(n,t)?[...oc(n,t),n]:t}function lc(e){return e.reduce((e,t)=>j(t)?[...e,t]:mn(t)?e:cc(t,e),[])}function uc(e){let t=Ai(lc(e));return t.length===0?k():t.length===1?t[0]:M(t)}function dc(e,t){return E(Si(e),{},t)}function fc(e,t,n,r){return dc(K(e,t,n),r)}function pc(e,t=[]){return jt(e)&&x(e.action,`Conditional`)?ln(e.parameters[0])?pc(e.parameters[2],pc(e.parameters[3],[...t,e.parameters[0].$ref])):pc(e.parameters[2],pc(e.parameters[3],t)):jt(e)&&x(e.action,`Mapped`)&&jt(e.parameters[1])&&x(e.parameters[1].action,`KeyOf`)&&ln(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function mc(e,t){return e.reduce((e,n)=>[...e,t.includes(n.name)],[])}function hc(e,t,n=[]){return S(e,(e,r)=>S(t,(t,i)=>hc(r,i,[...n,[t,e]]),()=>n),()=>n)}function gc(e){return N(e)?[...e.anyOf]:[e]}function _c(e,t){return e.reduce((e,n)=>[...e,[...n,t]],[])}function vc(e,t){return t.reduce((t,n)=>[...t,..._c(e,n)],[])}function yc(e){return e.reduce((e,t)=>x(t[0],!0)?vc(e,gc(t[1])):vc(e,[t[1]]),[[]])}function bc(e,t,n){let r=hc(t,mc(e,pc(n)));return jt(n)&&x(n.action,`Conditional`)||jt(n)&&x(n.action,`Mapped`)?yc(r):[t]}function xc(){return[`(not-resolvable)`,k()]}function Sc(){return[`(not-generic)`,k()]}function Cc(e,t,n){return[e,un(t,n)]}function wc(e,t,n){return t in e?Tc(e,t,e[t],n):xc()}function Tc(e,t,n,r){return dn(n)?Cc(t,n.parameters,n.expression):ln(n)?wc(e,n.$ref,r):Sc()}function Ec(e,t,n){return Tc(e,`(anonymous)`,t,n)}function Dc(e,t,n){if(Tn(t)||zc(t)||ho(ic({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function Oc(e,t,n,r,i){let a=K(e,t,i);return Dc(n,a,r),v(e,{[n]:a})}function kc(e,t,n,r,i){let a=K(e,t,n.extends),o=K(e,t,n.equals);return S(i,(i,o)=>Ac(Oc(e,t,n.name,a,i),t,r,o),()=>Ac(Oc(e,t,n.name,a,o),t,r,[]))}function Ac(e,t,n,r){return S(n,(n,i)=>kc(e,t,n,i,r),()=>e)}function jc(e,t,n,r){return Ac(e,t,n,r)}function Mc(e){return ze(e.callstack.length,0)?e.callstack[e.callstack.length-1]:``}function Nc(e,t){return x(Mc(e),t)}function Pc(e,t,n,r,i,a){return K(e,t,K(jc(e,t,r,a),{callstack:[...t.callstack,n.$ref]},i))}function Fc(e,t,n,r,i,a){return a.reduce((a,o)=>[...a,Pc(e,t,n,r,i,o)],[])}function Ic(e,t,n,r,i,a){let o=Fc(e,t,n,r,i,bc(r,a,i));return x(o.length,1)?o[0]:xi(o)}function Lc(e,t,n,r){let i=af(e,t,r),a=Ec(e,n,r),o=a[0],s=a[1];return dn(s)?Nc(t,o)?Rc(cn(o),i):Ic(e,t,cn(o),s.parameters,s.expression,i):Rc(n,i)}function Rc(e,t){return T({"~kind":`Call`},{target:e,arguments:t},{})}function zc(e){return D(e,`Call`)}function Bc(e,t){return e(t)}function Vc(e,t){return b(t)?L(Bc(e,t)):L(t)}function Hc(e,t){return Wc(e,Kr(t))}function Uc(e,t){return M(t.map(t=>Wc(e,t)))}function Wc(e,t){return R(t)?Vc(e,t.const):lo(t)?Hc(e,t.pattern):N(t)?Uc(e,t.anyOf):t}function Gc(e,t={}){return O(`Capitalize`,[e],t)}function Kc(e,t={}){return O(`Lowercase`,[e],t)}function qc(e,t={}){return O(`Uncapitalize`,[e],t)}function Jc(e,t={}){return O(`Uppercase`,[e],t)}const Yc=e=>e[0].toUpperCase()+e.slice(1),Xc=e=>e.toLowerCase(),Zc=e=>e[0].toLowerCase()+e.slice(1),Qc=e=>e.toUpperCase();function $c(e,t){return G([e])?E(Wc(Yc,e),{},t):Gc(e,t)}function el(e,t){return G([e])?E(Wc(Xc,e),{},t):Kc(e,t)}function tl(e,t){return G([e])?E(Wc(Zc,e),{},t):qc(e,t)}function nl(e,t){return G([e])?E(Wc(Qc,e),{},t):Jc(e,t)}function rl(e,t,n,r){return $c(K(e,t,n),r)}function il(e,t,n,r){return el(K(e,t,n),r)}function al(e,t,n,r){return tl(K(e,t,n),r)}function ol(e,t,n,r){return nl(K(e,t,n),r)}function sl(e,t,n,r,i={}){return O(`Conditional`,[e,t,n,r],i)}function cl(e,t,n,r,i,a){let o=ic(e,n,r);return fo(o)?M([K(o.inferred,t,i),K(e,t,a)]):po(o)?K(o.inferred,t,i):K(e,t,a)}function ll(e,t,n,r,i,a,o){return G([n,r])?E(cl(e,t,n,r,i,a),{},o):sl(n,r,i,a,o)}function ul(e,t,n,r,i,a,o){return ll(e,t,K(e,t,n),K(e,t,r),i,a,o)}function dl(e,t={}){return O(`ConstructorParameters`,[e],t)}function fl(e){return ni(rf({},{callstack:[]},nn(e)?e.parameters:[]))}function pl(e,t){return G([e])?E(fl(e),{},t):dl(e,t)}function ml(e,t,n,r){return pl(K(e,t,n),r)}function hl(e,t,n={}){return O(`Exclude`,[e,t],n)}function gl(e,t){return e.reduce((e,n)=>[...e,..._l(n,t)],[])}function _l(e,t){return ho(ic({},e,t))?[]:[e]}function vl(e,t){return xi(En(e)?gl(Zr(e.enum),t):N(e)?gl(Ai(e.anyOf),t):_l(e,t))}function yl(e,t,n){return G([e,t])?E(vl(e,t),{},n):hl(e,t,n)}function bl(e,t,n,r,i){return yl(K(e,t,n),K(e,t,r),i)}function xl(e,t,n={}){return O(`Extract`,[e,t],n)}function Sl(e,t){return e.reduce((e,n)=>[...e,...Cl(n,t)],[])}function Cl(e,t){return ho(ic({},e,t))?[e]:[]}function wl(e,t){return xi(En(e)?Sl(Zr(e.enum),t):N(e)?Sl(Ai(e.anyOf),t):Cl(e,t))}function Tl(e,t,n){return G([e,t])?E(wl(e,t),{},n):xl(e,t,n)}function El(e,t,n,r,i){return Tl(K(e,t,n),K(e,t,r),i)}function Dl(e,t,n={}){return O(`Index`,[e,t],n)}function Ol(e,t){return Il(nc(e,t))}function kl(e,t){let n=w(e).filter(e=>!C(t,e)),r=w(t).filter(t=>!C(e,t)),i=w(e).filter(e=>C(t,e)),a=n.reduce((t,n)=>({...t,[n]:e[n]}),{}),o=r.reduce((e,n)=>({...e,[n]:t[n]}),{}),s=i.reduce((n,r)=>({...n,[r]:bi([e[r],t[r]])}),{});return v(v(a,o),s)}function Al(e){return e.reduce((e,t)=>kl(e,Il(t)),{})}function jl(e){return e}function Ml(e){return Il(ai(ni(e)))}function Nl(e,t){return w(e).filter(e=>e in t).reduce((n,r)=>({...n,[r]:xi([e[r],t[r]])}),{})}function Pl(e,t){return S(e,(e,n)=>Pl(n,Nl(t,Il(e))),()=>t)}function Fl(e){return S(e,(e,t)=>Pl(t,Il(e)),()=>kn())}function Il(e){return Cn(e)?Ol(e.$defs,e.$ref):P(e)?Al(e.allOf):N(e)?Fl(e.anyOf):z(e)?Ml(e.items):j(e)?jl(e.properties):{}}function Ll(e){return A(Il(e))}const Rl=RegExp(`^(?:0|[1-9][0-9]*)$`);function zl(e){let t=`${e}`;return Rl.test(t)?parseInt(t):e}function Bl(e){return L(zl(e))}function Vl(e){return e.map(e=>Hl(e))}function Hl(e){return P(e)?Dn(Vl(e.allOf)):N(e)?M(Vl(e.anyOf)):R(e)?Bl(e.const):e}function Ul(e,t){return ho(ic({},Hl(t),wr()))?e:R(t)&&x(t.const,`length`)?wr():k()}function Wl(e,t){return Xl(nc(e,t))}function Gl(e){return e.reduce((e,t)=>[...e,...Xl(t)],[])}function Kl(e){return Gl(Zr(e))}function ql(e){return Xl(bi(e))}function Jl(e){return[`${e}`]}function Yl(e){return Xl(Kr(e))}function Xl(e){return Cn(e)?Wl(e.$defs,e.$ref):En(e)?Kl(e.enum):P(e)?ql(e.allOf):R(e)?Jl(e.const):lo(e)?Yl(e.pattern):N(e)?Gl(e.anyOf):[]}function Zl(e){return Xl(e)}function Ql(e,t){return t.map(t=>$l(e,t))}function $l(e,t){return Xt(t)?Yt($l(e,t.items)):$t(t)?Qt($l(e,t.iteratorItems)):nn(t)?tn(Ql(e,t.parameters),$l(e,t.instanceType)):on(t)?an(Ql(e,t.parameters),$l(e,t.returnType)):fr(t)?dr($l(e,t.iteratorItems)):Nt(t)?Mt($l(e,t.item)):z(t)?ni(Ql(e,t.items)):N(t)?M(Ql(e,t.anyOf)):P(t)?Dn(Ql(e,t.allOf)):Zi(t)?A(e):t}function eu(e,t){return $l(e,t)}function tu(e,t){return eu(e,t in e?e[t]:k())}function nu(e,t){return t.reduce((t,n)=>[...t,tu(e,n)],[])}function ru(e,t){return xi(nu(e,Zl(t)))}const iu=new RegExp(zi);function au(e){return e.filter(e=>iu.test(e))}function ou(e){return xi(nu(e,au(gn(e))))}function su(e,t){return Tr(t)?ou(e):ru(e,t)}function cu(e){return L(zl(e))}function lu(e){return e.map(e=>uu(e))}function uu(e){return P(e)?Dn(lu(e.allOf)):N(e)?M(lu(e.anyOf)):R(e)?cu(e.const):e}function du(e,t){return e.reduceRight((e,n,r)=>ho(ic({},L(r),t))?[n,...e]:e,[])}function fu(e,t){return Ci(du(e,uu(t)))}function pu(e){return Ci(e)}function mu(e,t){return R(t)&&x(t.const,`length`)?L(e.length):Tr(t)||ur(t)?pu(e):fu(e,t)}function hu(e,t){return Xt(e)?Ul(e.items,t):j(e)?su(e.properties,t):z(e)?mu(e.items,t):k()}function gu(e){return Cn(e)||P(e)||N(e)?Ll(e):e}function _u(e,t,n){return G([e,t])?E(hu(gu(e),t),{},n):Dl(e,t,n)}function vu(e,t,n,r,i){return _u(K(e,t,n),K(e,t,r),i)}function yu(e,t={}){return O(`InstanceType`,[e],t)}function bu(e){return nn(e)?e.instanceType:k()}function xu(e,t){return G([e])?E(bu(e),{},t):yu(e,t)}function Su(e,t,n,r={}){return xu(K(e,t,n),r)}function Cu(e,t={}){return O(`KeyOf`,[e],t)}function wu(){return M([wr(),Or(),Er()])}function Tu(e){return wr()}function Eu(e){return e.reduce((e,t)=>gr(t)?[...e,L(zl(t))]:kn(),[])}function Du(e){return Ci(Eu(w(e)))}function Ou(e){return Ki(e)}function ku(e){return Ci(e.map((e,t)=>L(t)))}function Au(e){return pn(e)?wu():Xt(e)?Tu(e.items):j(e)?Du(e.properties):Ji(e)?Ou(e):z(e)?ku(e.items):k()}function ju(e){return Cn(e)||P(e)||N(e)?Ll(e):e}function Mu(e,t){return G([e])?E(Au(ju(e)),{},t):Cu(e,t)}function Nu(e,t,n,r){return Mu(K(e,t,n),r)}function Pu(e,t,n,r,i={}){return O(`Mapped`,[e,t,n,r],i)}function Fu(e){return Ru(Kr(e))}function Iu(e){return e.reduce((e,t)=>[...e,...Ru(t)],[])}function Lu(e){return Fe(e)?[L(`${e}`)]:[L(e)]}function Ru(e){return En(e)?Iu(Zr(e.enum)):R(e)?Lu(e.const):lo(e)?Fu(e.pattern):N(e)?Iu(e.anyOf):[e]}function zu(e){return Ru(e)}function Bu(e){return lo(e)?Kr(e.pattern):e}function Vu(e,t,n,r,i,a){let o=v(e,{[n.name]:r}),s=Bu(K(o,t,i)),c=K(o,t,a);return yr(s)||br(s)?{[s.const]:c}:{}}function Hu(e,t,n,r,i,a){return r.reduce((r,o)=>[...r,Vu(e,t,n,o,i,a)],[])}function Uu(e){return e.reduce((e,t)=>[...e,A(t)],[])}function Wu(e,t,n,r,i,a){return bi(Uu(Hu(e,t,n,zu(r),i,a)))}function Gu(e,t,n,r,i,a,o){return G([r])?E(Wu(e,t,n,r,i,a),{},o):Pu(n,r,i,a,o)}function Ku(e,t,n,r,i,a,o){return Gu(e,t,n,K(e,t,r),i,a,o)}function qu(e,t){return w(e).filter(e=>t.includes(e)).reduce((t,n)=>({...t,[n]:ec(e,n,e[n])}),{})}function Ju(e,t){return w(e).filter(e=>!t.includes(e)).reduce((t,n)=>({...t,[n]:K(e,{callstack:[]},e[n])}),{})}function Yu(e,t){let n=Bs(e),r=qu(e,n),i=Ju(e,n);return E({...r,...i},{},t)}function Xu(e,t,n,r){return Yu(v(e,n),r)}function Zu(e,t={}){return O(`NonNullable`,[e],t)}function Qu(e){return yl(e,M([xr(),Qi()]),{})}function $u(e,t){return G([e])?E(Qu(e),{},t):Zu(e,t)}function ed(e,t,n,r){return $u(K(e,t,n),r)}function td(e,t,n={}){return O(`Omit`,[e,t],n)}function nd(e){let t=Ll(e);return j(t)?t.properties:kn()}function rd(e,t){return w(e).reduce((n,r)=>t.includes(r)?n:{...n,[r]:e[r]},{})}function id(e,t){return A(rd(nd(e),Zl(t)))}function ad(e,t,n){return G([e,t])?E(id(e,t),{},n):td(e,t,n)}function od(e,t,n,r,i){return ad(K(e,t,n),K(e,t,r),i)}function sd(e,t){return O(`Options`,[e,t],{})}function cd(e,t){return ld(e,t)}function ld(e,t){return G([e])?E(e,{},t):sd(e,t)}function ud(e,t,n,r){return ld(K(e,t,n),r)}function dd(e,t={}){return O(`Parameters`,[e],t)}function fd(e){return ni(rf({},{callstack:[]},on(e)?e.parameters:[]))}function pd(e,t){return G([e])?E(fd(e),{},t):dd(e,t)}function md(e,t,n,r){return pd(K(e,t,n),r)}function hd(e,t={}){return O(`Partial`,[e],t)}function gd(e,t){let n=bd(nc(e,t));return Sn(v(e,{[t]:n}),t)}function _d(e){return bi(e.map(e=>bd(e)))}function vd(e){return M(e.map(e=>bd(e)))}function yd(e){return A(w(e).reduce((t,n)=>({...t,[n]:Bt(e[n])}),{}))}function bd(e){return Cn(e)?gd(e.$defs,e.$ref):P(e)?_d(e.allOf):N(e)?vd(e.anyOf):j(e)?yd(e.properties):A({})}function xd(e,t){return G([e])?E(bd(e),{},t):hd(e,t)}function Sd(e,t,n,r){return xd(K(e,t,n),r)}function Cd(e,t,n={}){return O(`Pick`,[e,t],n)}function wd(e,t){return w(e).reduce((n,r)=>t.includes(r)?v(n,{[r]:e[r]}):n,{})}function Td(e,t){return A(wd(nd(e),Zl(t)))}function Ed(e,t,n){return G([e,t])?E(Td(e,t),{},n):Cd(e,t,n)}function Dd(e,t,n,r,i){return Ed(K(e,t,n),K(e,t,r),i)}function Od(e,t={}){return O(`ReadonlyObject`,[e],t)}function kd(e){return It(Yt(e))}function Ad(e,t){let n=Fd(nc(e,t));return Sn(v(e,{[t]:n}),t)}function jd(e){return bi(e.map(e=>Fd(e)))}function Md(e){return A(w(e).reduce((t,n)=>({...t,[n]:Wt(e[n])}),{}))}function Nd(e){return It(ni(e))}function Pd(e){return M(e.map(e=>Fd(e)))}function Fd(e){return Xt(e)?kd(e.items):Cn(e)?Ad(e.$defs,e.$ref):P(e)?jd(e.allOf):j(e)?Md(e.properties):z(e)?Nd(e.items):N(e)?Pd(e.anyOf):e}function Id(e,t){return G([e])?E(Fd(e),{},t):Od(e)}function Ld(e,t,n,r){return Id(K(e,t,n),r)}function Rd(e,t,n,r){return r in e?Rs([r],e,e[r])?n:K(e,t,e[r]):n}function zd(e,t){let n=Ud(nc(e,t));return Sn(v(e,{[t]:n}),t)}function Bd(e){return bi(e.map(e=>Ud(e)))}function Vd(e){return M(e.map(e=>Ud(e)))}function Hd(e){return A(w(e).reduce((t,n)=>({...t,[n]:Rt(e[n])}),{}))}function Ud(e){return Cn(e)?zd(e.$defs,e.$ref):P(e)?Bd(e.allOf):N(e)?Vd(e.anyOf):j(e)?Hd(e.properties):A({})}function Wd(e,t={}){return O(`Required`,[e],t)}function Gd(e,t){return G([e])?E(Ud(e),{},t):Wd(e,t)}function Kd(e,t,n,r){return Gd(K(e,t,n),r)}function qd(e,t={}){return O(`ReturnType`,[e],t)}function Jd(e){return on(e)?e.returnType:k()}function Yd(e,t){return G([e])?E(Jd(e),{},t):qd(e,t)}function Xd(e,t,n,r={}){return Yd(K(e,t,n),r)}function Zd(e){return Xi(e)?z(e.items)?Qd(e.items.items):Tn(e.items)||ln(e.items)?[e]:[k()]:[e]}function Qd(e){return e.reduce((e,t)=>[...e,...Zd(t)],[])}function G(e){return S(e,(e,t)=>!ln(e)&&G(t),()=>!0)}function $d(e,t,n){return At(e)?$d(e.type,`remove`,n):Ot(e)?$d(e.type,t,`remove`):kt(e)?$d(e.type,`add`,n):Dt(e)?$d(e.type,t,`add`):[e,t,n]}function ef(e,t){return x(e,`remove`)?Ht(t):x(e,`add`)?Ut(t):t}function tf(e,t){return x(e,`remove`)?Rt(t):x(e,`add`)?zt(t):t}function nf(e,t,n){return w(n).reduce((r,i)=>({...r,[i]:K(e,t,n[i])}),{})}function rf(e,t,n){return Qd(af(e,t,n))}function af(e,t,n){return n.map(n=>K(e,t,n))}function of(e,t,n,r,i){return x(n,`Awaited`)?uf(e,t,r[0],i):x(n,`Capitalize`)?rl(e,t,r[0],i):x(n,`Conditional`)?ul(e,t,r[0],r[1],r[2],r[3],i):x(n,`ConstructorParameters`)?ml(e,t,r[0],i):x(n,`Evaluate`)?fc(e,t,r[0],i):x(n,`Exclude`)?bl(e,t,r[0],r[1],i):x(n,`Extract`)?El(e,t,r[0],r[1],i):x(n,`Index`)?vu(e,t,r[0],r[1],i):x(n,`InstanceType`)?Su(e,t,r[0],i):x(n,`Interface`)?js(e,t,r[0],r[1],i):x(n,`KeyOf`)?Nu(e,t,r[0],i):x(n,`Lowercase`)?il(e,t,r[0],i):x(n,`Mapped`)?Ku(e,t,r[0],r[1],r[2],r[3],i):x(n,`Module`)?Xu(e,t,r[0],i):x(n,`NonNullable`)?ed(e,t,r[0],i):x(n,`Pick`)?Dd(e,t,r[0],r[1],i):x(n,`Options`)?ud(e,t,r[0],r[1]):x(n,`Parameters`)?md(e,t,r[0],i):x(n,`Partial`)?Sd(e,t,r[0],i):x(n,`Omit`)?od(e,t,r[0],r[1],i):x(n,`ReadonlyObject`)?Ld(e,t,r[0],i):x(n,`Record`)?Ri(e,t,r[0],r[1],i):x(n,`Required`)?Kd(e,t,r[0],i):x(n,`ReturnType`)?Xd(e,t,r[0],i):x(n,`TemplateLiteral`)?oo(e,t,r[0],i):x(n,`Uncapitalize`)?al(e,t,r[0],i):x(n,`Uppercase`)?ol(e,t,r[0],i):O(n,r,i)}function K(e,t,n){let r=Lt(n),i=$d(n,Gt(n)?`add`:`none`,Vt(n)?`add`:`none`),a=Jt(i[0])?i[0].Clone():i[0],o=ln(a)?Rd(e,t,a,a.$ref):Xt(a)?Yt(K(e,t,a.items),Zt(a)):$t(a)?Qt(K(e,t,a.iteratorItems),en(a)):zc(a)?Lc(e,t,a.target,a.arguments):nn(a)?tn(af(e,t,a.parameters),K(e,t,a.instanceType),rn(a)):jt(a)?of(e,t,a.action,a.parameters,a.options):on(a)?an(af(e,t,a.parameters),K(e,t,a.returnType),sn(a)):P(a)?Dn(af(e,t,a.allOf),On(a)):fr(a)?dr(K(e,t,a.iteratorItems),pr(a)):j(a)?A(nf(e,t,a.properties),vn(a)):Nt(a)?Mt(K(e,t,a.item),Pt(a)):Ji(a)?Wi(Gi(a),K(e,t,qi(a))):Xi(a)?Yi(K(e,t,a.items)):z(a)?ni(rf(e,t,a.items),ri(a)):N(a)?M(af(e,t,a.anyOf),yn(a)):a,s=r?It(o):o;return ef(i[1],tf(i[2],s))}function sf(e,t){return K(e,{callstack:[]},t)}function cf(e){return Nt(e)?cf(e.item):e}function lf(e,t){return G([e])?E(cf(e),{},t):df(e,t)}function uf(e,t,n,r){return lf(K(e,t,n),r)}function df(e,t={}){return O(`Awaited`,[e],t)}function ff(e,t={}){return dc(e,t)}const pf=Symbol.for(`yaml.alias`),mf=Symbol.for(`yaml.document`),hf=Symbol.for(`yaml.map`),gf=Symbol.for(`yaml.pair`),_f=Symbol.for(`yaml.scalar`),vf=Symbol.for(`yaml.seq`),yf=Symbol.for(`yaml.node.type`),bf=e=>!!e&&typeof e==`object`&&e[yf]===pf,xf=e=>!!e&&typeof e==`object`&&e[yf]===mf,Sf=e=>!!e&&typeof e==`object`&&e[yf]===hf,q=e=>!!e&&typeof e==`object`&&e[yf]===gf,J=e=>!!e&&typeof e==`object`&&e[yf]===_f,Cf=e=>!!e&&typeof e==`object`&&e[yf]===vf;function wf(e){if(e&&typeof e==`object`)switch(e[yf]){case hf:case vf:return!0}return!1}function Y(e){if(e&&typeof e==`object`)switch(e[yf]){case pf:case hf:case _f:case vf:return!0}return!1}const Tf=e=>(J(e)||wf(e))&&!!e.anchor,Ef=Symbol(`break visit`),Df=Symbol(`skip children`),Of=Symbol(`remove node`);function kf(e,t){let n=Nf(t);xf(e)?Af(null,e.contents,n,Object.freeze([e]))===Of&&(e.contents=null):Af(null,e,n,Object.freeze([]))}kf.BREAK=Ef,kf.SKIP=Df,kf.REMOVE=Of;function Af(e,t,n,r){let i=Pf(e,t,n,r);if(Y(i)||q(i))return Ff(e,r,i),Af(e,i,n,r);if(typeof i!=`symbol`){if(wf(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Af(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Ef)return Ef;else i===Of&&(t.items.splice(e,1),--e)}}else if(q(t)){r=Object.freeze(r.concat(t));let e=Af(`key`,t.key,n,r);if(e===Ef)return Ef;e===Of&&(t.key=null);let i=Af(`value`,t.value,n,r);if(i===Ef)return Ef;i===Of&&(t.value=null)}}return i}async function jf(e,t){let n=Nf(t);xf(e)?await Mf(null,e.contents,n,Object.freeze([e]))===Of&&(e.contents=null):await Mf(null,e,n,Object.freeze([]))}jf.BREAK=Ef,jf.SKIP=Df,jf.REMOVE=Of;async function Mf(e,t,n,r){let i=await Pf(e,t,n,r);if(Y(i)||q(i))return Ff(e,r,i),Mf(e,i,n,r);if(typeof i!=`symbol`){if(wf(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await Mf(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Ef)return Ef;else i===Of&&(t.items.splice(e,1),--e)}}else if(q(t)){r=Object.freeze(r.concat(t));let e=await Mf(`key`,t.key,n,r);if(e===Ef)return Ef;e===Of&&(t.key=null);let i=await Mf(`value`,t.value,n,r);if(i===Ef)return Ef;i===Of&&(t.value=null)}}return i}function Nf(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Pf(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Sf(t))return n.Map?.(e,t,r);if(Cf(t))return n.Seq?.(e,t,r);if(q(t))return n.Pair?.(e,t,r);if(J(t))return n.Scalar?.(e,t,r);if(bf(t))return n.Alias?.(e,t,r)}function Ff(e,t,n){let r=t[t.length-1];if(wf(r))r.items[e]=n;else if(q(r))e===`key`?r.key=n:r.value=n;else if(xf(r))r.contents=n;else{let e=bf(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}const If={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},Lf=e=>e.replace(/[!,[\]{}]/g,e=>If[e]);var Rf=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Lf(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Y(e.contents)){let t={};kf(e.contents,(e,n)=>{Y(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
4
|
+
`)}};Rf.defaultYaml={explicit:!1,version:`1.2`},Rf.defaultTags={"!!":`tag:yaml.org,2002:`};function zf(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Bf(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=Bf(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=Bf(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=Bf(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=Bf(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function Vf(e,t,n){if(Array.isArray(e))return e.map((e,t)=>Vf(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Tf(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Hf=class{constructor(e){Object.defineProperty(this,yf,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!xf(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=Vf(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Bf(i,{"":o},``,o):o}},Uf=class extends Hf{constructor(e){super(pf),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],kf(e,{Node:(e,t)=>{(bf(t)||Tf(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(Vf(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=Wf(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(zf(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Wf(e,t,n){if(bf(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(wf(t)){let r=0;for(let i of t.items){let t=Wf(e,i,n);t>r&&(r=t)}return r}else if(q(t)){let r=Wf(e,t.key,n),i=Wf(e,t.value,n);return Math.max(r,i)}return 1}const Gf=e=>!e||typeof e!=`function`&&typeof e!=`object`;var X=class extends Hf{constructor(e){super(_f),this.value=e}toJSON(e,t){return t?.keep?this.value:Vf(this.value,e,t)}toString(){return String(this.value)}};X.BLOCK_FOLDED=`BLOCK_FOLDED`,X.BLOCK_LITERAL=`BLOCK_LITERAL`,X.PLAIN=`PLAIN`,X.QUOTE_DOUBLE=`QUOTE_DOUBLE`,X.QUOTE_SINGLE=`QUOTE_SINGLE`;function Kf(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function qf(e,t,n){if(xf(e)&&(e=e.contents),Y(e))return e;if(q(e)){let t=n.schema[hf].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??=i(e),new Uf(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=`tag:yaml.org,2002:`+t.slice(2));let l=Kf(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new X(e);return c&&(c.node=t),t}l=e instanceof Map?o[hf]:Symbol.iterator in Object(e)?o[vf]:o[hf]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new X(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Jf(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return qf(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}const Yf=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var Xf=class extends Hf{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Y(t)||q(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Yf(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(wf(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Jf(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(wf(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&J(i)?i.value:i:wf(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!q(t))return!1;let n=t.value;return n==null||e&&J(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return wf(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(wf(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Jf(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}};const Zf=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Qf(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const $f=(e,t,n)=>e.endsWith(`
|
|
5
|
+
`)?Qf(n,t):n.includes(`
|
|
6
|
+
`)?`
|
|
7
|
+
`+Qf(n,t):(e.endsWith(` `)?``:` `)+n,ep=`flow`;function tp(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,ee=-1;n===`block`&&(h=np(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}ee=h}if(r===`
|
|
8
|
+
`)n===`block`&&(h=np(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
9
|
+
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
10
|
+
`&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>ee+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let _=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?_=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(_+=`${e[i]}\\`),_+=`\n${t}${e.slice(i+1,a)}`)}return _}function np(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
11
|
+
`);r=t,i=t+1,a=e[i]}return r}const rp=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),ip=e=>/^(%|---|\.\.\.)/m.test(e);function ap(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
12
|
+
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function op(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(ip(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
13
|
+
|
|
14
|
+
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
15
|
+
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:tp(o,a,`quoted`,rp(t,!1))}function sp(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return op(e,t);let n=t.indent||(ip(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:tp(r,n,ep,rp(t,!1))}function cp(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=op;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?sp:i&&!t?op:n?sp:op}return r(e,t)}let lp;try{lp=RegExp(`(^|(?<!
|
|
17
|
+
))
|
|
18
|
+
+(?!
|
|
19
|
+
|$)`,`g`)}catch{lp=/\n+(?!\n|$)/g}function up({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return cp(n,r);let l=r.indent||(r.forceBlockIndent||ip(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===X.BLOCK_FOLDED?!1:t===X.BLOCK_LITERAL||!ap(n,c,l.length);if(!n)return u?`|
|
|
20
|
+
`:`>
|
|
21
|
+
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
22
|
+
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
23
|
+
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
24
|
+
`&&(p=p.slice(0,-1)),p.replace(lp,`$&${l}`));let h=!1,g,ee=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
25
|
+
`)ee=g;else break}let _=n.substring(0,ee<g?ee+1:g);_&&=(n=n.substring(_.length),_.replace(/\n+/g,`$&${l}`));let te=(h?l?`2`:`1`:``)+d;if(e&&(te+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
|
|
26
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=rp(r,!0);o!==`folded`&&t!==X.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=tp(`${_}${e}${p}`,l,`block`,a);if(!i)return`>${te}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${te}\n${l}${_}${n}${p}`}function dp(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
27
|
+
`)||u&&/[[\]{},]/.test(a))return cp(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
28
|
+
`)?cp(a,t):up(e,t,n,r);if(!s&&!u&&i!==X.PLAIN&&a.includes(`
|
|
29
|
+
`))return up(e,t,n,r);if(ip(a)){if(c===``)return t.forceBlockIndent=!0,up(e,t,n,r);if(s&&c===l)return cp(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return cp(a,t)}return s?d:tp(d,c,ep,rp(t,!1))}function fp(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==X.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=X.QUOTE_DOUBLE);let c=e=>{switch(e){case X.BLOCK_FOLDED:case X.BLOCK_LITERAL:return i||a?cp(o.value,t):up(o,t,n,r);case X.QUOTE_DOUBLE:return op(o.value,t);case X.QUOTE_SINGLE:return sp(o.value,t);case X.PLAIN:return dp(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function pp(e,t){let n=Object.assign({blockQuote:!0,commentString:Zf,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function mp(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(J(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function hp(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(J(e)||wf(e))&&e.anchor;a&&zf(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function gp(e,t,n,r){if(q(e))return e.toString(t,n,r);if(bf(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=Y(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=mp(t.doc.schema.tags,a);let o=hp(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):J(a)?fp(a,t,n,r):a.toString(t,n,r);return o?J(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function _p({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=Y(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(wf(e)||!Y(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||wf(e)||(J(e)?e.type===X.BLOCK_FOLDED||e.type===X.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=gp(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=$f(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=$f(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=$f(g,n.indent,l(f))));let ee,_,te;Y(t)?(ee=!!t.spaceBefore,_=t.commentBefore,te=t.comment):(ee=!1,_=null,te=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&J(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Cf(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let ne=!1,re=gp(t,n,()=>ne=!0,()=>h=!0),ie=` `;if(f||ee||_){if(ie=ee?`
|
|
30
|
+
`:``,_){let e=l(_);ie+=`\n${Qf(e,n.indent)}`}re===``&&!n.inFlow?ie===`
|
|
31
|
+
`&&te&&(ie=`
|
|
32
|
+
|
|
33
|
+
`):ie+=`\n${n.indent}`}else if(!p&&wf(t)){let e=re[0],r=re.indexOf(`
|
|
34
|
+
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=re.indexOf(` `);e===`&`&&n!==-1&&n<r&&re[n+1]===`!`&&(n=re.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(ie=`\n${n.indent}`)}}else(re===``||re[0]===`
|
|
35
|
+
`)&&(ie=``);return g+=ie+re,n.inFlow?ne&&r&&r():te&&!ne?g+=$f(g,n.indent,l(te)):h&&i&&i(),g}function vp(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}const yp={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new X(Symbol(`<<`)),{addToJSMap:xp}),stringify:()=>`<<`},bp=(e,t)=>(yp.identify(t)||J(t)&&(!t.type||t.type===X.PLAIN)&&yp.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===yp.tag&&e.default);function xp(e,t,n){let r=Cp(e,n);if(Cf(r))for(let n of r.items)Sp(e,t,n);else if(Array.isArray(r))for(let n of r)Sp(e,t,n);else Sp(e,t,r)}function Sp(e,t,n){let r=Cp(e,n);if(!Sf(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function Cp(e,t){return e&&bf(t)?t.resolve(e.doc,e):t}function wp(e,t,{key:n,value:r}){if(Y(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(bp(e,n))xp(e,t,r);else{let i=Vf(n,``,e);if(t instanceof Map)t.set(i,Vf(r,i,e));else if(t instanceof Set)t.add(i);else{let a=Tp(n,i,e),o=Vf(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Tp(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(Y(e)&&n?.doc){let t=pp(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),vp(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function Ep(e,t,n){return new Dp(qf(e,void 0,n),qf(t,void 0,n))}var Dp=class e{constructor(e,t=null){Object.defineProperty(this,yf,{value:gf}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return Y(n)&&(n=n.clone(t)),Y(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return wp(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?_p(this,e,t,n):JSON.stringify(this)}};function Op(e,t,n){return(t.inFlow??e.flow?Ap:kp)(e,t,n)}function kp({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(Y(i))!d&&i.spaceBefore&&f.push(``),jp(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(q(i)){let e=Y(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),jp(n,f,e.commentBefore,d))}d=!1;let s=gp(i,u,()=>o=null,()=>d=!0);o&&(s+=$f(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
36
|
+
`}}return e?(p+=`
|
|
37
|
+
`+Qf(l(e),c),s&&s()):d&&o&&o(),p}function Ap({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Y(i))i.spaceBefore&&d.push(``),jp(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(q(i)){let e=Y(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),jp(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Y(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=gp(i,c,()=>a=null);l||=d.length>u||o.includes(`
|
|
38
|
+
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=$f(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
39
|
+
`;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function jp({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Qf(t(r),e);n.push(i.trimStart())}}function Mp(e,t){let n=J(t)?t.value:t;for(let r of e)if(q(r)&&(r.key===t||r.key===n||J(r.key)&&r.key.value===n))return r}var Np=class extends Xf{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(hf,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Ep(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=q(e)?e:!e||typeof e!=`object`||!(`key`in e)?new Dp(e,e?.value):new Dp(e.key,e.value);let r=Mp(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);J(r.value)&&Gf(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=Mp(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=Mp(this.items,e)?.value;return(!t&&J(n)?n.value:n)??void 0}has(e){return!!Mp(this.items,e)}set(e,t){this.add(new Dp(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)wp(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!q(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Op(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const Pp={collection:`map`,default:!0,nodeClass:Np,tag:`tag:yaml.org,2002:map`,resolve(e,t){return Sf(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>Np.from(e,t,n)};var Fp=class extends Xf{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(vf,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Ip(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=Ip(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&J(r)?r.value:r}has(e){let t=Ip(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=Ip(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];J(r)&&Gf(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(Vf(e,String(r++),t));return n}toString(e,t,n){return e?Op(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(qf(a,void 0,n))}}return i}};function Ip(e){let t=J(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}const Lp={collection:`seq`,default:!0,nodeClass:Fp,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Cf(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Fp.from(e,t,n)};function Rp(e){return typeof e==`bigint`||Number.isInteger(e)}const zp=({value:e})=>JSON.stringify(e),Bp=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:zp},{identify:e=>e==null,createNode:()=>new X(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:zp},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:zp},{identify:Rp,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Rp(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:zp}];[Pp,Lp].concat(Bp,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function Vp(e,t,n){let{replacer:r}=n,i=new Fp(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e))if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Ep(o,s,n))}return i}var Hp=class e extends Fp{constructor(){super(),this.add=Np.prototype.add.bind(this),this.delete=Np.prototype.delete.bind(this),this.get=Np.prototype.get.bind(this),this.has=Np.prototype.has.bind(this),this.set=Np.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(q(e)?(r=Vf(e.key,``,t),i=Vf(e.value,r,t)):r=Vf(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=Vp(e,t,n),i=new this;return i.items=r.items,i}};Hp.tag=`tag:yaml.org,2002:omap`;var Up=class e extends Np{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=q(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new Dp(e.key,null):new Dp(e,null),Mp(this.items,t.key)||this.items.push(t)}get(e,t){let n=Mp(this.items,e);return!t&&q(n)?J(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Mp(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Dp(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Ep(e,null,n));return i}};Up.tag=`tag:yaml.org,2002:set`;const Wp=Symbol(`break visit`),Gp=Symbol(`skip children`),Kp=Symbol(`remove item`);function qp(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),Jp(Object.freeze([]),e,t)}qp.BREAK=Wp,qp.SKIP=Gp,qp.REMOVE=Kp,qp.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},qp.parentCollection=(e,t)=>{let n=qp.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function Jp(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=Jp(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===Wp)return Wp;else r===Kp&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}t(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},ee=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],_=/(^|\\\/)?\\\*$/,te=`regex`,ne=`checkRegex`,re={[te](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[ne](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},ie=e=>ee.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),ae=e=>typeof e==`string`,oe=e=>e&&ae(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,se=e=>e.split(s).filter(Boolean);var ce=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(te,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(ne,e)}_make(e,t){let n=this.regexPrefix.replace(_,re[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let le=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=ie(i);return new ce(e,t,i,n,r,s)};var ue=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(ae(e)&&(e={pattern:e}),oe(e.pattern)){let t=le(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(ae(e)?se(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let de=(e,t)=>{throw new t(e)},v=(e,t,n)=>ae(e)?e?!v.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),fe=e=>c.test(e);v.isNotRelative=fe,v.convert=e=>e;var pe=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new ue(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&v.convert(e);return v(i,e,this._strictPathCheck?de:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,ne)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,te);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,te)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let me=e=>new pe(e),he=e=>v(e&&v.convert(e),e,m),ge=()=>{v.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;v.isNotRelative=t=>e.test(t)||fe(t)};typeof process<`u`&&process.platform===`win32`&&ge(),t.exports=me,me.default=me,t.exports.isPathValid=he,f(t.exports,Symbol.for(`setupWindows`),ge)}))(),globalThis.Buffer,A({command:Or({description:`Bash command to execute`}),timeout:Bt(wr({description:`Timeout in seconds (optional, no default timeout)`}))});var Yp=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends Yp{};function Xp(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Zp(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Qp(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function $p(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function em(e,t){return Qp(e,t,``)}function tm(e,t){return $p(e,t,``)}function nm(e,t){return t.slice(0,rm(e,t))}function rm(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function im(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function am(e,t){if(t)return sm(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function om(e,t){if(t)return sm(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function sm(e,t){if(!t)return[om(e),am(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=im(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}const cm=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,lm=RegExp(`[${cm}]+|\\s+|[^${cm}]`,`ug`);new class extends Yp{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=im(e,r)}else n=e.match(lm)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&um(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&um(n,i,r,null,t.intlSegmenter),e}};function um(e,t,n,r,i){if(t&&n){let[a,o]=sm(t.value,i),[s,c]=sm(n.value,i);if(e){let r=Xp(a,s);e.value=$p(e.value,s,r),t.value=em(t.value,r),n.value=em(n.value,r)}if(r){let e=Zp(o,c);r.value=Qp(r.value,c,e),t.value=tm(t.value,e),n.value=tm(n.value,e)}}else if(n){if(e){let e=om(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=om(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=om(r.value,i),[a,o]=sm(t.value,i),s=Xp(n,a);t.value=em(t.value,s);let c=Zp(em(n,s),o);t.value=tm(t.value,c),r.value=Qp(r.value,n,c),e.value=$p(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=om(r.value,i),n=nm(am(t.value,i),e);t.value=tm(t.value,n)}else if(e){let n=nm(am(e.value,i),om(t.value,i));t.value=em(t.value,n)}}new class extends Yp{tokenize(e){let t=RegExp(`(\\r?\\n)|[${cm}]+|[^\\S\\n\\r]+|[^${cm}]`,`ug`);return e.match(t)||[]}},new class extends Yp{constructor(){super(...arguments),this.tokenize=dm}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
40
|
+
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
41
|
+
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
42
|
+
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
43
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function dm(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
44
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function fm(e){return e==`.`||e==`!`||e==`?`}new class extends Yp{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(fm(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends Yp{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends Yp{constructor(){super(...arguments),this.tokenize=dm}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(pm(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function pm(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=pm(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=pm(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends Yp{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};const mm=A({oldText:Or({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:Or({description:`Replacement text for this targeted edit.`})},{});A({path:Or({description:`Path to the file to edit (relative or absolute)`}),edits:Yt(mm,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),A({path:Or({description:`Path to the file to read (relative or absolute)`}),offset:Bt(wr({description:`Line number to start reading from (1-indexed)`})),limit:Bt(wr({description:`Maximum number of lines to read`}))}),A({path:Or({description:`Path to the file to write (relative or absolute)`}),content:Or({description:`Content to write to the file`})});const hm=m({portName:`secrets.crud`,panelRpcOp:`secrets-bridge`,timeoutMs:1e4,onUnavailable:`resolve-undefined`,makeError:e=>Error(e),logNamespace:`secrets-bridge`,toPortMessage:({type:e,payload:t})=>({type:e,...t}),toPanelRpcPayload:({type:e,payload:t})=>({type:e,payload:t})});function gm(e,t){return hm({type:e,payload:t})}const _m=n(`secret-scrub`),vm=async e=>e;function ym(){let e=le();return e===`extension-direct`?async e=>{if(!e)return e;try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.scrub-tool-result`,text:e},e=>t(e??{}))});return t.error?(_m.debug(`SW scrub-tool-result returned error`,{error:t.error}),e):typeof t.text==`string`?t.text:e}catch(t){return _m.debug(`SW scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}:e===`extension-delegate`?async e=>{if(!e)return e;try{let t=await gm(`secrets.scrub-tool-result`,{text:e});return t?.error?(_m.debug(`Bridge scrub-tool-result returned error`,{error:t.error}),e):typeof t?.text==`string`?t.text:e}catch(t){return _m.debug(`Bridge scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}:e===`connect`?vm:async e=>{if(!e)return e;try{let t=await fetch(l(`/api/secrets/scrub`),{method:`POST`,headers:u({"content-type":`application/json`}),body:JSON.stringify({text:e})});if(!t.ok)return _m.debug(`Server scrub-tool-result returned non-ok`,{status:t.status}),e;let n=await t.json();return typeof n.text==`string`?n.text:e}catch(t){return _m.debug(`Server scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}}const bm=n(`tool-adapter`);function xm(e){let t=[],n=0;for(let r of e.matchAll(ee())){let i=h(r[0]);if(!i)continue;let a=e.slice(n,r.index);a.trim()&&t.push({type:`text`,text:a.trimEnd()}),t.push({type:`image`,mimeType:i.mimeType,data:i.data}),n=r.index+r[0].length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function Sm(e){let t=xm(e),n=[];for(let e of t)e.type===`image`?n.push(await g(e)):n.push(e);return n}function Cm(e,t,n,r){if(!r)return{tracked:null,effectiveSignal:n};let i=r.processManager.spawn({kind:`tool`,argv:[e.name,...km(t)],owner:r.owner,ppid:r.getParentPid?.()});n?.aborted?r.processManager.signal(i.pid,`SIGINT`):n&&n.addEventListener(`abort`,()=>r.processManager.signal(i.pid,`SIGINT`),{once:!0});let a=r.processManager.onSignal((e,t)=>{e.pid!==i.pid||t!==`SIGKILL`||r.processManager.exit(i.pid,null)});return{tracked:{record:i,manager:r.processManager,unsubscribeKill:a},effectiveSignal:i.abort.signal}}function wm(e,t){e&&e.manager.exit(e.record.pid,t)}async function Tm(e,t,n){if(!n||typeof e!=`string`||e.length===0)return e;try{return await n.scrubToolResult(e)}catch(n){return bm.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:t,error:n instanceof Error?n.message:String(n)}),e}}async function Em(e,t){try{return await Sm(e)}catch(n){return bm.warn(`Image processing failed, falling back to raw content`,{tool:t,error:n instanceof Error?n.message:String(n)}),xm(e)}}function Dm(e,t,n){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,async execute(r,i,a,o){let s;o&&(s=f({onUpdate:o,toolName:e.name,toolCallId:r}));let c=Cm(e,i,a,t);try{let t=await e.execute(i??{},c.effectiveSignal),r=await Em(await Tm(t.content,e.name,n),e.name);return wm(c.tracked,+!!t.isError),{content:r,details:{isError:t.isError}}}catch(e){throw wm(c.tracked,c.tracked?.record.abort.signal.aborted?null:1),e}finally{s&&p(s),c.tracked?.unsubscribeKill()}}}}function Om(e,t,n){return e.map(e=>Dm(e,t,n))}function km(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}function Am(e,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=re(e);if(!r)return n;let i;for(let e of t.values()){let t=re(e.id);!t||t.family!==r.family||(!i||t.major>i.major||t.major===i.major&&t.minor>i.minor)&&(i={major:t.major,minor:t.minor,cost:e.cost})}return i?.cost??n}var jm=e({ACCOUNTS_KEY:()=>Pm,__test__:()=>Um,addAccount:()=>lh,applyProviderDefaults:()=>Qm,clearAllSettings:()=>Nh,clearApiKey:()=>Oh,clearBaseUrl:()=>jh,clearSelectedProvider:()=>Th,exportProviders:()=>Mh,getAccounts:()=>Q,getAllAvailableModels:()=>nh,getAllExtraOAuthDomains:()=>oh,getApiKey:()=>Eh,getApiKeyForProvider:()=>_h,getApiVersionForProvider:()=>bh,getAvailableProviders:()=>Wm,getBaseUrl:()=>kh,getBaseUrlForProvider:()=>vh,getDeploymentForProvider:()=>yh,getExtraOAuthDomains:()=>rh,getOAuthAccountInfo:()=>Xm,getProviderConfig:()=>qm,getProviderModels:()=>Ym,getRawApiKeyForProvider:()=>gh,getSelectedModelId:()=>xh,getSelectedProvider:()=>$,isModelHiddenFromPicker:()=>eh,logoutOAuthAccount:()=>fh,maskOAuthTokenWithRetry:()=>ph,migrateLegacyAuthOnlySelection:()=>Vm,persistOAuthMaskViaServiceWorker:()=>mh,providerOffersLlmModels:()=>Gm,removeAccount:()=>dh,resolveCurrentModel:()=>Rh,resolveModelById:()=>Lh,resolveModelByShorthand:()=>zh,resolveModelIdForScoop:()=>Vh,saveOAuthAccount:()=>hh,setApiKey:()=>Dh,setBaseUrl:()=>Ah,setExtraOAuthDomains:()=>ih,setExtraOAuthDomainsAsync:()=>ah,setSelectedModelId:()=>Sh,setSelectedProvider:()=>wh});const Mm=te,Nm=ne,Pm=`slicc_accounts`,Fm=`selected-model`,Im=[`slicc_provider`,`slicc_api_key`,`slicc_base_url`,`anthropic_api_key`,`api_provider`,`azure_resource`,`bedrock_region`],Lm=new Set([`github`]);function Rm(e){let t;try{t=_()}catch{return!1}return t.includes(e)&&!o(e)}let zm=!1;function Bm(){if(!zm){zm=!0;for(let e of Im)try{localStorage.removeItem(e)}catch{}Vm()}}function Vm(){try{let e=localStorage.getItem(Fm);if(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);(Lm.has(n)||Rm(n))&&localStorage.removeItem(Fm)}}}catch{}try{let e=localStorage.getItem(Pm);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let n=t.filter(e=>!(typeof e==`object`&&e&&typeof e.providerId==`string`&&Rm(e.providerId)));n.length!==t.length&&localStorage.setItem(Pm,JSON.stringify(n))}catch{}}function Hm(){zm=!1}const Um={_resetLegacyCleanup:Hm};function Wm(){let e=_().filter(o),t=a();return[...new Set([...e,...t])].filter(e=>!s(e)?.hidden)}function Gm(e){try{if(Ym(e).length>0)return!0}catch{}try{if(ne(e).length>0)return!0}catch{}let t=s(e);return!!(t?.modelOverrides&&Object.keys(t.modelOverrides).length>0)}function Km(e,t){try{if(Ym(e).some(e=>e.id===t))return!0}catch{}try{if(ne(e).some(e=>e.id===t))return!0}catch{}let n=s(e);return!!(n?.modelOverrides&&Object.hasOwn(n.modelOverrides,t))}function qm(e){return s(e)||{id:e,name:e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),description:`${e} provider`,requiresApiKey:!0,requiresBaseUrl:!1}}function Jm(e,t){t.context_window!==void 0&&(e.contextWindow=t.context_window),t.max_tokens!==void 0&&(e.maxTokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),t.cost!==void 0&&(e.cost=t.cost,e.inputCost=t.cost.input,e.outputCost=t.cost.output,e.cacheReadCost=t.cost.cacheRead,e.cacheWriteCost=t.cost.cacheWrite),t.compat!==void 0&&(e.compat={...e.compat??{},...t.compat}),t.thinkingLevelMap!==void 0&&(e.thinkingLevelMap={...e.thinkingLevelMap??{},...t.thinkingLevelMap})}function Ym(e){try{if(e===`bedrock-camp`){let e=ae(vh(`bedrock-camp`));return Nm(`amazon-bedrock`).filter(t=>ie(t,e)).map(e=>({...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`}))}let t=qm(e);if(t.getModelIds){let n;try{n=t.getModelIds()}catch(t){return Z.error(`Provider getModelIds callback failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}let r=new Map;for(let e of _())try{for(let t of Nm(e))r.set(t.id,t)}catch{}return n.map(n=>{let i=n.api===`openai`?`openai`:`anthropic`,a=`${e}-${i}`,o=r.get(n.id),s;if(o)s={...o,api:a,provider:e};else if(s=Fh(e,n.id,``,a),n.name&&(s.name=n.name),i===`anthropic`){let e=Am(n.id,r);s.cost=e,s.inputCost=e.input,s.outputCost=e.output,s.cacheReadCost=e.cacheRead,s.cacheWriteCost=e.cacheWrite}let c=t.modelOverrides?.[n.id];return c&&Jm(s,c),Jm(s,n),s})}if(t.isOAuth){let n=Nm(`anthropic`),r=`${e}-anthropic`;return n.map(n=>{let i={...n,api:r,provider:e},a=t.modelOverrides?.[n.id];return a&&Jm(i,a),i})}return Nm(e===`azure-ai-foundry`?`anthropic`:e)}catch(t){return Z.error(`Failed to load models`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}}function Xm(e){let t=Q().find(t=>t.providerId===e);if(!t?.accessToken)return null;let n=!!t.tokenExpiresAt&&Date.now()>t.tokenExpiresAt-6e4;return{token:t.accessToken,maskedValue:t.maskedValue,expiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar,expired:n}}const Zm=Object.assign({})[`/packages/webapp/providers.json`]??[],Z=n(`provider-settings`);function Qm(e=Zm){if(e.length===0||Q().length>0)return;let t=new Set(Wm());for(let n of e)if(!(!n.providerId||!n.apiKey)){if(!t.has(n.providerId)){Z.warn(`Unknown provider "${n.providerId}" in providers.json — skipping`);continue}lh(n.providerId,n.apiKey,n.baseUrl)}let n=e.find(e=>e.providerId&&e.apiKey&&t.has(e.providerId));n?.model&&!localStorage.getItem(Fm)&&localStorage.setItem(Fm,`${n.providerId}:${n.model}`)}const $m=[/haiku/i];function eh(e){return $m.some(t=>t.test(e))}function th(e){return e.filter(e=>!eh(e.id))}function nh(){let e=Q();if(e.length===0)return[];let t=new Map;for(let n of e){if(t.has(n.providerId))continue;let e=qm(n.providerId);if(e.hidden||Rm(n.providerId))continue;let r=th(Ym(n.providerId));if(r.length===0)continue;let i={providerId:n.providerId,providerName:e.name,models:r};t.set(n.providerId,i)}return[...t.values()]}function Q(){Bm();let e=localStorage.getItem(Pm);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.providerId==`string`&&typeof e.apiKey==`string`):[]}catch{return[]}}function rh(e){return se(localStorage)[e]??[]}function ih(e,t){let n=se(localStorage),r=t.map(e=>e.trim()).filter(e=>e.length>0);r.length===0?delete n[e]:n[e]=r,ce(localStorage,n)}async function ah(e,t){if(i()){ih(e,t);return}let n=r();if(!n)throw Error(`setExtraOAuthDomainsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let{storeAfter:a}=await n.call(`oauth-extras-set`,{providerId:e,domains:t});try{ce(localStorage,a)}catch(t){Z.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{providerId:e,error:t instanceof Error?t.message:String(t)})}}function oh(){return se(localStorage)}function sh(e){localStorage.setItem(Pm,JSON.stringify(e))}async function ch(e){if(i()){sh(e);return}let t=r();if(!t)throw Error(`saveAccountsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let n=JSON.stringify(e),{storedJson:a}=await t.call(`save-oauth-accounts`,{accountsJson:n});try{localStorage.setItem(Pm,a)}catch(e){Z.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{error:e instanceof Error?e.message:String(e)})}}function lh(e,t,n,r,i){let a=Q().filter(t=>t.providerId!==e),o={providerId:e,apiKey:t};n&&(o.baseUrl=n),r&&(o.deployment=r),i&&(o.apiVersion=i),a.push(o),sh(a)}async function uh(e){let t=le();try{if(t===`extension-direct`){let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.delete`,name:`oauth.${e}.token`},n=>{chrome.runtime.lastError&&Z.error(`SW secrets.delete transport failed`,{providerId:e,error:chrome.runtime.lastError.message}),t(n??{})})});t.error&&Z.error(`SW secrets.delete returned error`,{providerId:e,error:t.error})}else if(t===`extension-delegate`){let t=await gm(`secrets.delete`,{name:`oauth.${e}.token`});t?.error&&Z.error(`Bridge secrets.delete returned error`,{providerId:e,error:t.error})}else if(t!==`connect`){let t=await fetch(l(`/api/secrets/oauth/${e}`),{method:`DELETE`,headers:u()});!t.ok&&t.status!==404&&Z.warn(`OAuth replica DELETE non-ok`,{providerId:e,status:t.status})}}catch(n){Z.error(`OAuth replica removal failed`,{providerId:e,topology:t,error:n instanceof Error?n.message:String(n)})}}async function dh(e){let t=Q().find(t=>t.providerId===e),n=qm(e);t&&n?.isOAuth&&await fh(e),await uh(e),await ch(Q().filter(t=>t.providerId!==e));let r=localStorage.getItem(Fm)??``,i=r.indexOf(`:`);i>0&&r.slice(0,i)===e&&localStorage.removeItem(Fm)}async function fh(e){let t=Q().find(t=>t.providerId===e);if(!t)return;let n=qm(e);if(n?.isOAuth){if(n.onOAuthLogout)try{await n.onOAuthLogout()}catch(t){Z.warn(`onOAuthLogout failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})}if(n.getOAuthLogoutUrl){let r=n.getOAuthLogoutUrl(t);if(r){let{openIdpLogoutUrl:t}=await import(`./oauth-service-bKcyWLK0.js`);await t(r).catch(t=>{Z.warn(`IdP logout popup failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})})}}await ch(Q().map(t=>t.providerId===e?{providerId:t.providerId,apiKey:``,baseUrl:t.baseUrl,userName:t.userName,userAvatar:t.userAvatar,loggedOut:!0}:t)),await uh(e)}}async function ph(e,t={}){let n=Math.max(1,t.attempts??3),r=t.delayMs??150,i=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),a;for(let t=0;t<n;t++){let o=await e();if(o.maskedValue)return{maskedValue:o.maskedValue};o.error&&(a=o.error),t<n-1&&await i(r)}return{lastError:a}}async function mh(e,t,n){let r={providerId:e.providerId,accessToken:e.accessToken,domains:e.domains.join(`,`)},{maskedValue:i,lastError:a}=await ph(()=>t.sendMaskRequest(r),n);if(!i){Z.error(`OAuth mask give-up: no masked value after retries`,{providerId:e.providerId,reason:a??`no error reported (cold SW or empty reply)`});return}let o=t.getAccounts(),s=o.find(t=>t.providerId===e.providerId);s&&(s.maskedValue=i,await t.saveAccounts(o))}async function hh(e){let t=Q().find(t=>t.providerId===e.providerId),n=Q().filter(t=>t.providerId!==e.providerId);n.push({providerId:e.providerId,apiKey:``,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar,baseUrl:e.baseUrl??t?.baseUrl}),await ch(n);let r=qm(e.providerId)?.oauthTokenDomains??[],i=rh(e.providerId),a=new Set,o=[];for(let e of[...r,...i]){let t=e.toLowerCase();a.has(t)||(a.add(t),o.push(e))}if(o.length===0)return;let s=le();try{if(s===`extension-direct`)await mh({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>new Promise(n=>{chrome.runtime.sendMessage({type:`secrets.mask-oauth-token`,...t},t=>{chrome.runtime.lastError&&Z.error(`SW mask-oauth-token transport failed`,{providerId:e.providerId,error:chrome.runtime.lastError.message});let r=typeof t==`object`&&t?t:void 0;r?.error&&Z.warn(`SW mask-oauth-token returned error`,{providerId:e.providerId,error:r.error}),n(r??{})})}),getAccounts:Q,saveAccounts:ch});else if(s===`extension-delegate`)await mh({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>gm(`secrets.mask-oauth-token`,t).then(t=>(t?.error&&Z.warn(`Bridge mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),t??{})).catch(t=>(Z.error(`Bridge mask-oauth-token transport failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)}),{})),getAccounts:Q,saveAccounts:ch});else if(s!==`connect`){let t=await fetch(l(`/api/secrets/oauth-update`),{method:`POST`,headers:u({"Content-Type":`application/json`}),body:JSON.stringify({providerId:e.providerId,accessToken:e.accessToken,domains:o})});if(t.ok){let n=await t.json();if(typeof n.maskedValue==`string`){let t=Q(),r=t.find(t=>t.providerId===e.providerId);r&&(r.maskedValue=n.maskedValue,await ch(t))}else Z.warn(`OAuth replica POST ok but missing maskedValue`,{providerId:e.providerId})}else Z.warn(`OAuth replica POST non-ok`,{providerId:e.providerId,status:t.status})}}catch(t){Z.error(`OAuth replica sync failed`,{providerId:e.providerId,topology:s,error:t instanceof Error?t.message:String(t)})}}function gh(e){let t=Q().find(t=>t.providerId===e);return t&&(t.accessToken||t.apiKey)||null}function _h(e){let t=Q().find(t=>t.providerId===e);return t?t.accessToken||t.apiKey||(qm(e).optionalApiKey?`local`:null):null}function vh(e){return Q().find(t=>t.providerId===e)?.baseUrl??null}function yh(e){return Q().find(t=>t.providerId===e)?.deployment??null}function bh(e){return Q().find(t=>t.providerId===e)?.apiVersion??null}function xh(){let e=localStorage.getItem(Fm)||``,t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function Sh(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t),r=new Set([...a(),...Wm()]),i=n.includes(`.`);if(r.has(n)||!i){localStorage.setItem(Fm,e);return}}let n=$();localStorage.setItem(Fm,`${n}:${e}`)}function Ch(){return localStorage.getItem(Fm)||``}function $(){let e=Ch(),t=e.indexOf(`:`);if(t>0)return e.slice(0,t);let n=Q(),r=xh();if(r){let e=n.find(e=>Gm(e.providerId)&&Km(e.providerId,r));if(e)return e.providerId}let i=n.find(e=>Gm(e.providerId));return i?i.providerId:n.length>0?n[0].providerId:`anthropic`}function wh(e){let t=xh();localStorage.setItem(Fm,`${e}:${t}`)}function Th(){let e=xh();localStorage.setItem(Fm,e)}function Eh(){return _h($())}function Dh(e){let t=$();lh(t,e,vh(t)??void 0)}async function Oh(){await dh($())}function kh(){return vh($())}function Ah(e){let t=$(),n=gh(t);n&&lh(t,n,e||void 0)}function jh(){let e=$(),t=gh(e);t&&lh(e,t)}function Mh(){let e=Q(),t=$(),n=xh();return e.map(e=>{let r={providerId:e.providerId,apiKey:e.apiKey};return e.baseUrl&&(r.baseUrl=e.baseUrl),e.providerId===t&&n&&(r.model=n),r})}async function Nh(){let e=Q();await Promise.allSettled(e.map(e=>dh(e.providerId))),localStorage.removeItem(Pm),localStorage.removeItem(Fm);for(let e of Im)localStorage.removeItem(e)}function Ph(e){return/^(?:gpt[-.]?|o[0-9]|chatgpt)/i.test(e)?`openai`:`anthropic`}function Fh(e,t,n,r){return{id:t,name:t,provider:e,api:r??`${e}-${Ph(t)}`,baseUrl:n??``,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},reasoning:!0}}function Ih(e,t){return t.isOAuth||e===`azure-ai-foundry`?`anthropic`:e===`bedrock-camp`?`amazon-bedrock`:e}function Lh(e){if(!e)return Rh();let t=$(),n=vh(t),r=qm(t);try{let i=Ih(t,r),a=Mm(i,e);if(!a?.id)throw Error(`Model ${e} not found`);let o=a;return r.isOAuth?o=Ym(t).find(t=>t.id===e)||{...o,api:`${t}-anthropic`,provider:t}:t===`bedrock-camp`&&(o={...o,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(o={...o,baseUrl:n}),o}catch(i){if(Z.debug(`resolveModelById: pi-ai lookup miss, using provider fallback`,{providerId:t,modelId:e,error:i instanceof Error?i.message:String(i)}),r.isOAuth){let r=Ym(t).find(t=>t.id===e);return r?n?{...r,baseUrl:n}:r:Fh(t,e,n)}return Rh()}}function Rh(){let e=$(),t=xh(),n=vh(e),r=Ym(e),i=qm(e),a=i.defaultModelId?r.find(e=>e.id.toLowerCase().includes(i.defaultModelId.toLowerCase()))?.id:void 0,o=t||a||r[0]?.id||`claude-sonnet-4-6`;try{let t=Ih(e,i),a=Mm(t,o);if(!a?.id)throw Error(`Model ${o} not found in ${t} registry`);let s=a;return i.isOAuth?s=r.find(e=>e.id===o)||{...s,api:`${e}-anthropic`,provider:e}:e===`bedrock-camp`&&(s={...s,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(s={...s,baseUrl:n}),s}catch(t){Z.debug(`resolveCurrentModel: pi-ai lookup miss, using provider fallback`,{providerId:e,effectiveModelId:o,error:t instanceof Error?t.message:String(t)});let a=r.find(e=>e.id===o);return a?n?{...a,baseUrl:n}:a:i.isOAuth?Fh(e,o,n):Mm(`anthropic`,`claude-sonnet-4-0`)}}function zh(e){let t=e.toLowerCase();if(!t)return null;let n=null;try{n=$()}catch{}if(n!==null){let e=Bh(t,[n]);if(e!==null)return e}return Bh(t,Q().map(e=>e.providerId))}function Bh(e,t){let n=null,r=-1;for(let i of t)for(let t of Ym(i)){let i=t.id.toLowerCase(),a=(t.name??``).toLowerCase();if(!i.includes(e)&&!a.includes(e))continue;let o=t.contextWindow??0;(o>r||o===r&&Hh(t.id,n??``)>0)&&(r=o,n=t.id)}return n}function Vh(e){if(!e)return null;let t=[e],n=zh(e);n!==null&&n!==e&&t.push(n);let r=[];try{r=Ym($())}catch{}for(let n of t)if(!(r.length>0&&!r.some(e=>e.id===n)))try{if(Lh(n).id===n)return n}catch(t){Z.debug(`resolveModelIdForScoop: candidate did not resolve`,{input:e,candidate:n,error:t instanceof Error?t.message:String(t)})}return null}function Hh(e,t){let n=e.match(/\d+/g)?.map(Number)??[],r=t.match(/\d+/g)?.map(Number)??[],i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}export{ac as $,Qe as $t,ph as A,w as An,Cn as At,Dh as B,nn as Bt,qm as C,y as Cn,or as Ct,$ as D,Re as Dn,kn as Dt,xh as E,Le as En,An as Et,Rh as F,A as Ft,wh as G,Vt as Gt,ih as H,Xt as Ht,Lh as I,mn as It,ym as J,St as Jt,Am as K,Nt as Kt,zh as L,ln as Lt,mh as M,Te as Mn,N as Mt,Gm as N,ue as Nn,M as Nt,eh as O,Ze as On,P as Ot,dh as P,le as Pn,j as Pt,cd as Q,$e as Qt,Vh as R,cn as Rt,Xm as S,Fe as Sn,sr as St,gh as T,b as Tn,rr as Tt,ah as U,qt as Ut,Ah as V,$t as Vt,Sh as W,Jt as Wt,ff as X,dt as Xt,gm as Y,ft as Yt,sf as Z,ct as Zt,Wm as _,Be as _n,yr as _t,Qm as a,Oe as an,qi as at,yh as b,Ue as bn,fr as bt,jh as c,Ae as cn,Kr as ct,Q as d,je as dn,Dr as dt,Ye as en,lo as et,nh as f,He as fn,Tr as ft,bh as g,Ve as gn,vr as gt,_h as h,Ne as hn,_r as ht,lh as i,De as in,Gi as it,Vm as j,et as jn,bn as jt,fh as k,Ge as kn,En as kt,Th as l,it as ln,kr as lt,Eh as m,Me as mn,R as mt,Um as n,C as nn,$i as nt,Nh as o,ke as on,z as ot,oh as p,ze as pn,Sr as pt,Om as q,Et as qt,jm as r,Ee as rn,Ji as rt,Oh as s,We as sn,$r as st,Pm as t,Xe as tn,ea as tt,Mh as u,x as un,Or as ut,kh as v,qe as vn,br as vt,Ym as w,Ie as wn,ir as wt,rh as x,Pe as xn,ur as xt,vh as y,Je as yn,L as yt,hh as z,on as zt};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-Dk3L2UWh.js","assets/preload-helper-Czpn1I53.js","assets/proxied-fetch-CfcFb0B0.js","assets/rolldown-runtime-aKtaBQYM.js","assets/base64-DpPqYZJF.js","assets/src-DoFhVmQT.js","assets/runtime-env-DH4NDw4t.js","assets/fetch-body-D2PwksUW.js","assets/panel-rpc-DmJSNs0I.js","assets/wc-permissions-registry-Blyunq37.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{i as r,n as i,r as a}from"./compat-CkpNnFQS.js";import"./context-compaction-C3e7rcEG.js";import{t as o}from"./logger-DDBAeTLF.js";import"./src-DoFhVmQT.js";import{o as s,t as c}from"./proxied-fetch-CfcFb0B0.js";import{t as l}from"./secret-topology-Baeul5rD.js";import{t as u}from"./secrets-bridge-client-CLRo0NLf.js";import"./tool-ui-DfXu6quJ.js";import{n as d,o as f,t as p}from"./providers-
|
|
2
|
+
import{n as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./preload-helper-Czpn1I53.js";import{i as r,n as i,r as a}from"./compat-CkpNnFQS.js";import"./context-compaction-C3e7rcEG.js";import{t as o}from"./logger-DDBAeTLF.js";import"./src-DoFhVmQT.js";import{o as s,t as c}from"./proxied-fetch-CfcFb0B0.js";import{t as l}from"./secret-topology-Baeul5rD.js";import{t as u}from"./secrets-bridge-client-CLRo0NLf.js";import"./tool-ui-DfXu6quJ.js";import"./tool-result-images-BFdAnBEq.js";import{n as d,o as f,t as p}from"./providers-BU_CYZEQ.js";import{n as m,t as h}from"./panel-rpc-DmJSNs0I.js";import{c as g,r as _,t as v}from"./bedrock-camp-CJY4i7di.js";var y={assign:0,create:0,clone:0,discard:0,update:0};function b(e){return Array.isArray(e)}function x(e){return C(e,null)}function S(e){return C(typeof e,`object`)&&!x(e)}function C(e,t){return e===t}function ee(e){return C(e,`__proto__`)||C(e,`constructor`)||C(e,`prototype`)}function te(e,t){return ee(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function ne(e){return Object.getOwnPropertyNames(e)}function re(e){return S(e)&&te(e,`~guard`)}function ie(e){return e}function ae(e){return e.map(e=>ce(e))}function w(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let e of Object.keys(n)){let r=n[e];te(r,`value`)&&Object.defineProperty(t,e,{...r,value:ce(r.value)})}return t}function oe(e){return new RegExp(e.source,e.flags)}function se(e){return e}function ce(e){return e instanceof RegExp?oe(e):re(e)?ie(e):b(e)?ae(e):S(e)?w(e):se(e)}function le(e){return y.clone+=1,ce(e)}var ue={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1};function de(){return ue}function fe(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function pe(e,t){return{...e,...t}}function me(e,t,n={}){y.create+=1;let r=de(),i=pe(t,n),a=r.enumerableKind?pe(i,e):fe(i,e);return r.immutableTypes?Object.freeze(a):a}function he(e,t,n){y.update+=1;let r=de(),i=le(e);for(let e of Object.keys(t))Object.defineProperty(i,e,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[e]});for(let e of Object.keys(n))Object.defineProperty(i,e,{configurable:!0,enumerable:!0,writable:!0,value:n[e]});return i}function ge(e){return S(e)}function _e(e){return he(e,{"~optional":!0},{})}function ve(e){return _e(e)}function ye(e){return ge(e)&&te(e,`~optional`)}function be(e,t){return me({"~kind":`Array`},{type:`array`,items:e},t)}function xe(e){return ne(e).filter(t=>!ye(e[t]))}function Se(e,t={}){let n=xe(e);return me({"~kind":`Object`},{type:`object`,...n.length>0?{required:n}:{},properties:e},t)}var Ce;(function(e){e[e.Array=0]=`Array`,e[e.BigInt=1]=`BigInt`,e[e.Boolean=2]=`Boolean`,e[e.Date=3]=`Date`,e[e.Constructor=4]=`Constructor`,e[e.Function=5]=`Function`,e[e.Null=6]=`Null`,e[e.Number=7]=`Number`,e[e.Object=8]=`Object`,e[e.RegExp=9]=`RegExp`,e[e.String=10]=`String`,e[e.Symbol=11]=`Symbol`,e[e.TypeArray=12]=`TypeArray`,e[e.Undefined=13]=`Undefined`})(Ce||={}),Array.from({length:256}).map((e,t)=>BigInt(t));var we=new Float64Array(1);new DataView(we.buffer),new Uint8Array(we.buffer),new TextEncoder;var Te=`-?(?:0|[1-9][0-9]*)`,Ee=`-?(?:0|[1-9][0-9]*)(?:.[0-9]+)?`;function De(e){return me({"~kind":`Number`},{type:`number`},e)}function T(e){return me({"~kind":`String`},{type:`string`},e)}var Oe=`^${Te}$`;`${Ee}`;function ke(e,t){return Array.from({length:t-e+1},(t,n)=>String.fromCharCode(e+n))}var Ae=[...ke(97,122),...ke(65,90)],je=[`0`,...ke(49,57)];[...je],[...Ae,...je],[...je],new RegExp(Oe);var Me=Symbol.for(`yaml.alias`),Ne=Symbol.for(`yaml.document`),E=Symbol.for(`yaml.map`),Pe=Symbol.for(`yaml.pair`),Fe=Symbol.for(`yaml.scalar`),Ie=Symbol.for(`yaml.seq`),D=Symbol.for(`yaml.node.type`),Le=e=>!!e&&typeof e==`object`&&e[D]===Me,Re=e=>!!e&&typeof e==`object`&&e[D]===Ne,ze=e=>!!e&&typeof e==`object`&&e[D]===E,O=e=>!!e&&typeof e==`object`&&e[D]===Pe,k=e=>!!e&&typeof e==`object`&&e[D]===Fe,Be=e=>!!e&&typeof e==`object`&&e[D]===Ie;function A(e){if(e&&typeof e==`object`)switch(e[D]){case E:case Ie:return!0}return!1}function j(e){if(e&&typeof e==`object`)switch(e[D]){case Me:case E:case Fe:case Ie:return!0}return!1}var Ve=e=>(k(e)||A(e))&&!!e.anchor,M=Symbol(`break visit`),He=Symbol(`skip children`),N=Symbol(`remove node`);function Ue(e,t){let n=Ge(t);Re(e)?P(null,e.contents,n,Object.freeze([e]))===N&&(e.contents=null):P(null,e,n,Object.freeze([]))}Ue.BREAK=M,Ue.SKIP=He,Ue.REMOVE=N;function P(e,t,n,r){let i=Ke(e,t,n,r);if(j(i)||O(i))return qe(e,r,i),P(e,i,n,r);if(typeof i!=`symbol`){if(A(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=P(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===M)return M;else i===N&&(t.items.splice(e,1),--e)}}else if(O(t)){r=Object.freeze(r.concat(t));let e=P(`key`,t.key,n,r);if(e===M)return M;e===N&&(t.key=null);let i=P(`value`,t.value,n,r);if(i===M)return M;i===N&&(t.value=null)}}return i}async function We(e,t){let n=Ge(t);Re(e)?await F(null,e.contents,n,Object.freeze([e]))===N&&(e.contents=null):await F(null,e,n,Object.freeze([]))}We.BREAK=M,We.SKIP=He,We.REMOVE=N;async function F(e,t,n,r){let i=await Ke(e,t,n,r);if(j(i)||O(i))return qe(e,r,i),F(e,i,n,r);if(typeof i!=`symbol`){if(A(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await F(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===M)return M;else i===N&&(t.items.splice(e,1),--e)}}else if(O(t)){r=Object.freeze(r.concat(t));let e=await F(`key`,t.key,n,r);if(e===M)return M;e===N&&(t.key=null);let i=await F(`value`,t.value,n,r);if(i===M)return M;i===N&&(t.value=null)}}return i}function Ge(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Ke(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(ze(t))return n.Map?.(e,t,r);if(Be(t))return n.Seq?.(e,t,r);if(O(t))return n.Pair?.(e,t,r);if(k(t))return n.Scalar?.(e,t,r);if(Le(t))return n.Alias?.(e,t,r)}function qe(e,t,n){let r=t[t.length-1];if(A(r))r.items[e]=n;else if(O(r))e===`key`?r.key=n:r.value=n;else if(Re(r))r.contents=n;else{let e=Le(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var Je={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},Ye=e=>e.replace(/[!,[\]{}]/g,e=>Je[e]),Xe=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Ye(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&j(e.contents)){let t={};Ue(e.contents,(e,n)=>{j(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
3
3
|
`)}};Xe.defaultYaml={explicit:!1,version:`1.2`},Xe.defaultTags={"!!":`tag:yaml.org,2002:`};function Ze(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Qe(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=Qe(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=Qe(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=Qe(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=Qe(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function I(e,t,n){if(Array.isArray(e))return e.map((e,t)=>I(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Ve(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var $e=class{constructor(e){Object.defineProperty(this,D,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Re(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=I(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Qe(i,{"":o},``,o):o}},et=class extends $e{constructor(e){super(Me),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Ue(e,{Node:(e,t)=>{(Le(t)||Ve(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(I(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=tt(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Ze(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function tt(e,t,n){if(Le(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(A(t)){let r=0;for(let i of t.items){let t=tt(e,i,n);t>r&&(r=t)}return r}else if(O(t)){let r=tt(e,t.key,n),i=tt(e,t.value,n);return Math.max(r,i)}return 1}var nt=e=>!e||typeof e!=`function`&&typeof e!=`object`,L=class extends $e{constructor(e){super(Fe),this.value=e}toJSON(e,t){return t?.keep?this.value:I(this.value,e,t)}toString(){return String(this.value)}};L.BLOCK_FOLDED=`BLOCK_FOLDED`,L.BLOCK_LITERAL=`BLOCK_LITERAL`,L.PLAIN=`PLAIN`,L.QUOTE_DOUBLE=`QUOTE_DOUBLE`,L.QUOTE_SINGLE=`QUOTE_SINGLE`;var rt=`tag:yaml.org,2002:`;function it(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function at(e,t,n){if(Re(e)&&(e=e.contents),j(e))return e;if(O(e)){let t=n.schema[E].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??=i(e),new et(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=rt+t.slice(2));let l=it(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new L(e);return c&&(c.node=t),t}l=e instanceof Map?o[E]:Symbol.iterator in Object(e)?o[Ie]:o[E]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new L(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function ot(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return at(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var st=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,ct=class extends $e{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>j(t)||O(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(st(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(A(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,ot(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(A(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&k(i)?i.value:i:A(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!O(t))return!1;let n=t.value;return n==null||e&&k(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return A(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(A(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,ot(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},lt=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function ut(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var R=(e,t,n)=>e.endsWith(`
|
|
4
4
|
`)?ut(n,t):n.includes(`
|
|
5
5
|
`)?`
|
|
@@ -40,4 +40,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
40
40
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
41
41
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
42
42
|
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function xn(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
43
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Sn(e){return e==`.`||e==`!`||e==`?`}new class extends U{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Sn(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends U{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends U{constructor(){super(...arguments),this.tokenize=xn}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Cn(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Cn(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Cn(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=Cn(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends U{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};var wn=Se({oldText:T({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:T({description:`Replacement text for this targeted edit.`})},{});Se({path:T({description:`Path to the file to edit (relative or absolute)`}),edits:be(wn,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),Se({path:T({description:`Path to the file to read (relative or absolute)`}),offset:ve(De({description:`Line number to start reading from (1-indexed)`})),limit:ve(De({description:`Maximum number of lines to read`}))}),Se({path:T({description:`Path to the file to write (relative or absolute)`}),content:T({description:`Content to write to the file`})});var Tn=`slicc_oauth_extra_domains`;function En(e){try{let t=e.getItem(Tn);if(!t)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){if(typeof e!=`string`||!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`&&e.length>0);n.length>0&&(r[e]=n)}return r}catch{return{}}}function Dn(e,t){try{e.setItem(Tn,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}o(`secret-scrub`),o(`image-processor`),o(`tool-adapter`);function On(e,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=g(e);if(!r)return n;let i;for(let e of t.values()){let t=g(e.id);!t||t.family!==r.family||(!i||t.major>i.major||t.major===i.major&&t.minor>i.minor)&&(i={major:t.major,minor:t.minor,cost:e.cost})}return i?.cost??n}var kn=e({ACCOUNTS_KEY:()=>W,__test__:()=>zn,addAccount:()=>nr,applyProviderDefaults:()=>Kn,clearAllSettings:()=>Tr,clearApiKey:()=>br,clearBaseUrl:()=>Cr,clearSelectedProvider:()=>_r,exportProviders:()=>wr,getAccounts:()=>Y,getAllAvailableModels:()=>Xn,getAllExtraOAuthDomains:()=>er,getApiKey:()=>vr,getApiKeyForProvider:()=>dr,getApiVersionForProvider:()=>pr,getAvailableProviders:()=>Bn,getBaseUrl:()=>xr,getBaseUrlForProvider:()=>Z,getDeploymentForProvider:()=>fr,getExtraOAuthDomains:()=>Zn,getOAuthAccountInfo:()=>Wn,getProviderConfig:()=>K,getProviderModels:()=>q,getRawApiKeyForProvider:()=>ur,getSelectedModelId:()=>Q,getSelectedProvider:()=>$,isModelHiddenFromPicker:()=>Jn,logoutOAuthAccount:()=>ar,maskOAuthTokenWithRetry:()=>or,migrateLegacyAuthOnlySelection:()=>Ln,persistOAuthMaskViaServiceWorker:()=>sr,providerOffersLlmModels:()=>Vn,removeAccount:()=>ir,resolveCurrentModel:()=>Ar,resolveModelById:()=>kr,resolveModelByShorthand:()=>jr,resolveModelIdForScoop:()=>Nr,saveOAuthAccount:()=>cr,setApiKey:()=>yr,setBaseUrl:()=>Sr,setExtraOAuthDomains:()=>Qn,setExtraOAuthDomainsAsync:()=>$n,setSelectedModelId:()=>mr,setSelectedProvider:()=>gr}),An=i,jn=a,W=`slicc_accounts`,G=`selected-model`,Mn=[`slicc_provider`,`slicc_api_key`,`slicc_base_url`,`anthropic_api_key`,`api_provider`,`azure_resource`,`bedrock_region`],Nn=new Set([`github`]);function Pn(e){let t;try{t=r()}catch{return!1}return t.includes(e)&&!f(e)}var Fn=!1;function In(){if(!Fn){Fn=!0;for(let e of Mn)try{localStorage.removeItem(e)}catch{}Ln()}}function Ln(){try{let e=localStorage.getItem(G);if(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);(Nn.has(n)||Pn(n))&&localStorage.removeItem(G)}}}catch{}try{let e=localStorage.getItem(W);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let n=t.filter(e=>!(typeof e==`object`&&e&&typeof e.providerId==`string`&&Pn(e.providerId)));n.length!==t.length&&localStorage.setItem(W,JSON.stringify(n))}catch{}}function Rn(){Fn=!1}var zn={_resetLegacyCleanup:Rn};function Bn(){let e=r().filter(f),t=d();return[...new Set([...e,...t])].filter(e=>!p(e)?.hidden)}function Vn(e){try{if(q(e).length>0)return!0}catch{}try{if(a(e).length>0)return!0}catch{}let t=p(e);return!!(t?.modelOverrides&&Object.keys(t.modelOverrides).length>0)}function Hn(e,t){try{if(q(e).some(e=>e.id===t))return!0}catch{}try{if(a(e).some(e=>e.id===t))return!0}catch{}let n=p(e);return!!(n?.modelOverrides&&Object.hasOwn(n.modelOverrides,t))}function K(e){return p(e)||{id:e,name:e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),description:`${e} provider`,requiresApiKey:!0,requiresBaseUrl:!1}}function Un(e,t){t.context_window!==void 0&&(e.contextWindow=t.context_window),t.max_tokens!==void 0&&(e.maxTokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),t.cost!==void 0&&(e.cost=t.cost,e.inputCost=t.cost.input,e.outputCost=t.cost.output,e.cacheReadCost=t.cost.cacheRead,e.cacheWriteCost=t.cost.cacheWrite),t.compat!==void 0&&(e.compat={...e.compat??{},...t.compat}),t.thinkingLevelMap!==void 0&&(e.thinkingLevelMap={...e.thinkingLevelMap??{},...t.thinkingLevelMap})}function q(e){try{if(e===`bedrock-camp`){let e=v(Z(`bedrock-camp`));return jn(`amazon-bedrock`).filter(t=>_(t,e)).map(e=>({...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`}))}let t=K(e);if(t.getModelIds){let n;try{n=t.getModelIds()}catch(t){return J.error(`Provider getModelIds callback failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}let i=new Map;for(let e of r())try{for(let t of jn(e))i.set(t.id,t)}catch{}return n.map(n=>{let r=n.api===`openai`?`openai`:`anthropic`,a=`${e}-${r}`,o=i.get(n.id),s;if(o)s={...o,api:a,provider:e};else if(s=Dr(e,n.id,``,a),n.name&&(s.name=n.name),r===`anthropic`){let e=On(n.id,i);s.cost=e,s.inputCost=e.input,s.outputCost=e.output,s.cacheReadCost=e.cacheRead,s.cacheWriteCost=e.cacheWrite}let c=t.modelOverrides?.[n.id];return c&&Un(s,c),Un(s,n),s})}if(t.isOAuth){let n=jn(`anthropic`),r=`${e}-anthropic`;return n.map(n=>{let i={...n,api:r,provider:e},a=t.modelOverrides?.[n.id];return a&&Un(i,a),i})}return jn(e===`azure-ai-foundry`?`anthropic`:e)}catch(t){return J.error(`Failed to load models`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}}function Wn(e){let t=Y().find(t=>t.providerId===e);if(!t?.accessToken)return null;let n=!!t.tokenExpiresAt&&Date.now()>t.tokenExpiresAt-6e4;return{token:t.accessToken,maskedValue:t.maskedValue,expiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar,expired:n}}var Gn=Object.assign({})[`/packages/webapp/providers.json`]??[],J=o(`provider-settings`);function Kn(e=Gn){if(e.length===0||Y().length>0)return;let t=new Set(Bn());for(let n of e)if(!(!n.providerId||!n.apiKey)){if(!t.has(n.providerId)){J.warn(`Unknown provider "${n.providerId}" in providers.json — skipping`);continue}nr(n.providerId,n.apiKey,n.baseUrl)}let n=e.find(e=>e.providerId&&e.apiKey&&t.has(e.providerId));n?.model&&!localStorage.getItem(G)&&localStorage.setItem(G,`${n.providerId}:${n.model}`)}var qn=[/haiku/i];function Jn(e){return qn.some(t=>t.test(e))}function Yn(e){return e.filter(e=>!Jn(e.id))}function Xn(){let e=Y();if(e.length===0)return[];let t=new Map;for(let n of e){if(t.has(n.providerId))continue;let e=K(n.providerId);if(e.hidden||Pn(n.providerId))continue;let r=Yn(q(n.providerId));if(r.length===0)continue;let i={providerId:n.providerId,providerName:e.name,models:r};t.set(n.providerId,i)}return[...t.values()]}function Y(){In();let e=localStorage.getItem(W);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.providerId==`string`&&typeof e.apiKey==`string`):[]}catch{return[]}}function Zn(e){return En(localStorage)[e]??[]}function Qn(e,t){let n=En(localStorage),r=t.map(e=>e.trim()).filter(e=>e.length>0);r.length===0?delete n[e]:n[e]=r,Dn(localStorage,n)}async function $n(e,t){if(m()){Qn(e,t);return}let n=h();if(!n)throw Error(`setExtraOAuthDomainsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let{storeAfter:r}=await n.call(`oauth-extras-set`,{providerId:e,domains:t});try{Dn(localStorage,r)}catch(t){J.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{providerId:e,error:t instanceof Error?t.message:String(t)})}}function er(){return En(localStorage)}function tr(e){localStorage.setItem(W,JSON.stringify(e))}async function X(e){if(m()){tr(e);return}let t=h();if(!t)throw Error(`saveAccountsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let n=JSON.stringify(e),{storedJson:r}=await t.call(`save-oauth-accounts`,{accountsJson:n});try{localStorage.setItem(W,r)}catch(e){J.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{error:e instanceof Error?e.message:String(e)})}}function nr(e,t,n,r,i){let a=Y().filter(t=>t.providerId!==e),o={providerId:e,apiKey:t};n&&(o.baseUrl=n),r&&(o.deployment=r),i&&(o.apiVersion=i),a.push(o),tr(a)}async function rr(e){let t=l();try{if(t===`extension-direct`){let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.delete`,name:`oauth.${e}.token`},n=>{chrome.runtime.lastError&&J.error(`SW secrets.delete transport failed`,{providerId:e,error:chrome.runtime.lastError.message}),t(n??{})})});t.error&&J.error(`SW secrets.delete returned error`,{providerId:e,error:t.error})}else if(t===`extension-delegate`){let t=await u(`secrets.delete`,{name:`oauth.${e}.token`});t?.error&&J.error(`Bridge secrets.delete returned error`,{providerId:e,error:t.error})}else if(t!==`connect`){let t=await fetch(s(`/api/secrets/oauth/${e}`),{method:`DELETE`,headers:c()});!t.ok&&t.status!==404&&J.warn(`OAuth replica DELETE non-ok`,{providerId:e,status:t.status})}}catch(n){J.error(`OAuth replica removal failed`,{providerId:e,topology:t,error:n instanceof Error?n.message:String(n)})}}async function ir(e){let t=Y().find(t=>t.providerId===e),n=K(e);t&&n?.isOAuth&&await ar(e),await rr(e),await X(Y().filter(t=>t.providerId!==e));let r=localStorage.getItem(G)??``,i=r.indexOf(`:`);i>0&&r.slice(0,i)===e&&localStorage.removeItem(G)}async function ar(e){let t=Y().find(t=>t.providerId===e);if(!t)return;let r=K(e);if(r?.isOAuth){if(r.onOAuthLogout)try{await r.onOAuthLogout()}catch(t){J.warn(`onOAuthLogout failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})}if(r.getOAuthLogoutUrl){let i=r.getOAuthLogoutUrl(t);if(i){let{openIdpLogoutUrl:t}=await n(async()=>{let{openIdpLogoutUrl:e}=await import(`./oauth-service-Dk3L2UWh.js`);return{openIdpLogoutUrl:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await t(i).catch(t=>{J.warn(`IdP logout popup failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})})}}await X(Y().map(t=>t.providerId===e?{providerId:t.providerId,apiKey:``,baseUrl:t.baseUrl,userName:t.userName,userAvatar:t.userAvatar,loggedOut:!0}:t)),await rr(e)}}async function or(e,t={}){let n=Math.max(1,t.attempts??3),r=t.delayMs??150,i=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),a;for(let t=0;t<n;t++){let o=await e();if(o.maskedValue)return{maskedValue:o.maskedValue};o.error&&(a=o.error),t<n-1&&await i(r)}return{lastError:a}}async function sr(e,t,n){let r={providerId:e.providerId,accessToken:e.accessToken,domains:e.domains.join(`,`)},{maskedValue:i,lastError:a}=await or(()=>t.sendMaskRequest(r),n);if(!i){J.error(`OAuth mask give-up: no masked value after retries`,{providerId:e.providerId,reason:a??`no error reported (cold SW or empty reply)`});return}let o=t.getAccounts(),s=o.find(t=>t.providerId===e.providerId);s&&(s.maskedValue=i,await t.saveAccounts(o))}async function cr(e){let t=Y().find(t=>t.providerId===e.providerId),n=Y().filter(t=>t.providerId!==e.providerId);n.push({providerId:e.providerId,apiKey:``,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar,baseUrl:e.baseUrl??t?.baseUrl}),await X(n);let r=K(e.providerId)?.oauthTokenDomains??[],i=Zn(e.providerId),a=new Set,o=[];for(let e of[...r,...i]){let t=e.toLowerCase();a.has(t)||(a.add(t),o.push(e))}if(o.length===0)return;let d=l();try{if(d===`extension-direct`)await sr({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>new Promise(n=>{chrome.runtime.sendMessage({type:`secrets.mask-oauth-token`,...t},t=>{chrome.runtime.lastError&&J.error(`SW mask-oauth-token transport failed`,{providerId:e.providerId,error:chrome.runtime.lastError.message});let r=typeof t==`object`&&t?t:void 0;r?.error&&J.warn(`SW mask-oauth-token returned error`,{providerId:e.providerId,error:r.error}),n(r??{})})}),getAccounts:Y,saveAccounts:X});else if(d===`extension-delegate`)await sr({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>u(`secrets.mask-oauth-token`,t).then(t=>(t?.error&&J.warn(`Bridge mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),t??{})).catch(t=>(J.error(`Bridge mask-oauth-token transport failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)}),{})),getAccounts:Y,saveAccounts:X});else if(d!==`connect`){let t=await fetch(s(`/api/secrets/oauth-update`),{method:`POST`,headers:c({"Content-Type":`application/json`}),body:JSON.stringify({providerId:e.providerId,accessToken:e.accessToken,domains:o})});if(t.ok){let n=await t.json();if(typeof n.maskedValue==`string`){let t=Y(),r=t.find(t=>t.providerId===e.providerId);r&&(r.maskedValue=n.maskedValue,await X(t))}else J.warn(`OAuth replica POST ok but missing maskedValue`,{providerId:e.providerId})}else J.warn(`OAuth replica POST non-ok`,{providerId:e.providerId,status:t.status})}}catch(t){J.error(`OAuth replica sync failed`,{providerId:e.providerId,topology:d,error:t instanceof Error?t.message:String(t)})}}var lr=`local`;function ur(e){let t=Y().find(t=>t.providerId===e);return t&&(t.accessToken||t.apiKey)||null}function dr(e){let t=Y().find(t=>t.providerId===e);return t?t.accessToken||t.apiKey||(K(e).optionalApiKey?lr:null):null}function Z(e){return Y().find(t=>t.providerId===e)?.baseUrl??null}function fr(e){return Y().find(t=>t.providerId===e)?.deployment??null}function pr(e){return Y().find(t=>t.providerId===e)?.apiVersion??null}function Q(){let e=localStorage.getItem(G)||``,t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function mr(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t),r=new Set([...d(),...Bn()]),i=n.includes(`.`);if(r.has(n)||!i){localStorage.setItem(G,e);return}}let n=$();localStorage.setItem(G,`${n}:${e}`)}function hr(){return localStorage.getItem(G)||``}function $(){let e=hr(),t=e.indexOf(`:`);if(t>0)return e.slice(0,t);let n=Y(),r=Q();if(r){let e=n.find(e=>Vn(e.providerId)&&Hn(e.providerId,r));if(e)return e.providerId}let i=n.find(e=>Vn(e.providerId));return i?i.providerId:n.length>0?n[0].providerId:`anthropic`}function gr(e){let t=Q();localStorage.setItem(G,`${e}:${t}`)}function _r(){let e=Q();localStorage.setItem(G,e)}function vr(){return dr($())}function yr(e){let t=$();nr(t,e,Z(t)??void 0)}async function br(){await ir($())}function xr(){return Z($())}function Sr(e){let t=$(),n=ur(t);n&&nr(t,n,e||void 0)}function Cr(){let e=$(),t=ur(e);t&&nr(e,t)}function wr(){let e=Y(),t=$(),n=Q();return e.map(e=>{let r={providerId:e.providerId,apiKey:e.apiKey};return e.baseUrl&&(r.baseUrl=e.baseUrl),e.providerId===t&&n&&(r.model=n),r})}async function Tr(){let e=Y();await Promise.allSettled(e.map(e=>ir(e.providerId))),localStorage.removeItem(W),localStorage.removeItem(G);for(let e of Mn)localStorage.removeItem(e)}function Er(e){return/^(?:gpt[-.]?|o[0-9]|chatgpt)/i.test(e)?`openai`:`anthropic`}function Dr(e,t,n,r){return{id:t,name:t,provider:e,api:r??`${e}-${Er(t)}`,baseUrl:n??``,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},reasoning:!0}}function Or(e,t){return t.isOAuth||e===`azure-ai-foundry`?`anthropic`:e===`bedrock-camp`?`amazon-bedrock`:e}function kr(e){if(!e)return Ar();let t=$(),n=Z(t),r=K(t);try{let i=An(Or(t,r),e);if(!i?.id)throw Error(`Model ${e} not found`);let a=i;return r.isOAuth?a=q(t).find(t=>t.id===e)||{...a,api:`${t}-anthropic`,provider:t}:t===`bedrock-camp`&&(a={...a,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(a={...a,baseUrl:n}),a}catch(i){if(J.debug(`resolveModelById: pi-ai lookup miss, using provider fallback`,{providerId:t,modelId:e,error:i instanceof Error?i.message:String(i)}),r.isOAuth){let r=q(t).find(t=>t.id===e);return r?n?{...r,baseUrl:n}:r:Dr(t,e,n)}return Ar()}}function Ar(){let e=$(),t=Q(),n=Z(e),r=q(e),i=K(e),a=i.defaultModelId?r.find(e=>e.id.toLowerCase().includes(i.defaultModelId.toLowerCase()))?.id:void 0,o=t||a||r[0]?.id||`claude-sonnet-4-6`;try{let t=Or(e,i),a=An(t,o);if(!a?.id)throw Error(`Model ${o} not found in ${t} registry`);let s=a;return i.isOAuth?s=r.find(e=>e.id===o)||{...s,api:`${e}-anthropic`,provider:e}:e===`bedrock-camp`&&(s={...s,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(s={...s,baseUrl:n}),s}catch(t){J.debug(`resolveCurrentModel: pi-ai lookup miss, using provider fallback`,{providerId:e,effectiveModelId:o,error:t instanceof Error?t.message:String(t)});let a=r.find(e=>e.id===o);return a?n?{...a,baseUrl:n}:a:i.isOAuth?Dr(e,o,n):An(`anthropic`,`claude-sonnet-4-0`)}}function jr(e){let t=e.toLowerCase();if(!t)return null;let n=null;try{n=$()}catch{}if(n!==null){let e=Mr(t,[n]);if(e!==null)return e}return Mr(t,Y().map(e=>e.providerId))}function Mr(e,t){let n=null,r=-1;for(let i of t)for(let t of q(i)){let i=t.id.toLowerCase(),a=(t.name??``).toLowerCase();if(!i.includes(e)&&!a.includes(e))continue;let o=t.contextWindow??0;(o>r||o===r&&Pr(t.id,n??``)>0)&&(r=o,n=t.id)}return n}function Nr(e){if(!e)return null;let t=[e],n=jr(e);n!==null&&n!==e&&t.push(n);let r=[];try{r=q($())}catch{}for(let n of t)if(!(r.length>0&&!r.some(e=>e.id===n)))try{if(kr(n).id===n)return n}catch(t){J.debug(`resolveModelIdForScoop: candidate did not resolve`,{input:e,candidate:n,error:t instanceof Error?t.message:String(t)})}return null}function Pr(e,t){let n=e.match(/\d+/g)?.map(Number)??[],r=t.match(/\d+/g)?.map(Number)??[],i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}export{or as A,yr as B,K as C,$ as D,Q as E,Ar as F,gr as G,Qn as H,kr as I,On as K,jr as L,sr as M,Vn as N,Jn as O,ir as P,Nr as R,Wn as S,ur as T,$n as U,Sr as V,mr as W,Bn as _,Kn as a,fr as b,Cr as c,Y as d,Xn as f,pr as g,dr as h,nr as i,Ln as j,ar as k,_r as l,vr as m,zn as n,Tr as o,er as p,kn as r,br as s,W as t,wr as u,xr as v,q as w,Zn as x,Z as y,cr as z};
|
|
43
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Sn(e){return e==`.`||e==`!`||e==`?`}new class extends U{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Sn(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends U{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends U{constructor(){super(...arguments),this.tokenize=xn}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Cn(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Cn(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Cn(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=Cn(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends U{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};var wn=Se({oldText:T({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:T({description:`Replacement text for this targeted edit.`})},{});Se({path:T({description:`Path to the file to edit (relative or absolute)`}),edits:be(wn,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),Se({path:T({description:`Path to the file to read (relative or absolute)`}),offset:ve(De({description:`Line number to start reading from (1-indexed)`})),limit:ve(De({description:`Maximum number of lines to read`}))}),Se({path:T({description:`Path to the file to write (relative or absolute)`}),content:T({description:`Content to write to the file`})});var Tn=`slicc_oauth_extra_domains`;function En(e){try{let t=e.getItem(Tn);if(!t)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){if(typeof e!=`string`||!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`&&e.length>0);n.length>0&&(r[e]=n)}return r}catch{return{}}}function Dn(e,t){try{e.setItem(Tn,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}o(`secret-scrub`),o(`tool-adapter`);function On(e,t){let n={input:0,output:0,cacheRead:0,cacheWrite:0},r=g(e);if(!r)return n;let i;for(let e of t.values()){let t=g(e.id);!t||t.family!==r.family||(!i||t.major>i.major||t.major===i.major&&t.minor>i.minor)&&(i={major:t.major,minor:t.minor,cost:e.cost})}return i?.cost??n}var kn=e({ACCOUNTS_KEY:()=>W,__test__:()=>zn,addAccount:()=>nr,applyProviderDefaults:()=>Kn,clearAllSettings:()=>Tr,clearApiKey:()=>br,clearBaseUrl:()=>Cr,clearSelectedProvider:()=>_r,exportProviders:()=>wr,getAccounts:()=>Y,getAllAvailableModels:()=>Xn,getAllExtraOAuthDomains:()=>er,getApiKey:()=>vr,getApiKeyForProvider:()=>dr,getApiVersionForProvider:()=>pr,getAvailableProviders:()=>Bn,getBaseUrl:()=>xr,getBaseUrlForProvider:()=>Z,getDeploymentForProvider:()=>fr,getExtraOAuthDomains:()=>Zn,getOAuthAccountInfo:()=>Wn,getProviderConfig:()=>K,getProviderModels:()=>q,getRawApiKeyForProvider:()=>ur,getSelectedModelId:()=>Q,getSelectedProvider:()=>$,isModelHiddenFromPicker:()=>Jn,logoutOAuthAccount:()=>ar,maskOAuthTokenWithRetry:()=>or,migrateLegacyAuthOnlySelection:()=>Ln,persistOAuthMaskViaServiceWorker:()=>sr,providerOffersLlmModels:()=>Vn,removeAccount:()=>ir,resolveCurrentModel:()=>Ar,resolveModelById:()=>kr,resolveModelByShorthand:()=>jr,resolveModelIdForScoop:()=>Nr,saveOAuthAccount:()=>cr,setApiKey:()=>yr,setBaseUrl:()=>Sr,setExtraOAuthDomains:()=>Qn,setExtraOAuthDomainsAsync:()=>$n,setSelectedModelId:()=>mr,setSelectedProvider:()=>gr}),An=i,jn=a,W=`slicc_accounts`,G=`selected-model`,Mn=[`slicc_provider`,`slicc_api_key`,`slicc_base_url`,`anthropic_api_key`,`api_provider`,`azure_resource`,`bedrock_region`],Nn=new Set([`github`]);function Pn(e){let t;try{t=r()}catch{return!1}return t.includes(e)&&!f(e)}var Fn=!1;function In(){if(!Fn){Fn=!0;for(let e of Mn)try{localStorage.removeItem(e)}catch{}Ln()}}function Ln(){try{let e=localStorage.getItem(G);if(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);(Nn.has(n)||Pn(n))&&localStorage.removeItem(G)}}}catch{}try{let e=localStorage.getItem(W);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let n=t.filter(e=>!(typeof e==`object`&&e&&typeof e.providerId==`string`&&Pn(e.providerId)));n.length!==t.length&&localStorage.setItem(W,JSON.stringify(n))}catch{}}function Rn(){Fn=!1}var zn={_resetLegacyCleanup:Rn};function Bn(){let e=r().filter(f),t=d();return[...new Set([...e,...t])].filter(e=>!p(e)?.hidden)}function Vn(e){try{if(q(e).length>0)return!0}catch{}try{if(a(e).length>0)return!0}catch{}let t=p(e);return!!(t?.modelOverrides&&Object.keys(t.modelOverrides).length>0)}function Hn(e,t){try{if(q(e).some(e=>e.id===t))return!0}catch{}try{if(a(e).some(e=>e.id===t))return!0}catch{}let n=p(e);return!!(n?.modelOverrides&&Object.hasOwn(n.modelOverrides,t))}function K(e){return p(e)||{id:e,name:e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),description:`${e} provider`,requiresApiKey:!0,requiresBaseUrl:!1}}function Un(e,t){t.context_window!==void 0&&(e.contextWindow=t.context_window),t.max_tokens!==void 0&&(e.maxTokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),t.cost!==void 0&&(e.cost=t.cost,e.inputCost=t.cost.input,e.outputCost=t.cost.output,e.cacheReadCost=t.cost.cacheRead,e.cacheWriteCost=t.cost.cacheWrite),t.compat!==void 0&&(e.compat={...e.compat??{},...t.compat}),t.thinkingLevelMap!==void 0&&(e.thinkingLevelMap={...e.thinkingLevelMap??{},...t.thinkingLevelMap})}function q(e){try{if(e===`bedrock-camp`){let e=v(Z(`bedrock-camp`));return jn(`amazon-bedrock`).filter(t=>_(t,e)).map(e=>({...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`}))}let t=K(e);if(t.getModelIds){let n;try{n=t.getModelIds()}catch(t){return J.error(`Provider getModelIds callback failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}let i=new Map;for(let e of r())try{for(let t of jn(e))i.set(t.id,t)}catch{}return n.map(n=>{let r=n.api===`openai`?`openai`:`anthropic`,a=`${e}-${r}`,o=i.get(n.id),s;if(o)s={...o,api:a,provider:e};else if(s=Dr(e,n.id,``,a),n.name&&(s.name=n.name),r===`anthropic`){let e=On(n.id,i);s.cost=e,s.inputCost=e.input,s.outputCost=e.output,s.cacheReadCost=e.cacheRead,s.cacheWriteCost=e.cacheWrite}let c=t.modelOverrides?.[n.id];return c&&Un(s,c),Un(s,n),s})}if(t.isOAuth){let n=jn(`anthropic`),r=`${e}-anthropic`;return n.map(n=>{let i={...n,api:r,provider:e},a=t.modelOverrides?.[n.id];return a&&Un(i,a),i})}return jn(e===`azure-ai-foundry`?`anthropic`:e)}catch(t){return J.error(`Failed to load models`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}}function Wn(e){let t=Y().find(t=>t.providerId===e);if(!t?.accessToken)return null;let n=!!t.tokenExpiresAt&&Date.now()>t.tokenExpiresAt-6e4;return{token:t.accessToken,maskedValue:t.maskedValue,expiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar,expired:n}}var Gn=Object.assign({})[`/packages/webapp/providers.json`]??[],J=o(`provider-settings`);function Kn(e=Gn){if(e.length===0||Y().length>0)return;let t=new Set(Bn());for(let n of e)if(!(!n.providerId||!n.apiKey)){if(!t.has(n.providerId)){J.warn(`Unknown provider "${n.providerId}" in providers.json — skipping`);continue}nr(n.providerId,n.apiKey,n.baseUrl)}let n=e.find(e=>e.providerId&&e.apiKey&&t.has(e.providerId));n?.model&&!localStorage.getItem(G)&&localStorage.setItem(G,`${n.providerId}:${n.model}`)}var qn=[/haiku/i];function Jn(e){return qn.some(t=>t.test(e))}function Yn(e){return e.filter(e=>!Jn(e.id))}function Xn(){let e=Y();if(e.length===0)return[];let t=new Map;for(let n of e){if(t.has(n.providerId))continue;let e=K(n.providerId);if(e.hidden||Pn(n.providerId))continue;let r=Yn(q(n.providerId));if(r.length===0)continue;let i={providerId:n.providerId,providerName:e.name,models:r};t.set(n.providerId,i)}return[...t.values()]}function Y(){In();let e=localStorage.getItem(W);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.providerId==`string`&&typeof e.apiKey==`string`):[]}catch{return[]}}function Zn(e){return En(localStorage)[e]??[]}function Qn(e,t){let n=En(localStorage),r=t.map(e=>e.trim()).filter(e=>e.length>0);r.length===0?delete n[e]:n[e]=r,Dn(localStorage,n)}async function $n(e,t){if(m()){Qn(e,t);return}let n=h();if(!n)throw Error(`setExtraOAuthDomainsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let{storeAfter:r}=await n.call(`oauth-extras-set`,{providerId:e,domains:t});try{Dn(localStorage,r)}catch(t){J.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{providerId:e,error:t instanceof Error?t.message:String(t)})}}function er(){return En(localStorage)}function tr(e){localStorage.setItem(W,JSON.stringify(e))}async function X(e){if(m()){tr(e);return}let t=h();if(!t)throw Error(`saveAccountsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let n=JSON.stringify(e),{storedJson:r}=await t.call(`save-oauth-accounts`,{accountsJson:n});try{localStorage.setItem(W,r)}catch(e){J.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{error:e instanceof Error?e.message:String(e)})}}function nr(e,t,n,r,i){let a=Y().filter(t=>t.providerId!==e),o={providerId:e,apiKey:t};n&&(o.baseUrl=n),r&&(o.deployment=r),i&&(o.apiVersion=i),a.push(o),tr(a)}async function rr(e){let t=l();try{if(t===`extension-direct`){let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.delete`,name:`oauth.${e}.token`},n=>{chrome.runtime.lastError&&J.error(`SW secrets.delete transport failed`,{providerId:e,error:chrome.runtime.lastError.message}),t(n??{})})});t.error&&J.error(`SW secrets.delete returned error`,{providerId:e,error:t.error})}else if(t===`extension-delegate`){let t=await u(`secrets.delete`,{name:`oauth.${e}.token`});t?.error&&J.error(`Bridge secrets.delete returned error`,{providerId:e,error:t.error})}else if(t!==`connect`){let t=await fetch(s(`/api/secrets/oauth/${e}`),{method:`DELETE`,headers:c()});!t.ok&&t.status!==404&&J.warn(`OAuth replica DELETE non-ok`,{providerId:e,status:t.status})}}catch(n){J.error(`OAuth replica removal failed`,{providerId:e,topology:t,error:n instanceof Error?n.message:String(n)})}}async function ir(e){let t=Y().find(t=>t.providerId===e),n=K(e);t&&n?.isOAuth&&await ar(e),await rr(e),await X(Y().filter(t=>t.providerId!==e));let r=localStorage.getItem(G)??``,i=r.indexOf(`:`);i>0&&r.slice(0,i)===e&&localStorage.removeItem(G)}async function ar(e){let t=Y().find(t=>t.providerId===e);if(!t)return;let r=K(e);if(r?.isOAuth){if(r.onOAuthLogout)try{await r.onOAuthLogout()}catch(t){J.warn(`onOAuthLogout failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})}if(r.getOAuthLogoutUrl){let i=r.getOAuthLogoutUrl(t);if(i){let{openIdpLogoutUrl:t}=await n(async()=>{let{openIdpLogoutUrl:e}=await import(`./oauth-service-Dk3L2UWh.js`);return{openIdpLogoutUrl:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));await t(i).catch(t=>{J.warn(`IdP logout popup failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})})}}await X(Y().map(t=>t.providerId===e?{providerId:t.providerId,apiKey:``,baseUrl:t.baseUrl,userName:t.userName,userAvatar:t.userAvatar,loggedOut:!0}:t)),await rr(e)}}async function or(e,t={}){let n=Math.max(1,t.attempts??3),r=t.delayMs??150,i=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),a;for(let t=0;t<n;t++){let o=await e();if(o.maskedValue)return{maskedValue:o.maskedValue};o.error&&(a=o.error),t<n-1&&await i(r)}return{lastError:a}}async function sr(e,t,n){let r={providerId:e.providerId,accessToken:e.accessToken,domains:e.domains.join(`,`)},{maskedValue:i,lastError:a}=await or(()=>t.sendMaskRequest(r),n);if(!i){J.error(`OAuth mask give-up: no masked value after retries`,{providerId:e.providerId,reason:a??`no error reported (cold SW or empty reply)`});return}let o=t.getAccounts(),s=o.find(t=>t.providerId===e.providerId);s&&(s.maskedValue=i,await t.saveAccounts(o))}async function cr(e){let t=Y().find(t=>t.providerId===e.providerId),n=Y().filter(t=>t.providerId!==e.providerId);n.push({providerId:e.providerId,apiKey:``,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar,baseUrl:e.baseUrl??t?.baseUrl}),await X(n);let r=K(e.providerId)?.oauthTokenDomains??[],i=Zn(e.providerId),a=new Set,o=[];for(let e of[...r,...i]){let t=e.toLowerCase();a.has(t)||(a.add(t),o.push(e))}if(o.length===0)return;let d=l();try{if(d===`extension-direct`)await sr({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>new Promise(n=>{chrome.runtime.sendMessage({type:`secrets.mask-oauth-token`,...t},t=>{chrome.runtime.lastError&&J.error(`SW mask-oauth-token transport failed`,{providerId:e.providerId,error:chrome.runtime.lastError.message});let r=typeof t==`object`&&t?t:void 0;r?.error&&J.warn(`SW mask-oauth-token returned error`,{providerId:e.providerId,error:r.error}),n(r??{})})}),getAccounts:Y,saveAccounts:X});else if(d===`extension-delegate`)await sr({providerId:e.providerId,accessToken:e.accessToken,domains:o},{sendMaskRequest:t=>u(`secrets.mask-oauth-token`,t).then(t=>(t?.error&&J.warn(`Bridge mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),t??{})).catch(t=>(J.error(`Bridge mask-oauth-token transport failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)}),{})),getAccounts:Y,saveAccounts:X});else if(d!==`connect`){let t=await fetch(s(`/api/secrets/oauth-update`),{method:`POST`,headers:c({"Content-Type":`application/json`}),body:JSON.stringify({providerId:e.providerId,accessToken:e.accessToken,domains:o})});if(t.ok){let n=await t.json();if(typeof n.maskedValue==`string`){let t=Y(),r=t.find(t=>t.providerId===e.providerId);r&&(r.maskedValue=n.maskedValue,await X(t))}else J.warn(`OAuth replica POST ok but missing maskedValue`,{providerId:e.providerId})}else J.warn(`OAuth replica POST non-ok`,{providerId:e.providerId,status:t.status})}}catch(t){J.error(`OAuth replica sync failed`,{providerId:e.providerId,topology:d,error:t instanceof Error?t.message:String(t)})}}var lr=`local`;function ur(e){let t=Y().find(t=>t.providerId===e);return t&&(t.accessToken||t.apiKey)||null}function dr(e){let t=Y().find(t=>t.providerId===e);return t?t.accessToken||t.apiKey||(K(e).optionalApiKey?lr:null):null}function Z(e){return Y().find(t=>t.providerId===e)?.baseUrl??null}function fr(e){return Y().find(t=>t.providerId===e)?.deployment??null}function pr(e){return Y().find(t=>t.providerId===e)?.apiVersion??null}function Q(){let e=localStorage.getItem(G)||``,t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function mr(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t),r=new Set([...d(),...Bn()]),i=n.includes(`.`);if(r.has(n)||!i){localStorage.setItem(G,e);return}}let n=$();localStorage.setItem(G,`${n}:${e}`)}function hr(){return localStorage.getItem(G)||``}function $(){let e=hr(),t=e.indexOf(`:`);if(t>0)return e.slice(0,t);let n=Y(),r=Q();if(r){let e=n.find(e=>Vn(e.providerId)&&Hn(e.providerId,r));if(e)return e.providerId}let i=n.find(e=>Vn(e.providerId));return i?i.providerId:n.length>0?n[0].providerId:`anthropic`}function gr(e){let t=Q();localStorage.setItem(G,`${e}:${t}`)}function _r(){let e=Q();localStorage.setItem(G,e)}function vr(){return dr($())}function yr(e){let t=$();nr(t,e,Z(t)??void 0)}async function br(){await ir($())}function xr(){return Z($())}function Sr(e){let t=$(),n=ur(t);n&&nr(t,n,e||void 0)}function Cr(){let e=$(),t=ur(e);t&&nr(e,t)}function wr(){let e=Y(),t=$(),n=Q();return e.map(e=>{let r={providerId:e.providerId,apiKey:e.apiKey};return e.baseUrl&&(r.baseUrl=e.baseUrl),e.providerId===t&&n&&(r.model=n),r})}async function Tr(){let e=Y();await Promise.allSettled(e.map(e=>ir(e.providerId))),localStorage.removeItem(W),localStorage.removeItem(G);for(let e of Mn)localStorage.removeItem(e)}function Er(e){return/^(?:gpt[-.]?|o[0-9]|chatgpt)/i.test(e)?`openai`:`anthropic`}function Dr(e,t,n,r){return{id:t,name:t,provider:e,api:r??`${e}-${Er(t)}`,baseUrl:n??``,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},reasoning:!0}}function Or(e,t){return t.isOAuth||e===`azure-ai-foundry`?`anthropic`:e===`bedrock-camp`?`amazon-bedrock`:e}function kr(e){if(!e)return Ar();let t=$(),n=Z(t),r=K(t);try{let i=An(Or(t,r),e);if(!i?.id)throw Error(`Model ${e} not found`);let a=i;return r.isOAuth?a=q(t).find(t=>t.id===e)||{...a,api:`${t}-anthropic`,provider:t}:t===`bedrock-camp`&&(a={...a,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(a={...a,baseUrl:n}),a}catch(i){if(J.debug(`resolveModelById: pi-ai lookup miss, using provider fallback`,{providerId:t,modelId:e,error:i instanceof Error?i.message:String(i)}),r.isOAuth){let r=q(t).find(t=>t.id===e);return r?n?{...r,baseUrl:n}:r:Dr(t,e,n)}return Ar()}}function Ar(){let e=$(),t=Q(),n=Z(e),r=q(e),i=K(e),a=i.defaultModelId?r.find(e=>e.id.toLowerCase().includes(i.defaultModelId.toLowerCase()))?.id:void 0,o=t||a||r[0]?.id||`claude-sonnet-4-6`;try{let t=Or(e,i),a=An(t,o);if(!a?.id)throw Error(`Model ${o} not found in ${t} registry`);let s=a;return i.isOAuth?s=r.find(e=>e.id===o)||{...s,api:`${e}-anthropic`,provider:e}:e===`bedrock-camp`&&(s={...s,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(s={...s,baseUrl:n}),s}catch(t){J.debug(`resolveCurrentModel: pi-ai lookup miss, using provider fallback`,{providerId:e,effectiveModelId:o,error:t instanceof Error?t.message:String(t)});let a=r.find(e=>e.id===o);return a?n?{...a,baseUrl:n}:a:i.isOAuth?Dr(e,o,n):An(`anthropic`,`claude-sonnet-4-0`)}}function jr(e){let t=e.toLowerCase();if(!t)return null;let n=null;try{n=$()}catch{}if(n!==null){let e=Mr(t,[n]);if(e!==null)return e}return Mr(t,Y().map(e=>e.providerId))}function Mr(e,t){let n=null,r=-1;for(let i of t)for(let t of q(i)){let i=t.id.toLowerCase(),a=(t.name??``).toLowerCase();if(!i.includes(e)&&!a.includes(e))continue;let o=t.contextWindow??0;(o>r||o===r&&Pr(t.id,n??``)>0)&&(r=o,n=t.id)}return n}function Nr(e){if(!e)return null;let t=[e],n=jr(e);n!==null&&n!==e&&t.push(n);let r=[];try{r=q($())}catch{}for(let n of t)if(!(r.length>0&&!r.some(e=>e.id===n)))try{if(kr(n).id===n)return n}catch(t){J.debug(`resolveModelIdForScoop: candidate did not resolve`,{input:e,candidate:n,error:t instanceof Error?t.message:String(t)})}return null}function Pr(e,t){let n=e.match(/\d+/g)?.map(Number)??[],r=t.match(/\d+/g)?.map(Number)??[],i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}export{or as A,yr as B,K as C,$ as D,Q as E,Ar as F,gr as G,Qn as H,kr as I,On as K,jr as L,sr as M,Vn as N,Jn as O,ir as P,Nr as R,Wn as S,ur as T,$n as U,Sr as V,mr as W,Bn as _,Kn as a,fr as b,Cr as c,Y as d,Xn as f,pr as g,dr as h,nr as i,Ln as j,ar as k,_r as l,vr as m,zn as n,Tr as o,er as p,kn as r,br as s,W as t,wr as u,xr as v,q as w,Zn as x,Z as y,cr as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./panel-rpc-CjFVE0nK.js";import{K as t,d as n,y as r,z as i}from"./account-store-DAs0V_cx.js";import{n as a}from"./event-stream-qbAZIAKV.js";import{a as o,i as s,r as c}from"./compat-BHfpuQ4D.js";import{a as l,r as u,s as d,t as f}from"./legacy-api-aliases-BLiHiLlu.js";import{a as p,i as m,o as h,s as g}from"./bedrock-camp-CvcU-31w.js";import{n as _}from"./llm-session-id-ZObKEXzb.js";import{n as v,t as ee}from"./silent-renew-backoff-Chq7fPuc.js";import{getOAuthPageOrigin as y}from"./oauth-service-BuEH8BXq.js";import"./provider-settings-D3dmj6k9.js";var te={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function ne(e,t){return p(e,t)}function b(e,t,n){return e!==`xhigh`||!t?e:g(t,n)?`xhigh`:h(t,n)?`max`:`high`}function re(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return b((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function ie(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function x(e,t){if(!ne(e.id,e.name))return t;let n=t,r=b(n.effort??re(n.reasoning,e),e.id,e.name);return{...t,onPayload:ie(r,n.onPayload)}}function ae(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s);let c=t?.cost??e.cost;return c&&(n.cost=c),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),/sonnet-5\b/i.test(e.id)&&!n.thinkingLevelMap&&(n.thinkingLevelMap={xhigh:`xhigh`}),n}const S=Object.assign({"/packages/webapp/providers/adobe-config.json":te})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function C(){let e=r(`adobe`);if(e)return e.replace(/\/$/,``);if(S.proxyEndpoint)return S.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const w=new Map,T=new Map,E=`slicc-adobe-models`;function D(e){try{localStorage.setItem(E,JSON.stringify(e))}catch{}}async function O(e){let t=w.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[G]:`6.0.3`}});if(t.ok){let n=await t.json();return w.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}return{}}function k(e){let t=e.clientId||S.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function A(e){return e.scopes||S.scopes}function j(e){return e.imsEnvironment||S.imsEnvironment||`prod`}const M={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function N(e){return M[e??S.imsEnvironment??`prod`]??M.prod}const P=typeof chrome<`u`&&!!chrome?.runtime?.id;function F(){return n().find(e=>e.providerId===`adobe`)}async function oe(e,t){try{let n=await fetch(`${N(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function I(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const L={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!S.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>ae(e,T.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id,reasoning:t.reasoning,input:t.input,cost:t.cost}));return D(n),n}for(let t of w.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(E);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t,n)=>{let r=C(),a=await O(r),o=k(a),s=A(a),c=j(a),l=P?null:await y(),u=P?null:v({pageHref:l.href,pageOrigin:l.origin,configuredRedirectUri:S.redirectUri},()=>crypto.randomUUID()),d=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:u.redirectUri,f=u?.oauthState,p=u?.expectedNonce??null,m=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:d});f&&m.set(`state`,f),n?.forceReauth&&m.set(`prompt`,`login`);let h=await e(`${N(c)}/ims/authorize/v2?${m}`);if(!h)return;if(p&&h)try{if(new URL(h).searchParams.get(`nonce`)!==p){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=I(h);if(!g){console.error(`[adobe] Could not extract token from redirect URL`);return}let _=await oe(g.accessToken,c);await i({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,baseUrl:S.proxyEndpoint?void 0:r}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=F();if(e?.accessToken)try{let t=w.values().next().value??{},n=t.clientId||S.clientId,r=j(t);if(n){let t=await fetch(`${N(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await i({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?B():null,refreshModels:async e=>{await $(e);let t=L.getModelIds?.();t?.length&&D(t)}};let R=null;const se=ee();async function z(){let e=F();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await se.run(()=>B());if(t)return t;let n=F();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function ce(){let e=F();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function B(){if(typeof window>`u`){let t=e();if(!t)return null;try{let{accessToken:e}=await t.call(`silent-renew`,{providerId:`adobe`},{timeoutMs:13e4});return e}catch(e){return console.warn(`[adobe] worker→page silent-renew bridge failed:`,e instanceof Error?e.message:String(e)),null}}return R||(R=W().finally(()=>{R=null}),R)}function V(e,t){let n=k(t),r=A(t),i=j(t),a=P?null:v({pageHref:window.location.href,pageOrigin:window.location.origin,configuredRedirectUri:S.redirectUri},()=>crypto.randomUUID()),o=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:a.redirectUri,s=a?.oauthState,c=a?.expectedNonce??null,l=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:o,prompt:`none`});return s&&l.set(`state`,s),{authorizeUrl:`${N(i)}/ims/authorize/v2?${l}`,expectedNonce:c,proxyEndpoint:e}}function H(e,t){if(!t)return!0;try{if(new URL(e).searchParams.get(`nonce`)!==t)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),!1}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}return!0}async function U(e,t){let n=F();await i({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:n?.userName,userAvatar:n?.userAvatar,baseUrl:S.proxyEndpoint?void 0:t})}async function W(){try{let e=C(),{authorizeUrl:t,expectedNonce:n}=V(e,await O(e)),{createOAuthLauncher:r}=await import(`./oauth-service-BuEH8BXq.js`),i=await r()(t,{interactive:!1});if(!i||!H(i,n))return null;let a=I(i);return a?(await U(a,e),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),a.accessToken):null}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}}const G=`X-Slicc-Version`;function K(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[G]=`6.0.3`,{...e,headers:t}}const q=new Set;function J(e,t){if(e.headers){for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()===`x-session-id`&&n!=null)return e}return q.has(t)||(q.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":_(`adobe-provider-fallback`)}}}function le(){q.clear()}function Y(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const X=(e,t,n={})=>{let r=a();return(async()=>{try{let i=await z();if(String(e.api).includes(`openai`)){let a=u({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=f({...e,baseUrl:C(),api:`anthropic-messages`},t,K(J(x(e,m(e.id,e.name,{...n,apiKey:i})),`streamAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(Y(e,t)),r.end()}})(),r},Z=(e,t,n)=>{let r=a();return(async()=>{try{let i=await z();if(String(e.api).includes(`openai`)){let a=d({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=l({...e,baseUrl:C(),api:`anthropic-messages`},t,K(J(x(e,m(e.id,e.name,{...n,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(Y(e,t)),r.end()}})(),r};function ue(e){let t={id:e.id,name:e.name};return e.api!==void 0&&(t.api=e.api),e.context_window!==void 0&&(t.context_window=e.context_window),e.max_tokens!==void 0&&(t.max_tokens=e.max_tokens),e.reasoning!==void 0&&(t.reasoning=e.reasoning),e.input!==void 0&&(t.input=e.input),t}function de(){let e=new Map;for(let t of s())try{for(let n of c(t))e.set(n.id,n)}catch{}return e}function fe(e,n,r){let i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,a=r.get(e.id);if(a)return{...a,provider:`adobe`,api:i};let o=t(e.id,r);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:o,inputCost:o.input,outputCost:o.output,cacheReadCost:o.cacheRead,cacheWriteCost:o.cacheWrite,reasoning:!0}}function pe(e,t){for(let t of e)T.set(t.id,ue(t));let n=de();return e.map(e=>fe(e,t,n))}async function me(e){try{let t=e??await z(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[G]:`6.0.3`}});if(!r.ok)console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`);else{let e=await r.json();if(e.data?.length)return pe(e.data,n)}}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function he(){return c(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=C(),n=Q.get(t);if(n)return n;let r=await me(e);return r?(Q.set(t,r),r):he()}function ge(){o({api:`adobe-anthropic`,stream:X,streamSimple:Z}),o({api:`adobe-openai`,stream:X,streamSimple:Z})}export{le as __resetAdobeSessionIdWarningCacheForTests,L as config,$ as getAdobeModels,z as getValidAccessToken,ce as isTokenExpired,ge as register};
|
|
1
|
+
import{n as e}from"./panel-rpc-CjFVE0nK.js";import{K as t,d as n,y as r,z as i}from"./account-store-Bj2PFEoD.js";import{n as a}from"./event-stream-qbAZIAKV.js";import{a as o,i as s,r as c}from"./compat-BHfpuQ4D.js";import{a as l,r as u,s as d,t as f}from"./legacy-api-aliases-BLiHiLlu.js";import{a as p,i as m,o as h,s as g}from"./bedrock-camp-CvcU-31w.js";import{n as _}from"./llm-session-id-ZObKEXzb.js";import{n as v,t as ee}from"./silent-renew-backoff-Chq7fPuc.js";import{getOAuthPageOrigin as y}from"./oauth-service-bKcyWLK0.js";import"./provider-settings-CzM2hHtV.js";var te={proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`};function ne(e,t){return p(e,t)}function b(e,t,n){return e!==`xhigh`||!t?e:g(t,n)?`xhigh`:h(t,n)?`max`:`high`}function re(e,t){let n=e?t?.thinkingLevelMap?.[e]:void 0;return b((()=>{if(typeof n==`string`)return n;switch(e){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`xhigh`:return`xhigh`;default:return`high`}})(),t?.id,t?.name)}function ie(e,t){return async(n,r)=>{let i=t?await t(n,r)??n:n,a=i.thinking;return a&&a.type===`enabled`&&(i.thinking={type:`adaptive`,...a.display===void 0?{}:{display:a.display}},i.output_config={...i.output_config??{},effort:e}),i}}function x(e,t){if(!ne(e.id,e.name))return t;let n=t,r=b(n.effort??re(n.reasoning,e),e.id,e.name);return{...t,onPayload:ie(r,n.onPayload)}}function ae(e,t){let n={id:e.id,name:e.name??e.id},r=t?.api??e.api,i=t?.context_window??e.context_window,a=t?.max_tokens??e.max_tokens,o=t?.reasoning??e.reasoning,s=t?.input??e.input;r&&(n.api=r),i!==void 0&&(n.context_window=i),a!==void 0&&(n.max_tokens=a),o!==void 0&&(n.reasoning=o),s&&(n.input=s);let c=t?.cost??e.cost;return c&&(n.cost=c),/haiku/i.test(e.id)&&(n.compat={supportsEagerToolInputStreaming:!1}),/sonnet-5\b/i.test(e.id)&&!n.thinkingLevelMap&&(n.thinkingLevelMap={xhigh:`xhigh`}),n}const S=Object.assign({"/packages/webapp/providers/adobe-config.json":te})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function C(){let e=r(`adobe`);if(e)return e.replace(/\/$/,``);if(S.proxyEndpoint)return S.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const w=new Map,T=new Map,E=`slicc-adobe-models`;function D(e){try{localStorage.setItem(E,JSON.stringify(e))}catch{}}async function O(e){let t=w.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[G]:`6.1.0`}});if(t.ok){let n=await t.json();return w.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}return{}}function k(e){let t=e.clientId||S.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function A(e){return e.scopes||S.scopes}function j(e){return e.imsEnvironment||S.imsEnvironment||`prod`}const M={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function N(e){return M[e??S.imsEnvironment??`prod`]??M.prod}const P=typeof chrome<`u`&&!!chrome?.runtime?.id;function F(){return n().find(e=>e.providerId===`adobe`)}async function oe(e,t){try{let n=await fetch(`${N(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function I(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const L={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!S.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`,`admin.hlx.page`,`admin.hlx.live`,`admin.aem.page`,`admin.aem.live`],getModelIds:()=>{let e=e=>ae(e,T.get(e.id));for(let t of Q.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id,reasoning:t.reasoning,input:t.input,cost:t.cost}));return D(n),n}for(let t of w.values())if(t.models?.length)return t.models.map(t=>e(t));try{let e=localStorage.getItem(E);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t,n)=>{let r=C(),a=await O(r),o=k(a),s=A(a),c=j(a),l=P?null:await y(),u=P?null:v({pageHref:l.href,pageOrigin:l.origin,configuredRedirectUri:S.redirectUri},()=>crypto.randomUUID()),d=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:u.redirectUri,f=u?.oauthState,p=u?.expectedNonce??null,m=new URLSearchParams({client_id:o,scope:s,response_type:`token`,redirect_uri:d});f&&m.set(`state`,f),n?.forceReauth&&m.set(`prompt`,`login`);let h=await e(`${N(c)}/ims/authorize/v2?${m}`);if(!h)return;if(p&&h)try{if(new URL(h).searchParams.get(`nonce`)!==p){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=I(h);if(!g){console.error(`[adobe] Could not extract token from redirect URL`);return}let _=await oe(g.accessToken,c);await i({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:_.name,userAvatar:_.avatar,baseUrl:S.proxyEndpoint?void 0:r}),await $().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=F();if(e?.accessToken)try{let t=w.values().next().value??{},n=t.clientId||S.clientId,r=j(t);if(n){let t=await fetch(`${N(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await i({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>F()?.accessToken?B():null,refreshModels:async e=>{await $(e);let t=L.getModelIds?.();t?.length&&D(t)}};let R=null;const se=ee();async function z(){let e=F();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);let t=await se.run(()=>B());if(t)return t;let n=F();if((n?.tokenExpiresAt??0)-Date.now()>0&&n?.accessToken)return n.accessToken;throw Error(`Adobe session expired — please log in again`)}function ce(){let e=F();return!e?.tokenExpiresAt||Date.now()>e.tokenExpiresAt-6e4}async function B(){if(typeof window>`u`){let t=e();if(!t)return null;try{let{accessToken:e}=await t.call(`silent-renew`,{providerId:`adobe`},{timeoutMs:13e4});return e}catch(e){return console.warn(`[adobe] worker→page silent-renew bridge failed:`,e instanceof Error?e.message:String(e)),null}}return R||(R=W().finally(()=>{R=null}),R)}function V(e,t){let n=k(t),r=A(t),i=j(t),a=P?null:v({pageHref:window.location.href,pageOrigin:window.location.origin,configuredRedirectUri:S.redirectUri},()=>crypto.randomUUID()),o=P?S.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:a.redirectUri,s=a?.oauthState,c=a?.expectedNonce??null,l=new URLSearchParams({client_id:n,scope:r,response_type:`token`,redirect_uri:o,prompt:`none`});return s&&l.set(`state`,s),{authorizeUrl:`${N(i)}/ims/authorize/v2?${l}`,expectedNonce:c,proxyEndpoint:e}}function H(e,t){if(!t)return!0;try{if(new URL(e).searchParams.get(`nonce`)!==t)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),!1}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}return!0}async function U(e,t){let n=F();await i({providerId:`adobe`,accessToken:e.accessToken,tokenExpiresAt:Date.now()+e.expiresIn*1e3,userName:n?.userName,userAvatar:n?.userAvatar,baseUrl:S.proxyEndpoint?void 0:t})}async function W(){try{let e=C(),{authorizeUrl:t,expectedNonce:n}=V(e,await O(e)),{createOAuthLauncher:r}=await import(`./oauth-service-bKcyWLK0.js`),i=await r()(t,{interactive:!1});if(!i||!H(i,n))return null;let a=I(i);return a?(await U(a,e),console.log(`[adobe] Token renewed silently`),await $().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),a.accessToken):null}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}}const G=`X-Slicc-Version`;function K(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[G]=`6.1.0`,{...e,headers:t}}const q=new Set;function J(e,t){if(e.headers){for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()===`x-session-id`&&n!=null)return e}return q.has(t)||(q.add(t),console.warn(`[adobe] Missing X-Session-Id from ${t} — using daily fallback. Attach an X-Session-Id header at the call site (see scoop-context.ts streamWithSessionId or docs/pitfalls.md).`)),{...e,headers:{...e.headers??{},"X-Session-Id":_(`adobe-provider-fallback`)}}}function le(){q.clear()}function Y(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const X=(e,t,n={})=>{let r=a();return(async()=>{try{let i=await z();if(String(e.api).includes(`openai`)){let a=u({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:i},`streamAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=f({...e,baseUrl:C(),api:`anthropic-messages`},t,K(J(x(e,m(e.id,e.name,{...n,apiKey:i})),`streamAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(Y(e,t)),r.end()}})(),r},Z=(e,t,n)=>{let r=a();return(async()=>{try{let i=await z();if(String(e.api).includes(`openai`)){let a=d({...e,baseUrl:`${C()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,K(J({...n,apiKey:i},`streamSimpleAdobe[openai]`)));for await(let e of a)r.push(e)}else{let a=l({...e,baseUrl:C(),api:`anthropic-messages`},t,K(J(x(e,m(e.id,e.name,{...n,apiKey:i})),`streamSimpleAdobe[anthropic]`)));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(Y(e,t)),r.end()}})(),r};function ue(e){let t={id:e.id,name:e.name};return e.api!==void 0&&(t.api=e.api),e.context_window!==void 0&&(t.context_window=e.context_window),e.max_tokens!==void 0&&(t.max_tokens=e.max_tokens),e.reasoning!==void 0&&(t.reasoning=e.reasoning),e.input!==void 0&&(t.input=e.input),t}function de(){let e=new Map;for(let t of s())try{for(let n of c(t))e.set(n.id,n)}catch{}return e}function fe(e,n,r){let i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`,a=r.get(e.id);if(a)return{...a,provider:`adobe`,api:i};let o=t(e.id,r);return{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:n,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:o,inputCost:o.input,outputCost:o.output,cacheReadCost:o.cacheRead,cacheWriteCost:o.cacheWrite,reasoning:!0}}function pe(e,t){for(let t of e)T.set(t.id,ue(t));let n=de();return e.map(e=>fe(e,t,n))}async function me(e){try{let t=e??await z(),n=C(),r=await fetch(`${n}/v1/models`,{headers:{Authorization:`Bearer ${t}`,[G]:`6.1.0`}});if(!r.ok)console.warn(`[adobe] Proxy /v1/models returned ${r.status}, falling back to Anthropic models`);else{let e=await r.json();if(e.data?.length)return pe(e.data,n)}}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return null}const Q=new Map;function he(){return c(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}async function $(e){let t=C(),n=Q.get(t);if(n)return n;let r=await me(e);return r?(Q.set(t,r),r):he()}function ge(){o({api:`adobe-anthropic`,stream:X,streamSimple:Z}),o({api:`adobe-openai`,stream:X,streamSimple:Z})}export{le as __resetAdobeSessionIdWarningCacheForTests,L as config,$ as getAdobeModels,z as getValidAccessToken,ce as isTokenExpired,ge as register};
|