sliccy 6.141.2 → 6.141.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/ui/.vite/manifest.json +161 -161
  2. package/dist/ui/assets/{SKILL-CkexdTt9.js → SKILL-B-lyKDjk.js} +1 -1
  3. package/dist/ui/assets/__vite-browser-external-oXcxoO19.js +1 -0
  4. package/dist/ui/assets/{account-store-1giUExSS.js → account-store-BSIs8eWH.js} +1 -1
  5. package/dist/ui/assets/{account-store-CEOiQheZ.js → account-store-CfKG-Ig3.js} +1 -1
  6. package/dist/ui/assets/{adobe-CuKX_Gw4.js → adobe--jIvF0ng.js} +1 -1
  7. package/dist/ui/assets/{adobe-CAJTksuy.js → adobe-BrcV3j-w.js} +1 -1
  8. package/dist/ui/assets/{agent-bridge-UBo80Ndw.js → agent-bridge-DEABZego.js} +1 -1
  9. package/dist/ui/assets/{agent-panels-DyOEhG6c.js → agent-panels-_ItKLnAu.js} +1 -1
  10. package/dist/ui/assets/{apply-layout-VtuQ2xkc.js → apply-layout-B0AnPvJo.js} +1 -1
  11. package/dist/ui/assets/{apps-U1kwfX_v.js → apps-3LBDpLXu.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-Ddl-lvTg.js → azure-openai-Cye1lDSV.js} +1 -1
  13. package/dist/ui/assets/{azure-openai-Cqv8rGOp.js → azure-openai-HqCDLaNq.js} +1 -1
  14. package/dist/ui/assets/{bsh-watchdog-ClwrdzEH.js → bsh-watchdog-DqSIi75u.js} +1 -1
  15. package/dist/ui/assets/{budget-usage-source-D542v3BA.js → budget-usage-source--h4cY6Ul.js} +1 -1
  16. package/dist/ui/assets/{cdp-CLhbRC4S.js → cdp-BX0PiRAg.js} +1 -1
  17. package/dist/ui/assets/{cerebras-_Db4_aiE.js → cerebras-BL4Mp561.js} +1 -1
  18. package/dist/ui/assets/{cerebras-CjIkFcWP.js → cerebras-BzO5UDZf.js} +1 -1
  19. package/dist/ui/assets/{composer-speech-DaflYjI9.js → composer-speech-4JiTrymN.js} +1 -1
  20. package/dist/ui/assets/{connect-surface-XZmKRFD-.js → connect-surface-COdJoI-e.js} +1 -1
  21. package/dist/ui/assets/{core-CbzVRzJt.js → core-BkHMrXyn.js} +1 -1
  22. package/dist/ui/assets/{directed-approval-BN6dULqi.js → directed-approval-Blbo1tMy.js} +1 -1
  23. package/dist/ui/assets/{ensure-speech-assets-Czc4X1XD.js → ensure-speech-assets-B14FEqf-.js} +1 -1
  24. package/dist/ui/assets/{esbuild-wasm-L2Rk3D-4.js → esbuild-wasm-CY2jFm-D.js} +1 -1
  25. package/dist/ui/assets/{extension-media-capture-I_fwSF5G.js → extension-media-capture-BwxRQ-WA.js} +1 -1
  26. package/dist/ui/assets/{fs-BA09m1QZ.js → fs-CxM_n_WI.js} +2 -2
  27. package/dist/ui/assets/{fs-CGTZ8FRd.js → fs-luCL6DCO.js} +1 -1
  28. package/dist/ui/assets/{github-Cq2ILMY9.js → github-CkKjkah0.js} +1 -1
  29. package/dist/ui/assets/{github-PSX9aEBn.js → github-DYjXr1_m.js} +2 -2
  30. package/dist/ui/assets/{github-copilot-DG4ZIs2I.js → github-copilot-BH7WyhE6.js} +1 -1
  31. package/dist/ui/assets/{github-copilot-D-4VMd3T.js → github-copilot-BgdxHbZb.js} +1 -1
  32. package/dist/ui/assets/{github-install-ldpkPFFj.js → github-install-DCTLf8fO.js} +1 -1
  33. package/dist/ui/assets/{github-zip-CNnBN_eK.js → github-zip-B98l3J_a.js} +1 -1
  34. package/dist/ui/assets/{guest-tool-gate-g70kqGoB.js → guest-tool-gate-CwWcQt6s.js} +1 -1
  35. package/dist/ui/assets/{hear-D1MeyTuZ.js → hear-BjVVAhs0.js} +1 -1
  36. package/dist/ui/assets/{help-CtvHLjUb.js → help-S6yh95LF.js} +1 -1
  37. package/dist/ui/assets/{installer-DK4dNFOa.js → installer-CTX50_zb.js} +1 -1
  38. package/dist/ui/assets/js-realm-worker-DPLcRbzk.js +50 -0
  39. package/dist/ui/assets/{kernel-worker-gHxPjWqC.js → kernel-worker-CFvPuOAi.js} +584 -584
  40. package/dist/ui/assets/{local-llm-D9n5Pv4v.js → local-llm-BDyp_VE9.js} +1 -1
  41. package/dist/ui/assets/{local-llm-795gKzFO.js → local-llm-DRegic15.js} +1 -1
  42. package/dist/ui/assets/{magick-wasm-IdXcHdTy.js → magick-wasm-DrHkiveP.js} +1 -1
  43. package/dist/ui/assets/{main-CmEbg5ii.js → main-DRyLg5pd.js} +3 -3
  44. package/dist/ui/assets/{main-cherry--4qAV7sk.js → main-cherry-D1YCAckw.js} +1 -1
  45. package/dist/ui/assets/{mount-WtleT3fD.js → mount-BehlIVTc.js} +1 -1
  46. package/dist/ui/assets/{mount-Cb23pYLO.js → mount-hVHVLao0.js} +3 -3
  47. package/dist/ui/assets/{mount-recovery-BaCu7G48.js → mount-recovery-Ds6xJnFc.js} +1 -1
  48. package/dist/ui/assets/{new-session-64SepVcs.js → new-session-Cvy359ZG.js} +2 -2
  49. package/dist/ui/assets/{oauth-bootstrap-D-BY9eAI.js → oauth-bootstrap-0NJ1uts7.js} +2 -2
  50. package/dist/ui/assets/{onboarding-orchestrator-bfS34kjc.js → onboarding-orchestrator-Q2fKoNJZ.js} +1 -1
  51. package/dist/ui/assets/{openai-codex-D-x53dS9.js → openai-codex-DqGAC_RJ.js} +1 -1
  52. package/dist/ui/assets/{openai-codex-zU3F7KlY.js → openai-codex-K0Kx4ldr.js} +1 -1
  53. package/dist/ui/assets/{openrouter-Ba1JpnSb.js → openrouter-BL1BgW8W.js} +1 -1
  54. package/dist/ui/assets/{openrouter-free-BqJ3pQB2.js → openrouter-free-CY-4NfFi.js} +1 -1
  55. package/dist/ui/assets/{openrouter-free-DQcwC3UT.js → openrouter-free-OvrtzVRw.js} +1 -1
  56. package/dist/ui/assets/{openrouter-oauth-DHUr88fi.js → openrouter-oauth-B7IMQSSe.js} +1 -1
  57. package/dist/ui/assets/{openrouter-oauth-C-erOniu.js → openrouter-oauth-CUoyHM94.js} +1 -1
  58. package/dist/ui/assets/{openrouter-CmS2rYhd.js → openrouter-x2bz26jc.js} +1 -1
  59. package/dist/ui/assets/{panel-rpc-handlers-98Ajkixu.js → panel-rpc-handlers-Bcgk807g.js} +2 -2
  60. package/dist/ui/assets/{panelize-shell-BMyKc1pp.js → panelize-shell-BgTzzpy_.js} +1 -1
  61. package/dist/ui/assets/{provider-D9l25_oW.js → provider-665TUltd.js} +2 -2
  62. package/dist/ui/assets/{provider-C5Z0FLhi.js → provider-DesDs-vM.js} +1 -1
  63. package/dist/ui/assets/provider-settings-D4bmGLB0.js +1 -0
  64. package/dist/ui/assets/provider-store-access-BYNLuUjQ.js +1 -0
  65. package/dist/ui/assets/provider-store-access-DTu0j6hV.js +1 -0
  66. package/dist/ui/assets/{providers-CDNZj56F.js → providers-CFCRFvFH.js} +2 -2
  67. package/dist/ui/assets/{providers-DU6K5lm4.js → providers-DdkKCDPr.js} +1 -1
  68. package/dist/ui/assets/py-realm-worker-CMUAG309.js +244 -0
  69. package/dist/ui/assets/{pyodide-BwD0AtZB.js → pyodide-BIBsaAI1.js} +2 -2
  70. package/dist/ui/assets/{quick-llm-CGmdkAbo.js → quick-llm-DDPHThwA.js} +1 -1
  71. package/dist/ui/assets/{recovery-screen-DbUQYiGt.js → recovery-screen-BxSagH2C.js} +1 -1
  72. package/dist/ui/assets/{run-BdNihxEm.js → run-DP2klSX1.js} +1 -1
  73. package/dist/ui/assets/{run-CEO6EbaH.js → run-DVF88haQ.js} +1 -1
  74. package/dist/ui/assets/{run-Brj7DLeJ.js → run-DcJO0Q_l.js} +1 -1
  75. package/dist/ui/assets/{run-C52p_9Qk.js → run-dSobJ2Jl.js} +1 -1
  76. package/dist/ui/assets/{run-D5XnzhFr.js → run-mty6BV1K.js} +2 -2
  77. package/dist/ui/assets/{setup-feature-flags-remote-Cvdn6hdM.js → setup-feature-flags-remote-BHnboyDd.js} +1 -1
  78. package/dist/ui/assets/shared-f0tP2HLX.js +1 -0
  79. package/dist/ui/assets/shared-pVZLJOGO.js +4 -0
  80. package/dist/ui/assets/sidecar-repair-BTfXbONN.js +1 -0
  81. package/dist/ui/assets/{silent-renew-backoff-CtePV08H.js → silent-renew-backoff-CefoN4SB.js} +1 -1
  82. package/dist/ui/assets/{skills-B-6EX8_-.js → skills-DQ9l8ZBo.js} +1 -1
  83. package/dist/ui/assets/slicc-version-Dao6QpwG.js +1 -0
  84. package/dist/ui/assets/{snapshot-features-ChRer_go.js → snapshot-features-CsC80g1q.js} +1 -1
  85. package/dist/ui/assets/{snapshot-WlEbVfgz.js → snapshot-x1OXJvjv.js} +1 -1
  86. package/dist/ui/assets/{soundscape-BVUWKD0V.js → soundscape-lMcnjSro.js} +1 -1
  87. package/dist/ui/assets/{speak-CgSo0rXK.js → speak-DAMy1Kok.js} +1 -1
  88. package/dist/ui/assets/{sprinkle-manager-LMSdR63e.js → sprinkle-manager-jUfWlPSr.js} +1 -1
  89. package/dist/ui/assets/{sprinkle-renderer-BGx8hJZ_.js → sprinkle-renderer-DRjk0Axq.js} +1 -1
  90. package/dist/ui/assets/{state-97_6_0AF.js → state-DnkBl3YO.js} +1 -1
  91. package/dist/ui/assets/{store-BsYziZmA.js → store-CvgWI8Er.js} +1 -1
  92. package/dist/ui/assets/{store-Czh0k7Ej.js → store-CyOgmeoj.js} +1 -1
  93. package/dist/ui/assets/{sudo-BLu3k0lA.js → sudo-BUdJPcIH.js} +1 -1
  94. package/dist/ui/assets/{sync-dialog-C2VQi8rS.js → sync-dialog-D1W1SkvI.js} +1 -1
  95. package/dist/ui/assets/{transformers-env-Dtjt9IFM.js → transformers-env-DnyPjSfP.js} +1 -1
  96. package/dist/ui/assets/{tray-sidecar-CyZO4AI3.js → tray-sidecar-Cq4YlygL.js} +1 -1
  97. package/dist/ui/assets/{upgrade-detection-BtelIV1o.js → upgrade-detection-DgoklRjO.js} +1 -1
  98. package/dist/ui/assets/{voice-reply-DP6xzedi.js → voice-reply-oNIB61T4.js} +1 -1
  99. package/dist/ui/assets/{wc-attach-CzsJrwZF.js → wc-attach-Dm3guiHt.js} +2 -2
  100. package/dist/ui/assets/{wc-extension-wMcey-Cc.js → wc-extension-B-HQw_fj.js} +2 -2
  101. package/dist/ui/assets/{wc-follower-ByN9dVQ1.js → wc-follower-UnBMtKdu.js} +3 -3
  102. package/dist/ui/assets/{wc-follower-oauth-9hxhD2eL.js → wc-follower-oauth-CUFehOmO.js} +1 -1
  103. package/dist/ui/assets/{wc-live-TppgvY0W.js → wc-live-B6vu9NGR.js} +6 -6
  104. package/dist/ui/assets/{wc-nav-CgkpNqYH.js → wc-nav-BCixgrNu.js} +2 -2
  105. package/dist/ui/assets/{wc-onboarding-D4pn4la8.js → wc-onboarding-hbn2eX0f.js} +2 -2
  106. package/dist/ui/assets/{wc-placeholder-BWlJ100a.js → wc-placeholder-VxPXRa-X.js} +3 -3
  107. package/dist/ui/assets/{wc-settings-nW_MRain.js → wc-settings-DjO1GovJ.js} +3 -3
  108. package/dist/ui/assets/{wc-shell-BFq7cCkV.js → wc-shell-CdkXzmml.js} +3 -3
  109. package/dist/ui/assets/{wc-shortcut-config-DX1ZeRvp.js → wc-shortcut-config-DRFDW5Tg.js} +1 -1
  110. package/dist/ui/assets/{wc-shortcuts-Cofh5Gbv.js → wc-shortcuts-udkJj992.js} +1 -1
  111. package/dist/ui/assets/{wc-sprinkles-f2qsZXFn.js → wc-sprinkles-CiVxUeGF.js} +2 -2
  112. package/dist/ui/assets/{wc-transcript-export-DaV1rNpE.js → wc-transcript-export-BCh_MVB_.js} +2 -2
  113. package/dist/ui/assets/{wc-tray-ijuKOV8w.js → wc-tray-B33mq_SX.js} +4 -4
  114. package/dist/ui/assets/welcome-detection-DtOhe2WK.js +1 -0
  115. package/dist/ui/assets/{whisper-session-CargUQnZ.js → whisper-session-BsYu0J3h.js} +2 -2
  116. package/dist/ui/assets/{xai-grok-DXFRDUbJ.js → xai-grok-BULrVqKw.js} +1 -1
  117. package/dist/ui/assets/{xai-grok-Bk0i1-e4.js → xai-grok-Cud8PiSx.js} +1 -1
  118. package/dist/ui/index.html +3 -3
  119. package/dist/ui/packages/webapp/index.html +3 -3
  120. package/package.json +4 -3
  121. package/dist/ui/assets/__vite-browser-external-B6A3FtA_.js +0 -1
  122. package/dist/ui/assets/js-realm-worker-CWWdnszr.js +0 -50
  123. package/dist/ui/assets/provider-settings-CqIZoy7n.js +0 -1
  124. package/dist/ui/assets/provider-store-access-B7Zu_WTv.js +0 -1
  125. package/dist/ui/assets/provider-store-access-CzfqGk9d.js +0 -1
  126. package/dist/ui/assets/py-realm-worker-BYQkpReo.js +0 -244
  127. package/dist/ui/assets/shared-Djytys1b.js +0 -1
  128. package/dist/ui/assets/shared-vu5AooI5.js +0 -4
  129. package/dist/ui/assets/sidecar-repair-Codn4wCd.js +0 -1
  130. package/dist/ui/assets/slicc-version-C4ygb52b.js +0 -1
  131. package/dist/ui/assets/welcome-detection-BPEhaGvB.js +0 -1
@@ -1,2 +1,2 @@
1
- import{S as e}from"./account-store-CEOiQheZ.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{d as n}from"./claude-model-version-CSATLzrT.js";import{r,s as i}from"./legacy-api-aliases-bAJ0Klzq.js";import{t as a}from"./logger-DDBAeTLF.js";var o=a(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{S as e}from"./account-store-CfKG-Ig3.js";import{a as t}from"./diagnostics-DN_idNHx.js";import{d as n}from"./claude-model-version-CSATLzrT.js";import{r,s as i}from"./legacy-api-aliases-bAJ0Klzq.js";import{t as a}from"./logger-DDBAeTLF.js";var o=a(`local-llm`),s=`local-llm`,c=`local`,l=`${s}-unconfigured`,u={id:s,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
2
2
  `),requiresApiKey:!1,optionalApiKey:!0,apiKeyPlaceholder:`Leave empty for local servers, or paste a key for hosted endpoints`,apiKeyEnvVar:`LOCAL_LLM_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`http://localhost:11434/v1`,baseUrlDescription:`Ollama: 11434 • LM Studio: 1234 • llama.cpp/mlx: 8080 • vLLM: 8000 • Jan: 1337. Trailing /v1 required.`,requiresDeployment:!0,deploymentPlaceholder:`llama3.1:8b, qwen2.5-coder:14b`,deploymentDescription:`Comma-separated model IDs from your server. List them with: curl <baseUrl>/models | jq -r .data[].id`,getModelIds:()=>{let t=d(e(s));return t.length===0?[{id:l,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:t.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function d(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}var f=`openai-completions`,p=`${s}-openai`;function m(e){return{...e,api:f}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:c}:t}var g=(e,t,n={})=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?r(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===l?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?i(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,n){let r=t(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,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:n,timestamp:Date.now()};return queueMicrotask(()=>{r.push({type:`error`,reason:`error`,error:i}),r.end()}),r}function y(){n({api:p,stream:g,streamSimple:_})}function b(e){return typeof e==`object`&&!!e&&`object`in e&&e.object===`list`}function x(e){return typeof e==`object`&&!!e&&`build_info`in e}function S(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function C(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function w(e,t,n){let r=`${C(e)}/models`,i={Accept:`application/json`};t&&t.length>0&&(i.Authorization=`Bearer ${t}`);let a=await fetch(r,{method:`GET`,headers:i,signal:n});if(!a.ok)throw Error(`GET ${r} -> ${a.status} ${a.statusText}`);let o=await a.json();return Array.isArray(o.data)?o.data.map(e=>e.id??``).filter(e=>e.length>0):[]}async function T(e,t){let n=S(e),r=await D(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};if(b(await D(`${n}/api/v0/models`,t)))return{kind:`lmstudio`};let i=await D(`${n}/props`,t);if(x(i))return{kind:`llamacpp`,version:i.build_info?.version};let a=E(e);return a===`11434`?{kind:`ollama`}:a===`1234`?{kind:`lmstudio`}:a===`8000`?{kind:`vllm`}:a===`1337`?{kind:`jan`}:{kind:`unknown`}}function E(e){try{return new URL(e).port||null}catch{return null}}async function D(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function O(e,t,n){let r={kind:`unknown`};try{r=await T(e,n)}catch{}try{let i=await w(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=k(n,r.kind);return o.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function k(e,t){let n=e.toLowerCase();return n.includes(`failed to fetch`)||n.includes(`networkerror`)?t===`ollama`?{kind:`cors`,message:e,hint:'Ollama rejects requests from non-localhost origins by default. Set OLLAMA_ORIGINS=* (or chrome-extension://*) and restart Ollama. macOS: `launchctl setenv OLLAMA_ORIGINS "*"` then quit and relaunch the Ollama app.'}:{kind:`connection`,message:e,hint:`Server unreachable. Check the URL and that the server is running.`}:n.includes(` 401`)||n.includes(` 403`)?{kind:`auth`,message:e,hint:`Server returned an auth error. If your endpoint requires a key, set it in Settings.`}:/-> \d{3} /.test(e)?{kind:`http`,message:e}:{kind:`unknown`,message:e}}export{u as config,T as detectRuntime,w as discoverModels,S as originOf,y as register,O as verifyConnection};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{c as n}from"./account-store-1giUExSS.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,s as o}from"./legacy-api-aliases-jKEvBgOL.js";var s=e({config:()=>d,detectRuntime:()=>T,discoverModels:()=>w,originOf:()=>S,register:()=>y,verifyConnection:()=>O});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{c as n}from"./account-store-BSIs8eWH.js";import{a as r}from"./diagnostics-DN_idNHx.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,s as o}from"./legacy-api-aliases-jKEvBgOL.js";var s=e({config:()=>d,detectRuntime:()=>T,discoverModels:()=>w,originOf:()=>S,register:()=>y,verifyConnection:()=>O});const c=t(`local-llm`),l=`local-llm`,u=`${l}-unconfigured`,d={id:l,name:`Local LLM (OpenAI-compatible)`,description:[`Connect to any OpenAI-compatible local model server.`,``,`Common base URLs:`,` • Ollama http://localhost:11434/v1`,` • LM Studio http://localhost:1234/v1`,` • llama.cpp http://localhost:8080/v1`,` • vLLM http://localhost:8000/v1`,` • mlx_lm http://localhost:8080/v1`,` • Jan http://localhost:1337/v1`,``,`Ollama needs OLLAMA_ORIGINS=* (or chrome-extension://*) so the`,`browser can reach it. macOS: launchctl setenv OLLAMA_ORIGINS "*".`].join(`
2
2
  `),requiresApiKey:!1,optionalApiKey:!0,apiKeyPlaceholder:`Leave empty for local servers, or paste a key for hosted endpoints`,apiKeyEnvVar:`LOCAL_LLM_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`http://localhost:11434/v1`,baseUrlDescription:`Ollama: 11434 • LM Studio: 1234 • llama.cpp/mlx: 8080 • vLLM: 8000 • Jan: 1337. Trailing /v1 required.`,requiresDeployment:!0,deploymentPlaceholder:`llama3.1:8b, qwen2.5-coder:14b`,deploymentDescription:`Comma-separated model IDs from your server. List them with: curl <baseUrl>/models | jq -r .data[].id`,getModelIds:()=>{let e=f(n(l));return e.length===0?[{id:u,name:`Local LLM (set base URL + model IDs in Settings)`,api:`openai`}]:e.map(e=>({id:e,name:e,api:`openai`,input:[`text`],context_window:32e3,max_tokens:4096}))}};function f(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}const p=`${l}-openai`;function m(e){return{...e,api:`openai-completions`}}function h(e){let t=e??{};return!t.apiKey||t.apiKey.length===0?{...t,apiKey:`local`}:t}const g=(e,t,n={})=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?a(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`),_=(e,t,n)=>e.id===u?v(e,`Local LLM is not configured. Set base URL and model IDs in Settings.`):e.baseUrl?o(m(e),t,h(n)):v(e,`Local LLM base URL is required (e.g. http://localhost:11434/v1).`);function v(e,t){let n=r(),i={role:`assistant`,content:[],api:e.api,provider:e.provider,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,timestamp:Date.now()};return queueMicrotask(()=>{n.push({type:`error`,reason:`error`,error:i}),n.end()}),n}function y(){i({api:p,stream:g,streamSimple:_})}function b(e){return typeof e==`object`&&!!e&&`object`in e&&e.object===`list`}function x(e){return typeof e==`object`&&!!e&&`build_info`in e}function S(e){try{let t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e.replace(/\/v1\/?$/,``).replace(/\/+$/,``)}}function C(e){let t=e.replace(/\/+$/,``);try{let e=new URL(t);if(e.pathname===``||e.pathname===`/`)return`${t}/v1`}catch{}return t}async function w(e,t,n){let r=`${C(e)}/models`,i={Accept:`application/json`};t&&t.length>0&&(i.Authorization=`Bearer ${t}`);let a=await fetch(r,{method:`GET`,headers:i,signal:n});if(!a.ok)throw Error(`GET ${r} -> ${a.status} ${a.statusText}`);let o=await a.json();return Array.isArray(o.data)?o.data.map(e=>e.id??``).filter(e=>e.length>0):[]}async function T(e,t){let n=S(e),r=await D(`${n}/api/version`,t);if(r&&typeof r.version==`string`)return{kind:`ollama`,version:r.version};if(b(await D(`${n}/api/v0/models`,t)))return{kind:`lmstudio`};let i=await D(`${n}/props`,t);if(x(i))return{kind:`llamacpp`,version:i.build_info?.version};let a=E(e);return a===`11434`?{kind:`ollama`}:a===`1234`?{kind:`lmstudio`}:a===`8000`?{kind:`vllm`}:a===`1337`?{kind:`jan`}:{kind:`unknown`}}function E(e){try{return new URL(e).port||null}catch{return null}}async function D(e,t){try{let n=await fetch(e,{method:`GET`,signal:t});return n.ok?await n.json():null}catch{return null}}async function O(e,t,n){let r={kind:`unknown`};try{r=await T(e,n)}catch{}try{let i=await w(e,t,n);return{ok:!0,runtime:r,models:i}}catch(t){let n=t instanceof Error?t.message:String(t),i=k(n,r.kind);return c.warn(`verifyConnection failed`,{baseUrl:e,runtime:r.kind,message:n}),{ok:!1,runtime:r,models:[],error:i}}}function k(e,t){let n=e.toLowerCase();return n.includes(`failed to fetch`)||n.includes(`networkerror`)?t===`ollama`?{kind:`cors`,message:e,hint:'Ollama rejects requests from non-localhost origins by default. Set OLLAMA_ORIGINS=* (or chrome-extension://*) and restart Ollama. macOS: `launchctl setenv OLLAMA_ORIGINS "*"` then quit and relaunch the Ollama app.'}:{kind:`connection`,message:e,hint:`Server unreachable. Check the URL and that the server is running.`}:n.includes(` 401`)||n.includes(` 403`)?{kind:`auth`,message:e,hint:`Server returned an auth error. If your endpoint requires a key, set it in Settings.`}:/-> \d{3} /.test(e)?{kind:`http`,message:e}:{kind:`unknown`,message:e}}export{s as n,d as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t}from"./path-utils-DNJG-zQf.js";import{C as n,p as r,t as i}from"./shared-vu5AooI5.js";import{n as a}from"./wasm-compiler-Ct7QZURL.js";function o(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}var s=class{fileName;data;constructor(e,t){this.fileName=e,this.data=t}},c={XmlResourceFiles:{log:`<?xml version="1.0" encoding="UTF-8"?>
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{a as t}from"./path-utils-DNJG-zQf.js";import{C as n,p as r,t as i}from"./shared-pVZLJOGO.js";import{n as a}from"./wasm-compiler-Ct7QZURL.js";function o(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}var s=class{fileName;data;constructor(e,t){this.fileName=e,this.data=t}},c={XmlResourceFiles:{log:`<?xml version="1.0" encoding="UTF-8"?>
2
2
  <!DOCTYPE logmap [
3
3
  <!ELEMENT logmap (log)+>
4
4
  <!ELEMENT log (#PCDATA)>
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-feature-flags-remote-Cvdn6hdM.js","assets/tray-runtime-config-BQL-GPqt.js","assets/bridge-protocol-06nbmp2X.js","assets/proxied-fetch-CiijUcSt.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/messages-BD4p8GuF.js","assets/feature-flags-DaSRRz0w.js","assets/sudo-BLu3k0lA.js","assets/logger-DDBAeTLF.js","assets/quick-llm-CGmdkAbo.js","assets/account-store-CEOiQheZ.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-CDNZj56F.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BXcp4CBT.js","assets/approval-decision-CS9Wwm5B.js","assets/capability-CTDMHYYU.js","assets/page-approval-service-IZdlRu-_.js","assets/extension-bridge-transport-B-i9vQpb.js","assets/pending-request-table-k-D7ZZsL.js","assets/lick-ws-bridge-Bb2eVADZ.js","assets/tray-leader-DaLUK8LB.js","assets/logger-BoSvu4mW.js","assets/cdp-CLhbRC4S.js","assets/navigation-watcher-BpA1OwJw.js","assets/wc-follower-oauth-9hxhD2eL.js","assets/wc-shortcuts-Cofh5Gbv.js","assets/sprinkle-renderer-BGx8hJZ_.js","assets/hid-device-registry-B2R-0rNt.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BsAiCAWF.js","assets/usb-device-registry-DmUBqrA-.js","assets/shared-Djytys1b.js","assets/mime-types-D0xZwlMO.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/slicc-app-url-B9OxaBDe.js","assets/transcript-export-DP-r8eDz.js","assets/tray-follower-status-BAjnN7Ar.js","assets/record-DOq72weu.js","assets/export-spool-CuNzzI8a.js","assets/src-BWaKqLvQ.js","assets/main-cherry--4qAV7sk.js","assets/synthetic-cdp-transport-OUVdC4zy.js","assets/oauth-service-t2taQm3p.js","assets/permissions-surface-registry-CilCRwhh.js","assets/wc-shell-BFq7cCkV.js","assets/telemetry-BWAgv6Hm.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-ByN9dVQ1.js","assets/wc-live-TppgvY0W.js","assets/slugify-BYJ6QVAt.js","assets/provider-budget-LCzMPlKv.js","assets/types-Dgm4REV3.js","assets/browser-DGwroBSO.js","assets/wc-unit-context-Cl6J7YTp.js","assets/wc-sprinkles-f2qsZXFn.js","assets/wc-attach-CzsJrwZF.js","assets/wc-permissions-Ch85s0Vv.js","assets/oauth-bootstrap-D-BY9eAI.js","assets/legacy-styles-B3nS5QUo.js","assets/connect-surface-XZmKRFD-.js","assets/wc-extension-wMcey-Cc.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import"./modulepreload-polyfill-P2Xu9kJm.js";import{A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,X as C,Y as ee,Z as te,_ as ne,a as re,b as ie,c as ae,d as oe,f as w,g as se,h as ce,i as T,j as le,k as ue,l as de,m as fe,n as pe,o as me,p as he,q as ge,s as _e,t as ve,u as ye,v as be,w as xe,x as Se,y as Ce,z as E}from"./account-store-CEOiQheZ.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{t as O}from"./logger-DDBAeTLF.js";import{i as we,n as Te,r as Ee,t as De}from"./bridge-protocol-06nbmp2X.js";import"./proxied-fetch-CiijUcSt.js";import{n as k,t as A}from"./runtime-env-Dlaokqg1.js";import{a as Oe,c as ke,o as Ae,s as je,t as Me,u as Ne}from"./tray-runtime-config-BQL-GPqt.js";import{c as Pe,o as j,s as Fe}from"./api-endpoint-DGxXvrur.js";import{o as Ie,t as Le}from"./telemetry-BWAgv6Hm.js";import{a as Re}from"./providers-CDNZj56F.js";import"./messages-BD4p8GuF.js";import{n as ze}from"./feature-flags-DaSRRz0w.js";import{t as Be}from"./tray-follower-status-BAjnN7Ar.js";import{n as Ve}from"./clipboard-eqmn97SP.js";import{n as He}from"./tray-join-url-BIvzbiFR.js";var Ue=`role`;function We(e){if(!e)return!1;let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(t===`localhost`||t===`::1`||/^127(\.\d{1,3}){3}$/.test(t))}function Ge(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function Ke(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function qe(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(Ee),r=t.get(Te);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i;try{i=new URL(n).hostname}catch{return null}if(!We(i))return null;let a=t.get(Ue),o=a===`leader`||a===`follower`?a:null;return{url:n,subprotocol:`${De}${r}`,token:r,apiBaseUrl:Ge(n),lickWsUrl:Ke(n),role:o}}var Je=`slicc:bridge-config`,Ye=`slicc:extension-delegate-config`;function Xe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var Ze=O(`boot/ext-fetch-delegate`);function Qe(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function $e(e,t,n){let r=Qe();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function et(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Xe(t.data))return;let n=t.ports?.[0];if(!n){Ze.warn(`delegated fetch envelope arrived without a response port`);return}$e(t.data,n,e)})}var tt=`slicc_feature_flags_remote`;function nt(e){return`${tt}:${e}`}function rt(e,t){let n=at(t);ze(e,ot(n,e)??{})}function it(e,t,n){try{e?.setItem(nt(t),JSON.stringify(n))}catch{}}function at(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function ot(e,t){try{let n=e?.getItem(nt(t));return n?st(JSON.parse(n)):null}catch{return null}}function st(e){return!ct(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function ct(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lt(e,t,n){if(t){try{if(new URL(e).searchParams.has(`detached`))return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);if(t.searchParams.get(`connect`)===`1`)return`connect`;if(t.searchParams.get(`runtime`)===`hosted-leader`)return`hosted-leader`;if(t.searchParams.get(`cherry`)===`1`)return`cherry`;let r=n===void 0?typeof window<`u`?window.localStorage:null:n;return je(e,r)?`follower`:dt(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ut(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function dt(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}function ft(e,t){rt(e,t.storage),D(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-Cvdn6hdM.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:n})=>n(e,t)).catch(()=>{})}function pt(e){let t=lt(e.locationHref,e.isExtension,e.storage);return ft(t,e),t}function mt(){if(k())return;let e=new Blob([`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-feature-flags-remote-BHnboyDd.js","assets/tray-runtime-config-BQL-GPqt.js","assets/bridge-protocol-06nbmp2X.js","assets/proxied-fetch-CiijUcSt.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/base64-DJRlyqZu.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/messages-BD4p8GuF.js","assets/feature-flags-DaSRRz0w.js","assets/sudo-BUdJPcIH.js","assets/logger-DDBAeTLF.js","assets/quick-llm-DDPHThwA.js","assets/account-store-CfKG-Ig3.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-CFCRFvFH.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-BXcp4CBT.js","assets/approval-decision-CS9Wwm5B.js","assets/capability-CTDMHYYU.js","assets/page-approval-service-IZdlRu-_.js","assets/extension-bridge-transport-B-i9vQpb.js","assets/pending-request-table-k-D7ZZsL.js","assets/lick-ws-bridge-Bb2eVADZ.js","assets/tray-leader-DaLUK8LB.js","assets/logger-BoSvu4mW.js","assets/cdp-BX0PiRAg.js","assets/navigation-watcher-BpA1OwJw.js","assets/wc-follower-oauth-CUFehOmO.js","assets/wc-shortcuts-udkJj992.js","assets/sprinkle-renderer-DRjk0Axq.js","assets/hid-device-registry-B2R-0rNt.js","assets/serial-port-registry-CCqklAEr.js","assets/usb-operations-BsAiCAWF.js","assets/usb-device-registry-DmUBqrA-.js","assets/shared-f0tP2HLX.js","assets/mime-types-D0xZwlMO.js","assets/theme-CXRqxpw6.js","assets/theme-engine-By4GU_Wc.js","assets/slicc-app-url-B9OxaBDe.js","assets/transcript-export-DP-r8eDz.js","assets/tray-follower-status-BAjnN7Ar.js","assets/record-DOq72weu.js","assets/export-spool-CuNzzI8a.js","assets/src-BWaKqLvQ.js","assets/main-cherry-D1YCAckw.js","assets/synthetic-cdp-transport-OUVdC4zy.js","assets/oauth-service-t2taQm3p.js","assets/permissions-surface-registry-CilCRwhh.js","assets/wc-shell-CdkXzmml.js","assets/telemetry-BWAgv6Hm.js","assets/wc-shell-WkeczD9x.css","assets/wc-follower-UnBMtKdu.js","assets/wc-live-B6vu9NGR.js","assets/slugify-BYJ6QVAt.js","assets/provider-budget-LCzMPlKv.js","assets/types-Dgm4REV3.js","assets/browser-DGwroBSO.js","assets/wc-unit-context-Cl6J7YTp.js","assets/wc-sprinkles-CiVxUeGF.js","assets/wc-attach-Dm3guiHt.js","assets/wc-permissions-Ch85s0Vv.js","assets/oauth-bootstrap-0NJ1uts7.js","assets/legacy-styles-B3nS5QUo.js","assets/connect-surface-COdJoI-e.js","assets/wc-extension-B-HQw_fj.js","assets/wc-detached-B3WCbbZT.js"])))=>i.map(i=>d[i]);
2
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import"./modulepreload-polyfill-P2Xu9kJm.js";import{A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,X as C,Y as ee,Z as te,_ as ne,a as re,b as ie,c as ae,d as oe,f as w,g as se,h as ce,i as T,j as le,k as ue,l as de,m as fe,n as pe,o as me,p as he,q as ge,s as _e,t as ve,u as ye,v as be,w as xe,x as Se,y as Ce,z as E}from"./account-store-CfKG-Ig3.js";import{t as D}from"./preload-helper-Czpn1I53.js";import{t as O}from"./logger-DDBAeTLF.js";import{i as we,n as Te,r as Ee,t as De}from"./bridge-protocol-06nbmp2X.js";import"./proxied-fetch-CiijUcSt.js";import{n as k,t as A}from"./runtime-env-Dlaokqg1.js";import{a as Oe,c as ke,o as Ae,s as je,t as Me,u as Ne}from"./tray-runtime-config-BQL-GPqt.js";import{c as Pe,o as j,s as Fe}from"./api-endpoint-DGxXvrur.js";import{o as Ie,t as Le}from"./telemetry-BWAgv6Hm.js";import{a as Re}from"./providers-CFCRFvFH.js";import"./messages-BD4p8GuF.js";import{n as ze}from"./feature-flags-DaSRRz0w.js";import{t as Be}from"./tray-follower-status-BAjnN7Ar.js";import{n as Ve}from"./clipboard-eqmn97SP.js";import{n as He}from"./tray-join-url-BIvzbiFR.js";var Ue=`role`;function We(e){if(!e)return!1;let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(t===`localhost`||t===`::1`||/^127(\.\d{1,3}){3}$/.test(t))}function Ge(e){try{let t=new URL(e);return`${t.protocol===`wss:`?`https:`:`http:`}//${t.host}`}catch{return null}}function Ke(e){try{let t=new URL(e);return`${t.protocol}//${t.host}/licks-ws`}catch{return null}}function qe(e){let t;try{t=new URLSearchParams(e)}catch{return null}let n=t.get(Ee),r=t.get(Te);if(!n||!r||!/^wss?:\/\//.test(n))return null;let i;try{i=new URL(n).hostname}catch{return null}if(!We(i))return null;let a=t.get(Ue),o=a===`leader`||a===`follower`?a:null;return{url:n,subprotocol:`${De}${r}`,token:r,apiBaseUrl:Ge(n),lickWsUrl:Ke(n),role:o}}var Je=`slicc:bridge-config`,Ye=`slicc:extension-delegate-config`;function Xe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`slicc:ext-fetch`&&typeof t.extensionId==`string`&&!!t.request&&typeof t.request==`object`}var Ze=O(`boot/ext-fetch-delegate`);function Qe(){let e=globalThis.chrome?.runtime;return e&&typeof e.connect==`function`?e:null}function $e(e,t,n){let r=Qe();if(!r){try{t.postMessage({type:`response-error`,error:`extension-delegate: chrome.runtime.connect unavailable`})}catch{}t.close();return}let i=e.extensionId||n,a;try{a=r.connect(i,{name:`fetch-proxy.fetch`})}catch(e){try{t.postMessage({type:`response-error`,error:`extension-delegate: connect failed — ${e instanceof Error?e.message:String(e)}`})}catch{}t.close();return}let o=!1,s=()=>{o=!0;try{a.disconnect()}catch{}try{t.close()}catch{}};a.onMessage.addListener(e=>{if(o)return;let n=e;try{t.postMessage(n)}catch{}(n.type===`response-end`||n.type===`response-error`)&&s()}),a.onDisconnect.addListener(()=>{if(!o){try{t.postMessage({type:`response-error`,error:`extension-delegate: fetch-proxy port disconnected`})}catch{}s()}}),a.postMessage({type:`request`,...e.request})}function et(e){typeof navigator>`u`||!navigator.serviceWorker||navigator.serviceWorker.addEventListener(`message`,t=>{if(!Xe(t.data))return;let n=t.ports?.[0];if(!n){Ze.warn(`delegated fetch envelope arrived without a response port`);return}$e(t.data,n,e)})}var tt=`slicc_feature_flags_remote`;function nt(e){return`${tt}:${e}`}function rt(e,t){let n=at(t);ze(e,ot(n,e)??{})}function it(e,t,n){try{e?.setItem(nt(t),JSON.stringify(n))}catch{}}function at(e){if(e!==void 0)return e;try{let e=globalThis.localStorage;return typeof e?.getItem!=`function`||typeof e.setItem!=`function`?void 0:e}catch{return}}function ot(e,t){try{let n=e?.getItem(nt(t));return n?st(JSON.parse(n)):null}catch{return null}}function st(e){return!ct(e)||Object.values(e).some(e=>typeof e!=`string`)?null:e}function ct(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lt(e,t,n){if(t){try{if(new URL(e).searchParams.has(`detached`))return`extension-detached`}catch{}return`extension`}try{let t=new URL(e);if(t.searchParams.get(`connect`)===`1`)return`connect`;if(t.searchParams.get(`runtime`)===`hosted-leader`)return`hosted-leader`;if(t.searchParams.get(`cherry`)===`1`)return`cherry`;let r=n===void 0?typeof window<`u`?window.localStorage:null:n;return je(e,r)?`follower`:dt(t)?`electron-overlay`:`standalone`}catch{return`standalone`}}function ut(e,t){return e===`electron-overlay`||e===`hosted-leader`||e===`standalone`&&t}function dt(e){return e.pathname===`/electron`||e.pathname===`/electron/`||e.searchParams.get(`runtime`)===`electron-overlay`}function ft(e,t){rt(e,t.storage),D(async()=>{let{refreshFeatureFlagsForPage:e}=await import(`./setup-feature-flags-remote-BHnboyDd.js`);return{refreshFeatureFlagsForPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])).then(({refreshFeatureFlagsForPage:n})=>n(e,t)).catch(()=>{})}function pt(e){let t=lt(e.locationHref,e.isExtension,e.storage);return ft(t,e),t}function mt(){if(k())return;let e=new Blob([`
3
3
  let lastPong = Date.now();
4
4
  let frozen = false;
5
5
  setInterval(() => {
@@ -19,4 +19,4 @@ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import"./modulepreload-polyfi
19
19
  }
20
20
  }
21
21
  };
22
- `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var ht=`slicc-nuke-control`,gt=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function _t(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(ht),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var M=null;function vt(){return M||(M=_t(),M)}O(`stale-asset`);var yt=`slicc-stale-asset-reload`;function bt(e,t){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(yt),r=n=>{let r=n.data;r?.type===`stale-asset-reload`&&r.instanceId===e&&t(r.replayTurn===!0)};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}var xt=`slicc:stale-asset-reloaded-at`,St=6e4,N=`slicc:stale-asset-replay`;function Ct(e=window.sessionStorage){try{e.setItem(N,`1`)}catch{}}function wt(e=window.sessionStorage){try{return e.getItem(N)===`1`&&(e.removeItem(N),!0)}catch{return!1}}function Tt(){return{reload:()=>window.location.reload(),storage:window.sessionStorage,now:()=>Date.now(),windowMs:St,storageKey:xt}}function Et(e,t,n){return e===null||t-e>=n}function P(e=Tt()){let t;try{t=e.storage.getItem(e.storageKey)}catch{return!1}let n=t===null?null:Number(t),r=n!==null&&Number.isFinite(n)?n:null,i=e.now();if(!Et(r,i,e.windowMs))return!1;try{e.storage.setItem(e.storageKey,String(i))}catch{return!1}return e.reload(),!0}var F=null,I=null;function Dt(e){F||(I={...Tt(),...e},F=e=>{P(I)&&e.preventDefault()},window.addEventListener(`vite:preloadError`,F))}var L=null;function Ot(e){return L||(L=bt(e,e=>{e&&Ct(),P(I??void 0)}),L)}var kt=`slicc-cdp-superseded-banner`;function At(e){if(e.getElementById(kt))return;let t=e.createElement(`div`);t.id=kt,t.setAttribute(`role`,`alert`),t.textContent=`Another SLICC tab or window has taken control of this browser instance. Only one tab can drive the browser per instance — close the other tabs, then reload this page to resume.`,t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`right:0`,`z-index:2147483647`,`padding:10px 16px`,`background:#b3261e`,`color:#fff`,`font:13px/1.4 system-ui,sans-serif`,`text-align:center`,`box-shadow:0 1px 4px rgba(0,0,0,0.3)`].join(`;`),e.body.appendChild(t)}var jt=e({setupSudoExtension:()=>Mt,setupSudoStandalone:()=>R});async function R(e){let{createSudoBroker:t,installSudoTestHook:n}=await D(async()=>{let{createSudoBroker:e,installSudoTestHook:t}=await import(`./sudo-BLu3k0lA.js`);return{createSudoBroker:e,installSudoTestHook:t}},__vite__mapDeps([12,5,13,14,4,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,31,32,33,34,35])),{createRestCapabilityBroker:r}=await D(async()=>{let{createRestCapabilityBroker:e}=await import(`./capability-CTDMHYYU.js`).then(e=>e.t);return{createRestCapabilityBroker:e}},__vite__mapDeps([34,4,5]));n(t(r()))}async function Mt(e){let{installPanelSudoResponder:t}=await D(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-BLu3k0lA.js`);return{installPanelSudoResponder:e}},__vite__mapDeps([12,5,13,14,4,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,31,32,33,34,35]));t()}function Nt(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function z(e){let t;try{t=new URLSearchParams(e)}catch{return null}if(t.get(`slicc`)!==`leader`)return null;let n=t.get(`ext`);return n?{extensionId:n}:null}var Pt=[100,200,400,800,1600];async function B(e,t,n,r=Pt,i=e=>new Promise(t=>setTimeout(t,e))){let a=r.length+1,o=null;for(let s=0;s<a;s++)try{await e.connect(t),s>0&&n.info(`CDP bridge connect succeeded after retry`,{attempt:s+1});return}catch(e){o=e,s<r.length&&await i(r[s]??0)}n.warn(`Initial CDP connect failed after retries; worker-forwarded commands will retry on demand`,o instanceof Error?o.message:String(o))}async function Ft(e,t,n){let{ExtensionBridgeTransport:r}=await D(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-B-i9vQpb.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([36,13,37])),{mapDiscoveryPayloadToLickEvent:i,mapNavigatePayloadToLickEvent:a}=await D(async()=>{let{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}=await import(`./lick-ws-bridge-Bb2eVADZ.js`);return{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}},__vite__mapDeps([38,13,39,4,3,5,6,7,8,9,1,2,10,40])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=e=>{if(e){if(o){o.sendForwardedLick(e);return}s.length>=50&&(s.shift(),c||(c=!0,n.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(e)}},d=new e(new r({extensionId:t,onLick:e=>{u(a(e))},onDiscovery:e=>{u(i(e))},onOpenSettings:()=>{globalThis.dispatchEvent(new CustomEvent(`slicc:open-settings-from-panel`))}}));return await B(d,void 0,n),{browser:d,attachLickForwardingClient:l}}async function It(e){let{runtimeMode:t,envBaseUrl:n,window:r,log:i,sleep:a}=e,o=t===`electron-overlay`;i.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:t});let{BrowserAPI:s}=await D(async()=>{let{BrowserAPI:e}=await import(`./cdp-CLhbRC4S.js`);return{BrowserAPI:e}},__vite__mapDeps([41,13,42,2,43,4,5,44,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,32,45,46,47,48,49,50,51,52,53,54,55,56,37,57,58,59]));await R({log:i});let c,l,u,d=null,f=null,p=null,m=null,h,g=t===`cherry`?null:z(r.location.search),_=!!g&&A(),v=t===`cherry`||_?null:qe(r.location.search);v?.apiBaseUrl&&(d=v.apiBaseUrl,Pe(v.apiBaseUrl),f=v.token,j(v.token)),v?.lickWsUrl&&(p=v.lickWsUrl);let y=t===`cherry`||_||v!==null,b=await Oe(),x=ut(t,b!==null)?Me:null;if(await ke({locationHref:r.location.href,storage:r.localStorage,envBaseUrl:n,defaultWorkerBaseUrl:x,runtimeConfigFetcher:async()=>b}),t===`cherry`){let{setupCherryFollower:e}=await D(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry--4qAV7sk.js`);return{setupCherryFollower:e}},__vite__mapDeps([60,13,55,37,41,42,2,43,4,5,44,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,32,45,46,47,48,49,50,51,52,53,54,56,57,58,59,61])),t=await e();c=t.browser,l=t.joinUrl,u=t.transport}else if(g&&A()){i.info(`Routing CDP through the extension bridge (leader tab)`);let e=await Ft(s,g.extensionId,i);c=e.browser,h=e.attachLickForwardingClient,m=g.extensionId,Fe(g.extensionId)}else{c=new s,v&&i.info(`Routing CDP through local standalone bridge`,{url:v.url,role:v.role??`(unset)`});let e=v?{url:v.url,protocols:v.subprotocol}:void 0;v?.role===`follower`?(i.info(`Skipping CDP connect for follower overlay tab`),c.primeConnectOptions(e)):(await B(c,e,i,void 0,a),c.setCdpSupersededHandler(()=>At(r.document)))}let S=c.getUnderlyingTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:S,hasLocalCdpSurface:y,cherryJoinUrl:l,cherryTransport:u,instanceId:Nt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m,attachLickForwardingClient:h}}var V=O(`storage-persist`);function Lt(){try{return globalThis.navigator?.storage}catch{return}}async function Rt(e=Lt()){try{return typeof e?.persist==`function`?typeof e.persisted==`function`&&await e.persisted()?`already-persisted`:await e.persist()?`granted`:`denied`:`unsupported`}catch(e){return V.warn(`storage persistence check failed`,e),`failed`}}var zt=!1;function Bt(){zt||(zt=!0,Rt().then(e=>{switch(e){case`granted`:V.info(`OPFS marked persistent — SLICC data is now exempt from disk-pressure eviction`);break;case`already-persisted`:V.debug(`OPFS already persistent`);break;case`denied`:V.warn(`Browser declined persistent storage — SLICC data can be evicted if the disk fills up`);break;case`unsupported`:V.debug(`navigator.storage.persist() unavailable in this runtime`)}}).catch(()=>{}))}var H=O(`boot/sw-registration`);async function Vt(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await Wt())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),H.info(`Preview SW registered`),!k())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),H.info(`LLM-proxy SW registered`)}catch(e){H.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),H.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(Ht(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{Ht(e)})),t&&(Ut(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{Ut(t)}))}catch(e){H.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function Ht(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Je,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){H.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function Ut(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ye,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){H.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function Wt(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),H.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){H.error(`connect-mode SW cleanup failed`,e)}return!1}var Gt=e({ACCOUNTS_KEY:()=>ve,__test__:()=>pe,addAccount:()=>T,applyProviderDefaults:()=>re,clearAllSettings:()=>me,clearApiKey:()=>_e,clearBaseUrl:()=>ae,clearSelectedProvider:()=>de,describeInvalidJoinUrl:()=>He,downloadProviders:()=>Yt,ensureOAuthMaskReplica:()=>ye,exportProviders:()=>oe,getAccounts:()=>w,getAllAvailableModels:()=>he,getAllExtraOAuthDomains:()=>fe,getAlternativeModelProviders:()=>ce,getApiKey:()=>se,getApiKeyForProvider:()=>ne,getApiVersionForProvider:()=>be,getAvailableProviders:()=>Ce,getBaseUrl:()=>ie,getBaseUrlForProvider:()=>Se,getDeploymentForProvider:()=>v,getExtraOAuthDomains:()=>r,getOAuthAccountInfo:()=>xe,getProviderConfig:()=>y,getProviderModels:()=>a,getRawApiKeyForProvider:()=>i,getSelectedModelId:()=>h,getSelectedProvider:()=>ue,isModelHiddenFromPicker:()=>t,isUsableOAuthMaskReplica:()=>le,logoutOAuthAccount:()=>p,maskOAuthTokenWithRetry:()=>m,migrateLegacyAuthOnlySelection:()=>g,modelRunsOnProvider:()=>o,persistOAuthMaskViaServiceWorker:()=>l,policyVisible:()=>f,providerOffersLlmModels:()=>_,reloginOAuthAccount:()=>Qt,removeAccount:()=>E,resolveCurrentModel:()=>n,resolveModelById:()=>x,resolveModelByShorthand:()=>c,resolveModelIdForScoop:()=>b,resolveModelSelectionForScoop:()=>S,saveOAuthAccount:()=>s,setApiKey:()=>d,setBaseUrl:()=>ge,setExtraOAuthDomains:()=>u,setExtraOAuthDomainsAsync:()=>ee,setSelectedModelId:()=>C,setSelectedProvider:()=>te,showProviderSettings:()=>vn,testOnlyDispatchTrayJoinWithFailureFeedback:()=>qt}),Kt=O(`provider-settings`);function qt(e,t){return Jt(e,t)}function Jt(e,t){let n=`tray-join-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=!1,i,a=()=>{r||(r=!0,i!==void 0&&clearTimeout(i),window.removeEventListener(`slicc:tray-join-failed`,o))},o=r=>{let i=r.detail;if(i.requestId!==void 0&&i.requestId!==n)return;if(a(),!t.isConnected){Kt.error(`Tray-join failure arrived after dialog dismissed (UX swallowed half-state)`,{joinUrl:e,error:i.error,requestId:n});return}let o=t.dataset.dismissTimer;if(o){let e=Number(o);Number.isFinite(e)&&clearTimeout(e),delete t.dataset.dismissTimer}t.textContent=`Sync failed: ${i.error}. Reload the page and try again.`,t.style.color=`var(--slicc-cone)`};return window.addEventListener(`slicc:tray-join-failed`,o),i=setTimeout(a,1e4),window.dispatchEvent(new CustomEvent(`slicc:tray-join`,{detail:{joinUrl:e,requestId:n}})),a}function Yt(){let e=JSON.stringify(oe(),null,2),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`providers.json`,r.click(),URL.revokeObjectURL(n)}function Xt(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function U(e){let t=`http://www.w3.org/2000/svg`,n=document.createElementNS(t,`svg`);n.setAttribute(`width`,`14`),n.setAttribute(`height`,`14`),n.setAttribute(`viewBox`,`0 0 20 20`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`1.5`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`);for(let r of e){let e=document.createElementNS(t,`path`);e.setAttribute(`d`,r),n.appendChild(e)}return n}var W={pen:[`M14.3 3.3a1.5 1.5 0 0 1 2.1 0l.3.3a1.5 1.5 0 0 1 0 2.1L7.7 14.8l-3.2.7.7-3.2z`],trash:[`M4 6h12`,`M8 6V4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2`,`M6 6v10a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V6`],logout:[`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,`M16 17l5-5-5-5`,`M21 12H9`],login:[`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,`M10 17l5-5-5-5`,`M15 12H3`]},G=`background: transparent; border: 1px solid var(--s2-border-subtle); color: var(--s2-content-secondary); border-radius: var(--s2-radius-s); padding: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color 0.15s, border-color 0.15s;`;function K(e,t){e.addEventListener(`mouseenter`,()=>{e.style.color=t,e.style.borderColor=t}),e.addEventListener(`mouseleave`,()=>{e.style.color=`var(--s2-content-secondary)`,e.style.borderColor=`var(--s2-border-subtle)`})}function q(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function J(e){e.options?.startInAddAccount?q(e):Y(e)}function Zt(e){let t=document.createElement(`div`);return t.style.cssText=`font-size: 11px; color: var(--s2-content-disabled); font-family: monospace; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`,e.loggedOut?(t.textContent=e.userName?`Logged out — was ${e.userName}`:`Logged out`,t.style.color=`var(--s2-content-disabled)`):t.textContent=e.userName?e.userName:e.accessToken?`Logged in`:Xt(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Qt(e,t){let{createOAuthLauncher:n,createInterceptingOAuthLauncherForCurrentRuntime:r}=await D(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-t2taQm3p.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([62,5,3,4,6,7,8,9,29,63])),i={forceReauth:!0};if(e.onOAuthLoginIntercepted){let n=await r();n&&await e.onOAuthLoginIntercepted(n,t,i)}else if(e.onOAuthLogin){let r=n();await e.onOAuthLogin(r,t,i)}}function $t(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(U(W.pen)),K(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function en(e,t,n){let r=document.createElement(`button`);return r.style.cssText=G,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(U(W.login)),K(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{Qt(n,()=>Y(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(U(W.logout)),K(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await p(t.providerId),Y(e)})()})),r}function tn(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(U(W.trash)),K(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await E(t.providerId),Y(e)})()}),n}function nn(e,t){let n=y(t.providerId),r=document.createElement(`div`);r.style.cssText=`display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); margin-bottom: 8px; border: 1px solid var(--s2-border-subtle);`;let i=document.createElement(`div`);i.style.cssText=`flex: 1; min-width: 0;`;let a=document.createElement(`div`);a.style.cssText=`font-size: 14px; font-weight: 600; color: var(--s2-content-default);`,a.textContent=n.name,i.appendChild(a),i.appendChild(Zt(t)),r.appendChild(i);let o=document.createElement(`div`);return o.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,o.appendChild($t(e,t)),n.isOAuth&&o.appendChild(en(e,t,n)),o.appendChild(tn(e,t)),r.appendChild(o),r}function rn(e){let t=document.createDocumentFragment(),n=document.createElement(`hr`);n.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-weight: 600; margin-bottom: 8px;`,r.textContent=`Tray`,t.appendChild(r);let i=Be(),a=i.state!==`inactive`,o=Ae(window.localStorage);if(a||o){let e=document.createElement(`div`);e.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px;`,e.textContent=`Follower: ${a?i.state:`configured`}`,i.error&&(e.textContent+=` — ${i.error}`,e.style.color=`var(--slicc-cone)`),t.appendChild(e)}let s=document.createElement(`button`);return s.className=`dialog__btn dialog__btn--secondary`,s.textContent=a||o?`Reconnect to other browser`:`Connect to another browser`,s.addEventListener(`click`,()=>Q(e)),t.appendChild(s),t}function Y(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Accounts`,t.appendChild(n);let r=w();if(r.length===0){let e=document.createElement(`div`);e.className=`dialog__desc`,e.textContent=`No accounts configured.`,t.appendChild(e)}else{let n=document.createElement(`div`);n.style.cssText=`margin-bottom: 16px;`;for(let t of r)n.appendChild(nn(e,t));t.appendChild(n)}let i=document.createElement(`div`);i.style.cssText=`display: flex; gap: 8px;`;let a=document.createElement(`button`);a.className=r.length>0?`dialog__btn dialog__btn--secondary`:`dialog__btn`,a.style.flex=`1`,a.textContent=`Add Account`,a.addEventListener(`click`,()=>Z(e)),i.appendChild(a);let o=document.createElement(`button`);o.className=`dialog__btn dialog__btn--secondary`,o.style.flex=`1`,o.textContent=`Export`,o.addEventListener(`click`,()=>Yt()),i.appendChild(o),t.appendChild(i),t.appendChild(rn(e));let s=document.createElement(`hr`);s.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Get Started`,c.addEventListener(`click`,()=>q(e)),t.appendChild(c)}function an(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=y(t.providerId),r=document.createElement(`option`);return r.value=t.providerId,r.textContent=e.name,n.appendChild(r),n.disabled=!0,n.style.opacity=`0.7`,n}let r=document.createElement(`option`);r.value=``,r.textContent=`Select a provider…`,r.disabled=!0,r.selected=!0,r.hidden=!0,n.appendChild(r);let i=new Set(w().map(e=>e.providerId)),a=[...Ce()].sort((e,t)=>y(e).name.localeCompare(y(t).name));for(let t of a){if(i.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!_(t))continue;let r=document.createElement(`option`);r.value=t,r.textContent=y(t).name,n.appendChild(r)}return n}function on(e,t){let n=an(e,t),r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-size: 12px; color: var(--s2-content-tertiary); margin-bottom: 16px; margin-top: -4px;`;let i=document.createElement(`div`);i.style.cssText=`margin-bottom: 16px; display: none;`;let a=document.createElement(`button`);a.className=`dialog__btn`,a.textContent=`Login`,a.style.cssText=`width: 100%; margin-bottom: 8px;`,i.appendChild(a);let o=document.createElement(`div`);o.className=`dialog__desc`,o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); text-align: center;`,i.appendChild(o);let s=document.createElement(`div`),c=document.createElement(`div`);c.className=`dialog__desc`,s.appendChild(c);let l=document.createElement(`input`);l.className=`dialog__input`,l.type=`password`,l.autocomplete=`off`,l.spellcheck=!1,t&&(l.value=t.apiKey),s.appendChild(l);let u=document.createElement(`div`),d=document.createElement(`div`);d.className=`dialog__desc`,d.textContent=`Base URL:`,u.appendChild(d);let f=document.createElement(`input`);f.className=`dialog__input`,f.type=`text`,f.autocomplete=`off`,f.spellcheck=!1,t?.baseUrl&&(f.value=t.baseUrl),u.appendChild(f);let p=document.createElement(`div`);p.className=`dialog__desc`,p.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,u.appendChild(p);let m=document.createElement(`div`);m.style.display=`none`;let h=document.createElement(`div`);h.className=`dialog__desc`,h.textContent=`Deployment:`,m.appendChild(h);let g=document.createElement(`input`);g.className=`dialog__input`,g.type=`text`,g.autocomplete=`off`,g.spellcheck=!1,t?.deployment&&(g.value=t.deployment),m.appendChild(g);let _=document.createElement(`div`);_.className=`dialog__desc`,_.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,m.appendChild(_);let v=document.createElement(`div`);v.style.display=`none`;let y=document.createElement(`div`);y.className=`dialog__desc`,y.textContent=`API Version:`,v.appendChild(y);let b=document.createElement(`input`);b.className=`dialog__input`,b.type=`text`,b.autocomplete=`off`,b.spellcheck=!1,t?.apiVersion&&(b.value=t.apiVersion),v.appendChild(b);let x=document.createElement(`div`);x.className=`dialog__desc`,x.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,v.appendChild(x);let S=document.createElement(`div`);S.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`;let C=document.createElement(`button`);return C.className=`dialog__btn`,C.textContent=t?`Save`:`Add`,{providerSelect:n,providerDesc:r,oauth:{section:i,loginBtn:a,status:o},apiKeySection:s,apiKeyLabel:c,apiKeyInput:l,baseUrlSection:u,baseUrlInput:f,baseUrlDesc:p,deploymentSection:m,deploymentInput:g,deploymentDesc:_,apiVersionSection:v,apiVersionInput:b,apiVersionDesc:x,errorEl:S,saveBtn:C}}function sn(e){let t=document.createElement(`div`);t.setAttribute(`data-slicc-device-code-prompt`,``),t.style.cssText=`display:flex;flex-direction:column;gap:8px`;let n=document.createElement(`div`);n.className=`dialog__desc`,n.textContent=`Verification code`,n.style.cssText=`font-size: 11px; color: var(--s2-content-tertiary);`;let r=document.createElement(`div`);r.textContent=e,r.style.cssText=[`font: 600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing: 2px`,`color: var(--s2-content-primary, #e6edf3)`,`background: var(--s2-bg-secondary, #161b22)`,`border: 1px solid var(--s2-border, #30363d)`,`border-radius: 6px`,`padding: 10px 12px`,`text-align: center`,`user-select: all`,`cursor: text`].join(`;`);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.cssText=`font-size: 12px; color: var(--s2-content-secondary);`,i.textContent=`Click Copy & Continue — we will open the GitHub authorization page in a new tab. Paste this code there if it is not already filled in.`;let a=document.createElement(`div`);a.style.cssText=`display:flex;gap:8px;justify-content:flex-end;margin-top:4px`;let o=document.createElement(`button`);o.type=`button`,o.className=`dialog__btn`,o.textContent=`Cancel`;let s=document.createElement(`button`);return s.type=`button`,s.className=`dialog__btn dialog__btn--primary`,s.textContent=`Copy & Continue`,a.appendChild(o),a.appendChild(s),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(a),{prompt:t,cancelBtn:o,continueBtn:s}}function cn(e){return t=>new Promise(n=>{let r=e.loginBtn.style.display,i=e.status.style.display;e.loginBtn.style.display=`none`,e.status.style.display=`none`;let{prompt:a,cancelBtn:o,continueBtn:s}=sn(t.userCode),c=()=>{try{a.remove()}catch{}e.loginBtn.style.display=r,e.status.style.display=i};o.addEventListener(`click`,()=>{c(),n(`cancel`)}),s.addEventListener(`click`,()=>{(async()=>{try{await Ve(t.userCode)}catch{}c(),e.status.style.display=i,e.status.textContent=`Waiting for you to authorize in the new tab…`,n(`continue`)})()}),e.section.appendChild(a)})}async function ln(e,t){let n=t.providerSelect.value;if(!n)return;let r=y(n);if(!r.onOAuthLogin&&!r.onOAuthLoginIntercepted)return;let{status:i}=t.oauth,a=w().some(e=>e.providerId===n),o=Se(n);if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()&&!o){i.textContent=`Base URL is required.`,i.style.color=`var(--slicc-cone)`,t.baseUrlInput.focus();return}r.requiresBaseUrl&&t.baseUrlInput.value.trim()&&T(n,``,t.baseUrlInput.value.trim()),i.textContent=`Opening login window...`;try{if(r.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:n}=await D(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-t2taQm3p.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([62,5,3,4,6,7,8,9,29,63])),i=await n();if(!i)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await r.onOAuthLoginIntercepted(i,()=>J(e),{presentDeviceCode:cn(t.oauth)})}else if(r.onOAuthLogin){let{createOAuthLauncher:t}=await D(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-t2taQm3p.js`);return{createOAuthLauncher:e}},__vite__mapDeps([62,5,3,4,6,7,8,9,29,63])),n=t();await r.onOAuthLogin(n,()=>J(e))}}catch(e){if(!a)try{await E(n)}catch{}Kt.error(`OAuth login failed`,{providerId:n,error:e instanceof Error?e.message:String(e)}),i.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function un(e,t){if(t.isOAuth){e.oauth.section.style.display=``,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,t.requiresBaseUrl&&(e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``),e.oauth.loginBtn.textContent=`Login with ${t.name}`,e.saveBtn.style.display=`none`;return}e.oauth.section.style.display=`none`;let n=t.requiresApiKey?`API Key`:`API Key (optional)`;e.apiKeyLabel.textContent=`${n}${t.apiKeyEnvVar?` (${t.apiKeyEnvVar})`:``}:`,e.apiKeyInput.placeholder=t.apiKeyPlaceholder||`API key`,e.apiKeySection.style.display=t.requiresApiKey||t.optionalApiKey?``:`none`,e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,e.saveBtn.style.display=``}function dn(e,t){t.requiresDeployment?(e.deploymentSection.style.display=``,e.deploymentInput.placeholder=t.deploymentPlaceholder||`deployment-name`,e.deploymentDesc.textContent=t.deploymentDescription||``):e.deploymentSection.style.display=`none`}function fn(e,t){t.requiresApiVersion?(e.apiVersionSection.style.display=``,!e.apiVersionInput.value&&t.apiVersionDefault&&(e.apiVersionInput.value=t.apiVersionDefault),e.apiVersionInput.placeholder=t.apiVersionDefault||`api-version`,e.apiVersionDesc.textContent=t.apiVersionDescription||``):e.apiVersionSection.style.display=`none`}function pn(e){let t=e.providerSelect.value;if(!t){e.providerDesc.textContent=``,e.oauth.section.style.display=`none`,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=`none`,e.deploymentSection.style.display=`none`,e.apiVersionSection.style.display=`none`,e.saveBtn.style.display=`none`;return}let n=y(t);e.providerDesc.textContent=n.description,un(e,n),dn(e,n),fn(e,n)}function X(e,t){let n=t.providerSelect.value;if(!n)return;let r=y(n),i=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(r.requiresApiKey&&t.apiKeyInput.value.trim().length<5){i(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()){i(`Base URL is required for this provider.`,t.baseUrlInput);return}if(r.requiresDeployment&&!t.deploymentInput.value.trim()){i(`Deployment name is required for this provider.`,t.deploymentInput);return}T(n,t.apiKeyInput.value.trim(),t.baseUrlInput.value.trim()||void 0,t.deploymentInput.value.trim()||void 0,t.apiVersionInput.value.trim()||void 0),J(e)}function mn(e,t){let{dialog:n,options:r}=e,i=w().length>0;if(r?.startInAddAccount){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Cancel`,t.addEventListener(`click`,()=>q(e)),n.appendChild(t)}else if(!t&&!i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Connect to another browser`,t.addEventListener(`click`,()=>Q(e)),n.appendChild(t)}else if(i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Back`,t.addEventListener(`click`,()=>Y(e)),n.appendChild(t)}}function Z(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=t?`Edit Account`:`Add Account`,n.appendChild(r);let i=document.createElement(`div`);i.className=`dialog__desc`,i.textContent=`Provider:`,n.appendChild(i);let a=on(e.options,t);n.appendChild(a.providerSelect),n.appendChild(a.providerDesc),a.oauth.loginBtn.addEventListener(`click`,()=>{ln(e,a)}),t?.userName&&(a.oauth.status.textContent=`Logged in as ${t.userName}`,a.oauth.loginBtn.textContent=`Re-login`),n.appendChild(a.oauth.section),n.appendChild(a.apiKeySection),n.appendChild(a.baseUrlSection),n.appendChild(a.deploymentSection),n.appendChild(a.apiVersionSection),n.appendChild(a.errorEl),a.providerSelect.addEventListener(`change`,()=>{a.errorEl.style.display=`none`,pn(a)}),pn(a),a.saveBtn.addEventListener(`click`,()=>X(e,a));let o=t=>{t.key===`Enter`&&X(e,a)};a.apiKeyInput.addEventListener(`keydown`,o),a.baseUrlInput.addEventListener(`keydown`,o),a.deploymentInput.addEventListener(`keydown`,o),a.apiVersionInput.addEventListener(`keydown`,o),n.appendChild(a.saveBtn),mn(e,!!t),requestAnimationFrame(()=>{let e=a.providerSelect.value;if(!e)return;let t=y(e);t.requiresApiKey?a.apiKeyInput.focus():t.requiresBaseUrl&&a.baseUrlInput.focus()})}function hn(e,t,n){Jt(t,n),n.textContent=`Connecting…`,n.style.display=``,n.style.color=`var(--s2-content-secondary)`;let r=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);n.dataset.dismissTimer=String(r)}function gn(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=`Connect this browser?`,n.appendChild(r);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.marginBottom=`12px`,i.textContent=`You’ve been invited to mirror another SLICC browser. Click below to start syncing.`,n.appendChild(i);let a=document.createElement(`div`);a.className=`dialog__desc`,a.style.cssText=`font-family: monospace; font-size: 11px; color: var(--s2-content-secondary); word-break: break-all; margin-bottom: 16px; padding: 8px; background: var(--s2-bg-secondary); border-radius: 4px;`,a.textContent=t.length>80?t.slice(0,40)+`…`+t.slice(-37):t,n.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`,n.appendChild(o);let s=document.createElement(`button`);s.className=`dialog__btn`,s.textContent=`Connect`,s.addEventListener(`click`,()=>{let n=Ne(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}hn(e,n.joinUrl,o)}),n.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn dialog__btn--secondary`,c.style.marginTop=`8px`,c.textContent=`Set up an account instead`,c.addEventListener(`click`,()=>Z(e)),n.appendChild(c)}function _n(){let e=document.createElement(`details`);e.style.cssText=`margin-bottom: 12px; font-size: 12px; color: var(--s2-content-secondary);`;let t=document.createElement(`summary`);t.style.cssText=`cursor: pointer; user-select: none; color: var(--s2-content-secondary);`,t.textContent=`How do I get the sync URL?`,e.appendChild(t);let n=document.createElement(`div`);n.style.cssText=`margin-top: 8px; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); border: 1px solid var(--s2-border-subtle); line-height: 1.5;`;let r=document.createElement(`ol`);r.style.cssText=`margin: 0; padding-left: 20px;`;for(let e of[`On the other SLICC, click the avatar (top right).`,`Choose “Enable multi-browser sync” — the URL is copied automatically.`,`Paste it below. Both browsers must be on the same SLICC version.`]){let t=document.createElement(`li`);t.textContent=e,r.appendChild(t)}return n.appendChild(r),e.appendChild(n),e}function Q(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Connect to another browser`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.marginBottom=`12px`,r.textContent=`Paste a multi-browser sync URL to mirror another SLICC browser.`,t.appendChild(r),t.appendChild(_n());let i=document.createElement(`div`);i.className=`dialog__desc`,i.textContent=`Sync URL:`,t.appendChild(i);let a=document.createElement(`input`);a.className=`dialog__input`,a.type=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.placeholder=`${we}/join/<token>`,t.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`,t.appendChild(o);let s=document.createElement(`div`);s.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`;let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Connect`,c.addEventListener(`click`,()=>{let t=a.value.trim();if(!t){o.textContent=`Paste a sync URL to continue.`,o.style.display=``,a.focus();return}let n=Ne(window.localStorage,t);if(!n){o.textContent=He(t),o.style.display=``,a.focus();return}hn(e,n.joinUrl,s)}),t.appendChild(c),t.appendChild(s);let l=document.createElement(`button`);l.className=`dialog__btn dialog__btn--secondary`,l.style.marginTop=`8px`,l.textContent=`Back`,l.addEventListener(`click`,()=>Z(e)),t.appendChild(l),a.addEventListener(`input`,()=>{o.style.display=`none`}),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&c.click()}),requestAnimationFrame(()=>a.focus())}function vn(e){return Ie(`button`),new Promise(t=>{let n=document.createElement(`div`);n.className=`dialog-overlay`;let r=document.createElement(`div`);r.className=`dialog`,r.style.cssText=`max-width: 480px; width: 90vw; padding: 32px;`;let i={overlay:n,dialog:r,options:e,accountsBefore:localStorage.getItem(`slicc_accounts`)??``,resolve:t};e?.startInAddAccount?Z(i):w().length>0?Y(i):e?.autoJoinUrl?gn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=O(`main`);function yn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function bn(){Dt();let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let t=k(),n=pt({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:t});if(yn(window.location.href)){let{mountWcUiPreview:t}=await D(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-BFq7cCkV.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([64,4,15,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,51,2,65,66]));t(e);return}mt(),vt(),Bt(),n!==`connect`&&Le({isExtensionRealm:t}).catch(()=>{});let r=qe(window.location.search),i=n===`cherry`?null:z(window.location.search),a=!!i&&A();if(await Vt(r?{apiBaseUrl:r.apiBaseUrl,token:r.token}:null,a&&i?{extensionId:i.extensionId}:null)===`reload-pending`)return;if(!t&&(n===`follower`||n===`cherry`)){let{bootFollowerFloat:t}=await D(async()=>{let{bootFollowerFloat:e}=await import(`./wc-follower-ByN9dVQ1.js`);return{bootFollowerFloat:e}},__vite__mapDeps([67,5,13,55,68,4,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,45,46,47,48,49,50,51,52,53,69,1,2,10,65,11,56,59,70,63,71,72,39,57,64,66,73,43,54,37,58,74,75,76]));return t(e,$,n)}await Re(),re(),r?.apiBaseUrl&&!a&&(Pe(r.apiBaseUrl),j(r.token));let{bootstrapOAuthReplicas:o}=await D(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-D-BY9eAI.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([77,15,4,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,40]));if(await Promise.race([o().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),n===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:t}=await D(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([78,5]));await t();let{mountConnectSurface:n}=await D(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-XZmKRFD-.js`);return{mountConnectSurface:e}},__vite__mapDeps([79,15,4,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30]));await n(e);return}if(t){let{bootExtensionFloat:t}=await D(async()=>{let{bootExtensionFloat:e}=await import(`./wc-extension-wMcey-Cc.js`);return{bootExtensionFloat:e}},__vite__mapDeps([80,5,68,4,15,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,45,46,47,48,49,50,51,52,53,69,55,1,2,10,65,11,56,59,70,63,71,72,39,57,64,66,73,81]));return t(e,$,n===`extension-detached`)}a&&i&&et(i.extensionId);let{bootLeaderFloat:s}=await D(async()=>{let{bootLeaderFloat:e}=await import(`./wc-live-TppgvY0W.js`).then(e=>e.n);return{bootLeaderFloat:e}},__vite__mapDeps([68,4,15,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,45,46,47,48,49,50,51,52,53,69,55,1,2,10,65,11,56,59,70,63,71,72,39,57,64,66,73]));return s(e,$,n)}function xn(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function Sn(e,t){let n;try{({renderBootRecoveryScreen:n}=await D(()=>import(`./recovery-screen-DbUQYiGt.js`),[]))}catch{xn(e,t);return}if(n(e,t),t instanceof Error&&t.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:r}=await D(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),i=await r();i===`browser-wedged`&&n(e,t,{verdict:i})}catch{}}bn().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&Sn(t,e)});export{wt as a,gt as c,We as d,jt as i,at as l,vn as n,P as o,It as r,Ot as s,Gt as t,it as u};
22
+ `],{type:`application/javascript`}),t=URL.createObjectURL(e),n=new Worker(t);URL.revokeObjectURL(t),n.onmessage=e=>{if(e.data.type===`ping`)n.postMessage({type:`pong`});else if(e.data.type===`freeze-detected`)console.error(`[freeze-watchdog] Main thread blocked for ${e.data.elapsed}ms — capturing trace on recovery`);else if(e.data.type===`freeze-recovered`){console.error(`[freeze-watchdog] Main thread recovered. Stack trace at recovery point:`),console.trace(`[freeze-watchdog] recovery stack`);let e=performance.getEntriesByType(`longtask`);e.length>0&&console.error(`[freeze-watchdog] Long tasks:`,e.map(e=>({duration:e.duration,startTime:e.startTime,name:e.name})))}},window.addEventListener(`beforeunload`,()=>{n.terminate()},{once:!0})}var ht=`slicc-nuke-control`,gt=[`slicc:welcome-flow-fired`,`slicc.trayJoinUrl`,`slicc.trayWorkerBaseUrl`];function _t(e=()=>location.reload()){if(typeof BroadcastChannel!=`function`)return()=>{};let t=new BroadcastChannel(ht),n=t=>{let n=t.data;if(n?.type===`nuke-reload`){if(Array.isArray(n.keysToRemove)){for(let e of n.keysToRemove)if(typeof e==`string`)try{localStorage.removeItem(e)}catch{}}e()}};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var M=null;function vt(){return M||(M=_t(),M)}O(`stale-asset`);var yt=`slicc-stale-asset-reload`;function bt(e,t){if(typeof BroadcastChannel!=`function`)return()=>{};let n=new BroadcastChannel(yt),r=n=>{let r=n.data;r?.type===`stale-asset-reload`&&r.instanceId===e&&t(r.replayTurn===!0)};return n.addEventListener(`message`,r),()=>{n.removeEventListener(`message`,r),n.close()}}var xt=`slicc:stale-asset-reloaded-at`,St=6e4,N=`slicc:stale-asset-replay`;function Ct(e=window.sessionStorage){try{e.setItem(N,`1`)}catch{}}function wt(e=window.sessionStorage){try{return e.getItem(N)===`1`&&(e.removeItem(N),!0)}catch{return!1}}function Tt(){return{reload:()=>window.location.reload(),storage:window.sessionStorage,now:()=>Date.now(),windowMs:St,storageKey:xt}}function Et(e,t,n){return e===null||t-e>=n}function P(e=Tt()){let t;try{t=e.storage.getItem(e.storageKey)}catch{return!1}let n=t===null?null:Number(t),r=n!==null&&Number.isFinite(n)?n:null,i=e.now();if(!Et(r,i,e.windowMs))return!1;try{e.storage.setItem(e.storageKey,String(i))}catch{return!1}return e.reload(),!0}var F=null,I=null;function Dt(e){F||(I={...Tt(),...e},F=e=>{P(I)&&e.preventDefault()},window.addEventListener(`vite:preloadError`,F))}var L=null;function Ot(e){return L||(L=bt(e,e=>{e&&Ct(),P(I??void 0)}),L)}var kt=`slicc-cdp-superseded-banner`;function At(e){if(e.getElementById(kt))return;let t=e.createElement(`div`);t.id=kt,t.setAttribute(`role`,`alert`),t.textContent=`Another SLICC tab or window has taken control of this browser instance. Only one tab can drive the browser per instance — close the other tabs, then reload this page to resume.`,t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`right:0`,`z-index:2147483647`,`padding:10px 16px`,`background:#b3261e`,`color:#fff`,`font:13px/1.4 system-ui,sans-serif`,`text-align:center`,`box-shadow:0 1px 4px rgba(0,0,0,0.3)`].join(`;`),e.body.appendChild(t)}var jt=e({setupSudoExtension:()=>Mt,setupSudoStandalone:()=>R});async function R(e){let{createSudoBroker:t,installSudoTestHook:n}=await D(async()=>{let{createSudoBroker:e,installSudoTestHook:t}=await import(`./sudo-BUdJPcIH.js`);return{createSudoBroker:e,installSudoTestHook:t}},__vite__mapDeps([12,5,13,14,4,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,31,32,33,34,35])),{createRestCapabilityBroker:r}=await D(async()=>{let{createRestCapabilityBroker:e}=await import(`./capability-CTDMHYYU.js`).then(e=>e.t);return{createRestCapabilityBroker:e}},__vite__mapDeps([34,4,5]));n(t(r()))}async function Mt(e){let{installPanelSudoResponder:t}=await D(async()=>{let{installPanelSudoResponder:e}=await import(`./sudo-BUdJPcIH.js`);return{installPanelSudoResponder:e}},__vite__mapDeps([12,5,13,14,4,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,31,32,33,34,35]));t()}function Nt(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`slicc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function z(e){let t;try{t=new URLSearchParams(e)}catch{return null}if(t.get(`slicc`)!==`leader`)return null;let n=t.get(`ext`);return n?{extensionId:n}:null}var Pt=[100,200,400,800,1600];async function B(e,t,n,r=Pt,i=e=>new Promise(t=>setTimeout(t,e))){let a=r.length+1,o=null;for(let s=0;s<a;s++)try{await e.connect(t),s>0&&n.info(`CDP bridge connect succeeded after retry`,{attempt:s+1});return}catch(e){o=e,s<r.length&&await i(r[s]??0)}n.warn(`Initial CDP connect failed after retries; worker-forwarded commands will retry on demand`,o instanceof Error?o.message:String(o))}async function Ft(e,t,n){let{ExtensionBridgeTransport:r}=await D(async()=>{let{ExtensionBridgeTransport:e}=await import(`./extension-bridge-transport-B-i9vQpb.js`);return{ExtensionBridgeTransport:e}},__vite__mapDeps([36,13,37])),{mapDiscoveryPayloadToLickEvent:i,mapNavigatePayloadToLickEvent:a}=await D(async()=>{let{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}=await import(`./lick-ws-bridge-Bb2eVADZ.js`);return{mapDiscoveryPayloadToLickEvent:e,mapNavigatePayloadToLickEvent:t}},__vite__mapDeps([38,13,39,4,3,5,6,7,8,9,1,2,10,40])),o=null,s=[],c=!1,l=e=>{o=e;for(let t of s)e.sendForwardedLick(t);s.length=0},u=e=>{if(e){if(o){o.sendForwardedLick(e);return}s.length>=50&&(s.shift(),c||(c=!0,n.warn(`extension-bridge lick buffer overflow (cap 50); dropping oldest pending licks until the kernel client attaches`))),s.push(e)}},d=new e(new r({extensionId:t,onLick:e=>{u(a(e))},onDiscovery:e=>{u(i(e))},onOpenSettings:()=>{globalThis.dispatchEvent(new CustomEvent(`slicc:open-settings-from-panel`))}}));return await B(d,void 0,n),{browser:d,attachLickForwardingClient:l}}async function It(e){let{runtimeMode:t,envBaseUrl:n,window:r,log:i,sleep:a}=e,o=t===`electron-overlay`;i.info(`setting up standalone page runtime (BrowserAPI + CDP)`,{runtimeMode:t});let{BrowserAPI:s}=await D(async()=>{let{BrowserAPI:e}=await import(`./cdp-BX0PiRAg.js`);return{BrowserAPI:e}},__vite__mapDeps([41,13,42,2,43,4,5,44,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,32,45,46,47,48,49,50,51,52,53,54,55,56,37,57,58,59]));await R({log:i});let c,l,u,d=null,f=null,p=null,m=null,h,g=t===`cherry`?null:z(r.location.search),_=!!g&&A(),v=t===`cherry`||_?null:qe(r.location.search);v?.apiBaseUrl&&(d=v.apiBaseUrl,Pe(v.apiBaseUrl),f=v.token,j(v.token)),v?.lickWsUrl&&(p=v.lickWsUrl);let y=t===`cherry`||_||v!==null,b=await Oe(),x=ut(t,b!==null)?Me:null;if(await ke({locationHref:r.location.href,storage:r.localStorage,envBaseUrl:n,defaultWorkerBaseUrl:x,runtimeConfigFetcher:async()=>b}),t===`cherry`){let{setupCherryFollower:e}=await D(async()=>{let{setupCherryFollower:e}=await import(`./main-cherry-D1YCAckw.js`);return{setupCherryFollower:e}},__vite__mapDeps([60,13,55,37,41,42,2,43,4,5,44,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,32,45,46,47,48,49,50,51,52,53,54,56,57,58,59,61])),t=await e();c=t.browser,l=t.joinUrl,u=t.transport}else if(g&&A()){i.info(`Routing CDP through the extension bridge (leader tab)`);let e=await Ft(s,g.extensionId,i);c=e.browser,h=e.attachLickForwardingClient,m=g.extensionId,Fe(g.extensionId)}else{c=new s,v&&i.info(`Routing CDP through local standalone bridge`,{url:v.url,role:v.role??`(unset)`});let e=v?{url:v.url,protocols:v.subprotocol}:void 0;v?.role===`follower`?(i.info(`Skipping CDP connect for follower overlay tab`),c.primeConnectOptions(e)):(await B(c,e,i,void 0,a),c.setCdpSupersededHandler(()=>At(r.document)))}let S=c.getUnderlyingTransport();return globalThis.__slicc_browser=c,{browser:c,realCdpTransport:S,hasLocalCdpSurface:y,cherryJoinUrl:l,cherryTransport:u,instanceId:Nt(),isElectronOverlay:o,localApiBaseUrl:d,bridgeToken:f,localLickWsUrl:p,extensionDelegateId:m,attachLickForwardingClient:h}}var V=O(`storage-persist`);function Lt(){try{return globalThis.navigator?.storage}catch{return}}async function Rt(e=Lt()){try{return typeof e?.persist==`function`?typeof e.persisted==`function`&&await e.persisted()?`already-persisted`:await e.persist()?`granted`:`denied`:`unsupported`}catch(e){return V.warn(`storage persistence check failed`,e),`failed`}}var zt=!1;function Bt(){zt||(zt=!0,Rt().then(e=>{switch(e){case`granted`:V.info(`OPFS marked persistent — SLICC data is now exempt from disk-pressure eviction`);break;case`already-persisted`:V.debug(`OPFS already persistent`);break;case`denied`:V.warn(`Browser declined persistent storage — SLICC data can be evicted if the disk fills up`);break;case`unsupported`:V.debug(`navigator.storage.persist() unavailable in this runtime`)}}).catch(()=>{}))}var H=O(`boot/sw-registration`);async function Vt(e=null,t=null){let n=(()=>{try{return new URL(window.location.href).searchParams.get(`connect`)===`1`}catch{return!1}})();if(`serviceWorker`in navigator&&n&&await Wt())return`reload-pending`;if(!(`serviceWorker`in navigator)||n)return`ready`;try{if(await navigator.serviceWorker.register(`/preview-sw.js`,{scope:`/preview/`}),H.info(`Preview SW registered`),!k())try{await navigator.serviceWorker.register(`/llm-proxy-sw.js`,{scope:`/`}),H.info(`LLM-proxy SW registered`)}catch(e){H.error(`LLM-proxy SW registration failed — cross-origin LLM calls will hit CORS`,e)}if(navigator.serviceWorker.controller||await Promise.race([new Promise(e=>navigator.serviceWorker.addEventListener(`controllerchange`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,1500))]),!navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-sw-reloaded`))return sessionStorage.setItem(`slicc-sw-reloaded`,`1`),H.info(`Reloading once to gain SW control`),location.reload(),`reload-pending`;sessionStorage.removeItem(`slicc-sw-reloaded`),e&&(Ht(e),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{Ht(e)})),t&&(Ut(t),navigator.serviceWorker.addEventListener(`controllerchange`,()=>{Ut(t)}))}catch(e){H.error(`Preview SW registration failed — preview feature will not work`,e)}return`ready`}function Ht(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Je,apiBaseUrl:e.apiBaseUrl,token:e.token};try{t.postMessage(n)}catch(e){H.warn(`LLM-proxy SW bridge-config postMessage failed`,e)}}function Ut(e){let t=navigator.serviceWorker.controller;if(!t)return;let n={type:Ye,extensionId:e.extensionId};try{t.postMessage(n)}catch(e){H.warn(`LLM-proxy SW extension-delegate postMessage failed`,e)}}async function Wt(){try{let e=await navigator.serviceWorker.getRegistrations();if(await Promise.all(e.map(e=>e.unregister().catch(()=>!1))),navigator.serviceWorker.controller&&!sessionStorage.getItem(`slicc-connect-sw-cleared`))return sessionStorage.setItem(`slicc-connect-sw-cleared`,`1`),H.info(`connect mode: detaching from service worker (no proxy on worker origin)`),location.reload(),!0;sessionStorage.removeItem(`slicc-connect-sw-cleared`)}catch(e){H.error(`connect-mode SW cleanup failed`,e)}return!1}var Gt=e({ACCOUNTS_KEY:()=>ve,__test__:()=>pe,addAccount:()=>T,applyProviderDefaults:()=>re,clearAllSettings:()=>me,clearApiKey:()=>_e,clearBaseUrl:()=>ae,clearSelectedProvider:()=>de,describeInvalidJoinUrl:()=>He,downloadProviders:()=>Yt,ensureOAuthMaskReplica:()=>ye,exportProviders:()=>oe,getAccounts:()=>w,getAllAvailableModels:()=>he,getAllExtraOAuthDomains:()=>fe,getAlternativeModelProviders:()=>ce,getApiKey:()=>se,getApiKeyForProvider:()=>ne,getApiVersionForProvider:()=>be,getAvailableProviders:()=>Ce,getBaseUrl:()=>ie,getBaseUrlForProvider:()=>Se,getDeploymentForProvider:()=>v,getExtraOAuthDomains:()=>r,getOAuthAccountInfo:()=>xe,getProviderConfig:()=>y,getProviderModels:()=>a,getRawApiKeyForProvider:()=>i,getSelectedModelId:()=>h,getSelectedProvider:()=>ue,isModelHiddenFromPicker:()=>t,isUsableOAuthMaskReplica:()=>le,logoutOAuthAccount:()=>p,maskOAuthTokenWithRetry:()=>m,migrateLegacyAuthOnlySelection:()=>g,modelRunsOnProvider:()=>o,persistOAuthMaskViaServiceWorker:()=>l,policyVisible:()=>f,providerOffersLlmModels:()=>_,reloginOAuthAccount:()=>Qt,removeAccount:()=>E,resolveCurrentModel:()=>n,resolveModelById:()=>x,resolveModelByShorthand:()=>c,resolveModelIdForScoop:()=>b,resolveModelSelectionForScoop:()=>S,saveOAuthAccount:()=>s,setApiKey:()=>d,setBaseUrl:()=>ge,setExtraOAuthDomains:()=>u,setExtraOAuthDomainsAsync:()=>ee,setSelectedModelId:()=>C,setSelectedProvider:()=>te,showProviderSettings:()=>vn,testOnlyDispatchTrayJoinWithFailureFeedback:()=>qt}),Kt=O(`provider-settings`);function qt(e,t){return Jt(e,t)}function Jt(e,t){let n=`tray-join-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=!1,i,a=()=>{r||(r=!0,i!==void 0&&clearTimeout(i),window.removeEventListener(`slicc:tray-join-failed`,o))},o=r=>{let i=r.detail;if(i.requestId!==void 0&&i.requestId!==n)return;if(a(),!t.isConnected){Kt.error(`Tray-join failure arrived after dialog dismissed (UX swallowed half-state)`,{joinUrl:e,error:i.error,requestId:n});return}let o=t.dataset.dismissTimer;if(o){let e=Number(o);Number.isFinite(e)&&clearTimeout(e),delete t.dataset.dismissTimer}t.textContent=`Sync failed: ${i.error}. Reload the page and try again.`,t.style.color=`var(--slicc-cone)`};return window.addEventListener(`slicc:tray-join-failed`,o),i=setTimeout(a,1e4),window.dispatchEvent(new CustomEvent(`slicc:tray-join`,{detail:{joinUrl:e,requestId:n}})),a}function Yt(){let e=JSON.stringify(oe(),null,2),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`providers.json`,r.click(),URL.revokeObjectURL(n)}function Xt(e){return e.length<=10?`****`:e.slice(0,4)+`...`+e.slice(-4)}function U(e){let t=`http://www.w3.org/2000/svg`,n=document.createElementNS(t,`svg`);n.setAttribute(`width`,`14`),n.setAttribute(`height`,`14`),n.setAttribute(`viewBox`,`0 0 20 20`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`1.5`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`);for(let r of e){let e=document.createElementNS(t,`path`);e.setAttribute(`d`,r),n.appendChild(e)}return n}var W={pen:[`M14.3 3.3a1.5 1.5 0 0 1 2.1 0l.3.3a1.5 1.5 0 0 1 0 2.1L7.7 14.8l-3.2.7.7-3.2z`],trash:[`M4 6h12`,`M8 6V4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2`,`M6 6v10a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V6`],logout:[`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,`M16 17l5-5-5-5`,`M21 12H9`],login:[`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,`M10 17l5-5-5-5`,`M15 12H3`]},G=`background: transparent; border: 1px solid var(--s2-border-subtle); color: var(--s2-content-secondary); border-radius: var(--s2-radius-s); padding: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color 0.15s, border-color 0.15s;`;function K(e,t){e.addEventListener(`mouseenter`,()=>{e.style.color=t,e.style.borderColor=t}),e.addEventListener(`mouseleave`,()=>{e.style.color=`var(--s2-content-secondary)`,e.style.borderColor=`var(--s2-border-subtle)`})}function q(e){e.overlay.remove(),e.resolve((localStorage.getItem(`slicc_accounts`)??``)!==e.accountsBefore)}function J(e){e.options?.startInAddAccount?q(e):Y(e)}function Zt(e){let t=document.createElement(`div`);return t.style.cssText=`font-size: 11px; color: var(--s2-content-disabled); font-family: monospace; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`,e.loggedOut?(t.textContent=e.userName?`Logged out — was ${e.userName}`:`Logged out`,t.style.color=`var(--s2-content-disabled)`):t.textContent=e.userName?e.userName:e.accessToken?`Logged in`:Xt(e.apiKey),e.baseUrl&&(t.textContent+=` • `+e.baseUrl),t}async function Qt(e,t){let{createOAuthLauncher:n,createInterceptingOAuthLauncherForCurrentRuntime:r}=await D(async()=>{let{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}=await import(`./oauth-service-t2taQm3p.js`);return{createOAuthLauncher:e,createInterceptingOAuthLauncherForCurrentRuntime:t}},__vite__mapDeps([62,5,3,4,6,7,8,9,29,63])),i={forceReauth:!0};if(e.onOAuthLoginIntercepted){let n=await r();n&&await e.onOAuthLoginIntercepted(n,t,i)}else if(e.onOAuthLogin){let r=n();await e.onOAuthLogin(r,t,i)}}function $t(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Edit account`),n.appendChild(U(W.pen)),K(n,`var(--s2-accent)`),n.addEventListener(`click`,()=>Z(e,t)),n}function en(e,t,n){let r=document.createElement(`button`);return r.style.cssText=G,t.loggedOut===!0?(r.setAttribute(`aria-label`,`Log in`),r.setAttribute(`title`,`Log in`),r.appendChild(U(W.login)),K(r,`var(--s2-accent)`),r.addEventListener(`click`,()=>{Qt(n,()=>Y(e))})):(r.setAttribute(`aria-label`,`Log out`),r.setAttribute(`title`,`Log out`),r.appendChild(U(W.logout)),K(r,`var(--s2-warning, #f59e0b)`),r.addEventListener(`click`,()=>{(async()=>{await p(t.providerId),Y(e)})()})),r}function tn(e,t){let n=document.createElement(`button`);return n.style.cssText=G,n.setAttribute(`aria-label`,`Remove account`),n.appendChild(U(W.trash)),K(n,`var(--s2-negative)`),n.addEventListener(`click`,()=>{(async()=>{await E(t.providerId),Y(e)})()}),n}function nn(e,t){let n=y(t.providerId),r=document.createElement(`div`);r.style.cssText=`display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); margin-bottom: 8px; border: 1px solid var(--s2-border-subtle);`;let i=document.createElement(`div`);i.style.cssText=`flex: 1; min-width: 0;`;let a=document.createElement(`div`);a.style.cssText=`font-size: 14px; font-weight: 600; color: var(--s2-content-default);`,a.textContent=n.name,i.appendChild(a),i.appendChild(Zt(t)),r.appendChild(i);let o=document.createElement(`div`);return o.style.cssText=`display: flex; gap: 4px; margin-left: 12px; flex-shrink: 0;`,o.appendChild($t(e,t)),n.isOAuth&&o.appendChild(en(e,t,n)),o.appendChild(tn(e,t)),r.appendChild(o),r}function rn(e){let t=document.createDocumentFragment(),n=document.createElement(`hr`);n.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-weight: 600; margin-bottom: 8px;`,r.textContent=`Tray`,t.appendChild(r);let i=Be(),a=i.state!==`inactive`,o=Ae(window.localStorage);if(a||o){let e=document.createElement(`div`);e.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px;`,e.textContent=`Follower: ${a?i.state:`configured`}`,i.error&&(e.textContent+=` — ${i.error}`,e.style.color=`var(--slicc-cone)`),t.appendChild(e)}let s=document.createElement(`button`);return s.className=`dialog__btn dialog__btn--secondary`,s.textContent=a||o?`Reconnect to other browser`:`Connect to another browser`,s.addEventListener(`click`,()=>Q(e)),t.appendChild(s),t}function Y(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Accounts`,t.appendChild(n);let r=w();if(r.length===0){let e=document.createElement(`div`);e.className=`dialog__desc`,e.textContent=`No accounts configured.`,t.appendChild(e)}else{let n=document.createElement(`div`);n.style.cssText=`margin-bottom: 16px;`;for(let t of r)n.appendChild(nn(e,t));t.appendChild(n)}let i=document.createElement(`div`);i.style.cssText=`display: flex; gap: 8px;`;let a=document.createElement(`button`);a.className=r.length>0?`dialog__btn dialog__btn--secondary`:`dialog__btn`,a.style.flex=`1`,a.textContent=`Add Account`,a.addEventListener(`click`,()=>Z(e)),i.appendChild(a);let o=document.createElement(`button`);o.className=`dialog__btn dialog__btn--secondary`,o.style.flex=`1`,o.textContent=`Export`,o.addEventListener(`click`,()=>Yt()),i.appendChild(o),t.appendChild(i),t.appendChild(rn(e));let s=document.createElement(`hr`);s.style.cssText=`border: none; border-top: 1px solid var(--s2-border-subtle); margin: 16px 0;`,t.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Get Started`,c.addEventListener(`click`,()=>q(e)),t.appendChild(c)}function an(e,t){let n=document.createElement(`select`);if(n.className=`dialog__input`,n.style.marginBottom=`8px`,t){let e=y(t.providerId),r=document.createElement(`option`);return r.value=t.providerId,r.textContent=e.name,n.appendChild(r),n.disabled=!0,n.style.opacity=`0.7`,n}let r=document.createElement(`option`);r.value=``,r.textContent=`Select a provider…`,r.disabled=!0,r.selected=!0,r.hidden=!0,n.appendChild(r);let i=new Set(w().map(e=>e.providerId)),a=[...Ce()].sort((e,t)=>y(e).name.localeCompare(y(t).name));for(let t of a){if(i.has(t))continue;if(e?.providerFilter){if(!e.providerFilter(t))continue}else if(!_(t))continue;let r=document.createElement(`option`);r.value=t,r.textContent=y(t).name,n.appendChild(r)}return n}function on(e,t){let n=an(e,t),r=document.createElement(`div`);r.className=`dialog__desc`,r.style.cssText=`font-size: 12px; color: var(--s2-content-tertiary); margin-bottom: 16px; margin-top: -4px;`;let i=document.createElement(`div`);i.style.cssText=`margin-bottom: 16px; display: none;`;let a=document.createElement(`button`);a.className=`dialog__btn`,a.textContent=`Login`,a.style.cssText=`width: 100%; margin-bottom: 8px;`,i.appendChild(a);let o=document.createElement(`div`);o.className=`dialog__desc`,o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); text-align: center;`,i.appendChild(o);let s=document.createElement(`div`),c=document.createElement(`div`);c.className=`dialog__desc`,s.appendChild(c);let l=document.createElement(`input`);l.className=`dialog__input`,l.type=`password`,l.autocomplete=`off`,l.spellcheck=!1,t&&(l.value=t.apiKey),s.appendChild(l);let u=document.createElement(`div`),d=document.createElement(`div`);d.className=`dialog__desc`,d.textContent=`Base URL:`,u.appendChild(d);let f=document.createElement(`input`);f.className=`dialog__input`,f.type=`text`,f.autocomplete=`off`,f.spellcheck=!1,t?.baseUrl&&(f.value=t.baseUrl),u.appendChild(f);let p=document.createElement(`div`);p.className=`dialog__desc`,p.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,u.appendChild(p);let m=document.createElement(`div`);m.style.display=`none`;let h=document.createElement(`div`);h.className=`dialog__desc`,h.textContent=`Deployment:`,m.appendChild(h);let g=document.createElement(`input`);g.className=`dialog__input`,g.type=`text`,g.autocomplete=`off`,g.spellcheck=!1,t?.deployment&&(g.value=t.deployment),m.appendChild(g);let _=document.createElement(`div`);_.className=`dialog__desc`,_.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,m.appendChild(_);let v=document.createElement(`div`);v.style.display=`none`;let y=document.createElement(`div`);y.className=`dialog__desc`,y.textContent=`API Version:`,v.appendChild(y);let b=document.createElement(`input`);b.className=`dialog__input`,b.type=`text`,b.autocomplete=`off`,b.spellcheck=!1,t?.apiVersion&&(b.value=t.apiVersion),v.appendChild(b);let x=document.createElement(`div`);x.className=`dialog__desc`,x.style.cssText=`font-size: 11px; color: var(--s2-content-secondary); margin-top: -12px; margin-bottom: 16px;`,v.appendChild(x);let S=document.createElement(`div`);S.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`;let C=document.createElement(`button`);return C.className=`dialog__btn`,C.textContent=t?`Save`:`Add`,{providerSelect:n,providerDesc:r,oauth:{section:i,loginBtn:a,status:o},apiKeySection:s,apiKeyLabel:c,apiKeyInput:l,baseUrlSection:u,baseUrlInput:f,baseUrlDesc:p,deploymentSection:m,deploymentInput:g,deploymentDesc:_,apiVersionSection:v,apiVersionInput:b,apiVersionDesc:x,errorEl:S,saveBtn:C}}function sn(e){let t=document.createElement(`div`);t.setAttribute(`data-slicc-device-code-prompt`,``),t.style.cssText=`display:flex;flex-direction:column;gap:8px`;let n=document.createElement(`div`);n.className=`dialog__desc`,n.textContent=`Verification code`,n.style.cssText=`font-size: 11px; color: var(--s2-content-tertiary);`;let r=document.createElement(`div`);r.textContent=e,r.style.cssText=[`font: 600 22px ui-monospace, SFMono-Regular, Menlo, monospace`,`letter-spacing: 2px`,`color: var(--s2-content-primary, #e6edf3)`,`background: var(--s2-bg-secondary, #161b22)`,`border: 1px solid var(--s2-border, #30363d)`,`border-radius: 6px`,`padding: 10px 12px`,`text-align: center`,`user-select: all`,`cursor: text`].join(`;`);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.cssText=`font-size: 12px; color: var(--s2-content-secondary);`,i.textContent=`Click Copy & Continue — we will open the GitHub authorization page in a new tab. Paste this code there if it is not already filled in.`;let a=document.createElement(`div`);a.style.cssText=`display:flex;gap:8px;justify-content:flex-end;margin-top:4px`;let o=document.createElement(`button`);o.type=`button`,o.className=`dialog__btn`,o.textContent=`Cancel`;let s=document.createElement(`button`);return s.type=`button`,s.className=`dialog__btn dialog__btn--primary`,s.textContent=`Copy & Continue`,a.appendChild(o),a.appendChild(s),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(a),{prompt:t,cancelBtn:o,continueBtn:s}}function cn(e){return t=>new Promise(n=>{let r=e.loginBtn.style.display,i=e.status.style.display;e.loginBtn.style.display=`none`,e.status.style.display=`none`;let{prompt:a,cancelBtn:o,continueBtn:s}=sn(t.userCode),c=()=>{try{a.remove()}catch{}e.loginBtn.style.display=r,e.status.style.display=i};o.addEventListener(`click`,()=>{c(),n(`cancel`)}),s.addEventListener(`click`,()=>{(async()=>{try{await Ve(t.userCode)}catch{}c(),e.status.style.display=i,e.status.textContent=`Waiting for you to authorize in the new tab…`,n(`continue`)})()}),e.section.appendChild(a)})}async function ln(e,t){let n=t.providerSelect.value;if(!n)return;let r=y(n);if(!r.onOAuthLogin&&!r.onOAuthLoginIntercepted)return;let{status:i}=t.oauth,a=w().some(e=>e.providerId===n),o=Se(n);if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()&&!o){i.textContent=`Base URL is required.`,i.style.color=`var(--slicc-cone)`,t.baseUrlInput.focus();return}r.requiresBaseUrl&&t.baseUrlInput.value.trim()&&T(n,``,t.baseUrlInput.value.trim()),i.textContent=`Opening login window...`;try{if(r.onOAuthLoginIntercepted){let{createInterceptingOAuthLauncherForCurrentRuntime:n}=await D(async()=>{let{createInterceptingOAuthLauncherForCurrentRuntime:e}=await import(`./oauth-service-t2taQm3p.js`);return{createInterceptingOAuthLauncherForCurrentRuntime:e}},__vite__mapDeps([62,5,3,4,6,7,8,9,29,63])),i=await n();if(!i)throw Error(`No controlled-browser CDP transport available — open SLICC in standalone mode or the Chrome extension.`);await r.onOAuthLoginIntercepted(i,()=>J(e),{presentDeviceCode:cn(t.oauth)})}else if(r.onOAuthLogin){let{createOAuthLauncher:t}=await D(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-t2taQm3p.js`);return{createOAuthLauncher:e}},__vite__mapDeps([62,5,3,4,6,7,8,9,29,63])),n=t();await r.onOAuthLogin(n,()=>J(e))}}catch(e){if(!a)try{await E(n)}catch{}Kt.error(`OAuth login failed`,{providerId:n,error:e instanceof Error?e.message:String(e)}),i.textContent=`Login failed: ${e instanceof Error?e.message:String(e)}`}}function un(e,t){if(t.isOAuth){e.oauth.section.style.display=``,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,t.requiresBaseUrl&&(e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``),e.oauth.loginBtn.textContent=`Login with ${t.name}`,e.saveBtn.style.display=`none`;return}e.oauth.section.style.display=`none`;let n=t.requiresApiKey?`API Key`:`API Key (optional)`;e.apiKeyLabel.textContent=`${n}${t.apiKeyEnvVar?` (${t.apiKeyEnvVar})`:``}:`,e.apiKeyInput.placeholder=t.apiKeyPlaceholder||`API key`,e.apiKeySection.style.display=t.requiresApiKey||t.optionalApiKey?``:`none`,e.baseUrlInput.placeholder=t.baseUrlPlaceholder||`https://...`,e.baseUrlDesc.textContent=t.baseUrlDescription||``,e.baseUrlSection.style.display=t.requiresBaseUrl?``:`none`,e.saveBtn.style.display=``}function dn(e,t){t.requiresDeployment?(e.deploymentSection.style.display=``,e.deploymentInput.placeholder=t.deploymentPlaceholder||`deployment-name`,e.deploymentDesc.textContent=t.deploymentDescription||``):e.deploymentSection.style.display=`none`}function fn(e,t){t.requiresApiVersion?(e.apiVersionSection.style.display=``,!e.apiVersionInput.value&&t.apiVersionDefault&&(e.apiVersionInput.value=t.apiVersionDefault),e.apiVersionInput.placeholder=t.apiVersionDefault||`api-version`,e.apiVersionDesc.textContent=t.apiVersionDescription||``):e.apiVersionSection.style.display=`none`}function pn(e){let t=e.providerSelect.value;if(!t){e.providerDesc.textContent=``,e.oauth.section.style.display=`none`,e.apiKeySection.style.display=`none`,e.baseUrlSection.style.display=`none`,e.deploymentSection.style.display=`none`,e.apiVersionSection.style.display=`none`,e.saveBtn.style.display=`none`;return}let n=y(t);e.providerDesc.textContent=n.description,un(e,n),dn(e,n),fn(e,n)}function X(e,t){let n=t.providerSelect.value;if(!n)return;let r=y(n),i=(e,n)=>{t.errorEl.textContent=e,t.errorEl.style.display=``,n.focus()};if(r.requiresApiKey&&t.apiKeyInput.value.trim().length<5){i(`API key is required (at least 5 characters).`,t.apiKeyInput);return}if(r.requiresBaseUrl&&!t.baseUrlInput.value.trim()){i(`Base URL is required for this provider.`,t.baseUrlInput);return}if(r.requiresDeployment&&!t.deploymentInput.value.trim()){i(`Deployment name is required for this provider.`,t.deploymentInput);return}T(n,t.apiKeyInput.value.trim(),t.baseUrlInput.value.trim()||void 0,t.deploymentInput.value.trim()||void 0,t.apiVersionInput.value.trim()||void 0),J(e)}function mn(e,t){let{dialog:n,options:r}=e,i=w().length>0;if(r?.startInAddAccount){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Cancel`,t.addEventListener(`click`,()=>q(e)),n.appendChild(t)}else if(!t&&!i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Connect to another browser`,t.addEventListener(`click`,()=>Q(e)),n.appendChild(t)}else if(i){let t=document.createElement(`button`);t.className=`dialog__btn dialog__btn--secondary`,t.style.marginTop=`8px`,t.textContent=`Back`,t.addEventListener(`click`,()=>Y(e)),n.appendChild(t)}}function Z(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=t?`Edit Account`:`Add Account`,n.appendChild(r);let i=document.createElement(`div`);i.className=`dialog__desc`,i.textContent=`Provider:`,n.appendChild(i);let a=on(e.options,t);n.appendChild(a.providerSelect),n.appendChild(a.providerDesc),a.oauth.loginBtn.addEventListener(`click`,()=>{ln(e,a)}),t?.userName&&(a.oauth.status.textContent=`Logged in as ${t.userName}`,a.oauth.loginBtn.textContent=`Re-login`),n.appendChild(a.oauth.section),n.appendChild(a.apiKeySection),n.appendChild(a.baseUrlSection),n.appendChild(a.deploymentSection),n.appendChild(a.apiVersionSection),n.appendChild(a.errorEl),a.providerSelect.addEventListener(`change`,()=>{a.errorEl.style.display=`none`,pn(a)}),pn(a),a.saveBtn.addEventListener(`click`,()=>X(e,a));let o=t=>{t.key===`Enter`&&X(e,a)};a.apiKeyInput.addEventListener(`keydown`,o),a.baseUrlInput.addEventListener(`keydown`,o),a.deploymentInput.addEventListener(`keydown`,o),a.apiVersionInput.addEventListener(`keydown`,o),n.appendChild(a.saveBtn),mn(e,!!t),requestAnimationFrame(()=>{let e=a.providerSelect.value;if(!e)return;let t=y(e);t.requiresApiKey?a.apiKeyInput.focus():t.requiresBaseUrl&&a.baseUrlInput.focus()})}function hn(e,t,n){Jt(t,n),n.textContent=`Connecting…`,n.style.display=``,n.style.color=`var(--s2-content-secondary)`;let r=setTimeout(()=>{e.overlay.remove(),e.resolve(!1)},800);n.dataset.dismissTimer=String(r)}function gn(e,t){let{dialog:n}=e;n.innerHTML=``;let r=document.createElement(`div`);r.className=`dialog__title`,r.textContent=`Connect this browser?`,n.appendChild(r);let i=document.createElement(`div`);i.className=`dialog__desc`,i.style.marginBottom=`12px`,i.textContent=`You’ve been invited to mirror another SLICC browser. Click below to start syncing.`,n.appendChild(i);let a=document.createElement(`div`);a.className=`dialog__desc`,a.style.cssText=`font-family: monospace; font-size: 11px; color: var(--s2-content-secondary); word-break: break-all; margin-bottom: 16px; padding: 8px; background: var(--s2-bg-secondary); border-radius: 4px;`,a.textContent=t.length>80?t.slice(0,40)+`…`+t.slice(-37):t,n.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`,n.appendChild(o);let s=document.createElement(`button`);s.className=`dialog__btn`,s.textContent=`Connect`,s.addEventListener(`click`,()=>{let n=Ne(window.localStorage,t);if(!n){o.textContent=`Invalid sync URL.`,o.style.display=``,o.style.color=`var(--slicc-cone)`;return}hn(e,n.joinUrl,o)}),n.appendChild(s);let c=document.createElement(`button`);c.className=`dialog__btn dialog__btn--secondary`,c.style.marginTop=`8px`,c.textContent=`Set up an account instead`,c.addEventListener(`click`,()=>Z(e)),n.appendChild(c)}function _n(){let e=document.createElement(`details`);e.style.cssText=`margin-bottom: 12px; font-size: 12px; color: var(--s2-content-secondary);`;let t=document.createElement(`summary`);t.style.cssText=`cursor: pointer; user-select: none; color: var(--s2-content-secondary);`,t.textContent=`How do I get the sync URL?`,e.appendChild(t);let n=document.createElement(`div`);n.style.cssText=`margin-top: 8px; padding: 10px 12px; background: var(--s2-bg-layer-2); border-radius: var(--s2-radius-default); border: 1px solid var(--s2-border-subtle); line-height: 1.5;`;let r=document.createElement(`ol`);r.style.cssText=`margin: 0; padding-left: 20px;`;for(let e of[`On the other SLICC, click the avatar (top right).`,`Choose “Enable multi-browser sync” — the URL is copied automatically.`,`Paste it below. Both browsers must be on the same SLICC version.`]){let t=document.createElement(`li`);t.textContent=e,r.appendChild(t)}return n.appendChild(r),e.appendChild(n),e}function Q(e){let{dialog:t}=e;t.innerHTML=``;let n=document.createElement(`div`);n.className=`dialog__title`,n.textContent=`Connect to another browser`,t.appendChild(n);let r=document.createElement(`div`);r.className=`dialog__desc`,r.style.marginBottom=`12px`,r.textContent=`Paste a multi-browser sync URL to mirror another SLICC browser.`,t.appendChild(r),t.appendChild(_n());let i=document.createElement(`div`);i.className=`dialog__desc`,i.textContent=`Sync URL:`,t.appendChild(i);let a=document.createElement(`input`);a.className=`dialog__input`,a.type=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.placeholder=`${we}/join/<token>`,t.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`color: var(--slicc-cone); font-size: 12px; margin-bottom: 8px; display: none;`,t.appendChild(o);let s=document.createElement(`div`);s.style.cssText=`font-size: 12px; color: var(--s2-content-secondary); margin-bottom: 8px; display: none;`;let c=document.createElement(`button`);c.className=`dialog__btn`,c.textContent=`Connect`,c.addEventListener(`click`,()=>{let t=a.value.trim();if(!t){o.textContent=`Paste a sync URL to continue.`,o.style.display=``,a.focus();return}let n=Ne(window.localStorage,t);if(!n){o.textContent=He(t),o.style.display=``,a.focus();return}hn(e,n.joinUrl,s)}),t.appendChild(c),t.appendChild(s);let l=document.createElement(`button`);l.className=`dialog__btn dialog__btn--secondary`,l.style.marginTop=`8px`,l.textContent=`Back`,l.addEventListener(`click`,()=>Z(e)),t.appendChild(l),a.addEventListener(`input`,()=>{o.style.display=`none`}),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&c.click()}),requestAnimationFrame(()=>a.focus())}function vn(e){return Ie(`button`),new Promise(t=>{let n=document.createElement(`div`);n.className=`dialog-overlay`;let r=document.createElement(`div`);r.className=`dialog`,r.style.cssText=`max-width: 480px; width: 90vw; padding: 32px;`;let i={overlay:n,dialog:r,options:e,accountsBefore:localStorage.getItem(`slicc_accounts`)??``,resolve:t};e?.startInAddAccount?Z(i):w().length>0?Y(i):e?.autoJoinUrl?gn(i,e.autoJoinUrl):e?.preferTrayJoin?Q(i):Z(i),n.appendChild(r),document.body.appendChild(n)})}var $=O(`main`);function yn(e){try{return new URL(e).searchParams.has(`ui-fixture`)}catch{return!1}}async function bn(){Dt();let e=document.getElementById(`app`);if(!e)throw Error(`#app element not found`);let t=k(),n=pt({locationHref:window.location.href,storage:window.localStorage,envBaseUrl:null,isDev:!1,isExtension:t});if(yn(window.location.href)){let{mountWcUiPreview:t}=await D(async()=>{let{mountWcUiPreview:e}=await import(`./wc-shell-CdkXzmml.js`).then(e=>e.s);return{mountWcUiPreview:e}},__vite__mapDeps([64,4,15,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,51,2,65,66]));t(e);return}mt(),vt(),Bt(),n!==`connect`&&Le({isExtensionRealm:t}).catch(()=>{});let r=qe(window.location.search),i=n===`cherry`?null:z(window.location.search),a=!!i&&A();if(await Vt(r?{apiBaseUrl:r.apiBaseUrl,token:r.token}:null,a&&i?{extensionId:i.extensionId}:null)===`reload-pending`)return;if(!t&&(n===`follower`||n===`cherry`)){let{bootFollowerFloat:t}=await D(async()=>{let{bootFollowerFloat:e}=await import(`./wc-follower-UnBMtKdu.js`);return{bootFollowerFloat:e}},__vite__mapDeps([67,5,13,55,68,4,15,16,17,18,19,20,21,22,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,45,46,47,48,49,50,51,52,53,69,1,2,10,65,11,56,59,70,63,71,72,39,57,64,66,73,43,54,37,58,74,75,76]));return t(e,$,n)}await Re(),re(),r?.apiBaseUrl&&!a&&(Pe(r.apiBaseUrl),j(r.token));let{bootstrapOAuthReplicas:o}=await D(async()=>{let{bootstrapOAuthReplicas:e}=await import(`./oauth-bootstrap-0NJ1uts7.js`);return{bootstrapOAuthReplicas:e}},__vite__mapDeps([77,15,4,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,40]));if(await Promise.race([o().catch(e=>{$.error(`OAuth bootstrap failed`,e)}),new Promise(e=>setTimeout(e,1e4))]),n===`connect`){globalThis.__slicc_connect_mode=!0;let{loadLegacyStyles:t}=await D(async()=>{let{loadLegacyStyles:e}=await import(`./legacy-styles-B3nS5QUo.js`);return{loadLegacyStyles:e}},__vite__mapDeps([78,5]));await t();let{mountConnectSurface:n}=await D(async()=>{let{mountConnectSurface:e}=await import(`./connect-surface-COdJoI-e.js`);return{mountConnectSurface:e}},__vite__mapDeps([79,15,4,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30]));await n(e);return}if(t){let{bootExtensionFloat:t}=await D(async()=>{let{bootExtensionFloat:e}=await import(`./wc-extension-B-HQw_fj.js`);return{bootExtensionFloat:e}},__vite__mapDeps([80,5,68,4,15,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,45,46,47,48,49,50,51,52,53,69,55,1,2,10,65,11,56,59,70,63,71,72,39,57,64,66,73,81]));return t(e,$,n===`extension-detached`)}a&&i&&et(i.extensionId);let{bootLeaderFloat:s}=await D(async()=>{let{bootLeaderFloat:e}=await import(`./wc-live-B6vu9NGR.js`).then(e=>e.n);return{bootLeaderFloat:e}},__vite__mapDeps([68,4,15,5,16,17,18,19,20,21,22,13,6,3,7,8,9,23,24,25,26,27,28,29,30,44,32,45,46,47,48,49,50,51,52,53,69,55,1,2,10,65,11,56,59,70,63,71,72,39,57,64,66,73]));return s(e,$,n)}function xn(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:2rem;text-align:center;font-family:system-ui;`;let r=document.createElement(`h1`);r.textContent=`Failed to start`;let i=document.createElement(`p`);i.textContent=t instanceof Error?t.message:String(t);let a=document.createElement(`button`);a.type=`button`,a.textContent=`Reload`,a.addEventListener(`click`,()=>location.reload()),n.append(r,i,a),e.replaceChildren(n)}async function Sn(e,t){let n;try{({renderBootRecoveryScreen:n}=await D(()=>import(`./recovery-screen-BxSagH2C.js`),[]))}catch{xn(e,t);return}if(n(e,t),t instanceof Error&&t.message.includes(`did not signal ready`))try{let{triageModuleWorkerHealth:r}=await D(async()=>{let{triageModuleWorkerHealth:e}=await import(`./worker-triage-BvsMZrdR.js`);return{triageModuleWorkerHealth:e}},[]),i=await r();i===`browser-wedged`&&n(e,t,{verdict:i})}catch{}}bn().catch(e=>{$.error(`Fatal error`,e);let t=document.getElementById(`app`);t&&Sn(t,e)});export{wt as a,gt as c,We as d,jt as i,at as l,vn as n,P as o,It as r,Ot as s,Gt as t,it as u};
@@ -1 +1 @@
1
- import{t as e}from"./logger-DDBAeTLF.js";import{n as t,r as n}from"./transcript-export-DP-r8eDz.js";import{t as r}from"./pending-request-table-k-D7ZZsL.js";import{BrowserAPI as i}from"./cdp-CLhbRC4S.js";import{t as a}from"./synthetic-cdp-transport-OUVdC4zy.js";var o=[2,1],s=new Set([`handshake.hello`,`handshake.welcome`,`handshake.version-mismatch`,`cdp.request`,`cdp.response`,`cdp.event`,`permission.request`,`permission.response`,`host.event`,`slicc.event`,`session.export.request`,`session.export.cancel`,`session.export.progress`,`session.export.response`,`session.export.error`]);function c(e,t=[2]){if(typeof e!=`object`||!e)return!1;let n=e;if(typeof n.cherry!=`number`||!t.includes(n.cherry)||typeof n.channelId!=`string`||typeof n.kind!=`string`||!s.has(n.kind))return!1;let r=n.kind;return!(r===`handshake.version-mismatch`&&typeof n.peerVersion!=`number`||(r===`session.export.request`||r===`session.export.cancel`||r===`session.export.progress`||r===`session.export.response`||r===`session.export.error`)&&(typeof n.requestId!=`string`||n.requestId===``||r===`session.export.progress`&&typeof n.phase!=`string`||r===`session.export.response`&&!(n.blob instanceof Blob)||r===`session.export.error`&&typeof n.code!=`string`))}function l(e,t){return!(!t.allowOrigins.includes(e.origin)||t.expectedSource!==null&&e.source!==t.expectedSource||!c(e.data,t.versions)||t.channelId!==null&&e.data.channelId!==t.channelId)}function u(e,t=[2]){if(typeof e!=`object`||!e)return!1;let n=e;return typeof n.cherry==`number`&&!t.includes(n.cherry)&&typeof n.channelId==`string`&&typeof n.kind==`string`}var d=e(`cherry-transport`),f=3e4;function p(e){let r=e instanceof t||typeof e==`object`&&e&&`code`in e?e.code:void 0;return typeof r==`string`&&n.has(r)?r:`transfer-corrupt`}var m=class extends a{opts;channelId=null;nextId=1;pending=new r;connectResolve=null;connectReject=null;connectTimer=null;_joinUrl=null;_features={terminal:!0,files:!0,memory:!0,browser:!0,modelPicker:!0,history:!0,nav:!0,monitor:!0};_theme=null;_layout=null;_effortLevel=null;_flags=null;negotiatedVersion=2;boundHandler=e=>this.handleMessage(e);onHostEvent=null;onExportRequest=null;pendingHostExports=new Map;constructor(e){super({targetUrl:typeof location<`u`?location.href:`about:blank`,targetOrigin:e.targetOrigin,title:`Cherry Host Page`,ids:{target:`cherry-target`,session:`cherry-session`,frame:`cherry-frame`,loader:`cherry-loader`}}),this.opts=e}get hostOrigin(){return this.opts.targetOrigin}getCurrentUrl(){return typeof location<`u`?location.href:super.getCurrentUrl()}get joinUrl(){return this._joinUrl}get features(){return this._features}get theme(){return this._theme}get layout(){return this._layout}get effortLevel(){return this._effortLevel}get flags(){return this._flags}get negotiatedProtocolVersion(){return this.negotiatedVersion}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);this._state=`connecting`,this.negotiatedVersion=2,this.channelId=`cherry-${crypto.randomUUID()}`,typeof window<`u`&&window.addEventListener(`message`,this.boundHandler);let t=e?.timeout??f;return new Promise((e,n)=>{this.connectResolve=e,this.connectReject=n,this.connectTimer=setTimeout(()=>{this.connectTimer=null,typeof window<`u`&&window.removeEventListener(`message`,this.boundHandler),this._state=`disconnected`,this.channelId=null,this.connectResolve=null,this.connectReject=null,n(Error(`Cherry handshake timed out after ${t}ms — no handshake.welcome from the embedding page (host SDK missing, not listening, or version-skewed; check the host page's console)`))},t);for(let e of o)this.post({cherry:e,channelId:this.channelId,kind:`handshake.hello`,capabilities:this.opts.capabilities??{navigate:!0,screenshot:!0,openUrl:!0}})})}failPendingConnect(e){if(this.connectReject===null)return;this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null),typeof window<`u`&&window.removeEventListener(`message`,this.boundHandler),this._state=`disconnected`,this.channelId=null;let t=this.connectReject;this.connectResolve=null,this.connectReject=null,t(e)}disconnect(){this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null),typeof window<`u`&&window.removeEventListener(`message`,this.boundHandler),this.pending.rejectAll(`Cherry transport disconnected`);for(let[,e]of this.pendingHostExports)e.abort();this.pendingHostExports.clear(),this._state=`disconnected`,this.channelId=null}async forward(e,t,n,r=f){let i=this.nextId++,a=this.pending.issue(i,r,`Cherry CDP timed out after ${r}ms: ${e}`);return this.post({cherry:this.negotiatedVersion,channelId:this.channelId,kind:`cdp.request`,id:i,method:e,params:t}),a}testReceive(e){this.handleMessage(e)}emitSliccEventToHost(e,t){if(!this.channelId){d.warn(`Dropping slicc.event before handshake (no channelId yet)`,{name:e});return}this.post({cherry:this.negotiatedVersion,channelId:this.channelId,kind:`slicc.event`,name:e,detail:t})}post(e){this.opts.counterpart.postMessage(e,this.opts.targetOrigin)}handleMessage(e){let t=this._state===`connected`?[this.negotiatedVersion]:o;if(!l(e,{allowOrigins:this.opts.allowOrigins,expectedSource:this.opts.counterpart,channelId:this.channelId,versions:t})){this.diagnoseRejectedMessage(e,t);return}let n=e.data;if(this.negotiatedVersion<2&&n.kind.startsWith(`session.export.`)){d.warn(`Ignoring a v2-only envelope on a v1-negotiated cherry channel`,{kind:n.kind});return}switch(n.kind){case`handshake.welcome`:this.handleWelcome(n);return;case`cdp.response`:n.error?this.pending.reject(n.id,Error(`Cherry CDP error: ${n.error.message} (${n.error.code})`)):this.pending.resolve(n.id,n.result??{});return;case`cdp.event`:this.emit(n.method,{...n.params??{},sessionId:n.sessionId??this.syntheticIds.session});return;case`host.event`:this.onHostEvent?.(n.name,n.detail);return;case`session.export.request`:this.handleExportRequest(n);return;case`session.export.cancel`:{let e=this.pendingHostExports.get(n.requestId);e&&(e.abort(),this.pendingHostExports.delete(n.requestId));return}default:return}}diagnoseRejectedMessage(e,t){u(e.data,t)?(d.warn(`Cherry protocol version mismatch — update the older side`,{peerVersion:e.data.cherry,supportedVersions:[...o],origin:e.origin}),e.data.channelId===this.channelId&&this.opts.allowOrigins.includes(e.origin)&&e.source===this.opts.counterpart&&this.failPendingConnect(Error(`Cherry protocol version mismatch (peer v${e.data.cherry}, ours v2) — update the older side`))):c(e.data,o)&&d.warn(`Rejected a cherry envelope (origin/source/channel mismatch)`,{origin:e.origin,allowOrigins:this.opts.allowOrigins})}handleWelcome(e){this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null),this._state=`connected`,this.negotiatedVersion=e.cherry,this._joinUrl=e.joinUrl??null,this._theme=e.theme??null,this._layout=e.layout??null,this._effortLevel=e.effortLevel??null,this._flags=e.flags??null,this._features=e.features??{terminal:!0,files:!0,memory:!0,browser:!0,modelPicker:!0,history:!0,nav:!0,monitor:!0},d.info(`Cherry handshake complete`,{channelId:this.channelId,negotiatedVersion:this.negotiatedVersion}),this.connectResolve?.(),this.connectResolve=null,this.connectReject=null}handleExportRequest(e){let{requestId:t,sessionId:n}=e;if(!this.onExportRequest||!this.channelId){this.postExportError(t,`transfer-aborted`);return}let r=new AbortController;this.pendingHostExports.set(t,r);let i=this.channelId;this.onExportRequest(t,n,r.signal,e=>{this.pendingHostExports.has(t)&&this.post({cherry:this.negotiatedVersion,channelId:i,kind:`session.export.progress`,requestId:t,phase:e.phase,...e.processedBytes===void 0?{}:{processedBytes:e.processedBytes},...e.estimatedBytes===void 0?{}:{estimatedBytes:e.estimatedBytes}})}).then(e=>{this.pendingHostExports.delete(t),this.post({cherry:this.negotiatedVersion,channelId:i,kind:`session.export.response`,requestId:t,blob:e})}).catch(e=>{this.pendingHostExports.delete(t),this.postExportError(t,p(e))})}postExportError(e,t){this.channelId&&this.post({cherry:this.negotiatedVersion,channelId:this.channelId,kind:`session.export.error`,requestId:e,code:t})}},h=e(`cherry-boot`);function g(){let e=location.ancestorOrigins;if(e&&e.length>0){let t=e[0];if(t&&t!==`null`)return t}if(document.referrer)try{return new URL(document.referrer).origin}catch{}return location.origin}async function _(){let e=g(),t=[e],n=e,r=new m({counterpart:window.parent,allowOrigins:t,targetOrigin:n});await r.connect(),h.info(`Cherry transport connected`);let a=r.joinUrl;if(!a)throw Error(`cherry boot: no joinUrl from handshake`);return{transport:r,browser:new i(r),joinUrl:a}}export{_ as setupCherryFollower};
1
+ import{t as e}from"./logger-DDBAeTLF.js";import{n as t,r as n}from"./transcript-export-DP-r8eDz.js";import{t as r}from"./pending-request-table-k-D7ZZsL.js";import{BrowserAPI as i}from"./cdp-BX0PiRAg.js";import{t as a}from"./synthetic-cdp-transport-OUVdC4zy.js";var o=[2,1],s=new Set([`handshake.hello`,`handshake.welcome`,`handshake.version-mismatch`,`cdp.request`,`cdp.response`,`cdp.event`,`permission.request`,`permission.response`,`host.event`,`slicc.event`,`session.export.request`,`session.export.cancel`,`session.export.progress`,`session.export.response`,`session.export.error`]);function c(e,t=[2]){if(typeof e!=`object`||!e)return!1;let n=e;if(typeof n.cherry!=`number`||!t.includes(n.cherry)||typeof n.channelId!=`string`||typeof n.kind!=`string`||!s.has(n.kind))return!1;let r=n.kind;return!(r===`handshake.version-mismatch`&&typeof n.peerVersion!=`number`||(r===`session.export.request`||r===`session.export.cancel`||r===`session.export.progress`||r===`session.export.response`||r===`session.export.error`)&&(typeof n.requestId!=`string`||n.requestId===``||r===`session.export.progress`&&typeof n.phase!=`string`||r===`session.export.response`&&!(n.blob instanceof Blob)||r===`session.export.error`&&typeof n.code!=`string`))}function l(e,t){return!(!t.allowOrigins.includes(e.origin)||t.expectedSource!==null&&e.source!==t.expectedSource||!c(e.data,t.versions)||t.channelId!==null&&e.data.channelId!==t.channelId)}function u(e,t=[2]){if(typeof e!=`object`||!e)return!1;let n=e;return typeof n.cherry==`number`&&!t.includes(n.cherry)&&typeof n.channelId==`string`&&typeof n.kind==`string`}var d=e(`cherry-transport`),f=3e4;function p(e){let r=e instanceof t||typeof e==`object`&&e&&`code`in e?e.code:void 0;return typeof r==`string`&&n.has(r)?r:`transfer-corrupt`}var m=class extends a{opts;channelId=null;nextId=1;pending=new r;connectResolve=null;connectReject=null;connectTimer=null;_joinUrl=null;_features={terminal:!0,files:!0,memory:!0,browser:!0,modelPicker:!0,history:!0,nav:!0,monitor:!0};_theme=null;_layout=null;_effortLevel=null;_flags=null;negotiatedVersion=2;boundHandler=e=>this.handleMessage(e);onHostEvent=null;onExportRequest=null;pendingHostExports=new Map;constructor(e){super({targetUrl:typeof location<`u`?location.href:`about:blank`,targetOrigin:e.targetOrigin,title:`Cherry Host Page`,ids:{target:`cherry-target`,session:`cherry-session`,frame:`cherry-frame`,loader:`cherry-loader`}}),this.opts=e}get hostOrigin(){return this.opts.targetOrigin}getCurrentUrl(){return typeof location<`u`?location.href:super.getCurrentUrl()}get joinUrl(){return this._joinUrl}get features(){return this._features}get theme(){return this._theme}get layout(){return this._layout}get effortLevel(){return this._effortLevel}get flags(){return this._flags}get negotiatedProtocolVersion(){return this.negotiatedVersion}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);this._state=`connecting`,this.negotiatedVersion=2,this.channelId=`cherry-${crypto.randomUUID()}`,typeof window<`u`&&window.addEventListener(`message`,this.boundHandler);let t=e?.timeout??f;return new Promise((e,n)=>{this.connectResolve=e,this.connectReject=n,this.connectTimer=setTimeout(()=>{this.connectTimer=null,typeof window<`u`&&window.removeEventListener(`message`,this.boundHandler),this._state=`disconnected`,this.channelId=null,this.connectResolve=null,this.connectReject=null,n(Error(`Cherry handshake timed out after ${t}ms — no handshake.welcome from the embedding page (host SDK missing, not listening, or version-skewed; check the host page's console)`))},t);for(let e of o)this.post({cherry:e,channelId:this.channelId,kind:`handshake.hello`,capabilities:this.opts.capabilities??{navigate:!0,screenshot:!0,openUrl:!0}})})}failPendingConnect(e){if(this.connectReject===null)return;this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null),typeof window<`u`&&window.removeEventListener(`message`,this.boundHandler),this._state=`disconnected`,this.channelId=null;let t=this.connectReject;this.connectResolve=null,this.connectReject=null,t(e)}disconnect(){this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null),typeof window<`u`&&window.removeEventListener(`message`,this.boundHandler),this.pending.rejectAll(`Cherry transport disconnected`);for(let[,e]of this.pendingHostExports)e.abort();this.pendingHostExports.clear(),this._state=`disconnected`,this.channelId=null}async forward(e,t,n,r=f){let i=this.nextId++,a=this.pending.issue(i,r,`Cherry CDP timed out after ${r}ms: ${e}`);return this.post({cherry:this.negotiatedVersion,channelId:this.channelId,kind:`cdp.request`,id:i,method:e,params:t}),a}testReceive(e){this.handleMessage(e)}emitSliccEventToHost(e,t){if(!this.channelId){d.warn(`Dropping slicc.event before handshake (no channelId yet)`,{name:e});return}this.post({cherry:this.negotiatedVersion,channelId:this.channelId,kind:`slicc.event`,name:e,detail:t})}post(e){this.opts.counterpart.postMessage(e,this.opts.targetOrigin)}handleMessage(e){let t=this._state===`connected`?[this.negotiatedVersion]:o;if(!l(e,{allowOrigins:this.opts.allowOrigins,expectedSource:this.opts.counterpart,channelId:this.channelId,versions:t})){this.diagnoseRejectedMessage(e,t);return}let n=e.data;if(this.negotiatedVersion<2&&n.kind.startsWith(`session.export.`)){d.warn(`Ignoring a v2-only envelope on a v1-negotiated cherry channel`,{kind:n.kind});return}switch(n.kind){case`handshake.welcome`:this.handleWelcome(n);return;case`cdp.response`:n.error?this.pending.reject(n.id,Error(`Cherry CDP error: ${n.error.message} (${n.error.code})`)):this.pending.resolve(n.id,n.result??{});return;case`cdp.event`:this.emit(n.method,{...n.params??{},sessionId:n.sessionId??this.syntheticIds.session});return;case`host.event`:this.onHostEvent?.(n.name,n.detail);return;case`session.export.request`:this.handleExportRequest(n);return;case`session.export.cancel`:{let e=this.pendingHostExports.get(n.requestId);e&&(e.abort(),this.pendingHostExports.delete(n.requestId));return}default:return}}diagnoseRejectedMessage(e,t){u(e.data,t)?(d.warn(`Cherry protocol version mismatch — update the older side`,{peerVersion:e.data.cherry,supportedVersions:[...o],origin:e.origin}),e.data.channelId===this.channelId&&this.opts.allowOrigins.includes(e.origin)&&e.source===this.opts.counterpart&&this.failPendingConnect(Error(`Cherry protocol version mismatch (peer v${e.data.cherry}, ours v2) — update the older side`))):c(e.data,o)&&d.warn(`Rejected a cherry envelope (origin/source/channel mismatch)`,{origin:e.origin,allowOrigins:this.opts.allowOrigins})}handleWelcome(e){this.connectTimer!==null&&(clearTimeout(this.connectTimer),this.connectTimer=null),this._state=`connected`,this.negotiatedVersion=e.cherry,this._joinUrl=e.joinUrl??null,this._theme=e.theme??null,this._layout=e.layout??null,this._effortLevel=e.effortLevel??null,this._flags=e.flags??null,this._features=e.features??{terminal:!0,files:!0,memory:!0,browser:!0,modelPicker:!0,history:!0,nav:!0,monitor:!0},d.info(`Cherry handshake complete`,{channelId:this.channelId,negotiatedVersion:this.negotiatedVersion}),this.connectResolve?.(),this.connectResolve=null,this.connectReject=null}handleExportRequest(e){let{requestId:t,sessionId:n}=e;if(!this.onExportRequest||!this.channelId){this.postExportError(t,`transfer-aborted`);return}let r=new AbortController;this.pendingHostExports.set(t,r);let i=this.channelId;this.onExportRequest(t,n,r.signal,e=>{this.pendingHostExports.has(t)&&this.post({cherry:this.negotiatedVersion,channelId:i,kind:`session.export.progress`,requestId:t,phase:e.phase,...e.processedBytes===void 0?{}:{processedBytes:e.processedBytes},...e.estimatedBytes===void 0?{}:{estimatedBytes:e.estimatedBytes}})}).then(e=>{this.pendingHostExports.delete(t),this.post({cherry:this.negotiatedVersion,channelId:i,kind:`session.export.response`,requestId:t,blob:e})}).catch(e=>{this.pendingHostExports.delete(t),this.postExportError(t,p(e))})}postExportError(e,t){this.channelId&&this.post({cherry:this.negotiatedVersion,channelId:this.channelId,kind:`session.export.error`,requestId:e,code:t})}},h=e(`cherry-boot`);function g(){let e=location.ancestorOrigins;if(e&&e.length>0){let t=e[0];if(t&&t!==`null`)return t}if(document.referrer)try{return new URL(document.referrer).origin}catch{}return location.origin}async function _(){let e=g(),t=[e],n=e,r=new m({counterpart:window.parent,allowOrigins:t,targetOrigin:n});await r.connect(),h.info(`Cherry transport connected`);let a=r.joinUrl;if(!a)throw Error(`cherry boot: no joinUrl from handshake`);return{transport:r,browser:new i(r),joinUrl:a}}export{_ as setupCherryFollower};
@@ -9,4 +9,4 @@ Content-Disposition: form-data; name="${e}"\r
9
9
  ${g(i.value)}\r
10
10
  `))}return r.push(n.encode(`--${t}--\r
11
11
  `)),{bytes:y(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}async function h(e,t=f()){let n=[];for(let[t,r]of e.entries()){if(typeof r==`string`){n.push({name:t,value:r});continue}let e=typeof r.name==`string`?r.name:`blob`;n.push({name:t,file:{bytes:new Uint8Array(await r.arrayBuffer()),filename:e,contentType:r.type||void 0}})}return m(n,t)}function g(e){return e.replace(/\r\n|\r|\n/g,`\r
12
- `)}function _(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function v(e){return(e??``).replace(/[\r\n]/g,``).trim()}function y(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function b(e,t,n){let r=m([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function x(e){return e.split(`/`).pop()||`data`}function S(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var C=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=S(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),a=await this.cache.getBody(n),o=b(x(e),r(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,d);let f=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function w(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var T=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=w(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:e}=await import(`./account-store-1giUExSS.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let O;function k(e){O=e}function A(){return O}const j=n,M=t,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function I(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function L(e){let t=A();if(!t)throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new i(`EIO`,`mount transport failed: ${n.message}${I(t.adapter,e)}`)}return n.value}function R(e){return async t=>F(await L({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function z(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await L({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}var B=e({AEM_SOURCE_BUS_ORIGIN:()=>o,AemMountBackend:()=>d,DaMountBackend:()=>C,RemoteMountCache:()=>a,S3MountBackend:()=>T,makeSignedFetchDa:()=>z,makeSignedFetchS3:()=>R});export{T as a,p as c,k as i,o as l,z as n,C as o,R as r,h as s,B as t,d as u};
12
+ `)}function _(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function v(e){return(e??``).replace(/[\r\n]/g,``).trim()}function y(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function b(e,t,n){let r=m([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function x(e){return e.split(`/`).pop()||`data`}function S(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var C=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=S(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),a=await this.cache.getBody(n),o=b(x(e),r(e),t),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,d);let f=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function w(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var T=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=w(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},E=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function D(){let{getAccounts:e}=await import(`./account-store-BSIs8eWH.js`).then(e=>e.t),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new E(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}let O;function k(e){O=e}function A(){return O}const j=n,M=t,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}function I(e,t){return t===void 0?e===`node-rest`?` (SLICC backend at localhost may not be running)`:e===`extension-direct`||e===`extension-delegate`?` (extension service worker not responding)`:``:``}async function L(e){let t=A();if(!t)throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`);let n=await t.mounts.signRequest(e);if(!n.ok){let e=`status`in n?n.status:void 0;throw new i(`EIO`,`mount transport failed: ${n.message}${I(t.adapter,e)}`)}return n.value}function R(e){return async t=>F(await L({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function z(e){let t=e?.getImsToken??(async()=>(await D()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await L({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}var B=e({AEM_SOURCE_BUS_ORIGIN:()=>o,AemMountBackend:()=>d,DaMountBackend:()=>C,RemoteMountCache:()=>a,S3MountBackend:()=>T,makeSignedFetchDa:()=>z,makeSignedFetchS3:()=>R});export{T as a,p as c,k as i,o as l,z as n,C as o,R as r,h as s,B as t,d as u};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-CEOiQheZ.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-CiijUcSt.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-CDNZj56F.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-D0xZwlMO.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import{t as i}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-BA09m1QZ.js";import{t as a}from"./remote-cache-3KNT1gsp.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:o,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=f(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=`\r
3
- `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=5242880,T=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function E(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var D=26214400,O=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-CEOiQheZ.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-CfKG-Ig3.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/preload-helper-Czpn1I53.js","assets/claude-model-version-CSATLzrT.js","assets/models-BSkXF4T6.js","assets/diagnostics-DN_idNHx.js","assets/provider-env-CTOcDKrQ.js","assets/__vite-browser-external-5eBdwsFd.js","assets/openrouter.models-B-zmcypy.js","assets/libesm-BypnjKEL.js","assets/logger-DDBAeTLF.js","assets/base64-DJRlyqZu.js","assets/proxied-fetch-CiijUcSt.js","assets/fetch-body-D2PwksUW.js","assets/api-endpoint-DGxXvrur.js","assets/runtime-env-Dlaokqg1.js","assets/float-topology-hfgMx1Yq.js","assets/secret-topology-Yt0aO4Gz.js","assets/secrets-bridge-client-BVl0YuB2.js","assets/port-bridge-client-C1tBBqwu.js","assets/tool-ui-eSQ1g2I1.js","assets/providers-CFCRFvFH.js","assets/panel-rpc-B3MSVImO.js","assets/bedrock-camp-compat-BeCSBUrZ.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./preload-helper-Czpn1I53.js";import{n as t}from"./mime-types-D0xZwlMO.js";import{r as n,t as r}from"./base64-DJRlyqZu.js";import{t as i}from"./types-Dgm4REV3.js";import"./mount-table-store-dY2IfQ5S.js";import"./fs-CxM_n_WI.js";import{t as a}from"./remote-cache-3KNT1gsp.js";var o=`https://api.aem.live`,s=`application/folder`,c=5242880;function l(e){let t=e.match(/^aem:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid AEM source '${e}' — expected aem://org/site[/path]`);return{org:t[1],site:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}function u(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?``:String(t)}function d(e){let t=Date.parse(e??``);return Number.isNaN(t)?0:t}function f(e){return e.map(e=>e[`content-type`]===s||e.name.endsWith(`/`)?{name:e.name.replace(/\/+$/,``),kind:`directory`}:{name:e.name,kind:`file`,size:e.size,etag:u(e[`last-modified`]),lastModified:d(e[`last-modified`])})}var p=class{kind=`aem`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=l(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??c,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`),r=`/${this.parsed.org}/sites/${this.parsed.site}/source`;return n?`${r}/${n}`:r}toListPath(e){return`${this.toSourcePath(e)}/`}request(e,t,n){return this.transport({method:e,path:t,origin:o,headers:n?.headers,body:n?.body})}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r=await this.request(`GET`,this.toSourcePath(t));if(r.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem readFile failed: ${r.status}`,e);let a=new Uint8Array(await r.arrayBuffer());if(a.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);return await this.cache.putBody(t,a,u(r.headers.get(`last-modified`))),a}async assertUnchanged(e,t,n){if(!n)return;let r=await this.request(`HEAD`,this.toSourcePath(t));if(r.status===404)return;if(r.status>=400)throw new i(`EIO`,`aem precondition HEAD failed: ${r.status}`,e);let a=u(r.headers.get(`last-modified`));if(a&&a!==n)throw await this.cache.invalidateBody(t),new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n);await this.assertUnchanged(e,n,r?.etag??``);let a=await this.request(`PUT`,this.toSourcePath(n),{body:t});if(a.status===401||a.status===403)throw new i(`EACCES`,`aem write denied`,e);if(a.status>=400)throw new i(`EIO`,`aem writeFile failed: ${a.status}`,e);await this.cache.invalidateBody(n);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.request(`GET`,this.toListPath(t));if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`aem access denied`,e);if(r.status>=400)throw new i(`EIO`,`aem list failed: ${r.status}`,e);let a=f(await r.json());return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e);if(t===``)return{kind:`directory`,size:0,mtime:0};let n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o),c=(s&&!this.cache.isStale(s.cachedAt)?s.entries:await this.readDirQuietly(o))?.find(e=>e.name===a);if(!c)throw new i(`ENOENT`,`no such file or directory`,e);return c.kind===`directory`?{kind:`directory`,size:0,mtime:c.lastModified??0}:{kind:`file`,size:c.size??0,mtime:c.lastModified??0,etag:c.etag??``}}async readDirQuietly(e){try{return await this.readDir(e)}catch{return null}}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.request(`DELETE`,this.toSourcePath(t));if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`aem delete denied`,e);if(n.status>=400)throw new i(`EIO`,`aem delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.request(`GET`,this.toListPath(e));if(r.status===404){await this.cache.putListing(e,[]);return}if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=f(await r.json());for(let r of i){let i=e?`${e}/${r.name}`:r.name;r.kind===`directory`?n.push(i):await this.classifyFile(i,r.etag??``,t)}await this.cache.putListing(e,i)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.site}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},m=`\r
3
+ `;function h(){let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return`----SliccFormBoundary${t}`}function g(e,t=h()){let n=new TextEncoder,r=[];for(let i of e){let e=v(_(i.name));if(`file`in i){let a=v(i.file.filename),o=y(i.file.contentType)||`application/octet-stream`;r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"; filename="${a}"${m}Content-Type: ${o}${m}${m}`)),r.push(i.file.bytes),r.push(n.encode(m))}else r.push(n.encode(`--${t}${m}Content-Disposition: form-data; name="${e}"${m}${m}${_(i.value)}${m}`))}return r.push(n.encode(`--${t}--${m}`)),{bytes:b(r),contentType:`multipart/form-data; boundary=${t}`,boundary:t}}function _(e){return e.replace(/\r\n|\r|\n/g,m)}function v(e){return e.replace(/\r/g,`%0D`).replace(/\n/g,`%0A`).replace(/"/g,`%22`)}function y(e){return(e??``).replace(/[\r\n]/g,``).trim()}function b(e){let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function x(e,t,n){let r=g([{name:`data`,file:{bytes:n,filename:e,contentType:t}}]);return{contentType:r.contentType,body:r.bytes}}function S(e){return e.split(`/`).pop()||`data`}function C(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var w=5242880,T=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=C(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??w,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`da access denied`,e);if(a.status>=400)throw new i(`EIO`,`da readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),a=await this.cache.getBody(r),o=x(S(e),t(e),n),s={"content-type":o.contentType,"content-length":String(o.body.byteLength)};a?.etag?s[`if-match`]=a.etag.startsWith(`W/`)?a.etag.slice(2):a.etag:a||(s[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:s,body:o.body}),l,u=1;try{l=await c()}catch{u=2,l=await c()}if(l.status===412){if(u===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new i(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let a=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,a);let o=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new i(`EACCES`,`da write denied`,e);if(l.status>=400)throw new i(`EIO`,`da writeFile failed: ${l.status}`,e);let d=l.headers.get(`etag`)??``;await this.cache.putBody(r,n,d);let f=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(f)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new i(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new i(`EIO`,`da list failed: ${r.status}`,e);let a=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,a),a}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(s){let n=s.entries.map(n=>n.name===a&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(o,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new i(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new i(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new i(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function E(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var D=26214400,O=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=E(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??D,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new i(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let a=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(a.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(a.status===404)throw await this.cache.invalidateBody(t),new i(`ENOENT`,`no such file`,e);if(a.status===401||a.status===403)throw new i(`EACCES`,`s3 access denied`,e);if(a.status>=400)throw new i(`EIO`,`s3 readFile failed: ${a.status}`,e);let o=a.headers.get(`content-length`),s=o?Number(o):void 0;if(s!==void 0&&s>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes (${s} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await a.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=a.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new i(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),a={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?a[`if-match`]=r.etag:a[`if-none-match`]=`*`;let o=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:a,body:t}),s,c=1;try{s=await o()}catch{c=2,s=await o()}if(s.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new i(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let a=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,a);let o=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(o);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new i(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(s.status===401||s.status===403)throw new i(`EACCES`,`s3 write denied`,e);if(s.status>=400)throw new i(`EIO`,`s3 writeFile failed: ${s.status}`,e);let l=s.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new i(`EIO`,`s3 list failed: ${r.status}`,`/`);let a=await r.text(),o=this.parseListingXml(a);e.push(...o.contents),t=o.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),a=r.pop()??``,o=r.join(`/`),s=await this.cache.getListing(o);if(s&&!this.cache.isStale(s.cachedAt)){let t=s.entries.find(e=>e.name===a);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??s.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??s.cachedAt};if(!t)throw new i(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new i(`ENOENT`,`no such file or directory`,e)}throw new i(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new i(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new i(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new i(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new i(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},k=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function A(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-CfKG-Ig3.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new k(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var j=r,M=n,N=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),P=new Set([101,103,204,205,304]);function F(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new i(`EACCES`,e.error):e.errorCode===`invalid_request`?new i(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||N.has(String(e.errorCode))?new i(`EIO`,e.error):new i(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=j(e.bodyBase64)}catch(e){throw new i(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=P.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function I(e){throw new i(`EIO`,`mount transport unavailable: setMountCapabilityBroker was never called for this float (composition bug — refusing to guess a transport for a privileged sign-and-forward request)`)}function L(e){return async t=>F(await I({backend:`s3`,envelope:{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?M(t.body):void 0}}))}function R(e){let t=e?.getImsToken??(async()=>(await A()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new i(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return F(await I({backend:`da`,envelope:{imsToken:n,method:e.method,path:e.path,origin:e.origin,query:e.query,headers:e.headers,bodyBase64:e.body?M(e.body):void 0}}))}}export{p as AemMountBackend,T as DaMountBackend,a as RemoteMountCache,O as S3MountBackend,R as makeSignedFetchDa,L as makeSignedFetchS3};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n}from"./mount-index-D9w_zMSm.js";import{a as r,n as i,o as a,r as o,u as s}from"./mount-WtleT3fD.js";import{n as c}from"./mount-table-store-DrF_Ifaz.js";import{t as l}from"./remote-cache-BE5T1-53.js";var u=e({formatMountRecoveryPrompt:()=>_,mdInlineCode:()=>g,recoverMounts:()=>m,shellQuote:()=>h});function d(e){return e instanceof Error?e.message:String(e)}async function f(e,r,i,a){let o=await c(r.idbHandleKey),s=typeof o?.name==`string`?o.name:``,l={kind:`local`,path:e,dirName:s};if(!o||!(`queryPermission`in o))return{entry:l,ok:!1};let u;try{u=await o.queryPermission({mode:`readwrite`})}catch(t){return a?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}if(u!==`granted`)return{entry:l,ok:!1};try{let c=t.fromHandle(o,{mountId:r.mountId});return await i.mount(e,c,{limits:n}),a?.info?.(`Restored mount from previous session`,{path:e,name:s}),{entry:l,ok:!0}}catch(t){return a?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}}async function p(e,t,n,c){let{kind:u,source:f,profile:p,mountId:m}=t,h=u===`s3`?`S3`:u===`aem`?`AEM`:`DA`;try{let t={source:f,profile:p,cache:new l({mountId:m,ttlMs:3e4}),mountId:m},d=u===`s3`?new r({...t,signedFetch:o(p)}):u===`aem`?new s({...t,signedFetch:i()}):new a({...t,signedFetch:i()});return await n.mount(e,d),c?.info?.(`Restored ${h} mount from previous session`,{path:e,source:f}),{entry:{kind:u,path:e,source:f,profile:p,reason:``},ok:!0}}catch(t){let n=d(t);return c?.warn?.(`Failed to restore ${h} mount`,{path:e,error:n}),{entry:{kind:u,path:e,source:f,profile:p,reason:n},ok:!1}}}async function m(e,t,n){let r=[],i=[];for(let{targetPath:a,descriptor:o}of e){if(o.kind===`hostfs`)continue;let e=o.kind===`local`?await f(a,o,t,n):await p(a,o,t,n);(e.ok?r:i).push(e.entry)}return{restored:r,needsRecovery:i}}function h(e){return`'${e.replace(/'/g,`'\\''`)}'`}function g(e){let t=e.replace(/\r\n|[\r\n]/g,` `),n=t.match(/`+/g),r=n?Math.max(...n.map(e=>e.length))+1:1,i="`".repeat(r);return`${i}${t.startsWith("`")||t.endsWith("`")?` ${t} `:t}${i}`}function _(e){if(!Array.isArray(e)||e.length===0)return null;let t=e.length===1?`mount point`:`mount points`,n=e.length===1?`it`:`them`,r=e.filter(e=>e.kind===`local`),i=e.filter(e=>e.kind===`s3`||e.kind===`da`||e.kind===`aem`),a=[`[Session Reload] Mount recovery required for ${e.length} ${t}.`,``];if(r.length>0){let e=r.map(({path:e,dirName:t})=>{let n=t?` (previously mounted from ${g(t)})`:``;return`- ${g(e)}${n}`}),i=r.map(({path:e})=>` mount ${h(e)}`);a.push(`The page was reloaded and the following local ${t} lost filesystem permission. The browser cannot restore access without a fresh user gesture, so ${n} cannot be used until the user re-authorizes:`,``,...e,``,`Please tell the user what happened and ask whether they want to re-mount. If yes, run the corresponding command(s) so the folder picker opens and they can re-select the same directory:`,``,...i,``)}if(i.length>0){let e=i.map(({path:e,source:t,profile:n,reason:r})=>{let i=n==="default"?``:` --profile ${h(n)}`,a=`mount --source ${h(t)}${i} ${h(e)}`;return`- ${g(e)} (${g(t)}, profile ${g(n)}) — ${r}\n Retry: ${g(a)}`});a.push(`The following remote ${t} could not be auto-restored:`,``,...e,``)}return a.push("If the user no longer needs a mount, run `mount unmount <path>` (with the path shell-quoted the same way) to clear the stale entry instead."),a.join(`
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{i as t,n}from"./mount-index-D9w_zMSm.js";import{a as r,n as i,o as a,r as o,u as s}from"./mount-BehlIVTc.js";import{n as c}from"./mount-table-store-DrF_Ifaz.js";import{t as l}from"./remote-cache-BE5T1-53.js";var u=e({formatMountRecoveryPrompt:()=>_,mdInlineCode:()=>g,recoverMounts:()=>m,shellQuote:()=>h});function d(e){return e instanceof Error?e.message:String(e)}async function f(e,r,i,a){let o=await c(r.idbHandleKey),s=typeof o?.name==`string`?o.name:``,l={kind:`local`,path:e,dirName:s};if(!o||!(`queryPermission`in o))return{entry:l,ok:!1};let u;try{u=await o.queryPermission({mode:`readwrite`})}catch(t){return a?.warn?.(`queryPermission threw on persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}if(u!==`granted`)return{entry:l,ok:!1};try{let c=t.fromHandle(o,{mountId:r.mountId});return await i.mount(e,c,{limits:n}),a?.info?.(`Restored mount from previous session`,{path:e,name:s}),{entry:l,ok:!0}}catch(t){return a?.warn?.(`Failed to re-mount persisted handle`,{path:e,error:d(t)}),{entry:l,ok:!1}}}async function p(e,t,n,c){let{kind:u,source:f,profile:p,mountId:m}=t,h=u===`s3`?`S3`:u===`aem`?`AEM`:`DA`;try{let t={source:f,profile:p,cache:new l({mountId:m,ttlMs:3e4}),mountId:m},d=u===`s3`?new r({...t,signedFetch:o(p)}):u===`aem`?new s({...t,signedFetch:i()}):new a({...t,signedFetch:i()});return await n.mount(e,d),c?.info?.(`Restored ${h} mount from previous session`,{path:e,source:f}),{entry:{kind:u,path:e,source:f,profile:p,reason:``},ok:!0}}catch(t){let n=d(t);return c?.warn?.(`Failed to restore ${h} mount`,{path:e,error:n}),{entry:{kind:u,path:e,source:f,profile:p,reason:n},ok:!1}}}async function m(e,t,n){let r=[],i=[];for(let{targetPath:a,descriptor:o}of e){if(o.kind===`hostfs`)continue;let e=o.kind===`local`?await f(a,o,t,n):await p(a,o,t,n);(e.ok?r:i).push(e.entry)}return{restored:r,needsRecovery:i}}function h(e){return`'${e.replace(/'/g,`'\\''`)}'`}function g(e){let t=e.replace(/\r\n|[\r\n]/g,` `),n=t.match(/`+/g),r=n?Math.max(...n.map(e=>e.length))+1:1,i="`".repeat(r);return`${i}${t.startsWith("`")||t.endsWith("`")?` ${t} `:t}${i}`}function _(e){if(!Array.isArray(e)||e.length===0)return null;let t=e.length===1?`mount point`:`mount points`,n=e.length===1?`it`:`them`,r=e.filter(e=>e.kind===`local`),i=e.filter(e=>e.kind===`s3`||e.kind===`da`||e.kind===`aem`),a=[`[Session Reload] Mount recovery required for ${e.length} ${t}.`,``];if(r.length>0){let e=r.map(({path:e,dirName:t})=>{let n=t?` (previously mounted from ${g(t)})`:``;return`- ${g(e)}${n}`}),i=r.map(({path:e})=>` mount ${h(e)}`);a.push(`The page was reloaded and the following local ${t} lost filesystem permission. The browser cannot restore access without a fresh user gesture, so ${n} cannot be used until the user re-authorizes:`,``,...e,``,`Please tell the user what happened and ask whether they want to re-mount. If yes, run the corresponding command(s) so the folder picker opens and they can re-select the same directory:`,``,...i,``)}if(i.length>0){let e=i.map(({path:e,source:t,profile:n,reason:r})=>{let i=n==="default"?``:` --profile ${h(n)}`,a=`mount --source ${h(t)}${i} ${h(e)}`;return`- ${g(e)} (${g(t)}, profile ${g(n)}) — ${r}\n Retry: ${g(a)}`});a.push(`The following remote ${t} could not be auto-restored:`,``,...e,``)}return a.push("If the user no longer needs a mount, run `mount unmount <path>` (with the path shell-quoted the same way) to clear the stale entry instead."),a.join(`
2
2
  `)}export{u as n,h as r,_ as t};